/[schmitzm]/trunk/src/skrueger/geotools/XMapPane.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/XMapPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/1.0-gt2-2.6/src/org/geotools/gui/swing/JMapPane.java revision 318 by alfonx, Wed Aug 26 13:33:32 2009 UTC branches/1.0-gt2-2.6/src/org/geotools/swing/JMapPane.java revision 384 by alfonx, Fri Sep 11 16:16:38 2009 UTC
# Line 13  Line 13 
13   *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *    Lesser General Public License for more details.   *    Lesser General Public License for more details.
15   */   */
16  package org.geotools.gui.swing;  package org.geotools.swing;
17    
18  /**  /**
19   * <b>Xulu:<br>   * <b>Xulu:<br>
# Line 58  import java.util.Map; Line 58  import java.util.Map;
58  import javax.swing.JPanel;  import javax.swing.JPanel;
59    
60  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
 import org.geotools.feature.FeatureCollection;  
 import org.geotools.filter.IllegalFilterException;  
 import org.geotools.map.DefaultMapContext;  
61  import org.geotools.map.MapContext;  import org.geotools.map.MapContext;
 import org.geotools.map.MapLayer;  
62  import org.geotools.map.event.MapLayerListEvent;  import org.geotools.map.event.MapLayerListEvent;
63  import org.geotools.map.event.MapLayerListListener;  import org.geotools.map.event.MapLayerListListener;
 import org.geotools.referencing.crs.DefaultGeographicCRS;  
64  import org.geotools.renderer.GTRenderer;  import org.geotools.renderer.GTRenderer;
65    import org.geotools.renderer.label.LabelCacheImpl;
66  import org.geotools.renderer.lite.LabelCache;  import org.geotools.renderer.lite.LabelCache;
 import org.geotools.renderer.lite.LabelCacheDefault;  
67  import org.geotools.renderer.lite.StreamingRenderer;  import org.geotools.renderer.lite.StreamingRenderer;
68  import org.geotools.renderer.shape.TransitionShapefileRenderer;  import org.geotools.renderer.shape.ShapefileRenderer;
69  import org.geotools.styling.Graphic;  import org.geotools.styling.Graphic;
70  import org.geotools.styling.LineSymbolizer;  import org.geotools.styling.LineSymbolizer;
71  import org.geotools.styling.Mark;  import org.geotools.styling.Mark;
72  import org.geotools.styling.PointSymbolizer;  import org.geotools.styling.PointSymbolizer;
73  import org.geotools.styling.PolygonSymbolizer;  import org.geotools.styling.PolygonSymbolizer;
 import org.geotools.styling.Style;  
74  import org.geotools.styling.StyleBuilder;  import org.geotools.styling.StyleBuilder;
75  import org.geotools.styling.StyleFactory;  import org.geotools.styling.StyleFactory;
 import org.opengis.filter.Filter;  
76  import org.opengis.filter.FilterFactory2;  import org.opengis.filter.FilterFactory2;
77  import org.opengis.referencing.crs.CoordinateReferenceSystem;  import org.opengis.referencing.crs.CoordinateReferenceSystem;
78    
# Line 87  import schmitzm.swing.SwingUtil; Line 80  import schmitzm.swing.SwingUtil;
80    
81  import com.vividsolutions.jts.geom.Coordinate;  import com.vividsolutions.jts.geom.Coordinate;
82  import com.vividsolutions.jts.geom.Envelope;  import com.vividsolutions.jts.geom.Envelope;
 import com.vividsolutions.jts.geom.Geometry;  
83  import com.vividsolutions.jts.geom.GeometryFactory;  import com.vividsolutions.jts.geom.GeometryFactory;
84    
85  public class JMapPane extends JPanel implements MouseListener,  public class JMapPane extends JPanel implements MouseListener,
86                  MouseMotionListener, HighlightChangeListener, SelectionChangeListener,                  MouseMotionListener, PropertyChangeListener, MapLayerListListener {
                 PropertyChangeListener, MapLayerListListener {  
87          private static Logger LOGGER = Logger.getLogger(JMapPane.class.getName());          private static Logger LOGGER = Logger.getLogger(JMapPane.class.getName());
88    
89          private static final long serialVersionUID = -8647971481359690499L;          private static final long serialVersionUID = -8647971481359690499L;
# Line 158  public class JMapPane extends JPanel imp Line 149  public class JMapPane extends JPanel imp
149          // SK: private BufferedImage baseImage, panningImage;          // SK: private BufferedImage baseImage, panningImage;
150    
151          /**          /**
          * image of selection  
          */  
         private BufferedImage selectImage;  
   
         /**  
          * style for selected items  
          */  
         private Style selectionStyle;  
   
         /**  
          * layer that selection works on  
          */  
         private MapLayer selectionLayer;  
   
         /**  
          * layer that highlight works on  
          */  
         private MapLayer highlightLayer;  
   
         /**  
          * the object which manages highlighting  
          */  
         private HighlightManager highlightManager;  
   
         /**  
          * is highlighting on or off  
          */  
         private boolean highlight = true;  
   
         /**  
152           * a factory for filters           * a factory for filters
153           */           */
154          FilterFactory2 ff;          FilterFactory2 ff;
# Line 197  public class JMapPane extends JPanel imp Line 158  public class JMapPane extends JPanel imp
158           */           */
159          GeometryFactory gf = new GeometryFactory(); // FactoryFinder.getGeometryFactory(null);          GeometryFactory gf = new GeometryFactory(); // FactoryFinder.getGeometryFactory(null);
160    
         /**  
          * the collections of features to be selected or highlighted  
          */  
         FeatureCollection selection;  
   
         /**  
          * the collections of features to be selected or highlighted  
          */  
         FeatureCollection highlightFeature;  
   
