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.Point;
15 import java.awt.event.MouseEvent;
17 import org.scilab.forge.scirenderer.tranformations.Vector3d;
18 import org.scilab.modules.renderer.JoGLView.DrawerVisitor;
19 import org.scilab.modules.renderer.JoGLView.interaction.util.PointAComputer;
22 * @author Bruno JOFRET
24 public class OnePointRubberBox extends RubberBox implements PointRubberBox {
27 * Default constructor.
29 * @param drawerVisitor parent drawer visitor.
31 public OnePointRubberBox(DrawerVisitor drawerVisitor) {
35 public OnePointRubberBox(DrawerVisitor drawerVisitor, double initialRect[]) {
37 firstPoint = new Vector3d(initialRect[0], initialRect[1], 0);
38 secondPoint = firstPoint;
39 status = Status.WAIT_POINT_B;
43 public double[] getResults() {
46 Math.min(firstPoint.getX(), secondPoint.getX()),
47 Math.max(firstPoint.getY(), secondPoint.getY()),
48 Math.max(firstPoint.getZ(), secondPoint.getZ()),
49 Math.abs(firstPoint.getX() - secondPoint.getX()),
50 Math.abs(firstPoint.getY() - secondPoint.getY()),
51 Math.abs(firstPoint.getZ() - secondPoint.getZ())
58 public void mouseClicked(MouseEvent e) {
59 mouseButton = e.getButton();
60 setPointB(e.getPoint());
67 * Set the first point.
68 * @param point first point AWT coordinate.
69 * @return true if the first point is valid.
71 protected boolean setPointB(Point point) {
72 axes = getUnderlyingAxes(point);
74 PointAComputer pointComputer = new PointAComputer(axes, point);
75 if (pointComputer.isValid()) {
76 pointBComputer = pointComputer;
77 secondPoint = pointComputer.getPosition();