|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.tigris.gef.base.Editor
This class provides an editor for manipulating graphical documents. The editor is the central class of the graph editing framework, but it does not contain very much code. It can be this small because all the net-level models, graphical objects, layers, editor modes, editor commands, and supporting dialogs and frames are implemented in their own classes.
An Editor's LayerManager has a stack of Layer's. Normally Layers contain Figs. Some Figs are linked to NetPrimitives. When Figs are selected the SelectionManager holds a Selection object. The behavior of the Editor is determined by its current Mode. The Editor's ModeManager keeps track of all the active Modes. Modes interpert user input events and decide how to change the state of the diagram. The Editor acts as a shell for executing Commands that modify the document or the Editor itself.
When Figs change visible state (e.g., color, size, or postition) they tell their Layer that they are damageAll and need to be repainted. The Layer tells all Editors that are editing that A major goal of GEF is to make it easy to extend the framework for application to a specific domain. It is very important that new functionality can be added without modifying what is already there. The fairly small size of the Editor is a good indicator that it is not a bottleneck for enhancing the framework.
Layer
,
Fig
,
NetPrimitive
,
Selection
,
Mode
,
Cmd
,
Serialized FormField Summary | |
protected boolean |
_canSelectElements
Should elements in this editor be selectable? |
protected org.tigris.gef.presentation.Fig |
_curFig
Deprecated. in 0.11 use getCurrentFig() this will be removed in 0.12 |
protected Selection |
_curSel
Deprecated. in 0.11 use getCurrentSelection() this will be removed in 0.12 |
protected java.lang.Object |
_document
This points to the document object that the user is working on. |
protected Guide |
_guide
The grid to snap points to. |
protected static java.awt.Rectangle |
_hitRect
Temp var used to implement hit() without doing memory allocation. |
protected LayerManager |
_layerManager
The LayerManager for this Editor. |
protected ModeManager |
_modeManager
The user interface mode that the Editor is currently in. |
protected double |
_scale
Deprecated. in 0.10.1 use getter/setter |
protected SelectionManager |
_selectionManager
All the selection objects for what the user currently has selected. |
static int |
GRIP_SIZE
Clicking exactly on a small shape is hard for users to do. |
Constructor Summary | |
Editor()
|
|
Editor(Diagram d)
|
|
Editor(GraphModel gm)
|
|
Editor(GraphModel gm,
javax.swing.JComponent jComponent)
Construct a new Editor to edit the given NetList |
|
Editor(GraphModel gm,
javax.swing.JComponent jComponent,
Layer lay)
|
Method Summary | |
void |
add(org.tigris.gef.presentation.Fig f)
Add a Fig to the diagram being edited. |
void |
addGraphSelectionListener(GraphSelectionListener listener)
Remember to notify listener whenever the selection changes. |
void |
addModeChangeListener(ModeChangeListener listener)
Remember to notify listener whenever the mode changes. |
boolean |
canSelectElements()
Returns this Editor's current value for the selection flag. |
java.lang.Object |
clone()
Clone the receiving editor. |
java.awt.Image |
createImage(int w,
int h)
Create an Image (an off-screen bit-map) to be used to reduce flicker in redrawing. |
void |
damageAll()
Mark the entire visible area of this Editor as damageAll. |
void |
damaged(org.tigris.gef.presentation.Fig f)
|
void |
damaged(int x,
int y,
int width,
int height)
Calling any one of the following damageAll() methods adds a damageAll region (rectangle) that will be redrawn asap. |
void |
damaged(java.awt.Rectangle r)
Calling any one of the following damageAll() methods adds a damageAll region (rectangle) that will be redrawn asap. |
void |
damaged(Selection sel)
This method will take the current scale into account |
protected void |
defineLayers(GraphModel gm,
Layer lay)
|
java.lang.Object |
document()
Get and set document being edited. |
void |
document(java.lang.Object d)
|
void |
drawingSizeChanged(java.awt.Dimension dim)
This method is called when the Editor is notified that the drawing panel's natural size has changed, typically because a new diagram has been set. |
void |
executeCmd(Cmd c,
java.awt.event.InputEvent ie)
The editor acts as a shell for Cmds. |
java.util.Enumeration |
figs()
Returns a collection of all Figs in the layer currently being edited. |
java.awt.Frame |
findFrame()
Find the AWT Frame that this Editor is being displayed in. |
void |
finishMode()
Set this Editor's current Mode to the next global Mode. |
org.tigris.gef.presentation.FigTextEditor |
getActiveTextEditor()
|
java.awt.Component |
getAwtComponent()
Deprecated. 0.10 replacing in 0.11 in favour of getJComponent() |
java.awt.Color |
getBackground()
Get the backgrund color of the Editor. |
org.tigris.gef.presentation.Fig |
getCurrentFig()
|
Selection |
getCurrentSelection()
Gets the selection object the mouse is in |
GraphEdgeRenderer |
getGraphEdgeRenderer()
Get the renderer object that decides how to display edges |
GraphModel |
getGraphModel()
Return the net under the diagram being edited. |
GraphNodeRenderer |
getGraphNodeRenderer()
Get the renderer object that decides how to display nodes |
boolean |
getGridHidden()
Return true if the Grid layer is currently hidden. |
Guide |
getGuide()
|
javax.swing.JComponent |
getJComponent()
|
LayerManager |
getLayerManager()
Return the LayerComposite that holds the diagram being edited. |
ModeManager |
getModeManager()
|
javax.swing.JPopupMenu |
getPopupMenu()
|
double |
getScale()
|
SelectionManager |
getSelectionManager()
Reply the current SelectionManager of this Editor. |
org.tigris.gef.presentation.Fig |
hit(int x,
int y)
|
org.tigris.gef.presentation.Fig |
hit(int x,
int y,
int w,
int h)
|
org.tigris.gef.presentation.Fig |
hit(java.awt.Point p)
Reply the top Fig in the current layer that contains the given point. |
org.tigris.gef.presentation.Fig |
hit(java.awt.Rectangle r)
|
void |
keyPressed(java.awt.event.KeyEvent ke)
Invoked when a key has been pressed. |
void |
keyReleased(java.awt.event.KeyEvent ke)
Invoked when a key has been released. |
void |
keyTyped(java.awt.event.KeyEvent ke)
Invoked when a key has been pressed and released. |
void |
mode(FigModifyingMode m)
Deprecated. in 0.11 use pushMode(FigModifyingMode mode) |
void |
mouseClicked(java.awt.event.MouseEvent me)
Invoked after the mouse has been pressed and released. |
void |
mouseDragged(java.awt.event.MouseEvent me)
Invoked when a mouse button is pressed in the Editor and then dragged. |
void |
mouseEntered(java.awt.event.MouseEvent me)
Invoked when the mouse enters the Editor. |
void |
mouseExited(java.awt.event.MouseEvent me)
Invoked when the mouse exits the Editor. |
void |
mouseMoved(java.awt.event.MouseEvent me)
Invoked when the mouse button has been moved (with no buttons no down). |
void |
mousePressed(java.awt.event.MouseEvent me)
Invoked when a mouse button has been pressed. |
void |
mouseReleased(java.awt.event.MouseEvent me)
Invoked when a mouse button has been released. |
void |
paint(java.awt.Graphics g)
Paints the graphs nodes by calling paint() on layers, selections, and mode. |
void |
postLoad()
Called after the Editor is loaded from a file. |
void |
postSave()
Called after the Editor is saved to a file. |
void |
preSave()
Called before the Editor is saved to a file. |
void |
print(java.awt.Graphics g)
|
void |
pushMode(FigModifyingMode mode)
Pushes a new mode to the mode manager |
void |
remove(org.tigris.gef.presentation.Fig f)
Remove a Fig from the diagram being edited. |
void |
removed(org.tigris.gef.presentation.Fig f)
The given Fig was removed from the diagram this Editor is showing. |
void |
removeGraphSelectionListener(GraphSelectionListener listener)
Stop notifing listener of selection changes. |
void |
removeModeChangeListener(ModeChangeListener listener)
Stop notifing listener of mode changes. |
java.awt.event.MouseEvent |
retranslateMouseEvent(java.awt.event.MouseEvent me)
Scales the mouse coordinates (which match the model scale) back to the drawing scale. |
void |
scaleRect(java.awt.Rectangle bounds)
|
void |
scrollToShow(org.tigris.gef.presentation.Fig fig)
Scroll the JGraph so that the given Fig is entirely visible. |
void |
scrollToShow(int x,
int y)
Scroll the JGraph so that the given point is visible. |
void |
setCursor(java.awt.Cursor c)
|
void |
setElementsSelectable(boolean selectable)
Set's the selection flag for the Editor. |
void |
setGraphEdgeRenderer(GraphEdgeRenderer rend)
|
void |
setGraphModel(GraphModel gm)
|
void |
setGraphNodeRenderer(GraphNodeRenderer rend)
|
void |
setGridHidden(boolean b)
Set the hidden state of the Grid layer. |
void |
setGuide(Guide g)
|
void |
setJComponent(javax.swing.JComponent c)
|
void |
setPopupMenu(javax.swing.JPopupMenu p)
|
void |
setScale(double scale)
Set this Editor's drawing scale. |
void |
setShouldPaint(boolean shouldPaint)
|
protected void |
setUnderMouse(java.awt.event.MouseEvent me)
Find the Fig under the mouse, and the node it represents, if any |
boolean |
shouldPaint()
|
void |
snap(java.awt.Point p)
Modify the given point to be on the guideline (In this case, a gridline). |
protected java.awt.event.MouseEvent |
translateMouseEvent(java.awt.event.MouseEvent me)
Scales the mouse coordinates (which match the drawing scale) back to the model scale. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int GRIP_SIZE
protected ModeManager _modeManager
ModeModify
,
ModeSelect
,
ModePlace
protected java.lang.Object _document
protected SelectionManager _selectionManager
protected LayerManager _layerManager
protected Guide _guide
protected org.tigris.gef.presentation.Fig _curFig
protected Selection _curSel
protected double _scale
protected boolean _canSelectElements
protected static java.awt.Rectangle _hitRect
Constructor Detail |
public Editor(GraphModel gm, javax.swing.JComponent jComponent)
public Editor(GraphModel gm)
public Editor()
public Editor(Diagram d)
public Editor(GraphModel gm, javax.swing.JComponent jComponent, Layer lay)
Method Detail |
protected void defineLayers(GraphModel gm, Layer lay)
public void preSave()
public void postSave()
public void setPopupMenu(javax.swing.JPopupMenu p)
public javax.swing.JPopupMenu getPopupMenu()
public void postLoad()
public boolean getGridHidden()
public void setGridHidden(boolean b)
public java.lang.Object clone()
public ModeManager getModeManager()
public void mode(FigModifyingMode m)
public void pushMode(FigModifyingMode mode)
public void finishMode()
public LayerManager getLayerManager()
public double getScale()
public void setScale(double scale)
public boolean canSelectElements()
public void setElementsSelectable(boolean selectable)
selectable
- New value for the flag.public GraphModel getGraphModel()
public void setGraphModel(GraphModel gm)
public GraphNodeRenderer getGraphNodeRenderer()
public void setGraphNodeRenderer(GraphNodeRenderer rend)
public GraphEdgeRenderer getGraphEdgeRenderer()
public void setGraphEdgeRenderer(GraphEdgeRenderer rend)
public java.util.Enumeration figs()
public void add(org.tigris.gef.presentation.Fig f)
public void remove(org.tigris.gef.presentation.Fig f)
public final org.tigris.gef.presentation.Fig hit(java.awt.Point p)
public final org.tigris.gef.presentation.Fig hit(int x, int y)
public final org.tigris.gef.presentation.Fig hit(int x, int y, int w, int h)
public org.tigris.gef.presentation.Fig hit(java.awt.Rectangle r)
protected void setUnderMouse(java.awt.event.MouseEvent me)
public java.lang.Object document()
public void document(java.lang.Object d)
public void snap(java.awt.Point p)
public Guide getGuide()
public void setGuide(Guide g)
public void damaged(java.awt.Rectangle r)
public void damaged(int x, int y, int width, int height)
public void damaged(Selection sel)
sel
- public void damaged(org.tigris.gef.presentation.Fig f)
public void scaleRect(java.awt.Rectangle bounds)
public void damageAll()
public void paint(java.awt.Graphics g)
public void print(java.awt.Graphics g)
public void scrollToShow(int x, int y)
public void scrollToShow(org.tigris.gef.presentation.Fig fig)
public SelectionManager getSelectionManager()
public org.tigris.gef.presentation.Fig getCurrentFig()
public java.awt.Component getAwtComponent()
public javax.swing.JComponent getJComponent()
public void setJComponent(javax.swing.JComponent c)
public void setCursor(java.awt.Cursor c)
public java.awt.Frame findFrame()
public java.awt.Image createImage(int w, int h)
public java.awt.Color getBackground()
public org.tigris.gef.presentation.FigTextEditor getActiveTextEditor()
public void drawingSizeChanged(java.awt.Dimension dim)
public void addGraphSelectionListener(GraphSelectionListener listener)
public void removeGraphSelectionListener(GraphSelectionListener listener)
public void addModeChangeListener(ModeChangeListener listener)
public void removeModeChangeListener(ModeChangeListener listener)
protected java.awt.event.MouseEvent translateMouseEvent(java.awt.event.MouseEvent me)
public java.awt.event.MouseEvent retranslateMouseEvent(java.awt.event.MouseEvent me)
public void mouseClicked(java.awt.event.MouseEvent me)
mouseClicked
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent me)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent me)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent me)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent me)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent me)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent me)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void keyTyped(java.awt.event.KeyEvent ke)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent ke)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent ke)
keyReleased
in interface java.awt.event.KeyListener
public void executeCmd(Cmd c, java.awt.event.InputEvent ie)
public void removed(org.tigris.gef.presentation.Fig f)
public void setShouldPaint(boolean shouldPaint)
public boolean shouldPaint()
public Selection getCurrentSelection()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |