Java Code Examples for javafx.scene.input.MouseEvent#getX()

The following examples show how to use javafx.scene.input.MouseEvent#getX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartZoomManager.java    From jfxutils with Apache License 2.0 6 votes vote down vote up
private void onMousePressed( MouseEvent mouseEvent ) {
	double x = mouseEvent.getX();
	double y = mouseEvent.getY();

	Rectangle2D plotArea = chartInfo.getPlotArea();
	DefaultChartInputContext context = new DefaultChartInputContext( chartInfo, x, y );
	zoomMode = axisConstraintStrategy.getConstraint(context);

	if ( zoomMode == AxisConstraint.Both ) {
		selectRect.setTranslateX( x );
		selectRect.setTranslateY( y );
		rectX.set( x );
		rectY.set( y );

	} else if ( zoomMode == AxisConstraint.Horizontal ) {
		selectRect.setTranslateX( x );
		selectRect.setTranslateY( plotArea.getMinY() );
		rectX.set( x );
		rectY.set( plotArea.getMaxY() );

	} else if ( zoomMode == AxisConstraint.Vertical ) {
		selectRect.setTranslateX( plotArea.getMinX() );
		selectRect.setTranslateY( y );
		rectX.set( plotArea.getMaxX() );
		rectY.set( y );
	}
}
 
Example 2
Source File: TargetEditorController.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
@FXML
public void mouseMoved(MouseEvent event) {
	if (freeformButton.isSelected()) {
		drawTempPolygonEdge(event);
	}

	if (!cursorRegion.isPresent() || cursorButton.isSelected()) return;

	final Node selected = cursorRegion.get();

	lastMouseX = event.getX() - (selected.getLayoutBounds().getWidth() / 2);
	lastMouseY = event.getY() - (selected.getLayoutBounds().getHeight() / 2);

	if (lastMouseX < 0) lastMouseX = 0;
	if (lastMouseY < 0) lastMouseY = 0;

	if (event.getX() + (selected.getLayoutBounds().getWidth() / 2) <= canvasPane.getWidth())
		selected.setLayoutX(lastMouseX - selected.getLayoutBounds().getMinX());

	if (event.getY() + (selected.getLayoutBounds().getHeight() / 2) <= canvasPane.getHeight())
		selected.setLayoutY(lastMouseY - selected.getLayoutBounds().getMinY());

	event.consume();
}
 
Example 3
Source File: CrosshairIndicator.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private void updateLabel(final MouseEvent event, final Bounds plotAreaBounds) {
    coordinatesLabel.setText(formatLabelText(getLocationInPlotArea(event)));

    final double width = coordinatesLabel.prefWidth(-1);
    final double height = coordinatesLabel.prefHeight(width);

    double xLocation = event.getX() + CrosshairIndicator.LABEL_X_OFFSET;
    double yLocation = event.getY() + CrosshairIndicator.LABEL_Y_OFFSET;

    if (xLocation + width > plotAreaBounds.getMaxX()) {
        xLocation = event.getX() - CrosshairIndicator.LABEL_X_OFFSET - width;
    }
    if (yLocation + height > plotAreaBounds.getMaxY()) {
        yLocation = event.getY() - CrosshairIndicator.LABEL_Y_OFFSET - height;
    }
    coordinatesLabel.resizeRelocate(xLocation, yLocation, width, height);
}
 
Example 4
Source File: Scene3DHandler.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void drag(final MouseEvent event)
{
	synchronized (getTransformLock())
	{
		LOG.trace("drag - translate");
		final double dX = event.getX() - getStartX();
		final double dY = event.getY() - getStartY();

		LOG.trace("dx " + dX + " dy: " + dY);

		final Affine target = affine.clone();
		target.prependTranslation(2 * dX / viewer.getHeight(), 2 * dY / viewer.getHeight());

		InvokeOnJavaFXApplicationThread.invoke(() -> setAffine(target));

		setStartX(getStartX() + dX);
		setStartY(getStartY() + dY);
	}
}
 
Example 5
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
    public void handlerPressed(MouseEvent event) {

        scrollPane.setPannable(false);
        mouseX = event.getX();
        mouseY = event.getY();
//        logger.debug((int) mouseX + " " + (int) mouseY);
    }
 
