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.


Variable Index

 o ADDARC
A flag used with setMouseAction to indicate that mouse drags add Arcs to the panel's JavaGraph.
 o ADDEDGE
A flag used with setMouseAction to indicate that mouse drags add Edges to the panel's JavaGraph.
 o ADDVERTEX
A flag used with setMouseAction to indicate that mouse presses add Vertices to the panel's JavaGraph.
 o AUTOMATICALGORITHM
A flag used with Algorithm.type to to indicate that the algorithm determined by getAlgorithm will start automatically.
 o MOVETHINGS
A flag used with setMouseAction to indicate that mouse drags move Vertices, Edges, and Arcs in the panel's JavaGraph.
 o NOTHING
A flag used with setMouseAction to indicate that mouse actions are ignored.
 o ONECLICKALGORITHM
A flag used with setMouseAction and Algorithm.type to indicate that the next mouse click will launch the algorithm determined by getAlgorithm.
 o TEXTINPUTALGORITHM
A flag used with Algorithm.type to to indicate that the algorithm determined by getAlgorithm requires text input.
 o TWOCLICKALGORITHM
A flag used with setMouseAction and Algorithm.type to indicate that the next two mouse clicks will launch the algorithm determined by getAlgorithm.

Constructor Index

 o JeditPanel(AudioClip, AudioClip)
This constructor creates a new JavaGraph for the new JeditPanel.
 o JeditPanel(JeditPanel)
This cloning constructor makes the new JeditPanel an exact copy of the JeditPanel first.

Method Index

 o actionPerformed(ActionEvent)
This method is used to act on the user's selections in the popup menus.
 o adjustmentValueChanged(AdjustmentEvent)
This method is used when Scrollbars are moved.
 o autoLabelAllEdges()
This method sets the labels of all Edges/Arcs to reflect their endpoint Vertices.
 o backup()
Store a copy of the current JavaGraph as a backup.
See restoreBackup
 o doTextualAlgorithm(String)
This method is used to run an algorithm that requires text input.
 o getAlgorithm()
Gets the Algorithm that will be run on the Panel.
 o getBackgroundColor()
Get the Panel's background color.
 o getDelay()
Gets the flag that determines whether or not algorithms should be animated when run on the Panel.
 o getEdgeAutoLabel()
Get the flag that tells whether or not to label new Edges/Arcs with their Endpoint Vertices' labels (starting at zero)
 o getEdgeColor()
Get the default Color for new Edges/Arcs
 o getEdgeLabel()
Get the default label for new Edes/Arcs that are not labeld with their endpoint vertices
 o getEdgeSound()
Gets the AudiClip associated with adding Edges/Arcs.
 o getEdgeWeight()
Get the default weight for new Edges/Arcs
 o getEdgeWeight2()
Get the default second weight for new Edges/Arcs
 o getEnable()
Used to get the panel's state for accepting mouse input (true) or ignoring it (false).
 o getGraph()
Retrieve the JavaGraph for this panel.
 o 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.
 o getLabelColor()
Get the Color of Edge/Arc labels and weights, Vertex weights, and the status string.
 o getMouseAction()
This method is used to determine the meaning of mouse actions on the canvas.
 o getOffSet()
Return the coordinates for the upper left corner of the visible panel.
 o getShowEdgeLabel()
Get the flag determining whether or not to render Edge/Arc labels
 o getShowEdgeWeight()
Get the flag that determines whether or not to show Edge/Arc weights
 o getShowVertexLabel()
Get the flag determining whether or not to render Vertex labels
 o getShowVertexWeight()
Get the flag that determines whether or not to show Vertex weights
 o getVertexAutoLabel()
Get the flag that tells whether or not to label new Vertices with their number in the graph (starting at zero)
 o getVertexColor()
Gets the default color for new Vertices
 o getVertexLabel()
Get the default label for new Vertices that are not automatically labeled with numbers
 o getVertexSound()
Gets the AudiClip associated with adding Vertices.
 o getVertexWeight()
Get the default weight for new Vertices.
 o mouseClicked(MouseEvent)
 o mouseDragged(MouseEvent)
This method is used for adding Edges/Arcs and moving objects around the panel.
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mouseMoved(MouseEvent)
 o mousePressed(MouseEvent)
This method is used to add Vertices and start algorithms.
 o mouseReleased(MouseEvent)
 o paint(Graphics)
This method is responsible for all of the JavaGraph rendering.
 o restoreBackup()
Change the panel's JavaGraph to the backed up version.
See backup
 o setAlgorithm(Algorithm)
Sets the Algorithm that will be run on the Panel.
 o setBackgroundColor(Color)
Set the Panel's background color.
 o setDelay(boolean)
