&& selectionRectangle.getWidth() == widthOfUpdatedRectangle && selectionRectangle.getHeight() == heightOfUpdatedRectangle)) { setMovableRectangleInImageCoordinates(xOfUpdatedRectangle, yOfUpdatedRectangle, widthOfUpdatedRectangle, heightOfUpdatedRectangle); Shape newFigureShape = getViewToModelTransform(event).createTransformedShape(movableRectangle); final Rectangle2D modelRectangle = newFigureShape.getBounds2D(); adaptToModelRectangle(modelRectangle);
@Override public void mousePressed(MouseEvent event) { point = event.getPoint(); determineDraggedRectangleBorders(event); }
@Override public void panStarted(MouseEvent event) { super.panStarted(event); p0 = event.getPoint(); final Rectangle2D.Double intersectionRectangle = createIntersectionRectangle(); if (intersectionRectangle.contains(event.getPoint())) { regionSelectionInteractor.mousePressed(event); } }
/** * Creates a RegionSelectableWorldMapPane. * * @param dataModel The data model to be used * @param bindingContext The binding context which has to contain at least the following properties: * {@link #NORTH_BOUND northBound} , * {@link #SOUTH_BOUND southBound}, {@link #WEST_BOUND westBound}, and * {@link #EAST_BOUND eastBound}. If all these property values are null, default values * will be used. The property values are considered valid when the latitude values are * within the allowed latitude range [-90, 90], the longitude values are within the * allowed longitude range [-180, 180], the northBound is bigger than the southBound, * the eastBound is bigger than the westBound, and no value is null. In this case, * the world map will be initialized with these values. * @throws IllegalArgumentException If the bindingContext is null, it does not contain the expected properties or * the properties do not contain valid values */ public RegionSelectableWorldMapPane(WorldMapPaneDataModel dataModel, BindingContext bindingContext) { ensureValidBindingContext(bindingContext); this.bindingContext = bindingContext; worldMapPane = new FigureEditorAwareWorldMapPane(dataModel, new SelectionOverlay(dataModel)); panSupport = new RegionSelectionDecoratingPanSupport(worldMapPane.getLayerCanvas()); worldMapPane.setPanSupport(panSupport); figureEditor = new DefaultFigureEditor(worldMapPane.getLayerCanvas()); regionSelectionInteractor = new RegionSelectionInteractor(); worldMapPane.getLayerCanvas().addMouseMotionListener(cursorChanger); }
@Override public void performPan(MouseEvent event) { final Rectangle2D.Double intersectionRectangle = createIntersectionRectangle(); if (intersectionRectangle.contains(p0)) { regionSelectionInteractor.mouseDragged(event); } else { super.performPan(event); } }
private void adaptToModelRectangle(Rectangle2D modelRectangle) { correctBoundsIfNecessary(modelRectangle); if (modelRectangle.getWidth() != 0 && modelRectangle.getHeight() != 0 && !modelRectangle.equals(getFirstFigure().getBounds())) { updateFigure(modelRectangle); updateProperties(modelRectangle); } }
private void reset() { selectionRectangle.setRect(defaultRectangle); movableRectangle.setRect(defaultRectangle); cursorChanger.updateRectanglesForDragCursor(); updateProperties(defaultShape.getBounds2D()); updateFigure(defaultShape.getBounds2D()); worldMapPane.zoomAll(); }