Example 6
Source File: DragResizerUtil.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
protected void setNewInitialEventCoordinates(final MouseEvent event) {
    final Bounds bounds = node.getBoundsInParent();
    nodePositionX = bounds.getMinX();
    nodePositionY = bounds.getMinY();
    nodeHeight = bounds.getHeight();
    nodeWidth = bounds.getWidth();
    clickX = event.getX();
    clickY = event.getY();
}
 
Example 7
Source File: AnchorHandlerFX.java    From jfreechart-fx with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Handles a mouse clicked event by setting the anchor point for the
 * canvas and redrawing the chart (the anchor point is a reference point
 * used by the chart to determine crosshair lines).
 * 
 * @param canvas  the chart canvas ({@code null} not permitted).
 * @param e  the mouse event ({@code null} not permitted).
 */
@Override
public void handleMouseClicked(ChartCanvas canvas, MouseEvent e) {
    if (this.mousePressedPoint == null) {
        return;
    }
    Point2D currPt = new Point2D.Double(e.getX(), e.getY());
    if (this.mousePressedPoint.distance(currPt) < 2) {
        canvas.setAnchor(currPt);
    }
    this.mousePressedPoint = null;
}
 
Example 8
Source File: TaDispatchHandler.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Handles a mouse clicked event by setting the anchor point for the
 * canvas and redrawing the org.sjwimmer.tacharting.chart (the anchor point is a reference point
 * used by the org.sjwimmer.tacharting.chart to determine crosshair lines).
 *
 * @param canvas  the org.sjwimmer.tacharting.chart canvas ({@code null} not permitted).
 * @param e  the mouse event ({@code null} not permitted).
 */
@Override
public void handleMouseClicked(TaChartCanvas canvas, MouseEvent e) {
    if (this.mousePressedPoint == null) {
        return;
    }
    double x = e.getX();
    double y = e.getY();
    ChartEntity entity = canvas.getRenderingInfo().getEntityCollection().getEntity(x, y);
    ChartMouseEventFX event = new ChartMouseEventFX(canvas.getChart(), e, entity);
    for (ChartMouseListenerFX listener : canvas.getChartMouseListeners()) {
        listener.chartMouseClicked(event);
    }
}
 
Example 9
Source File: NestedBarChart.java    From charts with Apache License 2.0 5 votes vote down vote up
public void checkForClick(final MouseEvent EVT) {
    final double X = EVT.getX();
    final double Y = EVT.getY();

    popup.setX(EVT.getScreenX());
    popup.setY(EVT.getScreenY() - popup.getHeight());

    long noOfBars       = series.size();
    double spacer       = width * 0.05;
    double mainBarWidth = (width - (spacer * (noOfBars - 1))) / noOfBars;

    // Find series with sum of values
    double maxSum = -Double.MAX_VALUE;
    for (int i = 0 ; i < noOfBars  ;i++) {
        maxSum = Math.max(maxSum, series.get(i).getItems().stream().mapToDouble(ChartItem::getValue).sum());
    }
    double                     stepY          = height / maxSum;
    ChartItemSeries<ChartItem> selectedSeries = null;
    for (int i = 0 ; i < noOfBars ; i++) {
        ChartItemSeries<ChartItem> s             = series.get(i);
        int                        noOfItems     = s.getNoOfItems();
        double                     sumOfItems    = s.getItems().stream().mapToDouble(ChartItem::getValue).sum();
        double                     innerBarWidth = mainBarWidth / noOfItems;
        double                     mainBarHeight = sumOfItems * stepY;
        double                     minX          = i * mainBarWidth + i * spacer;
        if (Helper.isInRectangle(X, Y, minX, height - mainBarHeight, minX + mainBarWidth, height)) {
            selectedSeries = s;
        }
        for (ChartItem item : s.getItems()) {
            double innerBarHeight = item.getValue() * stepY;
            if (Helper.isInRectangle(X, Y, minX, height - innerBarHeight, minX + innerBarWidth, height)) {
                fireSelectionEvent(new SelectionEvent(selectedSeries, item));
                return;
            }
            minX += innerBarWidth;
        }
    }
    if (null != selectedSeries) { fireSelectionEvent(new SelectionEvent(selectedSeries)); }
}
 