Sets the flag that determines whether or not algorithms should be animated when run on the Panel.
 o setEdgeAutoLabel(boolean)
Set the flag that tells whether or not to label new Edges/Arcs with their Endpoint Vertices' labels (starting at zero)
 o setEdgeColor(Color)
Set the default Color for new Edges/Arcs
 o setEdgeLabel(String)
Set the default label for new Edes/Arcs that are not labeld with their endpoint vertices
 o setEdgeWeight(double)
Set the default weight for new Edges/Arcs
 o setEdgeWeight2(double)
Set the default second weight for new Edges/Arcs
 o setEnable(boolean)
Used to set the panel in a state to accept mouse input (true) or ignore it (false).
 o setGraph(JavaGraph)
Set the JavaGraph for this panel.
 o 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.
 o setLabelColor(Color)
Set the Color of Edge/Arc labels and weights, Vertex weights, and the status string.
 o setMouseAction(int)
This method is used to set the meaning of mouse actions on the canvas.
 o setOffSet(Point)
Set the coordinates for the upper left corner of the visible panel.
 o setShowEdgeLabel(boolean)
Set the flag determining whether or not to render Edge/Arc labels
 o setShowEdgeWeight(boolean)
Set the flag that determines whether or not to show Edge/Arc weights
 o setShowVertexLabel(boolean)
Set the flag determining whether or not to render Vertex labels
 o setShowVertexWeight(boolean)
Set the flag that determines whether or not to show Vertex weights
 o setStatus(String)
Set the text for the status written in the lower left corner of the panel.
 o setVertexAutoLabel(boolean)
Set the flag that tells whether or not to label new Vertices with their number in the graph (starting at zero)
 o setVertexColor(Color)
Set the default label for new Vertices that are not automatically labeled with numbers
 o setVertexLabel(String)
Sets the default color for new Vertices
 o setVertexWeight(double)
Set the default weight for new Vertices.
 o update(Graphics)
This method is overridden for double-buffering.

Variables

 o ADDVERTEX
 public static final int ADDVERTEX
A flag used with setMouseAction to indicate that mouse presses add Vertices to the panel's JavaGraph.

 o ADDEDGE
 public static final int ADDEDGE
A flag used with setMouseAction to indicate that mouse drags add Edges to the panel's JavaGraph.

 o ADDARC
 public static final int ADDARC
A flag used with setMouseAction to indicate that mouse drags add Arcs to the panel's JavaGraph.

 o 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.

 o NOTHING
 public static final int NOTHING
A flag used with setMouseAction to indicate that mouse actions are ignored.

 o 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.

 o TEXTINPUTALGORITHM
 public static final int TEXTINPUTALGORITHM
A flag used with Algorithm.type to to indicate that the algorithm determined by getAlgorithm requires text input.

 o 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.

 o AUTOMATICALGORITHM
 public static final int AUTOMATICALGORITHM
A flag used with Algorithm.type to to indicate that the algorithm determined by getAlgorithm will start automatically.

Constructors

 o 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.

 o JeditPanel
 public JeditPanel(JeditPanel first)
This cloning constructor makes the new JeditPanel an exact copy of the JeditPanel first.

Methods

 o update
 public void update(Graphics g)
This method is overridden for double-buffering.

Overrides:
update in class Container
 o 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
 o mouseMoved
 public void mouseMoved(MouseEvent e)
 o mouseDragged
 public void mouseDragged(MouseEvent e)
This method is used for adding Edges/Arcs and moving objects around the panel.

 o mouseExited
 public void mouseExited(MouseEvent e)
 o mouseEntered
 public void mouseEntered(MouseEvent e)
 o mouseReleased
 public void mouseReleased(MouseEvent e)
 o mousePressed
 public void mousePressed(MouseEvent e)
This method is used to add Vertices and start algorithms.

 o mouseClicked
 public void mouseClicked(MouseEvent e)
 o adjustmentValueChanged
 public void adjustmentValueChanged(AdjustmentEvent e)
This method is used when Scrollbars are moved.

 o setMouseAction
 public void setMouseAction(int newAction)
This method is used to set the meaning of mouse actions on the canvas.
See Also:

 o getMouseAction
 public int getMouseAction()
This method is used to determine the meaning of mouse actions on the canvas.
See Also:

 o 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.

 o getGraph
 public JavaGraph getGraph()
Retrieve the JavaGraph for this panel.

 o setGraph
 public void setGraph(JavaGraph newGraph)
Set the JavaGraph for this panel.

 o setStatus
 public void setStatus(String newStatus)
Set the text for the status written in the lower left corner of the panel.

 o getEnable
 public boolean getEnable()
Used to get the panel's state for accepting mouse input (true) or ignoring it (false).

 o setEnable
 public void setEnable(boolean newvalue)
