public class EditManager
extends Object
implements ItemListener, ActionListener, ClipboardOwner, chargerlib.undo.Undoable
EditFrame
,
CanvasPanel
Modifier and Type | Field and Description |
---|---|
private boolean |
anyFound |
private static Color |
changeMarkerColor |
EditFrame |
ef
This class does a lot of communicating with the edit frame that owns it.
|
private Iterator<GraphObject> |
findIterator |
private String |
findString |
private String |
holdGraph |
static int |
maxUndo
Maximum number of actions that are undo-able -- currently set to 10
|
ArrayList<String> |
redoList
Whenever an undo is performed, the current ("future") graph, in text
form, is added to the list, up to its max
|
boolean |
showGloss |
ArrayList<String> |
undoList
Each past copy of the graph, in text form, is added to the list, up to
its max
|
chargerlib.undo.UndoStateManager |
urMgr |
boolean |
useNewUndoRedo |
Constructor and Description |
---|
EditManager(EditFrame outerFrame)
Only used by the editframe to instantiate its own manager.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Here's where the action is (performed)! the EditManager is generally the
action listener for the EditFrame, except for the Window Menu whose
ActionListener is the master hub frame, and the Canvas Panel which
handles text editing actions.
|
String |
arrowAllowed(GraphObject go1,
GraphObject go2)
Determines whether an arrow is allowed between the two objects.
|
void |
clearChanged(Graph g)
Sets every node in the graph to indicate that its changed state is false.
|
void |
clearGraph(boolean all)
Removes the frame's resident graph.
|
String |
corefAllowed(GraphObject go1,
GraphObject go2)
Determines whether a coreferent link is allowed between the two objects.
|
EditorState |
currentState()
Part of the interface needed for the undo redo stack
|
void |
doDo(String currentOne)
Track a regular editing action (other than undo or redo).
|
String |
doRedo(String currentOne)
Restore an editing state, moving forward with respect to the user's
actions.
|
String |
doUndo(String currentOne)
Undo the last editing state.
|
boolean |
enlargeObject(GraphObject go,
int increment)
Increases the graph object's size by an increment in pixels.
|
boolean |
enlargeSelection(int increment,
boolean atomicChange)
Increases the displayed size of all graph nodes selected.
|
protected void |
finalize() |
String |
genspecAllowed(GraphObject subobj,
GraphObject superobj)
Determines whether a generalization/specialization link is allowed
between the two objects.
|
JTextField |
getTextEditField(JDialog dialog) |
static Graph |
innermostContext(Graph outermost,
Point2D.Double p)
Determines the innermost context in which a point lies
|
void |
itemStateChanged(ItemEvent ie)
Handles the check box group for the various tool modes, and the modality
choice menu.
|
boolean |
labelEditingIsActive()
Checks to see if one of the label editing features is active
|
void |
lostOwnership(Clipboard clipboard,
Transferable contents) |
void |
makeHoldGraph()
"Remembers" what a graph looked like before a potential change.
|
private void |
makeMenus() |
void |
makeNewMenuItem(JMenu m,
String label,
int keyCode)
Convenience method to set up menu items for some of the various menus.
|
void |
minimizeSelection()
Makes all nodes as small as they can be.
|
void |
nothingChanged()
Used to tell the editor window that its current contents have not
changed, regardless of what actions have occurred.
|
void |
performActionAlign(String how)
Aligns the graph objects in the selection, adjusting the centers either
vertically or horizontally.
|
void |
performActionChangeFont()
Changes the font of the selected graph objects.
|
void |
performActionClearAll()
Clear the current edit frame, deleting all the components in its root
graph.
|
void |
performActionClipboardCopy()
Performs the copy to clipboard operation for graph objects.
|
void |
performActionClipboardCut()
Performs the cut from clipboard operation for graph objects.
|
void |
performActionClipboardPaste(Point2D.Double p)
Performs the paste from clipboard operation for graph objects.
|
void |
performActionColorSelection(String foreback,
Color c)
Changes the text or fill of all selected objects to the specified color.
|
void |
performActionColorSelection(String foreback,
Color c,
Hashtable<String,Color> colorlist)
Changes the color of the selected graph objects.
|
void |
performActionColorSelection(String foreback,
Hashtable<String,Color> table)
Changes the text or fill of all selected objects using the specified
color table.
|
void |
performActionDeleteSelection()
Delete the nodes in the selection, and their associated links.
|
void |
performActionDisplayAsCGIF()
Prints the outer edit frame's graph to the console window.
|
void |
performActionDisplayAsEnglish()
Shows the outer edit frame's graph in English in its own window.
|
void |
performActionDisplayAsXML()
Shows the outer edit frame's graph in English in its own window.
|
void |
performActionDisplayMetrics()
Shows the outer edit frame's graph metrics in its own window.
|
void |
performActionDupSelection()
Duplicates the selection, forming new contexts as necessary.
|
void |
performActionImportCGIF() |
void |
performActionLayoutUsingSpring()
Do the graph layout algorithm.
|
void |
performActionMakeContext(String what)
Use the selection and make a context out of them, if possible.
|
void |
performActionMinimizeSelection()
Shrink each selected node to its smallest size.
|
void |
performActionOpenGraph()
Loads a graph into the edit frame.
|
void |
performActionPreferences() |
void |
performActionPrintGraph()
Queues a graphic representation of the entire graph to a printer.
|
void |
performActionQuit()
Since user can invoke quit from the edit window, here's the handler.
|
void |
performActionReadFromJarfile() |
void |
performActionRedo() |
void |
performActionRedoNEW() |
void |
performActionRedoOLD() |
boolean |
performActionSaveGraphFormattedAs(chargerlib.FileFormat format)
Save or export the current graph, using the graph's name as the filename
destination.
|
boolean |
performActionSaveGraphWOInteraction(Graph g)
Save a graph in the default form, using the default filename as
destination.
|
void |
performActionSelectAll()
Clear the current edit frame, deleting all the components in its root
graph.
|
void |
performActionShowHierarchies() |
void |
performActionUndo() |
void |
performActionUndoNEW() |
void |
performActionUndoOLD()
Restores the previous graph from whatever the last change was.
|
void |
performActionUnMakeContext()
Attach the contents of one of the selected contexts to its owner graph.
|
void |
performActionUpdateGOIDs()
Updates all the object IDs to reflect the latest scheme.
|
private void |
performExportToTestXML() |
void |
performFindAgain(String s) |
void |
performFindMenuAction()
Operation resulting from the "Find" menu.
|
void |
performFindString(String s)
Does the actual work of finding a string, making it the selection and
centering the display.
|
void |
performZoomAction(String direction) |
boolean |
redoAvailable() |
boolean |
reduceSelection(int increment,
boolean atomicChange)
Reduces the displayed size of all graph nodes selected.
|
void |
refreshCGIF(chargerlib.GenericTextFrame t) |
void |
refreshEnglish(chargerlib.GenericTextFrame t) |
void |
resetUndo()
Initialize the undo/redo sequences, so that there are no past or future
states.
|
void |
restoreState(chargerlib.undo.UndoableState astate)
Part of the interface needed for the undo redo stack
|
void |
setChangedContent(EditingChangeState.EditChange... changes)
Convenience method to simplify the syntax for editing changes.
|
void |
setChangedContent(EditingChangeState change)
Tells the edit frame that something has changed.
|
void |
setEditMenuItems() |
void |
setMenuItems()
Determines for each menu item whether to be enabled or disabled ("gray'ed
out" ) Many items are disabled if there is no selection; other items are
disabled if the clipboard is empty or nothing's changed, etc.
|
void |
setupMenus() |
void |
setViewMenuItems(double scale)
Sets the view menu's scale indicator, and also sets whether Find Again
should be enabled
|
ArrayList |
sortSelectionObjects()
Gather together all the selected nodes, edges and graphs into a list.
|
boolean |
undoAvailable() |
private void |
undoRedoSizes(String label)
Announce the number of items on the undo and redo stacks
|
public EditFrame ef
public static int maxUndo
public boolean useNewUndoRedo
public ArrayList<String> undoList
public ArrayList<String> redoList
private String holdGraph
public chargerlib.undo.UndoStateManager urMgr
private Iterator<GraphObject> findIterator
private String findString
private boolean anyFound
public boolean showGloss
private static Color changeMarkerColor
public EditManager(EditFrame outerFrame)
outerFrame
- the EditFrame that owns this manager.private void makeMenus()
public void makeNewMenuItem(JMenu m, String label, int keyCode)
m
- the menu to which the item is to be added.label
- the label for the menu itemkeyCode
- the accelerator key letter (as in java.awt.event.KeyEvent) for
this menu item; 0 if none.public void setMenuItems()
EditFrame.somethingHasBeenSelected
public void setEditMenuItems()
public void setViewMenuItems(double scale)
scale
- varies from 0 to 3.0 shows actual scaling fractionpublic boolean undoAvailable()
public boolean redoAvailable()
public String doUndo(String currentOne)
currentOne
- The current editing state, ready to be the next
restored via "redo". It is in the form of a cgx xml string representing
the ENTIRE graph to be restored.private void undoRedoSizes(String label)
label
- an identifier usually telling where the method was called
frompublic String doRedo(String currentOne)
currentOne
- The current editing state, ready to be the next
restored via "undo". * It is in the form of a cgx xml string representing
the ENTIRE graph to be restored.public void doDo(String currentOne)
currentOne
- The current editing state, to become the most recent
state. * It is in the form of a cgx xml string representing the ENTIRE
graph to be restored.public void resetUndo()
protected void finalize() throws Throwable
finalize
in class Object
Throwable
public void itemStateChanged(ItemEvent ie)
itemStateChanged
in interface ItemListener
ie
- the item event that changedpublic void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
private void performExportToTestXML()
public boolean labelEditingIsActive()
public JTextField getTextEditField(JDialog dialog)
public void performActionClipboardCut()
public void performActionClipboardCopy()
public void performActionClipboardPaste(Point2D.Double p)
p
- The new upper left hand corner of the pasted part; * if null
then use default offsetpublic void performActionClearAll()
public void clearGraph(boolean all)
all
- whether to reset the graph name as well. it's a
cheap dispose -- NEEDS to be optimized to really get rid of the graph's
contentspublic void performActionSelectAll()
public void performActionPreferences()
public void performActionPrintGraph()
public void performActionDisplayAsCGIF()
public void performActionDisplayAsEnglish()
public void performActionDisplayAsXML()
public void performActionDisplayMetrics()
public void performActionMakeContext(String what)
what
- valued either "context" or "cut"actionPerformed(java.awt.event.ActionEvent)
public void performActionUnMakeContext()
public void performActionDeleteSelection()
public void performActionColorSelection(String foreback, Color c)
foreback
- one of "text" or "fill"c
- Color to be applied.public void performActionColorSelection(String foreback, Hashtable<String,Color> table)
foreback
- one of "text" or "fill"table
- list of classname,color that governs the change.public void performActionColorSelection(String foreback, Color c, Hashtable<String,Color> colorlist)
foreback
- one of "text" or "fill"c
- The color to be applied to all selected objects.colorlist
- a list of actionPerformed(java.awt.event.ActionEvent)
public void performActionChangeFont()
public void performActionDupSelection()
public void performActionUpdateGOIDs()
public void performActionAlign(String how)
how
- either "vertical" or "horizontal"public void performActionMinimizeSelection()
public boolean performActionSaveGraphFormattedAs(chargerlib.FileFormat format)
format
- one of the valid formatsactionPerformed(java.awt.event.ActionEvent)
,
IOManager
,
FileFormat
public boolean performActionSaveGraphWOInteraction(Graph g)
g
- graph to be savedactionPerformed(java.awt.event.ActionEvent)
public void performActionOpenGraph()
public void performActionImportCGIF()
public EditorState currentState()
currentState
in interface chargerlib.undo.Undoable
Undoable
public void restoreState(chargerlib.undo.UndoableState astate)
restoreState
in interface chargerlib.undo.Undoable
Undoable
public void setupMenus()
setupMenus
in interface chargerlib.undo.Undoable
Undoable
public void performActionUndoNEW()
public void performActionRedoNEW()
public void performActionUndo()
public void performActionRedo()
public void performActionUndoOLD()
public void performActionRedoOLD()
public void performActionQuit()
public void performActionLayoutUsingSpring()
SpringGraphLayout
public void performActionShowHierarchies()
public void performActionReadFromJarfile()
public ArrayList sortSelectionObjects()
public void makeHoldGraph()
public void setChangedContent(EditingChangeState change)
change
- the kind of change that was madeEditingChangeState
public void setChangedContent(EditingChangeState.EditChange... changes)
changes
- public void nothingChanged()
public void clearChanged(Graph g)
g
- the graph whose nodes' state is to be set.GNode.setChanged(boolean)
public void refreshEnglish(chargerlib.GenericTextFrame t)
t
- display frame whose text is to be refreshed with the English
paraphrasepublic void refreshCGIF(chargerlib.GenericTextFrame t)
t
- display frame whose text is to be refreshed with its CGIF
versionpublic void lostOwnership(Clipboard clipboard, Transferable contents)
lostOwnership
in interface ClipboardOwner
public void minimizeSelection()
public boolean enlargeSelection(int increment, boolean atomicChange)
increment
- amount to increase the selection; negative increment is
same as reduce.atomicChange
- indicates whether to consider this an atomic change
or part of another operation.public boolean reduceSelection(int increment, boolean atomicChange)
increment
- amount to reduce the selection.atomicChange
- indicates whether to consider this an atomic change
or part of another operation.public boolean enlargeObject(GraphObject go, int increment)
go
- Graph object to be enlarged.increment
- pixels to be enlarged by (may be negative for reducing).
When used for reducing, it tries to ensure that objects will not be
shrunk beyond some heuristic minimum.public static Graph innermostContext(Graph outermost, Point2D.Double p)
outermost
- The graph outside of which we need not bother to lookp
- the point of interestpublic String arrowAllowed(GraphObject go1, GraphObject go2)
go1
- "From" objectgo2
- "To" objectpublic String corefAllowed(GraphObject go1, GraphObject go2)
go1
- "From" objectgo2
- "To" objectpublic String genspecAllowed(GraphObject subobj, GraphObject superobj)
subobj
- "From" objectsuperobj
- "To" objectpublic void performZoomAction(String direction)
direction
- one of the values "in" "out" or "actual"public void performFindMenuAction()
performFindString(java.lang.String)
public void performFindString(String s)
s
- the string to search for.public void performFindAgain(String s)