Example 10
Source File: ZoomHandlerFX.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Handles a mouse pressed event by recording the initial mouse pointer
 * location.
 * 
 * @param canvas  the JavaFX canvas (<code>null</code> not permitted).
 * @param e  the mouse event (<code>null</code> not permitted).
 */
@Override
public void handleMousePressed(ChartCanvas canvas, MouseEvent e) {
    Point2D pt = new Point2D.Double(e.getX(), e.getY());
    Rectangle2D dataArea = canvas.findDataArea(pt);
    if (dataArea != null) {
        this.startPoint = ShapeUtilities.getPointInRectangle(e.getX(),
                e.getY(), dataArea);
    } else {
        this.startPoint = null;
        canvas.clearLiveHandler();
    }
}
 
Example 11
Source File: ChatListStage.java    From oim-fx with MIT License 5 votes vote down vote up
private Cursor getCursor(MouseEvent me, Pane pane) {
	Cursor cursor = Cursor.DEFAULT;

	double grp = 3;
	double width = pane.getWidth();
	double height = pane.getHeight();

	double x = me.getX();
	double y = me.getY();

	if (x < grp && y < grp) {
		// cursor = Cursor.SE_RESIZE;
		type = 1;
	} else if (x > (width - grp) && y < grp) {
		// cursor = Cursor.SW_RESIZE;
		type = 2;
	} else if (x < grp && y > (height - grp)) {
		// cursor = Cursor.SW_RESIZE;
		type = 3;
	} else if (x > (width - grp) && y > (height - grp)) {
		// cursor = Cursor.SE_RESIZE;
		type = 4;
	} else if (x < grp) {
		// cursor = Cursor.H_RESIZE;
		type = 5;
	} else if (x > (width - grp)) {
		cursor = Cursor.H_RESIZE;
		type = 6;
	} else if (y < grp) {
		// cursor = Cursor.V_RESIZE;
		type = 7;
	} else if (y > (height - grp)) {
		// cursor = Cursor.V_RESIZE;
		type = 8;
	} else {
		type = 0;
	}
	return cursor;
}
 
Example 12
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
public void topLeftHandlerReleased(MouseEvent event) {
    scrollPane.setPannable(true);
    if (isPickingColor.get() || topLeftHandler == null || !topLeftHandler.isVisible()
            || !maskPane.getChildren().contains(topLeftHandler)) {
        return;
    }

    double offsetX = topLeftHandler.getLayoutX() + event.getX() - mouseX - imageView.getLayoutX();
    double offsetY = topLeftHandler.getLayoutY() + event.getY() - mouseY - imageView.getLayoutY();
    double x = offsetX * getImageWidth() / imageView.getBoundsInParent().getWidth();
    double y = offsetY * getImageHeight() / imageView.getBoundsInParent().getHeight();
    if (maskRectangleLine != null && maskRectangleLine.isVisible()) {

        if (x < maskRectangleData.getBigX() && y < maskRectangleData.getBigY()) {
            if (x >= getImageWidth() - 1) {
                x = getImageWidth() - 2;
            }
            if (y >= getImageHeight() - 1) {
                y = getImageHeight() - 2;
            }
            maskRectangleData.setSmallX(x);
            maskRectangleData.setSmallY(y);
            drawMaskRectangleLine();
        }
    }

}
 
Example 13
Source File: ImageManufacturePenController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
    @Override
    public void mouseReleased(MouseEvent event) {
        if (null == opType || imageView == null || imageView.getImage() == null) {
            return;
        }
        imageController.scrollPane.setPannable(true);
        DoublePoint p = imageController.getImageXY(event, imageView);
        imageController.showXY(event, p);

        if (event.getButton() == MouseButton.SECONDARY || p == null) {
            return;
        }

        switch (opType) {
            case Polyline:
                if (lastX == event.getX() && lastY == event.getY()) {
                    return;
                }
                imageController.maskLineData.add(p);
                lastX = event.getX();
                lastY = event.getY();
                drawPolyline();
                break;
            case DrawLines:
            case Erase:
//            case Mosaic:
//            case Frosted:
                imageController.maskPenData.endLine(p);
                lastX = event.getX();
                lastY = event.getY();
                updateMask();
        }

    }
 
