public double[] isSelected(int[] screenCoordTest, AbstractDrawer draw) { for (int i = 0; i < XY.length; i++) { int[] screenCoord = draw.project(XY[i]); if ((screenCoord[0] + note_precision > screenCoordTest[0]) && (screenCoord[0] - note_precision < screenCoordTest[0]) && (screenCoord[1] + note_precision > screenCoordTest[1]) && (screenCoord[1] - note_precision < screenCoordTest[1])) { // System.out.println("fid of selected point: " + pointId[i]); List features = layer.getFeatureCollectionWrapper().getFeatures(); Feature selFeature = null; for (Iterator iter = features.iterator(); iter.hasNext(); ) { Feature f = (Feature) iter.next(); if (pointId[i] == f.getID()) { selFeature = f; } } // context.getLayerViewPanel().getSelectionManager().clear(); // context.getLayerViewPanel().getSelectionManager().getFeatureSelection().selectItems(layer, selFeature); Collection clickedFeatures = new ArrayList(); clickedFeatures.add(selFeature); try { zoomToSelectedItemsPlugIn.flash( FeatureUtil.toGeometries(clickedFeatures), context.getLayerViewPanel()); } catch (Throwable t) { context.getWorkbenchContext().getErrorHandler().handleThrowable(t); } // -- [sstein] modified to print FID as label // but this results with problems in AbstractDrawer.drawCoordinate() // since it will try to set the axes using the FID as well. /* double[] vals; if (pointId !=null){ vals = new double[3]; vals[0] = XY[i][0]; vals[1] = XY[i][1]; vals[2] = pointId[i]; } else{ vals = XY[i]; } return vals; */ return XY[i]; } } return null; }
public void updateLegend(PlugInContext context, I18NPlug iPlug) { Vector<LegendElement> tempItems = new Vector<>(10, 5); boolean showLine; boolean showFill; if (iPlug != null && legendName == null) { legendName = iPlug.get("JumpPrinter.Furniture.Legend"); } this.iPlug = iPlug; if (legendItems != null) { for (int i = 0; i < legendItems.size(); i++) { tempItems.addElement(legendItems.elementAt(i)); } } legendItems = new Vector<LegendElement>(10, 5); java.util.List layerCollection = context.getLayerViewPanel().getLayerManager().getVisibleLayers(true); Iterator i = layerCollection.iterator(); int count = 0; while (i.hasNext()) { Layer layer = (Layer) i.next(); String name = layer.getName(); String desc = layer.getDescription(); if (debug) { System.out.println("layer " + count + ":" + name + "," + desc); } BasicStyle basicStyle = layer.getBasicStyle(); VertexStyle vertexStyle = layer.getVertexStyle(); Collection themeStyles = null; ColorThemingStyle themeStyle = (ColorThemingStyle) layer.getStyle(ColorThemingStyle.class); if (debug) { System.out.println(" Theming enabled: " + themeStyle.isEnabled()); } if (themeStyle.isEnabled()) { Map themeMap = themeStyle.getAttributeValueToBasicStyleMap(); if (debug) { System.out.println("Map:" + themeMap.toString()); } themeStyles = themeMap.values(); } int alpha = basicStyle.getAlpha(); Color lineColor = basicStyle.getLineColor(); lineColor = new Color(lineColor.getRed(), lineColor.getGreen(), lineColor.getBlue(), alpha); showLine = true; if (!basicStyle.isRenderingLine()) { showLine = false; } Color fillColor = basicStyle.getFillColor(); fillColor = new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue(), alpha); showFill = true; if (!basicStyle.isRenderingFill()) { showFill = false; } Stroke lineStroke = basicStyle.getLineStroke(); Paint fillPattern = basicStyle.getFillPattern(); if (!basicStyle.isRenderingFillPattern()) { fillPattern = null; } // System.out.println(" LineColor: "+basicStyle.getLineColor()+" // FillColor:"+basicStyle.getFillColor()); // create new legend item, include by default LegendElement legendElement = new LegendElement( true, name, lineColor, lineStroke, fillColor, fillPattern, themeStyles, null, vertexStyle, showLine, showFill); // set include on existing items for (int k = 0; k < tempItems.size(); k++) { LegendElement anitem = tempItems.elementAt(k); if (anitem.name.equals(legendElement.name)) { legendElement.include = anitem.include; } } legendItems.addElement(legendElement); if (debug) { System.out.println(legendElement.toString()); } count++; } }