161          private int state = ZoomIn;          private int state = ZoomIn;
162    
163          /**          /**
# Line 214  public class JMapPane extends JPanel imp Line 165  public class JMapPane extends JPanel imp
165           */           */
166          private double zoomFactor = 2.0;          private double zoomFactor = 2.0;
167    
         Style lineHighlightStyle;  
   
         Style pointHighlightStyle;  
   
         Style polygonHighlightStyle;  
   
         Style polygonSelectionStyle;  
   
         Style pointSelectionStyle;  
   
         Style lineSelectionStyle;  
   
168          boolean changed = true;          boolean changed = true;
169    
170          LabelCache labelCache = new LabelCacheDefault();          LabelCache labelCache = new LabelCacheImpl();
171    
172          // xulu.sc          // xulu.sc
173          // private boolean reset = false;          // private boolean reset = false;
# Line 245  public class JMapPane extends JPanel imp Line 184  public class JMapPane extends JPanel imp
184    
185          int lastY;          int lastY;
186    
         private SelectionManager selectionManager;  
187          // xulu.sn          // xulu.sn
188          private Double maxZoomScale = Double.MIN_VALUE;          private Double maxZoomScale = Double.MIN_VALUE;
189          private Double minZoomScale = Double.MAX_VALUE;          private Double minZoomScale = Double.MAX_VALUE;
# Line 301  public class JMapPane extends JPanel imp Line 239  public class JMapPane extends JPanel imp
239    
240                  this.addMouseListener(this);                  this.addMouseListener(this);
241                  this.addMouseMotionListener(this);                  this.addMouseMotionListener(this);
                 setHighlightManager(new HighlightManager(highlightLayer));  
                 setSelectionManager(new SelectionManager(selectionLayer));  
                 lineHighlightStyle = setupStyle(LINE, Color.red);  
   
                 pointHighlightStyle = setupStyle(POINT, Color.red);  
   
                 polygonHighlightStyle = setupStyle(POLYGON, Color.red);  
   
                 polygonSelectionStyle = setupStyle(POLYGON, Color.cyan);  
   
                 pointSelectionStyle = setupStyle(POINT, Color.cyan);  
   
                 lineSelectionStyle = setupStyle(LINE, Color.cyan);  