Example 14
Source File: ConcentricRingChart.java    From charts with Apache License 2.0 5 votes vote down vote up
private void handleMouseEvents(final MouseEvent EVT) {
    double x           = EVT.getX();
    double y           = EVT.getY();
    double centerX     = size * 0.5;
    double centerY     = centerX;
    double radius      = size * 0.5;
    double innerSpacer = radius * 0.18;
    double barSpacer   = (radius - innerSpacer) * 0.005;
    int    noOfItems   = items.size();
    double barWidth    = (radius - innerSpacer - (noOfItems - 1) * barSpacer) / noOfItems;
    double startAngle  = 0;
    double maxValue    = noOfItems == 0 ? 0 : items.stream().max(Comparator.comparingDouble(ChartItem::getValue)).get().getValue();
    List<ChartItem> sortedItems;
    if (isSorted()) {
        if (Order.ASCENDING == getOrder()) {
            sortedItems = items.stream().sorted(Comparator.comparingDouble(ChartItem::getValue)).collect(Collectors.toList());
        } else {
            sortedItems = items.stream().sorted(Comparator.comparingDouble(ChartItem::getValue).reversed()).collect(Collectors.toList());
        }
    } else {
        sortedItems = items;
    }
    for (int i = 0 ; i < noOfItems ; i++) {
        ChartItem item    = sortedItems.get(i);
        double    value = Helper.clamp(0, Double.MAX_VALUE, item.getValue());
        double    barWH = size - barWidth - (2 * i * barWidth - barSpacer) - (2 * i * barSpacer);
        double    angle = value / maxValue * 270.0;

        boolean hit = Helper.isInRingSegment(x, y, centerX, centerY, (barWH + barWidth) * 0.5, (barWH - barWidth) * 0.5, startAngle, angle);
        if (hit) {
            popup.setX(EVT.getScreenX());
            popup.setY(EVT.getScreenY() - popup.getHeight());
            fireSelectionEvent(new SelectionEvent(item));
            break;
        }
    }
}
 
Example 15
Source File: GenericStyledAreaBehavior.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Result processPrimaryOnlyMouseDragged(MouseEvent e) {
    Point2D p = new Point2D(e.getX(), e.getY());
    if(view.getLayoutBounds().contains(p)) {
        dragTo(p);
    }
    view.setAutoScrollOnDragDesired(true);
    // autoScrollTo will be set in "continueOrStopAutoScroll(MouseEvent)"
    return Result.PROCEED;
}
 
Example 16
Source File: MouseCoordinatePrinter.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void handle(final MouseEvent e)
{
	this.x = e.getX();
	this.y = e.getY();
	updateStatusBar();
}
 
