Esempio n. 1
0
  public PathProperPanel(final PathLayer layer, final DartEarthAppFrame frame) {
    this.setLayout(new GridLayout(0, 1, 2, 2));

    this.layer = layer;
    this.frame = frame;
    this.path = layer.getPath();
    deleteBtns = new ArrayList<JButton>();
    latTexts = new ArrayList<JTextField>();
    lngTexts = new ArrayList<JTextField>();
    pointPanels = new ArrayList<JPanel>();

    layerNameLabel = new JLabel("图层名:");
    layerNameTextField = new JTextField();
    layerNameTextField.setText(layer.getName());
    put(layerNameLabel, layerNameTextField);

    // this.buildPointPanels();

    colorLabel = new JLabel("颜色:");
    // this.add(colorLabel);
    // colorChooser = new JColorChooser();
    color = path.getAttributes().getOutlineMaterial().getDiffuse();
    // colorChooser.setColor(color);
    // colorChooser.set
    // color=JColorChooser.showDialog(this, "请选择颜色", color);
    colorBtn = new JButton();
    // colorBtn.setText("");
    colorBtn.setBackground(color);
    // final LineProperPanel panel = this;
    ActionListener colorChooseListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            Color choosenColor = JColorChooser.showDialog(null, "请选择颜色", color);
            colorBtn.setBackground(choosenColor);
            // line.setColor(color);
            // layer.refresh();
          }
        };
    colorBtn.addActionListener(colorChooseListener);
    put(colorLabel, colorBtn);
    // this.add(colorBtn);

    opacityLabel = new JLabel("透明度:");
    // this.add(opacityLable);
    opacityTextField = new JTextField();
    opacityTextField.setText(layer.getPath().getAttributes().getOutlineOpacity() + "");
    // this.add(opacityTextField);
    put(opacityLabel, opacityTextField);

    sizeLabel = new JLabel("粗细:");
    // this.add(sizeLabel);
    sizeTextField = new JTextField();
    sizeTextField.setText(path.getAttributes().getOutlineWidth() + "");
    // this.add(sizeTextField);
    put(sizeLabel, sizeTextField);

    initialDialogBtns();
    buildPointPanels();
  }
Esempio n. 2
0
  private void applyModify() {
    layer.setName(layerNameTextField.getText());
    Color choosenColor = colorBtn.getBackground();
    color = new Color(choosenColor.getRed(), choosenColor.getGreen(), choosenColor.getBlue());
    List<Position> positions = new ArrayList<Position>();
    for (int i = 0; i < latTexts.size(); i++) {
      Position p = layer.getPositions().get(i);
      double lat = Double.valueOf(latTexts.get(i).getText());
      double lng = Double.valueOf(lngTexts.get(i).getText());
      Position newP =
          new Position(Angle.fromDegrees(lat), Angle.fromDegrees(lng), p.getElevation());
      positions.add(newP);
    }
    layer.setPositions(positions);
    path.setPositions(positions);

    // Create and set an attribute bundle.
    ShapeAttributes attrs = new BasicShapeAttributes();
    Material material = new Material(color);
    attrs.setOutlineMaterial(material);
    attrs.setOutlineWidth(Double.valueOf(sizeTextField.getText()));
    attrs.setOutlineOpacity(Double.valueOf(opacityTextField.getText()));
    //		path.setColor(color);
    //		path.setLineWidth(Double.valueOf(sizeTextField.getText()));
    path.setAttributes(attrs);

    layer.refresh();
    frame.getLayerPanelDialog().getLayerPanel().update();
  }
Esempio n. 3
0
 protected Path createPath() {
   Path path = new Path();
   path.setFollowTerrain(true);
   path.setPathType(AVKey.GREAT_CIRCLE);
   path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
   path.setDelegateOwner(this.getActiveDelegateOwner());
   return path;
 }
Esempio n. 4
0
  /** {@inheritDoc} */
  protected void doRenderGraphic(DrawContext dc) {
    for (Path path : this.paths) {
      path.render(dc);
    }

    this.arrowHead1.render(dc);
    this.arrowHead2.render(dc);
  }