242                  setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));                  setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
243          }          }
244    
# Line 325  public class JMapPane extends JPanel imp Line 250  public class JMapPane extends JPanel imp
250          }          }
251    
252          public void setRenderer(final GTRenderer renderer) {          public void setRenderer(final GTRenderer renderer) {
253                  Map hints = new HashMap();                  Map<Object,Object> hints = new HashMap<Object,Object>();
254                                    
255                  this.renderer = renderer;                  this.renderer = renderer;
256                                    
257                  if (renderer instanceof StreamingRenderer || renderer instanceof TransitionShapefileRenderer) {                  if (renderer instanceof StreamingRenderer || renderer instanceof ShapefileRenderer) {
258                          hints = renderer.getRendererHints();                          hints = renderer.getRendererHints();
259                          if (hints == null) {                          if (hints == null) {
260                                  hints = new HashMap();                                  hints = new HashMap<Object,Object>();
261                          }                          }
262                          if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) {                          if (hints.containsKey(StreamingRenderer.LABEL_CACHE_KEY)) {
263                                  labelCache = (LabelCache) hints                                  labelCache = (LabelCache) hints
# Line 405  public class JMapPane extends JPanel imp Line 330  public class JMapPane extends JPanel imp
330                  this.zoomFactor = zoomFactor;                  this.zoomFactor = zoomFactor;
331          }          }
332    
         public MapLayer getSelectionLayer() {  
                 return selectionLayer;  
         }  
   
         public void setSelectionLayer(final MapLayer selectionLayer) {  
                 this.selectionLayer = selectionLayer;  
                 if (selectionManager != null) {  
                         selectionManager.setSelectionLayer(selectionLayer);  
                 }  
         }  
   
         public boolean isHighlight() {  
                 return highlight;  
         }  
   
         public void setHighlight(final boolean highlight) {  
                 this.highlight = highlight;  
         }  
   
         public MapLayer getHighlightLayer() {  
                 return highlightLayer;  
         }  
   
         public void setHighlightLayer(final MapLayer highlightLayer) {  
                 this.highlightLayer = highlightLayer;  
   
                 if (highlightManager != null) {  
                         highlightManager.setHighlightLayer(highlightLayer);  
                 }  
         }  
   
         public HighlightManager getHighlightManager() {  
                 return highlightManager;  
         }  
   
         public void setHighlightManager(final HighlightManager highlightManager) {  
                 this.highlightManager = highlightManager;  
                 this.highlightManager.addHighlightChangeListener(this);  
                 this.addMouseMotionListener(this.highlightManager);  
         }  
   
         public Style getLineHighlightStyle() {  
                 return lineHighlightStyle;  
         }  
   
         public void setLineHighlightStyle(final Style lineHighlightStyle) {  
                 this.lineHighlightStyle = lineHighlightStyle;  
         }  
   
         public Style getLineSelectionStyle() {  
                 return lineSelectionStyle;  
         }  
   
         public void setLineSelectionStyle(final Style lineSelectionStyle) {  
                 this.lineSelectionStyle = lineSelectionStyle;  
         }  
   
         public Style getPointHighlightStyle() {  
                 return pointHighlightStyle;  
         }  
   
         public void setPointHighlightStyle(final Style pointHighlightStyle) {  
                 this.pointHighlightStyle = pointHighlightStyle;  
         }  
   
         public Style getPointSelectionStyle() {  
                 return pointSelectionStyle;  
         }  
   
         public void setPointSelectionStyle(final Style pointSelectionStyle) {  
                 this.pointSelectionStyle = pointSelectionStyle;  
         }  
   
         public Style getPolygonHighlightStyle() {  
                 return polygonHighlightStyle;  
         }  
   
         public void setPolygonHighlightStyle(final Style polygonHighlightStyle) {  
                 this.polygonHighlightStyle = polygonHighlightStyle;  
         }  
   
         public Style getPolygonSelectionStyle() {  
                 return polygonSelectionStyle;  
         }  
   
         public void setPolygonSelectionStyle(final Style polygonSelectionStyle) {  
                 this.polygonSelectionStyle = polygonSelectionStyle;  
         }  
333    
334          protected void paintComponent(final Graphics g) {          protected void paintComponent(final Graphics g) {
335                  super.paintComponent(g);                  super.paintComponent(g);
# Line 509  public class JMapPane extends JPanel imp Line 346  public class JMapPane extends JPanel imp
346                                  try {                                  try {
347                                          mapArea = context.getLayerBounds();                                          mapArea = context.getLayerBounds();
348                                  } catch (final IOException e) {                                  } catch (final IOException e) {
349                                          // TODO Auto-generated catch block                                          LOGGER.warn("context.getLayerBounds()", e);
                                         e.printStackTrace();  
350                                  }                                  }
351                          }                          }
352    
# Line 554  public class JMapPane extends JPanel imp Line 390  public class JMapPane extends JPanel imp
390                  }                  }
391    
392                  ((Graphics2D) g).drawImage(baseImage, 0, 0, this);                  ((Graphics2D) g).drawImage(baseImage, 0, 0, this);
   
                 if ((selection != null) && (selection.size() > 0)) {  
                         // paint selection  
   
                         String type = selectionLayer.getFeatureSource().getSchema()  
                                         .getDefaultGeometry().getType().getName();  
                         /* String type = selection.getDefaultGeometry().getGeometryType(); */  
                         /* System.out.println(type); */  
                         if (type == null)  
                                 type = "polygon";  
   
                         /* String type = "point"; */  
   
                         if (type.toLowerCase().endsWith("polygon")) {  
                                 selectionStyle = polygonSelectionStyle;  
                         } else if (type.toLowerCase().endsWith("point")) {  
                                 selectionStyle = pointSelectionStyle;  
                         } else if (type.toLowerCase().endsWith("line")) {  
                                 selectionStyle = lineSelectionStyle;  
                         }  
   
                         selectionContext = new DefaultMapContext(DefaultGeographicCRS.WGS84);  
   
                         selectionContext.addLayer(selection, selectionStyle);  
                         selectionRenderer.setContext(selectionContext);  
   
                         selectImage = new BufferedImage(dr.width, dr.height,  
                                         BufferedImage.TYPE_INT_ARGB);  
   
                         final Graphics2D ig = selectImage.createGraphics();  
                         /* System.out.println("rendering selection"); */  
                         selectionRenderer.paint((Graphics2D) ig, dr, mapArea);  
   
                         ((Graphics2D) g).drawImage(selectImage, 0, 0, this);  
                 }  
   
                 if (highlight && (highlightFeature != null)  
                                 && (highlightFeature.size() > 0)) {  
                         /*  
                          * String type = selection.getDefaultGeometry().getGeometryType();  
                          * System.out.println(type); if(type==null) type="polygon";  
                          */  
                         String type = highlightLayer.getFeatureSource().getSchema()  
                                         .getDefaultGeometry().getType().getName();  
                         /* String type = selection.getDefaultGeometry().getGeometryType(); */  
                         // System.out.println(type);  
                         if (type == null)  
                                 type = "polygon";  
   
                         /* String type = "point"; */  
                         Style highlightStyle = null;  
                         if (type.toLowerCase().endsWith("polygon")) {  
                                 highlightStyle = polygonHighlightStyle;  
                         } else if (type.toLowerCase().endsWith("point")) {  
                                 highlightStyle = pointHighlightStyle;  
                         } else if (type.toLowerCase().endsWith("line")) {  
                                 highlightStyle = lineHighlightStyle;  
                         }  
   
                         final MapContext highlightContext = new DefaultMapContext(  
                                         DefaultGeographicCRS.WGS84);  
   
                         highlightContext.addLayer(highlightFeature, highlightStyle);  
                         highlightRenderer.setContext(highlightContext);  
   
                         /* System.out.println("rendering highlight"); */  
                         highlightRenderer.paint((Graphics2D) g, dr, mapArea);  
                 }  
393          }          }
394    
395          private Envelope fixAspectRatio(final Rectangle r, final Envelope mapArea) {          private Envelope fixAspectRatio(final Rectangle r, final Envelope mapArea) {
# Line 660  public class JMapPane extends JPanel imp Line 428  public class JMapPane extends JPanel imp
428                  return new Envelope(ll, ur);                  return new Envelope(ll, ur);
429          }          }
430    
431          public void doSelection(final double x, final double y, final MapLayer layer) {  //      public void doSelection(final double x, final double y, final MapLayer layer) {
432    //
433                  final Geometry geometry = gf.createPoint(new Coordinate(x, y));  //              final Geometry geometry = gf.createPoint(new Coordinate(x, y));
434    //
435                  // org.opengis.geometry.Geometry geometry = new Point();  //              // org.opengis.geometry.Geometry geometry = new Point();
436    //
437                  findFeature(geometry, layer);  //              findFeature(geometry, layer);
438    //
439          }  //      }
440    //
441          /**  //      /**
442           * @param geometry  //       * @param geometry
443           *            - a geometry to construct the filter with  //       *            - a geometry to construct the filter with
444           * @param i  //       * @param i
445           *            - the index of the layer to search  //       *            - the index of the layer to search
446           * @throws IndexOutOfBoundsException  //       * @throws IndexOutOfBoundsException
447           */  //       */
448          private void findFeature(final Geometry geometry, final MapLayer layer)  //      private void findFeature(final Geometry geometry, final MapLayer layer)
449                          throws IndexOutOfBoundsException {  //                      throws IndexOutOfBoundsException {
450                  org.opengis.filter.spatial.BinarySpatialOperator f = null;  //              org.opengis.filter.spatial.BinarySpatialOperator f = null;
451    //
452                  if ((context == null) || (layer == null)) {  //              if ((context == null) || (layer == null)) {
453                          return;  //                      return;
454                  }  //              }
455    //
456                  try {  //              try {
457                          String name = layer.getFeatureSource().getSchema()  //                      String name = layer.getFeatureSource().getSchema()
458                                          .getDefaultGeometry().getLocalName();  //                                      .getDefaultGeometry().getLocalName();
459    //
460                          if (name == "") {  //                      if (name == "") {
461                                  name = "the_geom";  //                              name = "the_geom";
462                          }  //                      }
463    //
464                          try {  //                      try {
465                                  f = ff.contains(ff.property(name), ff.literal(geometry));  //                              f = ff.contains(ff.property(name), ff.literal(geometry));
466                                  if (selectionManager != null) {  //                              if (selectionManager != null) {
467  //                                      System.out.println("selection changed");  ////                                    System.out.println("selection changed");
468                                          selectionManager.selectionChanged(this, f);  //                                      selectionManager.selectionChanged(this, f);
469    //
470                                  }  //                              }
471                          } catch (final IllegalFilterException e) {  //                      } catch (final IllegalFilterException e) {
472                                  // TODO Auto-generated catch block  //                              // TODO Auto-generated catch block
473                                  e.printStackTrace();  //                              e.printStackTrace();
474                          }  //                      }
475    //
476                          /*  //                      /*
477                           * // f.addLeftGeometry(ff.property(name)); //  //                       * // f.addLeftGeometry(ff.property(name)); //
478                           * System.out.println("looking with " + f); FeatureCollection fc =  //                       * System.out.println("looking with " + f); FeatureCollection fc =
479                           * layer.getFeatureSource().getFeatures(f);  //                       * layer.getFeatureSource().getFeatures(f);
480                           *  //                       *
481                           *  //                       *
482                           *  //                       *
483                           * if (fcol == null) { fcol = fc;  //                       * if (fcol == null) { fcol = fc;
484                           *  //                       *
485                           * // here we should set the defaultgeom type } else {  //                       * // here we should set the defaultgeom type } else {
486                           * fcol.addAll(fc); }  //                       * fcol.addAll(fc); }
487                           */  //                       */
488    //
489                          /*  //                      /*
490                           * GeometryAttributeType gat =  //                       * GeometryAttributeType gat =
491                           * layer.getFeatureSource().getSchema().getDefaultGeometry();  //                       * layer.getFeatureSource().getSchema().getDefaultGeometry();
492                           * fcol.setDefaultGeometry((Geometry)gat.createDefaultValue());  //                       * fcol.setDefaultGeometry((Geometry)gat.createDefaultValue());
493                           */  //                       */
494    //
495                          /*  //                      /*
496                           * Iterator fi = fc.iterator(); while (fi.hasNext()) { SimpleFeature feat  //                       * Iterator fi = fc.iterator(); while (fi.hasNext()) { SimpleFeature feat
497                           * = (SimpleFeature) fi.next(); System.out.println("selected " +  //                       * = (SimpleFeature) fi.next(); System.out.println("selected " +
498                           * feat.getAttribute("STATE_NAME")); }  //                       * feat.getAttribute("STATE_NAME")); }
499                           */  //                       */
500                  } catch (final IllegalFilterException e) {  //              } catch (final IllegalFilterException e) {
501                          // TODO Auto-generated catch block  //                      // TODO Auto-generated catch block
502                          e.printStackTrace();  //                      e.printStackTrace();
503                  }  //              }
504                  return;  //              return;
505          }  //      }
506    
507          public void mouseClicked(final MouseEvent e) {          public void mouseClicked(final MouseEvent e) {
508                  if (mapArea == null) return;                  if (mapArea == null) return;
# Line 782  public class JMapPane extends JPanel imp Line 550  public class JMapPane extends JPanel imp
550                          zlevel = 1.0 / zoomFactor;                          zlevel = 1.0 / zoomFactor;
551    
552                          break;                          break;
553    //
554                  case Select:  //              case Select:
555                          doSelection(mapX, mapY, selectionLayer);  //                      doSelection(mapX, mapY, selectionLayer);
556    //
557                          return;  //                      return;
558    
559                  default:                  default:
560                          return;                          return;
# Line 884  public class JMapPane extends JPanel imp Line 652  public class JMapPane extends JPanel imp
652                          lastX = x;                          lastX = x;
653                          lastY = y;                          lastY = y;
654                          drawRectangle(graphics);                          drawRectangle(graphics);
655                  } else if (state == JMapPane.Select && selectionLayer != null) {                  }
656    //              else if (state == JMapPane.Select && selectionLayer != null) {
657                          // construct a new bbox filter  //
658                          final Rectangle bounds = this.getBounds();  //                      // construct a new bbox filter
659    //                      final Rectangle bounds = this.getBounds();
660                          final double mapWidth = mapArea.getWidth();  //
661                          final double mapHeight = mapArea.getHeight();  //                      final double mapWidth = mapArea.getWidth();
662    //                      final double mapHeight = mapArea.getHeight();
663                          final double x1 = ((this.startX * mapWidth) / (double) bounds.width)  //
664                                          + mapArea.getMinX();  //                      final double x1 = ((this.startX * mapWidth) / (double) bounds.width)
665                          final double y1 = (((bounds.getHeight() - this.startY) * mapHeight) / (double) bounds.height)  //                                      + mapArea.getMinX();
666                                          + mapArea.getMinY();  //                      final double y1 = (((bounds.getHeight() - this.startY) * mapHeight) / (double) bounds.height)
667                          final double x2 = ((x * mapWidth) / (double) bounds.width)  //                                      + mapArea.getMinY();
668                                          + mapArea.getMinX();  //                      final double x2 = ((x * mapWidth) / (double) bounds.width)
669                          final double y2 = (((bounds.getHeight() - y) * mapHeight) / (double) bounds.height)  //                                      + mapArea.getMinX();
670                                          + mapArea.getMinY();  //                      final double y2 = (((bounds.getHeight() - y) * mapHeight) / (double) bounds.height)
671                          final double left = Math.min(x1, x2);  //                                      + mapArea.getMinY();
672                          final double right = Math.max(x1, x2);  //                      final double left = Math.min(x1, x2);
673                          final double bottom = Math.min(y1, y2);  //                      final double right = Math.max(x1, x2);
674                          final double top = Math.max(y1, y2);  //                      final double bottom = Math.min(y1, y2);
675    //                      final double top = Math.max(y1, y2);
676                          String name = selectionLayer.getFeatureSource().getSchema()  //
677                                          .getDefaultGeometry().getName();  //                      String name = selectionLayer.getFeatureSource().getSchema()
678    //                                      .getDefaultGeometry().getName();
679                          if (name == "") {  //
680                                  name = "the_geom";  //                      if (name == "") {
681                          }  //                              name = "the_geom";
682                          final Filter bb = ff.bbox(ff.property(name), left, bottom, right, top,  //                      }
683                                          getContext().getCoordinateReferenceSystem().toString());  //                      final Filter bb = ff.bbox(ff.property(name), left, bottom, right, top,
684                          if (selectionManager != null) {  //                                      getContext().getCoordinateReferenceSystem().toString());
685                                  selectionManager.selectionChanged(this, bb);  //                      if (selectionManager != null) {
686                          }  //                              selectionManager.selectionChanged(this, bb);
687    //                      }
688                          graphics.setXORMode(Color.green);  //
689    //                      graphics.setXORMode(Color.green);
690                          /*  //
691                           * if ((lastX > 0) && (lastY > 0)) { drawRectangle(graphics); }  //                      /*
692                           */  //                       * if ((lastX > 0) && (lastY > 0)) { drawRectangle(graphics); }
693    //                       */
694                          // draw new box  //
695                          lastX = x;  //                      // draw new box
696                          lastY = y;  //                      lastX = x;
697                          drawRectangle(graphics);  //                      lastY = y;
698                  }  //                      drawRectangle(graphics);
699    //              }
700    
701          }          }
702    
# Line 1052  public class JMapPane extends JPanel imp Line 821  public class JMapPane extends JPanel imp
821                          setMapArea(bestAllowedMapArea(new Envelope(ll, ur)));                          setMapArea(bestAllowedMapArea(new Envelope(ll, ur)));
822    
823                          // xulu.ec                          // xulu.ec
824                  } else if (state == JMapPane.Select && selectionLayer != null) {                  }
825                          final double left = Math.min(startX, endX);  //              else if (state == JMapPane.Select && selectionLayer != null) {
826                          final double right = Math.max(startX, endX);  //                      final double left = Math.min(startX, endX);
827                          final double bottom = Math.min(startY, endY);  //                      final double right = Math.max(startX, endX);
828                          final double top = Math.max(startY, endY);  //                      final double bottom = Math.min(startY, endY);
829    //                      final double top = Math.max(startY, endY);
830                          String name = selectionLayer.getFeatureSource().getSchema()  //
831                                          .getDefaultGeometry().getLocalName();  //                      String name = selectionLayer.getFeatureSource().getSchema()
832    //                                      .getDefaultGeometry().getLocalName();
833                          if (name == "") {  //
834                                  name = "the_geom";  //                      if (name == "") {
835                          }  //                              name = "the_geom";
836                          final Filter bb = ff.bbox(ff.property(name), left, bottom, right, top,  //                      }
837                                          getContext().getCoordinateReferenceSystem().toString());  //                      final Filter bb = ff.bbox(ff.property(name), left, bottom, right, top,
838                          // System.out.println(bb.toString());  //                                      getContext().getCoordinateReferenceSystem().toString());
839                          if (selectionManager != null) {  //                      // System.out.println(bb.toString());
840                                  selectionManager.selectionChanged(this, bb);  //                      if (selectionManager != null) {
841                          }  //                              selectionManager.selectionChanged(this, bb);
842                          /*  //                      }
843                           * FeatureCollection fc; selection = null; try { fc =  //                      /*
844                           * selectionLayer.getFeatureSource().getFeatures(bb); selection =  //                       * FeatureCollection fc; selection = null; try { fc =
845                           * fc; } catch (IOException e) { e.printStackTrace(); }  //                       * selectionLayer.getFeatureSource().getFeatures(bb); selection =
846                           */  //                       * fc; } catch (IOException e) { e.printStackTrace(); }
847                  }  //                       */
848    //              }
849    
850                  // xulu.so                  // xulu.so
851                  // setMapArea(mapArea);                  // setMapArea(mapArea);
# Line 1124  public class JMapPane extends JPanel imp Line 894  public class JMapPane extends JPanel imp
894                  return s;                  return s;
895          }          }
896    
         public void highlightChanged(final HighlightChangedEvent e) {  
                 final org.opengis.filter.Filter f = e.getFilter();  
   
                 try {  
                         highlightFeature = highlightLayer.getFeatureSource().getFeatures(f);  
                 } catch (final IOException e1) {  
                         // TODO Auto-generated catch block  
                         e1.printStackTrace();  
                 }  
   
                 repaint();  
         }  
