Package chunmap.util

Examples of chunmap.util.Function


    text.setLineWrap(true);
    text.setAutoscrolls(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){
View Full Code Here


 
  @Override
  protected void addButton(){
    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){
View Full Code Here

TOP

Related Classes of chunmap.util.Function

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.