Esempio n. 5
0
  /** {@inheritDoc} */
  protected void applyDelegateOwner(Object owner) {
    if (this.paths == null) return;

    for (Path path : this.paths) {
      path.setDelegateOwner(owner);
    }

    if (this.symbol != null) this.symbol.setDelegateOwner(owner);

    this.arrowHead1.setDelegateOwner(owner);
    this.arrowHead2.setDelegateOwner(owner);
  }
    protected void addContourShapes(
        List<List<Position>> contourList, double value, RenderableLayer layer) {
      String text = this.textForValue(value);
      Color color = this.colorForValue(value, 1.0); // color for value at 100% brightness

      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setOutlineMaterial(new Material(color));
      attrs.setOutlineWidth(2);

      for (List<Position> positions : contourList) {
        Path path = new Path(positions);
        path.setAttributes(attrs);
        path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
        path.setFollowTerrain(true);
        path.setValue(AVKey.DISPLAY_NAME, text);
        layer.addRenderable(path);
      }
    }
    protected void showGridSightLines(List<Position> grid, Position cPos) {
      this.sightLinesLayer.removeAllRenderables();

      // Display lines from the center to each grid point.
      ShapeAttributes lineAttributes;
      lineAttributes = new BasicShapeAttributes();
      lineAttributes.setDrawOutline(true);
      lineAttributes.setDrawInterior(false);
      lineAttributes.setOutlineMaterial(Material.GREEN);
      lineAttributes.setOutlineOpacity(0.6);

      for (Position p : grid) {
        List<Position> endPoints = new ArrayList<Position>();
        endPoints.add(cPos);
        endPoints.add(new Position(p.getLatitude(), p.getLongitude(), 0));

        Path path = new Path(endPoints);
        path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
        path.setAttributes(lineAttributes);
        this.sightLinesLayer.addRenderable(path);
      }
    }
    protected void showSightLines(List<Position[]> sightLines) {
      this.sightLinesLayer.removeAllRenderables();

      // Display the sight lines as green lines.
      ShapeAttributes lineAttributes;
      lineAttributes = new BasicShapeAttributes();
      lineAttributes.setDrawOutline(true);
      lineAttributes.setDrawInterior(false);
      lineAttributes.setOutlineMaterial(Material.GREEN);
      lineAttributes.setOutlineOpacity(0.6);

      for (Position[] pp : sightLines) {
        List<Position> endPoints = new ArrayList<Position>();
        endPoints.add(pp[0]);
        endPoints.add(pp[1]);

        Path path = new Path(endPoints);
        path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
        path.setAttributes(lineAttributes);
        this.sightLinesLayer.addRenderable(path);
      }
    }
    public AppFrame() {
      super(true, true, false);

      RenderableLayer layer = new RenderableLayer();

      // Create and set an attribute bundle.
      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setOutlineMaterial(Material.RED);
      attrs.setOutlineWidth(2d);

      // Create a path, set some of its properties and set its attributes.
      ArrayList<Position> pathPositions = new ArrayList<Position>();
      pathPositions.add(Position.fromDegrees(49.01653274909177, -122.7349081128505, 1));
      pathPositions.add(Position.fromDegrees(49.01715024535254, -122.7596194200486, 10));
      pathPositions.add(Position.fromDegrees(49.02781845803761, -122.7651733463364, 100));
      pathPositions.add(Position.fromDegrees(49.05312411976134, -122.7926787136435, 1000));
      pathPositions.add(Position.fromDegrees(49.0747697644625, -122.8224152286015, 1000));
      pathPositions.add(Position.fromDegrees(49.09727187849899, -122.8187118695457, 1000));
      pathPositions.add(Position.fromDegrees(49.1002974270654, -122.7348314826556, 100));
      pathPositions.add(Position.fromDegrees(49.11190305133165, -122.7345541413842, 100));
      pathPositions.add(Position.fromDegrees(49.11101764617014, -122.7455553490629, 10));
      pathPositions.add(Position.fromDegrees(49.11509767012883, -122.7459193678911, 10));
      pathPositions.add(Position.fromDegrees(49.11467371318521, -122.7563706291131, 10));

      Path path = new DirectedPath(pathPositions);

      // To ensure that the arrowheads resize smoothly, refresh each time the path is drawn.
      path.setAttributes(attrs);
      path.setVisible(true);
      path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      path.setPathType(AVKey.GREAT_CIRCLE);
      layer.addRenderable(path);

      // Add the layer to the model.
      insertBeforeCompass(getWwd(), layer);

      // Update layer panel
      this.getLayerPanel().update(this.getWwd());
    }
Esempio n. 10
0
 /**
  * Create and configure the Path used to render this graphic.
  *
  * @param positions Positions that define the path.
  * @return New path configured with defaults appropriate for this type of graphic.
  */
 protected Path createPath(List<Position> positions) {
   Path path = new Path(positions);
   path.setFollowTerrain(true);
   path.setPathType(AVKey.GREAT_CIRCLE);
   path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
   path.setDelegateOwner(this.getActiveDelegateOwner());
   path.setAttributes(this.getActiveShapeAttributes());
   return path;
 }
    protected void addPath(RenderableLayer layer, List<Position> positions, String displayName) {
      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setOutlineWidth(5);

      Path path = new Path(positions);
      path.setPathType(AVKey.LINEAR);
      path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      path.setAttributes(attrs);
      path.setValue(AVKey.DISPLAY_NAME, displayName);
      layer.addRenderable(path);

      // Show how to make the colors vary along the paths.
      path.setPositionColors(new ExamplePositionColors());
    }