sarsegmentplane.java
来自「world wind java sdk 源码」· Java 代码 · 共 913 行 · 第 1/3 页
JAVA
913 行
{ return null; } return globe.computePositionFromPoint(point); } public double getObjectSize(String key, Vec4 point) { if (key == null) { String message = Logging.getMessage("nullValue.KeyIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (point == null) { String message = Logging.getMessage("nullValue.PointIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (this.wwd == null) { String message = Logging.getMessage("nullValue.WorldWindow"); Logging.logger().severe(message); throw new IllegalStateException(message); } View view = this.wwd.getView(); Globe globe = this.wwd.getModel().getGlobe(); return this.segmentPlaneEditor.getSegmentPlaneRenderer().computeObjectSize(view, globe, this.segmentPlane, key, point); } //**************************************************************// //******************** Segment Plane initialization **********// //**************************************************************// protected void initSegmentPlane() { double gridSize = SAR2.feetToMeters(1000); this.segmentPlane.setGridCellDimensions(gridSize, gridSize); this.segmentPlane.setPlaneOutlineMask(SegmentPlane.TOP); this.segmentPlane.setBorderMask(SegmentPlane.LEFT); Color foregroundColor = new Color(90, 146, 200); Color backgroundColor = new Color(163, 191, 222); Color segmentPointColor = Color.YELLOW; Color axisLabelColor = Color.YELLOW; Color moveControlPointColor = Color.GREEN; Color resizeControlPointColor = Color.MAGENTA; double maxAxisLabelActiveDistance = Double.MAX_VALUE; double maxSecondaryControlPointActiveDistance = Double.MAX_VALUE; double maxPrimaryControlPointActiveDistance = Double.MAX_VALUE; SegmentPlaneAttributes attributes = new SegmentPlaneAttributes(); this.segmentPlane.setAttributes(attributes); //**************************************************************// //******************** Plane Attributes **********************// //**************************************************************// SegmentPlaneAttributes.GeometryAttributes background = new SegmentPlaneAttributes.GeometryAttributes( new Material(backgroundColor), 0.7); SegmentPlaneAttributes.GeometryAttributes outline = new SegmentPlaneAttributes.GeometryAttributes( new Material(foregroundColor), 1.0); SegmentPlaneAttributes.GeometryAttributes grid = new SegmentPlaneAttributes.GeometryAttributes( new Material(foregroundColor), 1.0); SegmentPlaneAttributes.GeometryAttributes border = new SegmentPlaneAttributes.GeometryAttributes( new Material(foregroundColor), 1.0); grid.setSize(1); grid.setPickSize(10); outline.setSize(3); border.setSize(3); attributes.setGeometryAttributes(SegmentPlane.PLANE_BACKGROUND, background); attributes.setGeometryAttributes(SegmentPlane.PLANE_OUTLINE, outline); attributes.setGeometryAttributes(SegmentPlane.PLANE_GRID, grid); attributes.setGeometryAttributes(SegmentPlane.PLANE_BORDER, border); //**************************************************************// //******************** Segment Altimeter Attributes **********// //**************************************************************// SegmentPlaneAttributes.GeometryAttributes altimeterGeometry = new SegmentPlaneAttributes.GeometryAttributes( new Material(segmentPointColor), 1.0); AxisLabelAttributes altimeterLabel = new AxisLabelAttributes( axisLabelColor, Font.decode("Arial-12"), AVKey.LEFT, AVKey.CENTER, this); altimeterGeometry.setSize(1); altimeterLabel.setVisible(false); altimeterLabel.setMaxActiveDistance(maxAxisLabelActiveDistance); attributes.setGeometryAttributes(SegmentPlane.ALTIMETER, altimeterGeometry); attributes.setLabelAttributes(SegmentPlane.ALTIMETER, altimeterLabel); //**************************************************************// //******************** Segment Control Point Attributes ******// //**************************************************************// SegmentPlaneAttributes.GeometryAttributes segmentPointGeom = new SegmentPlaneAttributes.GeometryAttributes( new Material(segmentPointColor), 1.0); ControlPointLabelAttributes segmentBeginPointLabel = new ControlPointLabelAttributes( segmentPointColor, Font.decode("Arial-14"), AVKey.RIGHT, AVKey.CENTER, this); ControlPointLabelAttributes segmentEndPointLabel = new ControlPointLabelAttributes( segmentPointColor, Font.decode("Arial-14"), AVKey.RIGHT, AVKey.CENTER, this); segmentPointGeom.setSize(8); segmentPointGeom.setPickSize(10); segmentBeginPointLabel.setMaxActiveDistance(maxSecondaryControlPointActiveDistance); segmentBeginPointLabel.setShowHeightAboveSurface(true); segmentBeginPointLabel.setOffset(new Vec4(-10, 0, 0)); segmentEndPointLabel.setMaxActiveDistance(maxPrimaryControlPointActiveDistance); segmentEndPointLabel.setShowHeightAboveSurface(true); segmentEndPointLabel.setShowSegmentHeading(true); segmentEndPointLabel.setOffset(new Vec4(-10, 0, 0)); attributes.setGeometryAttributes(SegmentPlane.SEGMENT_BEGIN, segmentPointGeom.copy()); attributes.setGeometryAttributes(SegmentPlane.SEGMENT_END, segmentPointGeom.copy()); attributes.setLabelAttributes(SegmentPlane.SEGMENT_BEGIN, segmentBeginPointLabel); attributes.setLabelAttributes(SegmentPlane.SEGMENT_END, segmentEndPointLabel); //**************************************************************// //******************** Axis Label Attributes *****************// //**************************************************************// AxisLabelAttributes horizontalAxisLabels = new AxisLabelAttributes( axisLabelColor, Font.decode("Arial-10"), AVKey.CENTER, AVKey.BOTTOM, this); AltitudeLabelAttributes verticalAxisLabels = new AltitudeLabelAttributes( axisLabelColor, Font.decode("Arial-10"), AVKey.RIGHT, AVKey.BOTTOM, this); horizontalAxisLabels.setMaxActiveDistance(maxAxisLabelActiveDistance); verticalAxisLabels.setMaxActiveDistance(maxAxisLabelActiveDistance); attributes.setLabelAttributes(SegmentPlane.HORIZONTAL_AXIS_LABELS, horizontalAxisLabels); attributes.setLabelAttributes(SegmentPlane.VERTICAL_AXIS_LABELS, verticalAxisLabels); //**************************************************************// //******************** Plane Move Control Point Attributes ***// //**************************************************************// SegmentPlaneAttributes.GeometryAttributes moveControlPointLLGeom = new SegmentPlaneAttributes.GeometryAttributes(new Material(moveControlPointColor), 1.0); SegmentPlaneAttributes.GeometryAttributes moveControlPointLRGeom = new SegmentPlaneAttributes.GeometryAttributes(new Material(moveControlPointColor), 1.0); SegmentPlaneAttributes.GeometryAttributes moveControlPointURGeom = new SegmentPlaneAttributes.GeometryAttributes(new Material(moveControlPointColor), 1.0); ControlPointLabelAttributes moveControlPointLLLabel = new ControlPointLabelAttributes( moveControlPointColor, Font.decode("Arial-14"), AVKey.LEFT, AVKey.CENTER, this); ControlPointLabelAttributes moveControlPointLRLabel = new ControlPointLabelAttributes( moveControlPointColor, Font.decode("Arial-14"), AVKey.LEFT, AVKey.CENTER, this); ControlPointLabelAttributes moveControlPointURLabel = new ControlPointLabelAttributes( moveControlPointColor, Font.decode("Arial-14"), AVKey.LEFT, AVKey.CENTER, this); moveControlPointLLGeom.setSize(9); moveControlPointLLGeom.setPickSize(10); moveControlPointLLGeom.setOffset(new Vec4(0, 0, 9)); moveControlPointLRGeom.setSize(7); moveControlPointLRGeom.setPickSize(10); moveControlPointLRGeom.setOffset(new Vec4(0, 0, 7)); moveControlPointURGeom.setSize(7); moveControlPointURGeom.setPickSize(10); moveControlPointLLLabel.setVisible(false); moveControlPointLLLabel.setShowSegmentHeading(true); moveControlPointLLLabel.setMaxActiveDistance(maxSecondaryControlPointActiveDistance); moveControlPointLRLabel.setVisible(false); moveControlPointLRLabel.setShowSegmentHeading(true); moveControlPointLRLabel.setMaxActiveDistance(maxSecondaryControlPointActiveDistance); moveControlPointURLabel.setShowSegmentHeading(true); moveControlPointURLabel.setMaxActiveDistance(maxSecondaryControlPointActiveDistance); moveControlPointURLabel.setOffset(new Vec4(15, 0, 0)); attributes.setGeometryAttributes(SegmentPlane.CONTROL_POINT_LOWER_LEFT, moveControlPointLLGeom.copy()); attributes.setGeometryAttributes(SegmentPlane.CONTROL_POINT_LOWER_RIGHT, moveControlPointLRGeom.copy()); attributes.setGeometryAttributes(SegmentPlane.CONTROL_POINT_UPPER_RIGHT, moveControlPointURGeom.copy()); attributes.setLabelAttributes(SegmentPlane.CONTROL_POINT_LOWER_LEFT, moveControlPointLLLabel); attributes.setLabelAttributes(SegmentPlane.CONTROL_POINT_LOWER_RIGHT, moveControlPointLRLabel); attributes.setLabelAttributes(SegmentPlane.CONTROL_POINT_UPPER_RIGHT, moveControlPointURLabel); //**************************************************************// //******************** Plane Resize Control Point Attributes *// //**************************************************************// SegmentPlaneAttributes.GeometryAttributes resizeControlPointGeom = new SegmentPlaneAttributes.GeometryAttributes( new Material(resizeControlPointColor), 1.0); ControlPointLabelAttributes resizeControlPointLabel = new ControlPointLabelAttributes( resizeControlPointColor, Font.decode("Arial-10"), AVKey.LEFT, AVKey.CENTER, this); resizeControlPointGeom.setSize(7); resizeControlPointGeom.setPickSize(10); resizeControlPointLabel.setVisible(false); resizeControlPointLabel.setMaxActiveDistance(maxSecondaryControlPointActiveDistance); attributes.setGeometryAttributes(SegmentPlane.CONTROL_POINT_LEADING_EDGE, resizeControlPointGeom.copy()); attributes.setGeometryAttributes(SegmentPlane.CONTROL_POINT_TOP_EDGE, resizeControlPointGeom.copy()); attributes.setLabelAttributes(SegmentPlane.CONTROL_POINT_LEADING_EDGE, resizeControlPointLabel.copy()); attributes.setLabelAttributes(SegmentPlane.CONTROL_POINT_TOP_EDGE, resizeControlPointLabel.copy()); } //**************************************************************// //******************** Control Point Label Attributes ********// //**************************************************************// public static class SARLabelAttributes extends SegmentPlaneAttributes.LabelAttributes { private SARSegmentPlane context; public SARLabelAttributes(Color color, Font font, String horizontalAlignment, String verticalAlignment, SARSegmentPlane context) { super(color, font, horizontalAlignment, verticalAlignment); this.context = context; } public SARLabelAttributes() { } public SARSegmentPlane getContext() { return this.context; } public void setContext(SARSegmentPlane context) { this.context = context; } public SegmentPlaneAttributes.LabelAttributes copy() { return this.copyTo(new SARLabelAttributes()); } protected SegmentPlaneAttributes.LabelAttributes copyTo(SegmentPlaneAttributes.LabelAttributes copy) { super.copyTo(copy); if (copy instanceof SARLabelAttributes) { ((SARLabelAttributes) copy).setContext(this.getContext()); } return copy; } protected String formatAngle(Angle angle) { return SARSegmentPlane.formatAngle(this.context.getAngleFormat(), angle); } protected String formatElevation(double value) { return SARSegmentPlane.formatElevation(this.context.getElevationUnit(), value); } } public static class ControlPointLabelAttributes extends SARLabelAttributes { private boolean showSegmentHeading = false; private boolean showHeightAboveSurface = false; public ControlPointLabelAttributes(Color color, Font font, String horizontalAlignment, String verticalAlignment, SARSegmentPlane context) { super(color, font, horizontalAlignment, verticalAlignment, context); } public ControlPointLabelAttributes() { } public boolean isShowSegmentHeading() { return this.showSegmentHeading; } public void setShowSegmentHeading(boolean show) { this.showSegmentHeading = show; } public boolean isShowHeightAboveSurface() { return this.showHeightAboveSurface; } public void setShowHeightAboveSurface(boolean show) { this.showHeightAboveSurface = show; } public SegmentPlaneAttributes.LabelAttributes copy() { return this.copyTo(new ControlPointLabelAttributes()); } protected SegmentPlaneAttributes.LabelAttributes copyTo(SegmentPlaneAttributes.LabelAttributes copy) { super.copyTo(copy); if (copy instanceof ControlPointLabelAttributes) { ((ControlPointLabelAttributes) copy).setShowSegmentHeading(this.isShowSegmentHeading()); ((ControlPointLabelAttributes) copy).setShowHeightAboveSurface(this.isShowHeightAboveSurface()); } return copy; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?