int
// Next segment
i += 2;
}
- // Create polyline
- line = new Polyline(positions);
+ // Create path
+ line = new Path(positions);
line.setNumSubsegments(0);
- line.setFollowTerrain(true);
- line.setColor(this.getColor());
- line.setLineWidth(this.getLineWidth());
+ line.setSurfacePath(true);
+ var attrs = new BasicShapeAttributes();
+ attrs.setOutlineWidth(this.getLineWidth());
+ attrs.setOutlineMaterial(new Material(this.getColor()));
+ line.setAttributes(attrs);
this.getRenderables().add(line);
count++;
}
diff --git a/src/gov/nasa/worldwind/render/Path.java b/src/gov/nasa/worldwind/render/Path.java
index c30cea5e02..a2f4b9374d 100644
--- a/src/gov/nasa/worldwind/render/Path.java
+++ b/src/gov/nasa/worldwind/render/Path.java
@@ -3,7 +3,6 @@
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
-
package gov.nasa.worldwind.render;
import com.jogamp.common.nio.Buffers;
@@ -19,8 +18,11 @@
import gov.nasa.worldwind.pick.*;
import gov.nasa.worldwind.terrain.Terrain;
import gov.nasa.worldwind.util.*;
+import gov.nasa.worldwind.util.measure.LengthMeasurer;
+import static gov.nasa.worldwind.ogc.kml.impl.KMLExportUtil.kmlBoolean;
import com.jogamp.opengl.*;
+
import javax.xml.stream.*;
import java.awt.*;
import java.io.IOException;
@@ -28,10 +30,7 @@
import java.util.*;
import java.util.List;
-import static gov.nasa.worldwind.ogc.kml.impl.KMLExportUtil.kmlBoolean;
-
-// TODO: Measurement (getLength), Texture, lighting
-
+// TODO: Texture, lighting
/**
* Displays a line or curve between positions. The path is drawn between input positions to achieve a specified path
* type, e.g., {@link AVKey#GREAT_CIRCLE}. It can also conform to the underlying terrain. A curtain may be formed by
@@ -46,7 +45,7 @@
* AVKey#GREAT_CIRCLE}, {@link AVKey#RHUMB_LINE} or {@link AVKey#LINEAR}. (See {@link #setPathType(String)}.)
*
* Paths have separate attributes for normal display and highlighted display. If no attributes are specified, default
- * attributes are used. See {@link #DEFAULT_INTERIOR_MATERIAL}, {@link #DEFAULT_OUTLINE_MATERIAL}, and {@link
+ * attributes are used. See {@link #DEFAULT_PATH_INTERIOR_MATERIAL}, {@link #DEFAULT_PATH_OUTLINE_MATERIAL}, and {@link
* #DEFAULT_HIGHLIGHT_MATERIAL}.
*
* When the path type is LINEAR the path conforms to terrain only if the follow-terrain property is true.
@@ -81,13 +80,19 @@
* @author tag
* @version $Id: Path.java 3032 2015-04-17 17:53:35Z dcollins $
*/
-public class Path extends AbstractShape
-{
- /** The default interior color. */
- protected static final Material DEFAULT_INTERIOR_MATERIAL = Material.PINK;
- /** The default outline color. */
- protected static final Material DEFAULT_OUTLINE_MATERIAL = Material.RED;
- /** The default path type. */
+public class Path extends AbstractShape {
+
+ /**
+ * The default interior color.
+ */
+ protected static final Material DEFAULT_PATH_INTERIOR_MATERIAL = Material.PINK;
+ /**
+ * The default outline color.
+ */
+ protected static final Material DEFAULT_PATH_OUTLINE_MATERIAL = Material.RED;
+ /**
+ * The default path type.
+ */
protected static final String DEFAULT_PATH_TYPE = AVKey.LINEAR;
/**
* The offset applied to a terrain following Path's depth values to to ensure it shows over the terrain: 0.99.
@@ -95,18 +100,28 @@ public class Path extends AbstractShape
* terrain.
*/
protected static final double SURFACE_PATH_DEPTH_OFFSET = 0.99;
- /** The default number of tessellation points between the specified path positions. */
+ /**
+ * The default number of tessellation points between the specified path positions.
+ */
protected static final int DEFAULT_NUM_SUBSEGMENTS = 10;
- /** The default terrain conformance target. */
+ /**
+ * The default terrain conformance target.
+ */
protected static final double DEFAULT_TERRAIN_CONFORMANCE = 10;
- /** The default distance from the eye beyond which positions dots are not drawn. */
+ /**
+ * The default distance from the eye beyond which positions dots are not drawn.
+ */
protected static final double DEFAULT_DRAW_POSITIONS_THRESHOLD = 1e6;
- /** The default scale for position dots. The scale is applied to the current outline width to produce the dot size. */
+ /**
+ * The default scale for position dots. The scale is applied to the current outline width to produce the dot size.
+ */
protected static final double DEFAULT_DRAW_POSITIONS_SCALE = 10;
- /** The PositionColors interface defines an RGBA color for each of a path's original positions. */
- public static interface PositionColors
- {
+ /**
+ * The PositionColors interface defines an RGBA color for each of a path's original positions.
+ */
+ public static interface PositionColors {
+
/**
* Returns an RGBA color corresponding to the specified position and ordinal. This returns null if
* a color cannot be determined for the specified position and ordinal. The specified position is
@@ -120,7 +135,7 @@ public static interface PositionColors
* The returned color's RGB components must not be premultiplied by its Alpha component.
*
* @param position the path position the color corresponds to.
- * @param ordinal the ordinal number of the specified position.
+ * @param ordinal the ordinal number of the specified position.
*
* @return an RGBA color corresponding to the position and ordinal, or null if a color cannot be
* determined.
@@ -133,9 +148,11 @@ public static interface PositionColors
* distinct globe that this shape encounters in calls to {@link AbstractShape#render(DrawContext)}. See {@link
* AbstractShape}.
*/
- protected static class PathData extends AbstractShapeData
- {
- /** The positions formed from applying path type and terrain conformance. */
+ protected static class PathData extends AbstractShapeData {
+
+ /**
+ * The positions formed from applying path type and terrain conformance.
+ */
protected ArrayList tessellatedPositions;
/**
* The colors corresponding to each tessellated position, or null if the path's
@@ -167,7 +184,9 @@ protected static class PathData extends AbstractShapeData
* line. Used only when the path's positions span the dateline and a 2D globe is being used.
*/
protected ArrayList splitPositions;
- /** Indicates whether the rendered path has extrusion points in addition to path points. */
+ /**
+ * Indicates whether the rendered path has extrusion points in addition to path points.
+ */
protected boolean hasExtrusionPoints; // true when the rendered path contains extrusion points
/**
* Indicates the offset in number of floats to the first RGBA color tuple in renderedPath. This is
@@ -179,11 +198,12 @@ protected static class PathData extends AbstractShapeData
* renderedPath.
*/
protected int vertexStride;
- /** Indicates the number of vertices represented by renderedPath. */
+ /**
+ * Indicates the number of vertices represented by renderedPath.
+ */
protected int vertexCount;
- public PathData(DrawContext dc, Path shape)
- {
+ public PathData(DrawContext dc, Path shape) {
super(dc, shape.minExpiryTime, shape.maxExpiryTime);
}
@@ -193,13 +213,11 @@ public PathData(DrawContext dc, Path shape)
*
* @return the positions computed by path tessellation.
*/
- public List getTessellatedPositions()
- {
+ public List getTessellatedPositions() {
return this.tessellatedPositions;
}
- public void setTessellatedPositions(ArrayList tessellatedPositions)
- {
+ public void setTessellatedPositions(ArrayList tessellatedPositions) {
this.tessellatedPositions = tessellatedPositions;
}
@@ -210,8 +228,7 @@ public void setTessellatedPositions(ArrayList tessellatedPositions)
* @return the colors corresponding to each path position, or null if the path does not have
* per-position colors.
*/
- public List getTessellatedColors()
- {
+ public List getTessellatedColors() {
return this.tessellatedColors;
}
@@ -221,10 +238,9 @@ public List getTessellatedColors()
* list must have a one-to-one correspondence with the entries in tessellatedPositions.
*
* @param tessellatedColors the colors corresponding to each path position, or null if the path
- * does not have per-position colors.
+ * does not have per-position colors.
*/
- public void setTessellatedColors(ArrayList tessellatedColors)
- {
+ public void setTessellatedColors(ArrayList tessellatedColors) {
this.tessellatedColors = tessellatedColors;
}
@@ -234,30 +250,25 @@ public void setTessellatedColors(ArrayList tessellatedColors)
*
* @return the Cartesian coordinates of the tessellated positions.
*/
- public FloatBuffer getRenderedPath()
- {
+ public FloatBuffer getRenderedPath() {
return this.renderedPath;
}
- public void setRenderedPath(FloatBuffer renderedPath)
- {
+ public void setRenderedPath(FloatBuffer renderedPath) {
this.renderedPath = renderedPath;
}
/**
* Returns a buffer of indices into the rendered path ({@link #renderedPath} that identify the originally
- * specified positions that remain after tessellation. These positions are those of the position dots, if
- * drawn.
+ * specified positions that remain after tessellation. These positions are those of the position dots, if drawn.
*
* @return the path's originally specified positions that survived tessellation.
*/
- public IntBuffer getPositionPoints()
- {
+ public IntBuffer getPositionPoints() {
return this.positionPoints;
}
- public void setPositionPoints(IntBuffer posPoints)
- {
+ public void setPositionPoints(IntBuffer posPoints) {
this.positionPoints = posPoints;
}
@@ -267,13 +278,11 @@ public void setPositionPoints(IntBuffer posPoints)
*
* @return the path's pole positions.
*/
- public IntBuffer getPolePositions()
- {
+ public IntBuffer getPolePositions() {
return this.polePositions;
}
- public void setPolePositions(IntBuffer polePositions)
- {
+ public void setPolePositions(IntBuffer polePositions) {
this.polePositions = polePositions;
}
@@ -282,13 +291,11 @@ public void setPolePositions(IntBuffer polePositions)
*
* @return true if the path is extruded and the extrusion points are computed, otherwise false.
*/
- public boolean isHasExtrusionPoints()
- {
+ public boolean isHasExtrusionPoints() {
return this.hasExtrusionPoints;
}
- public void setHasExtrusionPoints(boolean hasExtrusionPoints)
- {
+ public void setHasExtrusionPoints(boolean hasExtrusionPoints) {
this.hasExtrusionPoints = hasExtrusionPoints;
}
@@ -298,8 +305,7 @@ public void setHasExtrusionPoints(boolean hasExtrusionPoints)
*
* @return the offset in number of floats to the first RGBA color tuple in renderedPath.
*/
- public int getColorOffset()
- {
+ public int getColorOffset() {
return this.colorOffset;
}
@@ -309,8 +315,7 @@ public int getColorOffset()
*
* @param offset the offset in number of floats to the first RGBA color tuple in renderedPath.
*/
- public void setColorOffset(int offset)
- {
+ public void setColorOffset(int offset) {
this.colorOffset = offset;
}
@@ -320,8 +325,7 @@ public void setColorOffset(int offset)
*
* @return the stride in number of floats between vertices in in renderedPath.
*/
- public int getVertexStride()
- {
+ public int getVertexStride() {
return this.vertexStride;
}
@@ -331,8 +335,7 @@ public int getVertexStride()
*
* @param stride the stride in number of floats between vertices in in renderedPath.
*/
- public void setVertexStride(int stride)
- {
+ public void setVertexStride(int stride) {
this.vertexStride = stride;
}
@@ -341,8 +344,7 @@ public void setVertexStride(int stride)
*
* @return the the number of verices in renderedPath.
*/
- public int getVertexCount()
- {
+ public int getVertexCount() {
return this.vertexCount;
}
@@ -352,25 +354,23 @@ public int getVertexCount()
*
* @param count the the number of vertices in renderedPath.
*/
- public void setVertexCount(int count)
- {
+ public void setVertexCount(int count) {
this.vertexCount = count;
}
}
@Override
- protected SurfaceShape createSurfaceShape()
- {
+ protected SurfaceShape createSurfaceShape() {
SurfacePolyline polyline = new SurfacePolyline();
- if (this.getPositions() != null)
+ if (this.getPositions() != null) {
polyline.setLocations(this.getPositions());
+ }
return polyline;
}
@Override
- protected void updateSurfaceShape()
- {
+ protected void updateSurfaceShape() {
super.updateSurfaceShape();
this.surfaceShape.setPathType(this.getPathType());
@@ -381,15 +381,20 @@ protected void updateSurfaceShape()
* colors that the Path's position points are drawn in. The color codes represent ARGB colors packed into a 32-bit
* integer.
*/
- protected static class PickablePositions
- {
+ protected static class PickablePositions {
// TODO: Replace this class with usage of PickSupport.addPickableObjectRange.
- /** The minimum color code, inclusive. */
+ /**
+ * The minimum color code, inclusive.
+ */
public final int minColorCode;
- /** The maximum color code, inclusive. */
+ /**
+ * The maximum color code, inclusive.
+ */
public final int maxColorCode;
- /** The Path who's position points are associated with the specified color code range. */
+ /**
+ * The Path who's position points are associated with the specified color code range.
+ */
public final Path path;
/**
@@ -398,10 +403,9 @@ protected static class PickablePositions
*
* @param minColorCode the minimum color code, inclusive.
* @param maxColorCode the maximum color code, inclusive.
- * @param path the Path who's position points are associated with the specified color code range.
+ * @param path the Path who's position points are associated with the specified color code range.
*/
- public PickablePositions(int minColorCode, int maxColorCode, Path path)
- {
+ public PickablePositions(int minColorCode, int maxColorCode, Path path) {
this.minColorCode = minColorCode;
this.maxColorCode = maxColorCode;
this.path = path;
@@ -418,8 +422,7 @@ public PickablePositions(int minColorCode, int maxColorCode, Path path)
* PickedObject that specifies the picked Path. If a position point is picked, the PickedObject's AVList contains
* the position and ordinal number of the picked position.
*/
- protected static class PathPickSupport extends PickSupport
- {
+ protected static class PathPickSupport extends PickSupport {
// TODO: Replace this subclass with usage of PickSupport.addPickableObjectRange.
// TODO: Take care to retain the behavior in doResolvePick below that merges multiple picks from a single path.
@@ -428,13 +431,13 @@ protected static class PathPickSupport extends PickSupport
* of color codes to a Path, where the color codes represent the range of pick colors that the Path's position
* points are drawn in.
*/
- protected List pickablePositions = new ArrayList();
+ protected List pickablePositions = new ArrayList<>();
/**
* A map that associates each path with a picked object. Used to during box picking to consolidate the
* information about what parts of each path are picked into a single picked object. Path's positions are drawn
* in unique colors and are therefore separately pickable during box picking.
*/
- protected Map