/** * {@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); } }