Skip to content
Open
Changes from all commits
提交
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
package gov.nasa.worldwind.util.measure;

import gov.nasa.worldwind.WorldWindow;
import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.layers.Terrain个人资料Layer;
import gov.nasa.worldwind.util.Logging;

import java.beans.*;
import java.util.ArrayList;

/**
* Adapter that forwards control-point position changes from a {@link MeasureTool}
* to a {@link Terrain个人资料Layer} so that the height-data along the measured
* path can be visualized.
*
* @author Wiehann Matthysen
*/
public class Terrain个人资料Adapter implements PropertyChangeListener
{
protected WorldWindow wwd;
protected Terrain个人资料Layer profileLayer;

/**
* Construct an adapter for the specified <code>WorldWindow</code> and <code>Terrain个人资料Layer</code>.
*
* @param wwd the <code>WorldWindow</code> the specified layer is associated with.
* @param layer the layer to forward control-point events to.
*/
public Terrain个人资料Adapter(WorldWindow wwd, Terrain个人资料Layer layer)
{
if (wwd == null)
{
String msg = Logging.getMessage("nullValue.WorldWindow");
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}
if (layer == null)
{
String msg = Logging.getMessage("nullValue.LayerIsNull");
Logging.logger().severe(msg);
throw new IllegalArgumentException(msg);
}

this.wwd = wwd;
this.profileLayer = layer;
}

@Override
public void propertyChange(PropertyChangeEvent event)
{
MeasureTool measureTool = (MeasureTool)event.getSource();
// Measure shape position list changed - update terrain profile
if (event.getPropertyName().equals(MeasureTool.EVENT_POSITION_ADD)
|| event.getPropertyName().equals(MeasureTool.EVENT_POSITION_REMOVE)
|| event.getPropertyName().equals(MeasureTool.EVENT_POSITION_REPLACE))
{
ArrayList<? extends LatLon> positions = measureTool.getPositions();
if (positions != null && positions.size() > 1)
{
this.profileLayer.setPathPositions(positions);
this.profileLayer.setEnabled(true);
} else
{
this.profileLayer.setEnabled(false);
}
this.wwd.redraw();
}
}
}