/** {@inheritDoc} */ public Position getReferencePosition() { if (positions != null) { Iterator<? extends Position> iterator = this.positions.iterator(); if (iterator.hasNext()) return iterator.next(); } return null; }
/** {@inheritDoc} */ public TreeNode getNode(TreePath path) { TreeNode node = this.getModel().getRoot(); if (!node.getText().equals(path.get(0))) // Test root node return null; Iterator<String> iterator = path.iterator(); iterator.next(); // Skip root node, we already tested it above while (iterator.hasNext()) { String nodeText = iterator.next(); boolean foundMatch = false; for (TreeNode child : node.getChildren()) { if (child.getText().equals(nodeText)) { node = child; foundMatch = true; break; } } if (!foundMatch) return null; } return node; }
/** * Create positions that describe lines parallel to a control line. * * @param iterator Iterator of control line positions. * @param leftPositions List to collect positions on the left line. * @param rightPositions List to collect positions on the right line. * @param halfWidth Distance from the center line to the left or right lines. * @param globe Current globe. */ public void generateParallelLines( Iterator<? extends Position> iterator, List<Position> leftPositions, List<Position> rightPositions, double halfWidth, Globe globe) { // Starting at the start of the line, take points three at a time. B is the current control // point, A is the next // point in the line, and C is the previous point. We need to a find a vector that bisects angle // ABC. // B // ---------> C // / // / // / // A / Position posB = iterator.next(); Position posA = iterator.next(); Vec4 ptA = globe.computePointFromLocation(posA); Vec4 ptB = globe.computePointFromLocation(posB); Vec4 ptC; // Compute side points at the start of the line. this.generateParallelPoints(ptB, null, ptA, leftPositions, rightPositions, halfWidth, globe); while (iterator.hasNext()) { posA = iterator.next(); ptC = ptB; ptB = ptA; ptA = globe.computePointFromLocation(posA); generateParallelPoints(ptB, ptC, ptA, leftPositions, rightPositions, halfWidth, globe); } // Compute side points at the end of the line. generateParallelPoints(ptA, ptB, null, leftPositions, rightPositions, halfWidth, globe); }
/** * Create the circles used to draw this graphic. * * @param dc Current draw context. */ protected void createShapes(DrawContext dc) { if (this.positions == null) return; this.rings = new ArrayList<SurfaceCircle>(); Iterator<? extends Position> iterator = this.positions.iterator(); Position center = iterator.next(); double globeRadius = dc.getGlobe().getRadius(); while (iterator.hasNext()) { SurfaceCircle ring = this.createCircle(); ring.setCenter(center); Position pos = iterator.next(); Angle radius = LatLon.greatCircleDistance(center, pos); double radiusMeters = radius.radians * globeRadius; ring.setRadius(radiusMeters); this.rings.add(ring); } }