EDU.auburn.VGJ.gui
Class GraphCanvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended byEDU.auburn.VGJ.gui.OffsetCanvas
              extended byEDU.auburn.VGJ.gui.GraphCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, GraphUpdate, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class GraphCanvas
extends OffsetCanvas
implements GraphUpdate

A window class for editing and displaying Graphs.

Here is the source.

Author:
Larry Barowski
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int CREATE_EDGES
           
static int CREATE_NODES
           
 double hSpacing
           
static int MOUSEMOVE
           
static int SELECT_BOTH
           
static int SELECT_EDGES
           
static int SELECT_NODES
           
static int UPDATE
           
 double vSpacing
           
 
Fields inherited from class EDU.auburn.VGJ.gui.OffsetCanvas
LABEL, RESIZE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GraphCanvas(Graph graph_in, java.awt.Frame frame_in)
           
 
Method Summary
 void center()
          Update the display and boundaries, and center the graph in the display window.
 DDimension contentsSize()
          Return the size of the contents.
 void deleteSelected(boolean group_warning)
           
 void drawObjects_(boolean selected, java.awt.Graphics graphics, int which_gr)
           
 void drawRotatedText(java.lang.String string, double theta, int cx, int cy, java.awt.Graphics graphics_in, int which_gr)
           
 DPoint3 getCenter()
           
 void getDrawBounds_(DPoint width, DPoint height)
           
 java.awt.Font getFont()
           
 java.awt.Frame getFrame()
          Get an application Frame from which to pop up windows.
 Graph getGraph()
           
 double getHSpacing()
           
 DPoint getOffset()
           
 Node getSelectedNode()
          Get the index of the selected node. -1 is returned if no node is selected.
 double getVSpacing()
           
 void groupControl(int key)
           
 boolean handleEvent(java.awt.Event e)
           
 boolean keyDown(java.awt.Event e, int key)
           
 boolean mouseDown(java.awt.Event e, int x_in, int y_in)
           
 boolean mouseDrag(java.awt.Event e, int x_in, int y_in)
           
 boolean mouseExit(java.awt.Event event, int x_in, int y_in)
           
 boolean mouseMove(java.awt.Event event, int x_in, int y_in)
           
 boolean mouseUp(java.awt.Event e, int x_in, int y_in)
           
 void paint(java.awt.Graphics graphics)
           
 void paintOver()
           
 java.awt.Dimension preferredSize()
           
 void removeEdgeBends()
           
 void removeGroups()
           
 void removeNotify()
           
 void scale(double scaleval)
          Set the scale value for display, and update the display. scaleval is interpreted as follows: screen_distance = physical_distance * scaleval.
 void scaleBounds(boolean sb)
           
 void selectAll()
           
 void selectNode(int node_index)
           
 void setDirected(boolean directed)
           
 void setEdgeProperties(boolean always_default)
           
 void setFont(java.awt.Font font)
           
 void setMouseMode(int mode)
           
 void setNodeProperties(boolean always_default)
           
 void setOffsets(double xoffset, double yoffset, boolean redraw)
          Adjust the offset of the contents of the canvas.
 void setQuality(int quality)
           
 void setScale(double new_scale)
           
 void setViewAngles(double theta, double phi)
           
 void setWireframe(boolean wireframe)
           
 java.lang.String toPS(double width, double height, double pagewidth, double pageheight, double fontsize, double margin, double overlap, boolean landscape)
           
 void unselectItems()
           
 void update(boolean adjust_bounds)
          Update the display.
 DRect windowRect()
          Get the position and dimensions of the display window.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseEnter, move, nextFocus, paintAll, paramString, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MOUSEMOVE

public static final int MOUSEMOVE
See Also:
Constant Field Values

CREATE_NODES

public static final int CREATE_NODES
See Also:
Constant Field Values

CREATE_EDGES

public static final int CREATE_EDGES
See Also:
Constant Field Values

SELECT_NODES

public static final int SELECT_NODES
See Also:
Constant Field Values

SELECT_EDGES

public static final int SELECT_EDGES
See Also:
Constant Field Values

SELECT_BOTH

public static final int SELECT_BOTH
See Also:
Constant Field Values

UPDATE

public static final int UPDATE
See Also:
Constant Field Values

hSpacing

public double hSpacing

vSpacing

public double vSpacing
Constructor Detail

GraphCanvas

public GraphCanvas(Graph graph_in,
                   java.awt.Frame frame_in)
Method Detail

preferredSize

public java.awt.Dimension preferredSize()

paint

public void paint(java.awt.Graphics graphics)

