예제 #1
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();
  }
예제 #2
0
  /**
   * 绑定绘制椭圆所需的鼠标操作
   *
   * @param frame DartEarthAppFrame
   */
  public static void bindMouseListener(DartEarthAppFrame frame) {

    final EllipseLayer layer = new EllipseLayer(frame);

    /** 绘制椭圆的鼠标动作,详见该类 */
    final EllipseMouseAdapter ellipseMouseAdapter = new EllipseMouseAdapter(layer, frame);

    /** 绘制椭圆的鼠标动作的鼠标运动监听器 */
    MouseMotionAdapter mouseMotionAdapter =
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent mouseEvent) {
            if ((mouseEvent.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
              if (ellipseMouseAdapter.isActive()) mouseEvent.consume();
            }
          }
        };
    frame.getWwd().getInputHandler().addMouseMotionListener(mouseMotionAdapter);

    /** 绘制椭圆的鼠标动作的位置监听器 */
    PositionListener positionListener =
        new PositionListener() {
          public void moved(PositionEvent event) {
            if (!ellipseMouseAdapter.isActive()) return;
            if (layer.getPositions().size() == 1) layer.addPosition();
            else layer.replacePosition();
            // System.out.println(layer.getPositions());
          }
        };
    frame.getWwd().addPositionListener(positionListener);

    ellipseMouseAdapter.setMouseMotionAdapter(mouseMotionAdapter);
    ellipseMouseAdapter.setPositionListener(positionListener);
    frame.getWwd().getInputHandler().addMouseListener(ellipseMouseAdapter);

    EllipseProperPanel panel = new EllipseProperPanel(layer, frame);
    frame.getPropertiesDialog().show(panel, layer.getName(), layer);
    layer.setPanel(panel);
  }
예제 #3
0
  /**
   * 通过deml来生成一个椭圆
   *
   * @param DEML中对这个椭圆的属性的描述
   * @param frame DartearthAppFrame
   */
  @Override
  public void buildByDEML(Element e, DartEarthAppFrame frame) {
    String LayerName = e.element("LayerName").getText();

    Element pointList = e.element("PointList");
    Iterator<Element> i = pointList.elementIterator("Point");

    List<Position> positions = new ArrayList<Position>();
    while (i.hasNext()) {
      Element el = i.next();
      String lat = el.attribute("Lat").getText();
      String lng = el.attribute("Lng").getText();
      Position p = Position.fromDegrees(Double.valueOf(lat), Double.valueOf(lng));
      positions.add(p);
    }

    String centerLat = e.element("Attributes").element("CenterPoint").attribute("Lat").getText();
    String centerLng = e.element("Attributes").element("CenterPoint").attribute("Lng").getText();
    String majorRadius = e.element("Attributes").element("MajorRadius").getText();
    String minorRadius = e.element("Attributes").element("MinorRadius").getText();
    SurfaceEllipse ellipse =
        new SurfaceEllipse(
            LatLon.fromDegrees(Double.valueOf(centerLat), Double.valueOf(centerLng)),
            Double.valueOf(majorRadius),
            Double.valueOf(minorRadius));

    ShapeAttributes attrs = new BasicShapeAttributes();
    attrs.setOutlineOpacity(
        Double.valueOf(e.element("Attributes").element("OutlineOpacity").getText()));
    attrs.setOutlineWidth(
        Double.valueOf(e.element("Attributes").element("OutlineWidth").getText()));

    int red =
        Integer.valueOf(
            e.element("Attributes").element("InteriorMaterial").attribute("r").getText());
    int green =
        Integer.valueOf(
            e.element("Attributes").element("InteriorMaterial").attribute("g").getText());
    int blue =
        Integer.valueOf(
            e.element("Attributes").element("InteriorMaterial").attribute("b").getText());

    Material im = new Material(new Color(red, green, blue));
    attrs.setInteriorMaterial(im);

    red =
        Integer.valueOf(
            e.element("Attributes").element("OutlineMaterial").attribute("r").getText());
    green =
        Integer.valueOf(
            e.element("Attributes").element("OutlineMaterial").attribute("g").getText());
    blue =
        Integer.valueOf(
            e.element("Attributes").element("OutlineMaterial").attribute("b").getText());
    Material om = new Material(new Color(red, green, blue));
    attrs.setOutlineMaterial(om);

    ellipse.setAttributes(attrs);

    EllipseLayer layer = new EllipseLayer(frame, LayerName);
    layer.addRenderable(ellipse);
    layer.setEllipse(ellipse);
    layer.setPositions(positions);
    EllipseProperPanel panel = new EllipseProperPanel(layer, frame);
    layer.setPanel(panel);
    frame.getWwd().getModel().getLayers().add(0, layer);
    frame.getLayerPanelDialog().getLayerPanel().update();
    frame.getPropertiesDialog().show(panel, layer.getName(), layer);
  }