interactors
Class InteractionHandler

java.lang.Object
  extended by interactors.InteractionHandler
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener

public class InteractionHandler
extends java.lang.Object
implements java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener

Class for handling interactions between the user and objects in the map. Different interactions are split up into different interator classes, which perform a single interaction.


Field Summary
private  Canvas canvas
          the canvas
static java.lang.String CONCEPT_NEIGHBORHOOD_INTERACTOR
           
static java.lang.String CONSTRAINT_INTERACTOR
           
static java.lang.String COORDINATES_INTERACTOR
           
private  javax.swing.JMenuItem coordinatesMenu
           
private  java.awt.geom.Point2D currentPoint
          the current mouse location, in virtual coordinates
private  javax.swing.JMenuItem deleteMenu
           
static java.lang.String DISTANCE_INTERACTOR
           
private  javax.swing.JMenu interactionMenu
          the interaction menu for the popup
(package private)  java.util.LinkedHashMap<java.lang.String,Interactor> interactions
          a mapping of interactor names to interactors
private  Interactor interactor
          the current interaction
private  MainWindow mainWindow
          the main frame
private  Map map
          the map to edit
static java.lang.String MEASUREMENT_INTERACTOR
           
static java.lang.String NEW_SHAPE_INTERACTOR
           
static java.lang.String ORIENTATION_INTERACTOR
           
static java.lang.String PICK_INTERACTOR
           
private  java.awt.geom.Point2D pickedPoint
          the previously point clicked by the mouse, in virtual coordinates
private  boolean playbackMode
          specifies if the editor is currently displaying a recording
private  javax.swing.JPopupMenu popupMenu
          the popup menu
private  java.awt.geom.Point2D previousPoint
          the previous mouse location, in virtual coordinates
private  javax.swing.JMenuItem propertiesMenu
           
static java.lang.String RECORDING_INTERACTOR
           
static java.lang.String RELATION_INTERACTOR
           
private  double ROTATE_AMOUNT
          the amout to rotate the canvas
private  javax.swing.JMenu rotateMenu
           
static java.lang.String ROUTE_INTERACTOR
           
private  double SCALE_AMOUNT
          the amout to scale the canvas
static java.lang.String SCALE_INTERACTOR
           
private  javax.swing.JMenuItem scaleMenu
           
private  java.awt.Point screenCurrentPoint
          the current mouse location, in screen coordinates
private  java.awt.Point screenPickedPoint
          the previously point clicked by the mouse, in screen coordinates
private  java.awt.Point screenPreviousPoint
          the previous mouse location, in screen coordinates
private  OntologyObject selectedObject
          the object currently selected
private  SpatialRelation selectedRelation
           
private  javax.swing.JPopupMenu.Separator separator
           
private  javax.swing.JMenuItem snapMenu
           
static java.lang.String TOPOLOGY_INTERACTOR
           
private  double TRANSLATE_AMOUNT
          the amout to translate the canvas
 
Constructor Summary
InteractionHandler(MainWindow mainWindow, Canvas canvas)
          Constructs the interaction handler.
 
Method Summary
 void addInteractor(java.lang.String name, Interactor interactor)
          Adds a new interactor to the popup menu.