paintOver

public void paintOver()

drawObjects_

public void drawObjects_(boolean selected,
                         java.awt.Graphics graphics,
                         int which_gr)

mouseDown

public boolean mouseDown(java.awt.Event e,
                         int x_in,
                         int y_in)

mouseDrag

public boolean mouseDrag(java.awt.Event e,
                         int x_in,
                         int y_in)

mouseMove

public boolean mouseMove(java.awt.Event event,
                         int x_in,
                         int y_in)

mouseUp

public boolean mouseUp(java.awt.Event e,
                       int x_in,
                       int y_in)

mouseExit

public boolean mouseExit(java.awt.Event event,
                         int x_in,
                         int y_in)

contentsSize

public DDimension contentsSize()
Description copied from class: OffsetCanvas
Return the size of the contents.

Specified by:
contentsSize in class OffsetCanvas

setOffsets

public void setOffsets(double xoffset,
                       double yoffset,
                       boolean redraw)
Description copied from class: OffsetCanvas
Adjust the offset of the contents of the canvas. These must have the following meaning: screen position + offset = contents position. e.g. if xoffset is 10, contents starts 10 pixels to the left of the screen.

Specified by:
setOffsets in class OffsetCanvas
Parameters:
xoffset - horizontal offset
yoffset - vertical offset

getOffset

public DPoint getOffset()
Specified by:
getOffset in class OffsetCanvas

setScale

public void setScale(double new_scale)

setViewAngles

public void setViewAngles(double theta,
                          double phi)

getCenter

public DPoint3 getCenter()

update

public void update(boolean adjust_bounds)
Description copied from interface: GraphUpdate
Update the display. If adjust_bounds is set, the boundaries are recomputed (basically, the controls get updated as well as the display, and this will be slow for large graphs).

Specified by:
update in interface GraphUpdate

scale

public void scale(double scaleval)
Description copied from interface: GraphUpdate
Set the scale value for display, and update the display. scaleval is interpreted as follows: screen_distance = physical_distance * scaleval.

Specified by:
scale in interface GraphUpdate

center

public void center()
Description copied from interface: GraphUpdate
Update the display and boundaries, and center the graph in the display window.

Specified by:
center in interface GraphUpdate

getFrame

public java.awt.Frame getFrame()
Description copied from interface: GraphUpdate
Get an application Frame from which to pop up windows.

Specified by:
getFrame in interface GraphUpdate

getGraph

public Graph getGraph()

deleteSelected

public void deleteSelected(boolean group_warning)

getSelectedNode

public Node getSelectedNode()
Description copied from interface: GraphUpdate
Get the index of the selected node. -1 is returned if no node is selected.

Specified by:
getSelectedNode in interface GraphUpdate

unselectItems

public void unselectItems()

scaleBounds

public void scaleBounds(boolean sb)

setMouseMode

public void setMouseMode(int mode)

windowRect

public DRect windowRect()
Description copied from interface: GraphUpdate
Get the position and dimensions of the display window.

Specified by:
windowRect in interface GraphUpdate

setDirected

public void setDirected(boolean directed)

toPS

public java.lang.String toPS(double width,
                             double height,
                             double pagewidth,
                             double pageheight,
                             double fontsize,
                             double margin,
                             double overlap,
                             boolean landscape)

getDrawBounds_

public void getDrawBounds_(DPoint width,
                           DPoint height)

setNodeProperties

public void setNodeProperties(boolean always_default)

setEdgeProperties

public void setEdgeProperties(boolean always_default)

selectAll

public void selectAll()

getHSpacing

public double getHSpacing()
Specified by:
getHSpacing in interface GraphUpdate

getVSpacing

public double getVSpacing()
Specified by:
getVSpacing in interface GraphUpdate

handleEvent

public boolean handleEvent(java.awt.Event e)

keyDown

public boolean keyDown(java.awt.Event e,
                       int key)

removeNotify

public void removeNotify()

getFont

public java.awt.Font getFont()
Specified by:
getFont in interface java.awt.MenuContainer

setFont

public void setFont(java.awt.Font font)

setWireframe

public void setWireframe(boolean wireframe)

setQuality

public void setQuality(int quality)

removeEdgeBends

public void removeEdgeBends()

removeGroups

public void removeGroups()

groupControl

public void groupControl(int key)

drawRotatedText

public void drawRotatedText(java.lang.String string,
                            double theta,
                            int cx,
                            int cy,
                            java.awt.Graphics graphics_in,
                            int which_gr)

selectNode

public void selectNode(int node_index)