Class JeditPanel
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----JeditPanel
- public class JeditPanel
- extends Panel
- implements MouseListener, MouseMotionListener, AdjustmentListener, ActionListener
JeditPanel.java
by Aaron Nall
Wed 07-01-1998
This class renders a JavaGraph
and allows the user to manipulate it with mouse events. It is the
largest class of Jedit3.1.
-
ADDARC
- A flag used with setMouseAction to
indicate that mouse drags add Arcs to the panel's
JavaGraph.
-
ADDEDGE
- A flag used with setMouseAction to
indicate that mouse drags add Edges to the panel's
JavaGraph.
-
ADDVERTEX
- A flag used with setMouseAction to
indicate that mouse presses add Vertices to the panel's
JavaGraph.
-
AUTOMATICALGORITHM
- A flag used with Algorithm.type to
to indicate that the algorithm determined by getAlgorithm will start automatically.
-
MOVETHINGS
- A flag used with setMouseAction to
indicate that mouse drags move Vertices, Edges, and Arcs
in the panel's
JavaGraph.
-
NOTHING
- A flag used with setMouseAction to
indicate that mouse actions are ignored.
-
ONECLICKALGORITHM
- A flag used with setMouseAction
and Algorithm.type to
indicate that the next mouse click will launch the algorithm
determined by getAlgorithm.
-
TEXTINPUTALGORITHM
- A flag used with Algorithm.type to
to indicate that the algorithm determined by getAlgorithm requires text input.
-
TWOCLICKALGORITHM
- A flag used with setMouseAction
and Algorithm.type to
indicate that the next two mouse clicks will launch the algorithm
determined by getAlgorithm.
-
JeditPanel(AudioClip, AudioClip)
- This constructor creates a new JavaGraph
for the new JeditPanel.
-
JeditPanel(JeditPanel)
- This cloning constructor makes the new JeditPanel
an exact copy of the JeditPanel first.
-
actionPerformed(ActionEvent)
- This method is used to act on the user's selections in the
popup menus.
-
adjustmentValueChanged(AdjustmentEvent)
- This method is used when Scrollbars are moved.
-
autoLabelAllEdges()
- This method sets the labels of all Edges/Arcs to
reflect their endpoint Vertices.
-
backup()
- Store a copy of the current
JavaGraph
as a backup.
See restoreBackup
-
doTextualAlgorithm(String)
- This method is used to run an algorithm that
requires text input.
-
getAlgorithm()
- Gets the Algorithm that will be run on the
Panel.
-
getBackgroundColor()
- Get the Panel's background color.
-
getDelay()
- Gets the flag that determines whether or not
algorithms should be animated when run on
the Panel.
-
getEdgeAutoLabel()
- Get the flag that tells whether or not to label
new Edges/Arcs with their Endpoint Vertices' labels
(starting at zero)
-
getEdgeColor()
- Get the default Color for new Edges/Arcs
-
getEdgeLabel()
- Get the default label for new Edes/Arcs that
are not labeld with their endpoint vertices
-
getEdgeSound()
- Gets the AudiClip associated with adding
Edges/Arcs.
-
getEdgeWeight()
- Get the default weight for new Edges/Arcs
-
getEdgeWeight2()
- Get the default second weight for new Edges/Arcs
-
getEnable()
- Used to get the panel's state for accepting mouse input (true)
or ignoring it (false).
-
getGraph()
- Retrieve the JavaGraph for this panel.
-
getInputTextString()
- Gets the String that will appear by default in the
window prompting a user for input to start an
algorithm that requires text input.
-
getLabelColor()
- Get the Color of Edge/Arc labels and weights,
Vertex weights, and the status string.
-
getMouseAction()
- This method is used to determine the meaning of mouse actions on the canvas.
-
getOffSet()
- Return the coordinates for the upper left corner of the
visible panel.
-
getShowEdgeLabel()
- Get the flag determining whether or not to
render Edge/Arc labels
-
getShowEdgeWeight()
- Get the flag that determines whether or not
to show Edge/Arc weights
-
getShowVertexLabel()
- Get the flag determining whether or not to
render Vertex labels
-
getShowVertexWeight()
- Get the flag that determines whether or not
to show Vertex weights
-
getVertexAutoLabel()
- Get the flag that tells whether or not to label
new Vertices with their number in the graph
(starting at zero)
-
getVertexColor()
- Gets the default color for new Vertices
-
getVertexLabel()
- Get the default label for new Vertices
that are not automatically labeled with numbers
-
getVertexSound()
- Gets the AudiClip associated with adding
Vertices.
-
getVertexWeight()
- Get the default weight for new Vertices.
-
mouseClicked(MouseEvent)
-
-
mouseDragged(MouseEvent)
- This method is used for adding Edges/Arcs and moving objects around the panel.
-
mouseEntered(MouseEvent)
-
-
mouseExited(MouseEvent)
-
-
mouseMoved(MouseEvent)
-
-
mousePressed(MouseEvent)
- This method is used to add Vertices and start algorithms.
-
mouseReleased(MouseEvent)
-
-
paint(Graphics)
- This method is responsible for all of the
JavaGraph
rendering.
-
restoreBackup()
- Change the panel's
JavaGraph
to the backed up version.
See backup
-
setAlgorithm(Algorithm)
- Sets the Algorithm that will be run on the
Panel.
-
setBackgroundColor(Color)
- Set the Panel's background color.
-
setDelay(boolean)
- Sets the flag that determines whether or not
algorithms should be animated when run on
the Panel.
-
setEdgeAutoLabel(boolean)
- Set the flag that tells whether or not to label
new Edges/Arcs with their Endpoint Vertices' labels
(starting at zero)
-
setEdgeColor(Color)
- Set the default Color for new Edges/Arcs
-
setEdgeLabel(String)
- Set the default label for new Edes/Arcs that
are not labeld with their endpoint vertices
-
setEdgeWeight(double)
- Set the default weight for new Edges/Arcs
-
setEdgeWeight2(double)
- Set the default second weight for new Edges/Arcs
-
setEnable(boolean)
- Used to set the panel in a state to accept mouse input (true) or ignore
it (false).
-
setGraph(JavaGraph)
- Set the JavaGraph for this panel.
-
setInputTextString(String)
- Sets the String that will appear by default in the
window prompting a user for input to start an
algorithm that requires text input.
-
setLabelColor(Color)
- Set the Color of Edge/Arc labels and weights,
Vertex weights, and the status string.
-
setMouseAction(int)
- This method is used to set the meaning of mouse actions on the canvas.
-
setOffSet(Point)
- Set the coordinates for the upper left corner of the
visible panel.
-
setShowEdgeLabel(boolean)
- Set the flag determining whether or not to
render Edge/Arc labels
-
setShowEdgeWeight(boolean)
- Set the flag that determines whether or not
to show Edge/Arc weights
-
setShowVertexLabel(boolean)
- Set the flag determining whether or not to
render Vertex labels
-
setShowVertexWeight(boolean)
- Set the flag that determines whether or not
to show Vertex weights
-
setStatus(String)
- Set the text for the status written in the lower left corner of the panel.
-
setVertexAutoLabel(boolean)
- Set the flag that tells whether or not to label
new Vertices with their number in the graph
(starting at zero)
-
setVertexColor(Color)
- Set the default label for new Vertices
that are not automatically labeled with numbers
-
setVertexLabel(String)
- Sets the default color for new Vertices
-
setVertexWeight(double)
- Set the default weight for new Vertices.
-
update(Graphics)
- This method is overridden for double-buffering.
ADDVERTEX
public static final int ADDVERTEX
- A flag used with setMouseAction to
indicate that mouse presses add Vertices to the panel's
JavaGraph.
ADDEDGE
public static final int ADDEDGE
- A flag used with setMouseAction to
indicate that mouse drags add Edges to the panel's
JavaGraph.
ADDARC
public static final int ADDARC
- A flag used with setMouseAction to
indicate that mouse drags add Arcs to the panel's
JavaGraph.
MOVETHINGS
public static final int MOVETHINGS
- A flag used with setMouseAction to
indicate that mouse drags move Vertices, Edges, and Arcs
in the panel's
JavaGraph.
NOTHING
public static final int NOTHING
- A flag used with setMouseAction to
indicate that mouse actions are ignored.
ONECLICKALGORITHM
public static final int ONECLICKALGORITHM
- A flag used with setMouseAction
and Algorithm.type to
indicate that the next mouse click will launch the algorithm
determined by getAlgorithm.
TEXTINPUTALGORITHM
public static final int TEXTINPUTALGORITHM
- A flag used with Algorithm.type to
to indicate that the algorithm determined by getAlgorithm requires text input.
TWOCLICKALGORITHM
public static final int TWOCLICKALGORITHM
- A flag used with setMouseAction
and Algorithm.type to
indicate that the next two mouse clicks will launch the algorithm
determined by getAlgorithm.
AUTOMATICALGORITHM
public static final int AUTOMATICALGORITHM
- A flag used with Algorithm.type to
to indicate that the algorithm determined by getAlgorithm will start automatically.
JeditPanel
public JeditPanel(AudioClip newVertexSound,
AudioClip newEdgeSound)
- This constructor creates a new JavaGraph
for the new JeditPanel. newVertexSound is the sound played
when a new vertex is added. newEdgeSound is the sound
played while adding an Edge or Vertex.
JeditPanel
public JeditPanel(JeditPanel first)
- This cloning constructor makes the new JeditPanel
an exact copy of the JeditPanel first.
update
public void update(Graphics g)
- This method is overridden for double-buffering.
- Overrides:
- update in class Container
paint
public void paint(Graphics g)
- This method is responsible for all of the
JavaGraph
rendering. The 279 lines of code that make up
this method are best examined directly for a better
understanding of how this method works.
- Overrides:
- paint in class Container
mouseMoved
public void mouseMoved(MouseEvent e)
mouseDragged
public void mouseDragged(MouseEvent e)
- This method is used for adding Edges/Arcs and moving objects around the panel.
mouseExited
public void mouseExited(MouseEvent e)
mouseEntered
public void mouseEntered(MouseEvent e)
mouseReleased
public void mouseReleased(MouseEvent e)
mousePressed
public void mousePressed(MouseEvent e)
- This method is used to add Vertices and start algorithms.
mouseClicked
public void mouseClicked(MouseEvent e)
adjustmentValueChanged
public void adjustmentValueChanged(AdjustmentEvent e)
- This method is used when Scrollbars are moved.
setMouseAction
public void setMouseAction(int newAction)
- This method is used to set the meaning of mouse actions on the canvas.
See Also:
getMouseAction
public int getMouseAction()
- This method is used to determine the meaning of mouse actions on the canvas.
See Also:
actionPerformed
public void actionPerformed(ActionEvent e)
- This method is used to act on the user's selections in the
popup menus. The three popup menus are for Vertices, Edges,
and Arcs.
getGraph
public JavaGraph getGraph()
- Retrieve the JavaGraph for this panel.
setGraph
public void setGraph(JavaGraph newGraph)
- Set the JavaGraph for this panel.
setStatus
public void setStatus(String newStatus)
- Set the text for the status written in the lower left corner of the panel.
getEnable
public boolean getEnable()
- Used to get the panel's state for accepting mouse input (true)
or ignoring it (false).
setEnable
public void setEnable(boolean newvalue)
- Used to set the panel in a state to accept mouse input (true) or ignore
it (false).
backup
public void backup()
- Store a copy of the current
JavaGraph
as a backup.
See restoreBackup
restoreBackup
public void restoreBackup()
- Change the panel's
JavaGraph
to the backed up version.
See backup
getVertexWeight
public double getVertexWeight()
- Get the default weight for new Vertices.
setVertexWeight
public void setVertexWeight(double newWeight)
- Set the default weight for new Vertices.
getVertexAutoLabel
public boolean getVertexAutoLabel()
- Get the flag that tells whether or not to label
new Vertices with their number in the graph
(starting at zero)
setVertexAutoLabel
public void setVertexAutoLabel(boolean toDo)
- Set the flag that tells whether or not to label
new Vertices with their number in the graph
(starting at zero)
getEdgeAutoLabel
public boolean getEdgeAutoLabel()
- Get the flag that tells whether or not to label
new Edges/Arcs with their Endpoint Vertices' labels
(starting at zero)
setEdgeAutoLabel
public void setEdgeAutoLabel(boolean toDo)
- Set the flag that tells whether or not to label
new Edges/Arcs with their Endpoint Vertices' labels
(starting at zero)
getVertexColor
public Color getVertexColor()
- Gets the default color for new Vertices
setVertexLabel
public void setVertexLabel(String newString)
- Sets the default color for new Vertices
getVertexLabel
public String getVertexLabel()
- Get the default label for new Vertices
that are not automatically labeled with numbers
setVertexColor
public void setVertexColor(Color newColor)
- Set the default label for new Vertices
that are not automatically labeled with numbers
getEdgeWeight
public double getEdgeWeight()
- Get the default weight for new Edges/Arcs
setEdgeWeight
public void setEdgeWeight(double newValue)
- Set the default weight for new Edges/Arcs
getEdgeWeight2
public double getEdgeWeight2()
- Get the default second weight for new Edges/Arcs
setEdgeWeight2
public void setEdgeWeight2(double newValue)
- Set the default second weight for new Edges/Arcs
getEdgeLabel
public String getEdgeLabel()
- Get the default label for new Edes/Arcs that
are not labeld with their endpoint vertices
setEdgeLabel
public void setEdgeLabel(String newLabel)
- Set the default label for new Edes/Arcs that
are not labeld with their endpoint vertices
setEdgeColor
public void setEdgeColor(Color newColor)
- Set the default Color for new Edges/Arcs
getEdgeColor
public Color getEdgeColor()
- Get the default Color for new Edges/Arcs
getBackgroundColor
public Color getBackgroundColor()
- Get the Panel's background color.
setBackgroundColor
public void setBackgroundColor(Color newColor)
- Set the Panel's background color.
getLabelColor
public Color getLabelColor()
- Get the Color of Edge/Arc labels and weights,
Vertex weights, and the status string.
setLabelColor
public void setLabelColor(Color newColor)
- Set the Color of Edge/Arc labels and weights,
Vertex weights, and the status string.
setShowVertexLabel
public void setShowVertexLabel(boolean in)
- Set the flag determining whether or not to
render Vertex labels
setShowEdgeLabel
public void setShowEdgeLabel(boolean in)
- Set the flag determining whether or not to
render Edge/Arc labels
getShowVertexLabel
public boolean getShowVertexLabel()
- Get the flag determining whether or not to
render Vertex labels
getShowEdgeLabel
public boolean getShowEdgeLabel()
- Get the flag determining whether or not to
render Edge/Arc labels
getShowEdgeWeight
public boolean getShowEdgeWeight()
- Get the flag that determines whether or not
to show Edge/Arc weights
getShowVertexWeight
public boolean getShowVertexWeight()
- Get the flag that determines whether or not
to show Vertex weights
setShowEdgeWeight
public void setShowEdgeWeight(boolean in)
- Set the flag that determines whether or not
to show Edge/Arc weights
setShowVertexWeight
public void setShowVertexWeight(boolean in)
- Set the flag that determines whether or not
to show Vertex weights
getVertexSound
public AudioClip getVertexSound()
- Gets the AudiClip associated with adding
Vertices.
getEdgeSound
public AudioClip getEdgeSound()
- Gets the AudiClip associated with adding
Edges/Arcs.
setAlgorithm
public void setAlgorithm(Algorithm newAlgorithm)
- Sets the Algorithm that will be run on the
Panel.
getAlgorithm
public Algorithm getAlgorithm()
- Gets the Algorithm that will be run on the
Panel.
getDelay
public boolean getDelay()
- Gets the flag that determines whether or not
algorithms should be animated when run on
the Panel.
setDelay
public void setDelay(boolean newValue)
- Sets the flag that determines whether or not
algorithms should be animated when run on
the Panel.
doTextualAlgorithm
public void doTextualAlgorithm(String inputText)
- This method is used to run an algorithm that
requires text input.
setInputTextString
public void setInputTextString(String input)
- Sets the String that will appear by default in the
window prompting a user for input to start an
algorithm that requires text input.
getInputTextString
public String getInputTextString()
- Gets the String that will appear by default in the
window prompting a user for input to start an
algorithm that requires text input.
getOffSet
public Point getOffSet()
- Return the coordinates for the upper left corner of the
visible panel.
setOffSet
public void setOffSet(Point newPoint)
- Set the coordinates for the upper left corner of the
visible panel.
autoLabelAllEdges
public void autoLabelAllEdges()
- This method sets the labels of all Edges/Arcs to
reflect their endpoint Vertices.