private  void buildPopupMenu()
          Constructs the popup menu.
 void draw(GL gl, GLU glu, GLUT glut)
          Draws the current interaction.
 Canvas getCanvas()
          Gets the canvas.
 java.awt.geom.Point2D getCurrentPoint()
          Gets the current mouse location in virtual coordinates.
 MainWindow getMainFrame()
           
 Map getMap()
          Gets the map.
 MapImporter getMapLoader()
          Gets the map importer.
 java.awt.geom.Point2D getPickedPoint()
          Gets the last picked point in virtual coordinates.
 java.awt.geom.Point2D getPreviousPoint()
          Gets the previous mouse location in virtual coordinates.
 java.awt.Point getScreenCurrentPoint()
          Gets the current mouse location in screen coordinates.
 java.awt.Point getScreenPickedPoint()
          Gets the last picked point in screen coordinates.
 java.awt.Point getScreenPreviousPoint()
          Gets the previous mouse location in screen coordinates.
 OntologyObject getSelectedObject()
          Gets the currently selected object.
 SpatialRelation getSelectedRelation()
          Gets the currently selected relation.
 void keyPressed(java.awt.event.KeyEvent arg0)
          Informs the current interactor of a key pressed events.
 void keyReleased(java.awt.event.KeyEvent arg0)
          Informs the current interactor of a key released event.
 void keyTyped(java.awt.event.KeyEvent arg0)
          Not implemented.
 void mouseClicked(java.awt.event.MouseEvent arg0)
          Not implemented.
 void mouseDragged(java.awt.event.MouseEvent arg0)
          Updates the current and previous points.
 void mouseEntered(java.awt.event.MouseEvent arg0)
          Not implemented.
 void mouseExited(java.awt.event.MouseEvent arg0)
          Not implemented.
 void mouseMoved(java.awt.event.MouseEvent arg0)
          Updates the current and previous points and informs the current interacotr of a mouse moved event.
 void mousePressed(java.awt.event.MouseEvent arg0)
          Updates the current and picked point and informs the current interactor of the mouse press.
 void mouseReleased(java.awt.event.MouseEvent arg0)
          Informs the current interactor of a mouse released event.
 void mouseWheelMoved(java.awt.event.MouseWheelEvent arg0)
          The mouse wheel controls the current zoom factor.
 void redo()
          Redoes the previsouly undone actions.
 void setInteractor(java.lang.String name)
          Sets the current interactor.
 void setMap(Map map)
          Sets the map to edit.
 void setPlaybackMode(boolean mode)
          Sets if the editor is in playback mode.
 void setSelectedObject(OntologyObject object)
          Sets the given object as selected and deselects the previously selected object.
 void setSelectedRelation(SpatialRelation relation)
          Sets the relation that is currently selected.
 void snapSelectedObjectToGrid()
          Aligns the currently selected object with the grid.
 void undo()
          Undoes the previous action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interactions

java.util.LinkedHashMap<java.lang.String,Interactor> interactions
a mapping of interactor names to interactors


PICK_INTERACTOR

public static java.lang.String PICK_INTERACTOR

RELATION_INTERACTOR

public static java.lang.String RELATION_INTERACTOR

SCALE_INTERACTOR

public static java.lang.String SCALE_INTERACTOR

NEW_SHAPE_INTERACTOR

public static java.lang.String NEW_SHAPE_INTERACTOR

COORDINATES_INTERACTOR

public static java.lang.String COORDINATES_INTERACTOR

MEASUREMENT_INTERACTOR

public static java.lang.String MEASUREMENT_INTERACTOR

RECORDING_INTERACTOR

public static java.lang.String RECORDING_INTERACTOR

ROUTE_INTERACTOR

public static java.lang.String ROUTE_INTERACTOR

CONSTRAINT_INTERACTOR

public static java.lang.String CONSTRAINT_INTERACTOR

DISTANCE_INTERACTOR

public static java.lang.String DISTANCE_INTERACTOR

TOPOLOGY_INTERACTOR

public static java.lang.String TOPOLOGY_INTERACTOR

ORIENTATION_INTERACTOR

public static java.lang.String ORIENTATION_INTERACTOR

CONCEPT_NEIGHBORHOOD_INTERACTOR

public static java.lang.String CONCEPT_NEIGHBORHOOD_INTERACTOR

interactor

private Interactor interactor
the current interaction


playbackMode

private boolean playbackMode
specifies if the editor is currently displaying a recording


mainWindow

private MainWindow mainWindow
the main frame


canvas

private Canvas canvas
the canvas


map

private Map map
the map to edit


screenPickedPoint

private java.awt.Point screenPickedPoint
the previously point clicked by the mouse, in screen coordinates


pickedPoint

private java.awt.geom.Point2D pickedPoint
the previously point clicked by the mouse, in virtual coordinates


screenCurrentPoint

private java.awt.Point screenCurrentPoint
the current mouse location, in screen coordinates


currentPoint

private java.awt.geom.Point2D currentPoint
the current mouse location, in virtual coordinates


screenPreviousPoint

private java.awt.Point screenPreviousPoint
the previous mouse location, in screen coordinates


previousPoint

private java.awt.geom.Point2D previousPoint
the previous mouse location, in virtual coordinates


popupMenu

private javax.swing.JPopupMenu popupMenu
the popup menu


interactionMenu

private javax.swing.JMenu interactionMenu
the interaction menu for the popup


propertiesMenu

private javax.swing.JMenuItem propertiesMenu

coordinatesMenu

private javax.swing.JMenuItem coordinatesMenu

scaleMenu

private javax.swing.JMenuItem scaleMenu

snapMenu

private javax.swing.JMenuItem snapMenu

deleteMenu

private javax.swing.JMenuItem deleteMenu

rotateMenu

private javax.swing.JMenu rotateMenu