Example 17
Source File: ViewshedLocationController.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
public void initialize() {
  // create a scene and add a basemap to it
  ArcGISScene scene = new ArcGISScene();
  scene.setBasemap(Basemap.createImagery());
  sceneView.setArcGISScene(scene);

  // add base surface for elevation data
  Surface surface = new Surface();
  final String localElevationImageService = "http://scene.arcgis" +
      ".com/arcgis/rest/services/BREST_DTM_1M/ImageServer";
  surface.getElevationSources().add(new ArcGISTiledElevationSource(localElevationImageService));
  scene.setBaseSurface(surface);

  // add a scene layer
  final String buildings = "http://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0";
  ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(buildings);
  scene.getOperationalLayers().add(sceneLayer);

  // create a viewshed from the camera
  Point location = new Point(-4.50, 48.4,100.0);
  LocationViewshed viewshed = new LocationViewshed(location, headingSlider.getValue(), pitchSlider.getValue(),
      horizontalAngleSlider.getValue(), verticalAngleSlider.getValue(), minDistanceSlider.getValue(),
      maxDistanceSlider.getValue());

  // set the camera
  Camera camera = new Camera(location, 200.0, 20.0, 70.0, 0.0);
  sceneView.setViewpointCamera(camera);

  // create an analysis overlay to add the viewshed to the scene view
  AnalysisOverlay analysisOverlay = new AnalysisOverlay();
  analysisOverlay.getAnalyses().add(viewshed);
  sceneView.getAnalysisOverlays().add(analysisOverlay);

  // create a listener to update the viewshed location when the mouse moves
  EventHandler<MouseEvent> mouseMoveEventHandler = new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent event) {
      Point2D point2D = new Point2D(event.getX(), event.getY());
      ListenableFuture<Point> pointFuture = sceneView.screenToLocationAsync(point2D);
      pointFuture.addDoneListener(() -> {
        try {
          Point point = pointFuture.get();
          PointBuilder pointBuilder = new PointBuilder(point);
          pointBuilder.setZ(point.getZ() + 50.0);
          viewshed.setLocation(pointBuilder.toGeometry());
          // add listener back
          sceneView.setOnMouseMoved(this);
        } catch (InterruptedException | ExecutionException e) {
          e.printStackTrace();
        }
      });
      // disable listener until location is updated (for performance)
      sceneView.setOnMouseMoved(null);
    }
  };
  // remove the default listener for mouse move events
  sceneView.setOnMouseMoved(null);

  // click to start/stop moving viewshed with mouse
  sceneView.setOnMouseClicked(event -> {
    if (event.isStillSincePress() && event.getButton() == MouseButton.PRIMARY) {
      if (sceneView.getOnMouseMoved() == null) {
        sceneView.setOnMouseMoved(mouseMoveEventHandler);
      } else {
        sceneView.setOnMouseMoved(null);
      }
    }
  });

  // toggle visibility
  visibilityToggle.selectedProperty().addListener(e -> viewshed.setVisible(visibilityToggle.isSelected()));
  visibilityToggle.textProperty().bind(Bindings.createStringBinding(() -> visibilityToggle.isSelected() ? "ON" :
      "OFF", visibilityToggle.selectedProperty()));
  frustumToggle.selectedProperty().addListener(e -> viewshed.setFrustumOutlineVisible(frustumToggle.isSelected()));
  frustumToggle.textProperty().bind(Bindings.createStringBinding(() -> frustumToggle.isSelected() ? "ON" :
      "OFF", frustumToggle.selectedProperty()));
  // heading slider
  headingSlider.valueProperty().addListener(e -> viewshed.setHeading(headingSlider.getValue()));
  // pitch slider
  pitchSlider.valueProperty().addListener(e -> viewshed.setPitch(pitchSlider.getValue()));
  // horizontal angle slider
  horizontalAngleSlider.valueProperty().addListener(e -> viewshed.setHorizontalAngle(horizontalAngleSlider.getValue()));
  // vertical angle slider
  verticalAngleSlider.valueProperty().addListener(e -> viewshed.setVerticalAngle(verticalAngleSlider
      .getValue()));
  // distance sliders
  minDistanceSlider.valueProperty().addListener(e -> viewshed.setMinDistance(minDistanceSlider.getValue()));
  maxDistanceSlider.valueProperty().addListener(e -> viewshed.setMaxDistance(maxDistanceSlider.getValue()));
  // colors
  visibleColorPicker.setValue(Color.rgb(0, 255, 0, 0.8));
  visibleColorPicker.valueProperty().addListener(e -> Viewshed.setVisibleColor(colorToInt(visibleColorPicker
      .getValue())));
  obstructedColorPicker.setValue(Color.rgb(255, 0, 0, 0.8));
  obstructedColorPicker.valueProperty().addListener(e -> Viewshed.setObstructedColor(colorToInt(obstructedColorPicker
      .getValue())));
  frustumColorPicker.setValue(Color.rgb(0, 0, 255, 0.8));
  frustumColorPicker.valueProperty().addListener(e -> Viewshed.setFrustumOutlineColor(colorToInt(frustumColorPicker
      .getValue())));
}
 
Example 18
Source File: TargetView.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
private boolean isLeftZone(MouseEvent event) {
	return event.getX() < (targetGroup.getLayoutBounds().getMinX() + RESIZE_MARGIN);
}
 