Used to set the panel in a state to accept mouse input (true) or ignore it (false).

 o backup
 public void backup()
Store a copy of the current JavaGraph as a backup.
See restoreBackup

 o restoreBackup
 public void restoreBackup()
Change the panel's JavaGraph to the backed up version.
See backup

 o getVertexWeight
 public double getVertexWeight()
Get the default weight for new Vertices.

 o setVertexWeight
 public void setVertexWeight(double newWeight)
Set the default weight for new Vertices.

 o 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)

 o 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)

 o 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)

 o 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)

 o getVertexColor
 public Color getVertexColor()
Gets the default color for new Vertices

 o setVertexLabel
 public void setVertexLabel(String newString)
Sets the default color for new Vertices

 o getVertexLabel
 public String getVertexLabel()
Get the default label for new Vertices that are not automatically labeled with numbers

 o setVertexColor
 public void setVertexColor(Color newColor)
Set the default label for new Vertices that are not automatically labeled with numbers

 o getEdgeWeight
 public double getEdgeWeight()
Get the default weight for new Edges/Arcs

 o setEdgeWeight
 public void setEdgeWeight(double newValue)
Set the default weight for new Edges/Arcs

 o getEdgeWeight2
 public double getEdgeWeight2()
Get the default second weight for new Edges/Arcs

 o setEdgeWeight2
 public void setEdgeWeight2(double newValue)
Set the default second weight for new Edges/Arcs

 o getEdgeLabel
 public String getEdgeLabel()
Get the default label for new Edes/Arcs that are not labeld with their endpoint vertices

 o setEdgeLabel
 public void setEdgeLabel(String newLabel)
Set the default label for new Edes/Arcs that are not labeld with their endpoint vertices

 o setEdgeColor
 public void setEdgeColor(Color newColor)
Set the default Color for new Edges/Arcs

 o getEdgeColor
 public Color getEdgeColor()
Get the default Color for new Edges/Arcs

 o getBackgroundColor
 public Color getBackgroundColor()
Get the Panel's background color.

 o setBackgroundColor
 public void setBackgroundColor(Color newColor)
Set the Panel's background color.

 o getLabelColor
 public Color getLabelColor()
Get the Color of Edge/Arc labels and weights, Vertex weights, and the status string.

 o setLabelColor
 public void setLabelColor(Color newColor)
Set the Color of Edge/Arc labels and weights, Vertex weights, and the status string.

 o setShowVertexLabel
 public void setShowVertexLabel(boolean in)
Set the flag determining whether or not to render Vertex labels

 o setShowEdgeLabel
 public void setShowEdgeLabel(boolean in)
Set the flag determining whether or not to render Edge/Arc labels

 o getShowVertexLabel
 public boolean getShowVertexLabel()
Get the flag determining whether or not to render Vertex labels

 o getShowEdgeLabel
 public boolean getShowEdgeLabel()
Get the flag determining whether or not to render Edge/Arc labels

 o getShowEdgeWeight
 public boolean getShowEdgeWeight()
Get the flag that determines whether or not to show Edge/Arc weights

 o getShowVertexWeight
 public boolean getShowVertexWeight()
Get the flag that determines whether or not to show Vertex weights

 o setShowEdgeWeight
 public void setShowEdgeWeight(boolean in)
Set the flag that determines whether or not to show Edge/Arc weights

 o setShowVertexWeight
 public void setShowVertexWeight(boolean in)
Set the flag that determines whether or not to show Vertex weights

 o getVertexSound
 public AudioClip getVertexSound()
Gets the AudiClip associated with adding Vertices.

 o getEdgeSound
 public AudioClip getEdgeSound()
Gets the AudiClip associated with adding Edges/Arcs.

 o setAlgorithm
 public void setAlgorithm(Algorithm newAlgorithm)
Sets the Algorithm that will be run on the Panel.

 o getAlgorithm
 public Algorithm getAlgorithm()
Gets the Algorithm that will be run on the Panel.

 o getDelay
 public boolean getDelay()
Gets the flag that determines whether or not algorithms should be animated when run on the Panel.

 o setDelay
 public void setDelay(boolean newValue)
Sets the flag that determines whether or not algorithms should be animated when run on the Panel.

 o doTextualAlgorithm
 public void doTextualAlgorithm(String inputText)
This method is used to run an algorithm that requires text input.

 o 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.

 o 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.

 o getOffSet
 public Point getOffSet()
Return the coordinates for the upper left corner of the visible panel.

 o setOffSet
 public void setOffSet(Point newPoint)
Set the coordinates for the upper left corner of the visible panel.

 o autoLabelAllEdges
 public void autoLabelAllEdges()
This method sets the labels of all Edges/Arcs to reflect their endpoint Vertices.