separator

private javax.swing.JPopupMenu.Separator separator

selectedObject

private OntologyObject selectedObject
the object currently selected


selectedRelation

private SpatialRelation selectedRelation

TRANSLATE_AMOUNT

private double TRANSLATE_AMOUNT
the amout to translate the canvas


SCALE_AMOUNT

private double SCALE_AMOUNT
the amout to scale the canvas


ROTATE_AMOUNT

private double ROTATE_AMOUNT
the amout to rotate the canvas

Constructor Detail

InteractionHandler

public InteractionHandler(MainWindow mainWindow,
                          Canvas canvas)
Constructs the interaction handler.

Parameters:
mainWindow - - the main frame
canvas - - the canvas
Method Detail

buildPopupMenu

private void buildPopupMenu()
Constructs the popup menu.


addInteractor

public void addInteractor(java.lang.String name,
                          Interactor interactor)
Adds a new interactor to the popup menu.

Parameters:
name - - the interactor name
interactor - - the new interactor

setMap

public void setMap(Map map)
Sets the map to edit.

Parameters:
map - - the new map

setSelectedRelation

public void setSelectedRelation(SpatialRelation relation)
Sets the relation that is currently selected.

Parameters:
relation - - the selected relation

getSelectedRelation

public SpatialRelation getSelectedRelation()
Gets the currently selected relation.


setInteractor

public void setInteractor(java.lang.String name)
Sets the current interactor.

Parameters:
name - - the new interaction

snapSelectedObjectToGrid

public void snapSelectedObjectToGrid()
Aligns the currently selected object with the grid.


setSelectedObject

public void setSelectedObject(OntologyObject object)
Sets the given object as selected and deselects the previously selected object.

Parameters:
object - - the object to select

getSelectedObject

public OntologyObject getSelectedObject()
Gets the currently selected object.


draw

public void draw(GL gl,
                 GLU glu,
                 GLUT glut)
Draws the current interaction.


getCanvas

public Canvas getCanvas()
Gets the canvas.


setPlaybackMode

public void setPlaybackMode(boolean mode)
Sets if the editor is in playback mode.


getMap

public Map getMap()
Gets the map.


getMapLoader

public MapImporter getMapLoader()
Gets the map importer.


getMainFrame

public MainWindow getMainFrame()

getScreenPickedPoint

public java.awt.Point getScreenPickedPoint()
Gets the last picked point in screen coordinates.


getPickedPoint

public java.awt.geom.Point2D getPickedPoint()
Gets the last picked point in virtual coordinates.


getScreenPreviousPoint

public java.awt.Point getScreenPreviousPoint()
Gets the previous mouse location in screen coordinates.


getPreviousPoint

public java.awt.geom.Point2D getPreviousPoint()
Gets the previous mouse location in virtual coordinates.


getScreenCurrentPoint

public java.awt.Point getScreenCurrentPoint()
Gets the current mouse location in screen coordinates.


getCurrentPoint

public java.awt.geom.Point2D getCurrentPoint()
Gets the current mouse location in virtual coordinates.


keyPressed

public void keyPressed(java.awt.event.KeyEvent arg0)
Informs the current interactor of a key pressed events. Also checks if the key pressed is a hotkey that transforms the canvas or selects a new interaction.

Specified by:
keyPressed in interface java.awt.event.KeyListener

undo

public void undo()
Undoes the previous action.


redo

public void redo()
Redoes the previsouly undone actions.


keyReleased

public void keyReleased(java.awt.event.KeyEvent arg0)
Informs the current interactor of a key released event.

Specified by:
keyReleased in interface java.awt.event.KeyListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent arg0)
Updates the current and picked point and informs the current interactor of the mouse press. If the current interaction is the pick interactor and the right mouse button is pressed, then the popup menu is displayed.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent arg0)
Informs the current interactor of a mouse released event.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent arg0)
Updates the current and previous points and informs the current interacotr of a mouse moved event.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent arg0)
Updates the current and previous points. If the left button is performing the drag, then the current interactor is informed of the event. If the right button is performing the drag, then the canvas is panned and interactors are not informed of the event.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent arg0)
The mouse wheel controls the current zoom factor. Iteractors do not receive mouse wheel events.

Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent arg0)
Not implemented.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent arg0)
Not implemented.

Specified by:
keyTyped in interface java.awt.event.KeyListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent arg0)
Not implemented.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent arg0)
Not implemented.

Specified by:
mouseExited in interface java.awt.event.MouseListener