Package chunmap.model.geom

Examples of chunmap.model.geom.Geometry


        while (true)
        {
            int nowCompare = compareY(other);
            if (mustHasIntersection || (nowCompare == 0 || nowCompare != compare))
            {// 位置改变时必有交点
                Geometry g = getIntersection(other);
                if (g != null)
                {
                    geometrys.add(g);
                    if (!myContinue)
                    {
View Full Code Here


        .getX(), p2.getY()));
    return geometry.transform(transf2);
  }

  public void draw(Graphics g, Feature f, View renderer) {
    Geometry geo=((Shape)f).getGeometry().transform(renderer.world2Screen());
    drawGeo(g,geo,renderer);
  }
View Full Code Here

    }
  }
 

  private void drawShape(Shape shape) {
    Geometry geo = shape.getGeometry();
    if (geo == null) return;
   
    draw(geo);
  }
View Full Code Here

    super.addButton();
   
    final Function listener=new Function(){
          @Override
          public Object call(Object... args) {
            Geometry g=(Geometry)args[0];
            add2Layer(g);
            map.refreshMap();
            return null;
          }};
   
    UiUtil.addButton(frame,map,"创建点",new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        PointTool tool=new PointTool();
        tool.onCreateFinish.add(listener);
        map.setCurrentPlug(tool);
      }
    });
   
    UiUtil.addButton(frame,map,"创建线",new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        LineTool tool=new LineTool();
        tool.onCreateFinish.add(listener);
        map.setCurrentPlug(tool);
      }
    });
   
    UiUtil.addButton(frame,map,"创建面",new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        AreaTool tool=new AreaTool();
        tool.onCreateFinish.add(listener);
        map.setCurrentPlug(tool);
      }
    });
   
    final JTextArea text=new JTextArea(5,70);
    text.setLineWrap(true);

   
    UiUtil.addButton(frame,map,"添加",new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        Geometry g =null;
        try{
          g= wktReader.read(text.getText().trim());
        }catch(WktParseException exp){
          JOptionPane.showMessageDialog(null
              , "无效的文本", "error", JOptionPane.ERROR_MESSAGE);
          return;
        }
                add2Layer(g);
                map.refreshMap();
      }
    });
   
    UiUtil.addButton(frame,map,"删除",new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent arg0) {
        final VectorLayer l = (VectorLayer) map.getLayerCollection().getSelectedLayer();

              if (l == null)
              {
                  return;
              }

              l.getFeatures().find(new VisitFunc(){
          @Override
          public boolean execute(Feature f) {
            if (f != null)
                    {
                        boolean success=f.getFeatureClass().remove(f);
                        l.getFeatures().remove(f);
                        if (success)
                        {
                            map.refreshMap();
                        }
                        return false;
                    }
                    return true;
          }
              });
      }
    });
   
   
    frame.add(text);
   
    tool.onSelectChange.add(new Function(){
      @SuppressWarnings("unchecked")
      @Override
      public Object call(Object... args) {
        List<Feature> fs=(List<Feature>)args[0];
        if(fs.size()==0){
          text.setText("");
        }else{
          Geometry g=((Shape)fs.get(0)).getGeometry();
          text.setText(g.toString());
        }
        return null;
      }});
  }
View Full Code Here

TOP

Related Classes of chunmap.model.geom.Geometry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.