@Override public List<Graphic> getSelectedAllGraphicsIntersecting(Rectangle rectangle, AffineTransform transform) { ArrayList<Graphic> selectedGraphicList = new ArrayList<>(); if (rectangle != null) { synchronized (models) { for (int i = models.size() - 1; i >= 0; i--) { Graphic graphic = models.get(i); GraphicLayer layer = graphic.getLayer(); if (layer.getVisible() && layer.getSelectable()) { Rectangle graphBounds = graphic.getBounds(transform); if (graphBounds != null && graphBounds.intersects(rectangle)) { Area selectionArea = graphic.getArea(transform); if (selectionArea != null && selectionArea.intersects(rectangle)) { selectedGraphicList.add(graphic); continue; } } GraphicLabel graphicLabel = graphic.getGraphicLabel(); if (graphic.getLabelVisible() && graphicLabel != null && graphicLabel.getLabels() != null) { Area selectionArea = graphicLabel.getArea(transform); if (selectionArea != null && selectionArea.intersects(rectangle)) { selectedGraphicList.add(graphic); } } } } } } return selectedGraphicList; }
Graphic g = models.get(i); GraphicLayer l = g.getLayer(); if (l.getVisible() && l.getSelectable()) { if (g.isOnGraphicLabel(mouseEvent)) { if (g.getSelected()) {
Graphic graphic = models.get(i); GraphicLayer layer = graphic.getLayer(); if (layer.getVisible() && layer.getSelectable()) {
public static Graphic drawFromCurrentGraphic(ViewCanvas<?> canvas, Graphic graphicCreator) { Objects.requireNonNull(canvas); Graphic newGraphic = Optional.ofNullable(graphicCreator).orElse(MeasureToolBar.selectionGraphic); GraphicLayer layer = getOrBuildLayer(canvas, newGraphic.getLayerType()); if (!layer.getVisible() || !(Boolean) canvas.getActionValue(ActionW.DRAWINGS.cmd())) { JOptionPane.showMessageDialog(canvas.getJComponent(), Messages.getString("AbstractLayerModel.msg_not_vis"), //$NON-NLS-1$ Messages.getString("AbstractLayerModel.draw"), //$NON-NLS-1$ JOptionPane.ERROR_MESSAGE); return null; } else { Graphic graph = newGraphic.copy(); if (graph != null) { graph.updateLabel(Boolean.TRUE, canvas); for (PropertyChangeListener listener : canvas.getGraphicManager().getGraphicsListeners()) { graph.addPropertyChangeListener(listener); } graph.setLayer(layer); canvas.getGraphicManager().addGraphic(graph); } return graph; } }
private static void applyPaint(Graphic graphic, Graphics2D g2d, AffineTransform transform, Rectangle2D bounds) { if (graphic.getLayer().getVisible()) { if (bounds != null) { Rectangle repaintBounds = graphic.getRepaintBounds(transform); if (repaintBounds != null && repaintBounds.intersects(bounds)) { graphic.paint(g2d, transform); } else { GraphicLabel graphicLabel = graphic.getGraphicLabel(); if (graphicLabel != null && graphicLabel.getLabels() != null) { Rectangle2D labelBounds = graphicLabel.getBounds(transform); if (labelBounds.intersects(bounds)) { graphic.paintLabel(g2d, transform); } } } } else { // convention is when bounds equals null graphic is repaint graphic.paint(g2d, transform); graphic.paintLabel(g2d, transform); } } }