897    
898          public void propertyChange(final PropertyChangeEvent evt) {          public void propertyChange(final PropertyChangeEvent evt) {
899                  final String prop = evt.getPropertyName();                  final String prop = evt.getPropertyName();
# Line 1219  public class JMapPane extends JPanel imp Line 977  public class JMapPane extends JPanel imp
977          public void mouseMoved(final MouseEvent e) {          public void mouseMoved(final MouseEvent e) {
978          }          }
979    
         public FeatureCollection getSelection() {  
                 return selection;  
         }  
   
         public void setSelection(final FeatureCollection selection) {  
                 this.selection = selection;  
                 repaint();  
         }  
   
         /*  
          * (non-Javadoc)  
          *  
          * @see  
          * org.geotools.gui.swing.event.SelectionChangeListener#selectionChanged  
          * (org.geotools.gui.swing.event.SelectionChangedEvent)  
          */  
         public void selectionChanged(final SelectionChangedEvent e) {  
980    
                 try {  
                         selection = selectionLayer.getFeatureSource().getFeatures(  
                                         e.getFilter());  
                         repaint();  
                 } catch (final IOException e1) {  
                         e1.printStackTrace();  
                 }  
         }  
   
         public SelectionManager getSelectionManager() {  
                 return selectionManager;  
         }  
   
         public void setSelectionManager(final SelectionManager selectionManager) {  
                 this.selectionManager = selectionManager;  
                 this.selectionManager.addSelectionChangeListener(this);  
   
         }  
981    
982          // xulu.sn          // xulu.sn
983          /**          /**

Legend:
Removed from v.318  
changed lines
  Added in v.384

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26