2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 package org.scilab.modules.renderer.JoGLView.interaction;
14 import java.awt.event.MouseEvent;
16 import org.scilab.modules.graphic_objects.graphicController.GraphicController;
17 import org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProperties;
18 import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
21 * @author Bruno JOFRET
23 public class ZoomRubberBox extends RubberBox {
26 * Default constructor.
28 * @param drawerVisitor parent drawer visitor.
30 public ZoomRubberBox(DrawerVisitor drawerVisitor) {
35 public final void mouseClicked(MouseEvent e) {
36 mouseButton = e.getButton();
37 if (e.getButton() == MouseEvent.BUTTON1) {
40 if (setPointA(e.getPoint())) {
41 status = Status.WAIT_POINT_B;
48 setPointB(e.getPoint());
49 if (pointBComputer.is2D()) {
54 status = Status.WAIT_POINT_C;
58 setPointC(e.getPoint());
59 status = Status.WAIT_POINT_D;
62 setPointD(e.getPoint());
72 if (e.getButton() == MouseEvent.BUTTON3) {
79 * Actually set the zoom box depending on current value of firstPoint and secondPoint.
82 protected void process() {
84 Math.min(firstPoint.getX(), secondPoint.getX()), Math.max(firstPoint.getX(), secondPoint.getX()),
85 Math.min(firstPoint.getY(), secondPoint.getY()), Math.max(firstPoint.getY(), secondPoint.getY()),
86 Math.min(firstPoint.getZ(), secondPoint.getZ()), Math.max(firstPoint.getZ(), secondPoint.getZ()),
89 if (bounds[0].compareTo(bounds[1]) != 0 && bounds[2].compareTo(bounds[3]) != 0 && bounds[4].compareTo(bounds[5]) != 0) {
90 Boolean zoomed = tightZoomBounds(axes, bounds);
91 GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_ZOOM_BOX__, bounds);
92 GraphicController.getController().setProperty(axes.getIdentifier(), GraphicObjectProperties.__GO_ZOOM_ENABLED__, zoomed);
93 getDrawerVisitor().getCanvas().redraw();