Example 19
Source File: ImagePlot.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** onMousePressed */
private void mouseDown(final MouseEvent e)
{
    // Don't start mouse actions when user invokes context menu
    if (! e.isPrimaryButtonDown()  ||  (PlatformInfo.is_mac_os_x && e.isControlDown()))
        return;

    // Received a click while a tacker is active
    // -> User clicked outside of tracker. Remove it.
    if (roi_tracker != null)
    {
        removeROITracker();
        // Don't cause accidental 'zoom out' etc.
        // User needs to click again for that.
        return;
    }

    // Select any tracker
    final Point2D current = new Point2D(e.getX(), e.getY());
    for (RegionOfInterest roi : rois)
        if (roi.isVisible()  &&  roi.isInteractive())
        {
            final Rectangle rect = roiToScreen(roi);
            if (rect.contains(current.getX(), current.getY()))
            {   // Check if complete ROI is visible,
                // because otherwise tracker would extend beyond the
                // current image viewport
                final Rectangle2D image_rect = GraphicsUtils.convert(image_area);
                if (image_rect.contains(rect.x, rect.y, rect.width, rect.height))
                {
                    roi_tracker = new Tracker(image_rect);
                    roi_tracker.setPosition(rect.x, rect.y, rect.width, rect.height);
                    ChildCare.addChild(getParent(), roi_tracker);
                    final int index = rois.indexOf(roi);
                    roi_tracker.setListener((old_pos, new_pos) -> updateRoiFromScreen(index, new_pos));
                    return;
                }
            }
        }

    mouse_start = mouse_current = Optional.of(current);

    final int clicks = e.getClickCount();

    if (mouse_mode == MouseMode.NONE)
    {
        if (crosshair)
        {
            updateLocationInfo(e.getX(), e.getY());
            requestRedraw();
        }
    }
    else if (mouse_mode == MouseMode.PAN)
    {   // Determine start of 'pan'
        mouse_start_x_range = x_axis.getValueRange();
        mouse_start_y_range = y_axis.getValueRange();
        mouse_mode = MouseMode.PAN_PLOT;
    }
    else if (mouse_mode == MouseMode.ZOOM_IN  &&  clicks == 1)
    {   // Determine start of 'rubberband' zoom.
        // Reset cursor from SIZE* to CROSS.
        if (y_axis.getBounds().contains(current.getX(), current.getY()))
        {
            mouse_mode = MouseMode.ZOOM_IN_Y;
            PlotCursors.setCursor(this, mouse_mode);
        }
        else if (image_area.contains(current.getX(), current.getY()))
        {
            mouse_mode = MouseMode.ZOOM_IN_PLOT;
            PlotCursors.setCursor(this, mouse_mode);
        }
        else if (x_axis.getBounds().contains(current.getX(), current.getY()))
        {
            mouse_mode = MouseMode.ZOOM_IN_X;
            PlotCursors.setCursor(this, mouse_mode);
        }
    }
    else if ((mouse_mode == MouseMode.ZOOM_IN && clicks == 2)  ||  mouse_mode == MouseMode.ZOOM_OUT)
        zoomInOut(current.getX(), current.getY(), ZOOM_FACTOR);
}
 
Example 20
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
@FXML
public void leftCenterHandlerReleased(MouseEvent event) {
    scrollPane.setPannable(true);
    if (isPickingColor.get()) {
        return;
    }

    if (maskRectangleLine != null && maskRectangleLine.isVisible()) {
        double offsetX = leftCenterHandler.getLayoutX() + event.getX() - mouseX - imageView.getLayoutX();
        double x = offsetX * getImageWidth() / imageView.getBoundsInParent().getWidth();

        if (x < maskRectangleData.getBigX()) {
            if (x >= getImageWidth() - 1) {
                x = getImageWidth() - 2;
            }
            maskRectangleData.setSmallX(x);
            drawMaskRectangleLine();
        }
    }

    if (maskCircleLine != null && maskCircleLine.isVisible()) {
        double d = rightCenterHandler.getLayoutX() - leftCenterHandler.getLayoutX() - event.getX() + mouseX;
        if (d > 0) {
            d = d * getImageWidth() / imageView.getBoundsInParent().getWidth();
            maskCircleData.setRadius(d / 2);
            drawMaskCircleLine();
        }
    }

    if (maskEllipseLine != null && maskEllipseLine.isVisible()) {
        double rx = (rightCenterHandler.getLayoutX() - leftCenterHandler.getLayoutX() - event.getX() + mouseX) / 2;
        if (rx > 0) {
            rx = rx * getImageWidth() / imageView.getBoundsInParent().getWidth();
            double ry = maskEllipseData.getRadiusY();
            double cx = maskEllipseData.getCenterX();
            double cy = maskEllipseData.getCenterY();
            maskEllipseData = new DoubleEllipse(cx - rx, cy - ry, cx + rx, cy + ry);
            drawMaskEllipseLine();
        }
    }

}