nl.tudelft.simulation.dsol.gui.editor2D.actions
Class EditorUtilities

java.lang.Object
  extended by nl.tudelft.simulation.dsol.gui.editor2D.actions.EditorUtilities

public final class EditorUtilities
extends Object

Utility methods to select, create, edit and delete editables

(c) copyright 2002-2005 Delft University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser General Public License (LGPL) , no warranty.

Version:
$Revision: 1.1 $ $Date: 2007/01/06 13:23:35 $
Author:
Roy Chin

Field Summary
static int DEFAULT_OFFSET
          the default offset value in x and y dirextion for new points
 
Method Summary
static void addPointToEditable(EditableRenderable2DInterface target, Editor2DPanel panel)
          add a point behind the last point of the editable
static CartesianPoint convertToGlobalCoordinates(CartesianPoint point, DirectedPoint location)
          converts a coordinate in local coordinates to global coordinates note: this works only for 2D
static CartesianPoint convertToLocalCoordinates(CartesianPoint point, DirectedPoint location)
          converts a coordinate in global coordinates to local coordinates note: this works only for 2D
static void deleteEditable(EditableRenderable2DInterface target, Editor2DPanel panel)
          delete the selected editable
static Renderable2DInterface determineSelected(Point2D worldCoordinate, Editor2DPanel panel)
          determine selected object as the mouse CartesianPoint.
static List determineTargets(Point2D worldCoordinate, Editor2DPanel panel)
          determine the targeted objects at the mouse CartesianPoint
static void instantiateNewEditable(Point2D worldCoordinate, DSOLApplicationInterface application, Editor2DPanel panel)
          instantiate a new editable
static void moveEditable(EditableRenderable2DInterface target, Point2D newCoordinate, Point2D oldCoordinate)
          move the object
static void moveSelectedPoint(EditableRenderable2DInterface target, Point2D worldCoordinate, Editor2DPanel panel)
          move the selected control point
static void rotateEditable(EditableRenderable2DInterface target, Point2D newCoordinate, Point2D centerCoordinate, Point2D oldCoordinate)
          rotate the editable
static Renderable2DInterface selectEditable(Point2D worldCoordinate, Editor2DPanel panel)
          determine the selected object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_OFFSET

public static final int DEFAULT_OFFSET
the default offset value in x and y dirextion for new points

See Also:
Constant Field Values
Method Detail

selectEditable

public static Renderable2DInterface selectEditable(Point2D worldCoordinate,
                                                   Editor2DPanel panel)
determine the selected object

Parameters:
worldCoordinate - point in world coordinates
panel - the editable animation panel
Returns:
the selected renderable

instantiateNewEditable

public static void instantiateNewEditable(Point2D worldCoordinate,
                                          DSOLApplicationInterface application,
                                          Editor2DPanel panel)
instantiate a new editable

Parameters:
worldCoordinate - point in world coordinates
application - the application
panel - the editable animation panel

moveSelectedPoint

public static void moveSelectedPoint(EditableRenderable2DInterface target,
                                     Point2D worldCoordinate,
                                     Editor2DPanel panel)
move the selected control point

Parameters:
target - the editableRenderable which is moved.
worldCoordinate - point in world coordinates where to move to
panel - the Editor2D panel

moveEditable

public static void moveEditable(EditableRenderable2DInterface target,
                                Point2D newCoordinate,
                                Point2D oldCoordinate)
move the object

Parameters:
target - the target editable renderable
newCoordinate - Point in world coordinates where to move to
oldCoordinate - Point in world coordinates where the mouse was the last iteration, because we move relative to this coordinate

rotateEditable

public static void rotateEditable(EditableRenderable2DInterface target,
                                  Point2D newCoordinate,
                                  Point2D centerCoordinate,
                                  Point2D oldCoordinate)
rotate the editable

Parameters:
target - the target editable renderable
newCoordinate - point in world coordinates where to rotate to
oldCoordinate - Point in world coordinates where the mouse was the last iteration, because we move relative to this coordinate
centerCoordinate - the center of rotation in world coordinates

deleteEditable

public static void deleteEditable(EditableRenderable2DInterface target,
                                  Editor2DPanel panel)
delete the selected editable

Parameters:
target - the target editable renderable
panel - the editable animation panel

addPointToEditable

public static void addPointToEditable(EditableRenderable2DInterface target,
                                      Editor2DPanel panel)
add a point behind the last point of the editable

Parameters:
target - the target editable renderable
panel - the animation panel

determineSelected

public static Renderable2DInterface determineSelected(Point2D worldCoordinate,
                                                      Editor2DPanel panel)
determine selected object as the mouse CartesianPoint. This is the topmost target when objects overlap.

Parameters:
worldCoordinate - the selected point in world coordinates
panel - the editable animation panel
Returns:
a renderable if there is one at the selected point

determineTargets

public static List determineTargets(Point2D worldCoordinate,
                                    Editor2DPanel panel)
determine the targeted objects at the mouse CartesianPoint

Parameters:
worldCoordinate - point in world coordinates
panel - the editable animation panel
Returns:
targeted objects

convertToGlobalCoordinates

public static CartesianPoint convertToGlobalCoordinates(CartesianPoint point,
                                                        DirectedPoint location)
converts a coordinate in local coordinates to global coordinates note: this works only for 2D

Parameters:
point - point in local coordinates
location - location vector
Returns:
point in global coordinates

convertToLocalCoordinates

public static CartesianPoint convertToLocalCoordinates(CartesianPoint point,
                                                       DirectedPoint location)
converts a coordinate in global coordinates to local coordinates note: this works only for 2D

Parameters:
point - point in local coordinates
location - location vector
Returns:
point in global coordinates


Copyright © 2002-2010 Delft University of Technology, the Netherlands. All Rights Reserved.