/** {@inheritDoc} */ public Position getReferencePosition() { if (positions != null) { Iterator<? extends Position> iterator = this.positions.iterator(); if (iterator.hasNext()) return iterator.next(); } return null; }
/** * {@inheritDoc} * * @param positions Control points. This graphic uses only two control point, which determine the * midpoints of two opposite sides of the quad. See Fire Support Area (2.X.4.3.2.1.2) on pg. * 652 of MIL-STD-2525C for an example of how these points are interpreted. */ public void setPositions(Iterable<? extends Position> positions) { if (positions == null) { String message = Logging.getMessage("nullValue.PositionsListIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } Iterator<? extends Position> iterator = positions.iterator(); try { Position pos1 = iterator.next(); Position pos2 = iterator.next(); LatLon center = LatLon.interpolateGreatCircle(0.5, pos1, pos2); this.quad.setCenter(center); Angle heading = LatLon.greatCircleAzimuth(pos2, pos1); this.quad.setHeading(heading.subtract(Angle.POS90)); this.positions = positions; this.shapeInvalid = true; // Need to recompute quad size } catch (NoSuchElementException e) { String message = Logging.getMessage("generic.InsufficientPositions"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } }
/** * {@inheritDoc} * * @param positions Control points that orient the graphic. Must provide at least three points. */ public void setPositions(Iterable<? extends Position> positions) { if (positions == null) { String message = Logging.getMessage("nullValue.PositionsListIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } try { Iterator<? extends Position> iterator = positions.iterator(); this.position1 = iterator.next(); this.position2 = iterator.next(); this.position3 = iterator.next(); } catch (NoSuchElementException e) { String message = Logging.getMessage("generic.InsufficientPositions"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.paths = null; // Need to recompute path for the new control points this.arrowHead1 = null; this.arrowHead2 = null; if (this.symbol != null) { this.symbol.setPosition(this.position1); } }
protected void computeQuadSize(DrawContext dc) { if (this.positions == null) return; Iterator<? extends Position> iterator = this.positions.iterator(); Position pos1 = iterator.next(); Position pos2 = iterator.next(); Angle angularDistance = LatLon.greatCircleDistance(pos1, pos2); double length = angularDistance.radians * dc.getGlobe().getRadius(); this.quad.setWidth(length); }
/** {@inheritDoc} */ @Override public void setModifier(String modifier, Object value) { if (SymbologyConstants.DISTANCE.equals(modifier)) { if (value instanceof Double) { this.setWidth((Double) value); } else if (value instanceof Iterable) { // Only use the first value of the iterable. This graphic uses two control points and a // width. Iterator iterator = ((Iterable) value).iterator(); this.setWidth((Double) iterator.next()); } } else { super.setModifier(modifier, value); } }
/** * {@inheritDoc} * * <p>The dummy graphic requires exactly three control points. Any positions beyond the first * three will be ignored. * * @throws IllegalArgumentException if less than three control points are provided. */ public void setPositions(Iterable<? extends Position> positions) { if (positions == null) { String message = Logging.getMessage("nullValue.PositionsListIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } try { Iterator<? extends Position> iterator = positions.iterator(); Position pt1 = iterator.next(); Position pt2 = iterator.next(); Position pt3 = iterator.next(); this.path.setPositions(Arrays.asList(pt2, pt1, pt3)); } catch (NoSuchElementException e) { String message = Logging.getMessage("generic.InsufficientPositions"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } }
/** {@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); }
/** * {@inheritDoc} * * @param positions Control points. This graphic uses only one control point, which determines the * center of the circle. */ public void setPositions(Iterable<? extends Position> positions) { if (positions == null) { String message = Logging.getMessage("nullValue.PositionsListIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } try { // Ensure that the iterable provides at least four positions. Iterator<? extends Position> iterator = positions.iterator(); for (int i = 0; i < 3; i++) { iterator.next(); } } catch (NoSuchElementException e) { String message = Logging.getMessage("generic.InsufficientPositions"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } this.positions = positions; this.rings = null; }
/** * 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); } }