public abstract class GraphPanelState extends Object implements Serializable
Implementations of this class now also acts as state machines, in that an input to a state may return a new state. The input can be mouse and keyboard events or a ChangeStateEvent.
For mouse and keyboard events, after a state has processed the input, the input is then passed on to the VisualGraphComponent, if any, to process the input. These are done via the mouseXXX() and keyEvent() methods.
For ChangeStateEvents, they can be passed to the method recommendState() where a new state may or may not be returned.
| Modifier and Type | Method and Description |
|---|---|
void |
informTargetVisualGraphComponentOfKeyEvent(KeyEvent e)
This method calls processKeyEvent(e) upon the target (if any) VisualGraphComponent
of a key action.
|
void |
informTargetVisualGraphComponentOfMouseEvent(MouseEvent e)
This method calls processMouseEvent(e) upon the target (if any) VisualGraphComponent
of a mouse action.
|
GraphPanelState |
keyPressed(KeyEvent e) |
GraphPanelState |
keyReleased(KeyEvent e) |
GraphPanelState |
keyTyped(KeyEvent e) |
GraphPanelState |
mouseClicked(MouseEvent e)
GraphPanel delegates all MouseEvents to its current state.
|
GraphPanelState |
mouseDragged(MouseEvent e)
GraphPanel delegates all MouseEvents to its current state.
|
GraphPanelState |
mouseEntered(MouseEvent e)
GraphPanel delegates all MouseEvents to its current state.
|
GraphPanelState |
mouseExited(MouseEvent e)
GraphPanel delegates all MouseEvents to its current state.
|
GraphPanelState |
mouseMoved(MouseEvent e)
GraphPanel delegates all MouseEvents to its current state.
|
GraphPanelState |
mousePressed(MouseEvent e)
GraphPanel delegates all MouseEvents to its current state.
|
GraphPanelState |
mouseReleased(MouseEvent e)
GraphPanel delegates all MouseEvents to its current state.
|
abstract void |
paint(Graphics2D ged)
Different painting actions may occur depending on the GraphPanel's state.
|
GraphPanelState |
recommendState(ChangeStateEvent cse)
Returns a state depending on the ChangeStateEvent.
|
void |
setGraphPanel(GraphPanel gpanel) |
public void setGraphPanel(GraphPanel gpanel)
public GraphPanelState recommendState(ChangeStateEvent cse)
This method is called by GraphPanel from within the GraphPanel's processChangeStateEvent method.
cse - an event object that gives this state a hint on the direction of the transition.public GraphPanelState mousePressed(MouseEvent e)
e - the MouseEvent, as it was received by the GraphPanel.public GraphPanelState mouseReleased(MouseEvent e)
e - the MouseEvent, as it was received by the GraphPanel.public GraphPanelState mouseDragged(MouseEvent e)
e - the MouseEvent, as it was received by the GraphPanel.public GraphPanelState mouseEntered(MouseEvent e)
e - the MouseEvent, as it was received by the GraphPanel.public GraphPanelState mouseExited(MouseEvent e)
e - the MouseEvent, as it was received by the GraphPanel.public GraphPanelState mouseClicked(MouseEvent e)
e - the MouseEvent, as it was received by the GraphPanel.public GraphPanelState mouseMoved(MouseEvent e)
e - the MouseEvent, as it was received by the GraphPanel.public GraphPanelState keyPressed(KeyEvent e)
public GraphPanelState keyReleased(KeyEvent e)
public GraphPanelState keyTyped(KeyEvent e)
public void informTargetVisualGraphComponentOfMouseEvent(MouseEvent e)
e - the MouseEvent.public void informTargetVisualGraphComponentOfKeyEvent(KeyEvent e)
Since this method is only called when the focus is on GraphPanel, and VisualGraphComponents are themselves not AWT or Swing components, it is up to this class to determine which VisualGraphComponent is the current "focus". Therefore, currently, this method is empty, and even though there is a processKeyEvent() method in VisualGraphComponent, we still have a devise a scheme to determine the currently focused VisualGraphComponent based on the key event. A simple solution may be to simply query GraphPanelNormalState for the component in focus.
e - the KeyEvent.public abstract void paint(Graphics2D ged)
Copyright © 2019 JULIE Lab, Germany. All rights reserved.