EDU.auburn.VGJ.gui
Class GraphCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--EDU.auburn.VGJ.gui.OffsetCanvas
                    |
                    +--EDU.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

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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.
 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, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, 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

CREATE_NODES

public static final int CREATE_NODES

CREATE_EDGES

public static final int CREATE_EDGES

SELECT_NODES

public static final int SELECT_NODES

SELECT_EDGES

public static final int SELECT_EDGES

SELECT_BOTH

public static final int SELECT_BOTH

UPDATE

public static final int UPDATE

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()
Overrides:
preferredSize in class java.awt.Component

paint

public void paint(java.awt.Graphics graphics)
Overrides:
paint in class java.awt.Canvas

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)
Overrides:
mouseDown in class java.awt.Component

mouseDrag

public boolean mouseDrag(java.awt.Event e,
                         int x_in,
                         int y_in)
Overrides:
mouseDrag in class java.awt.Component

mouseMove

public boolean mouseMove(java.awt.Event event,
                         int x_in,
                         int y_in)
Overrides:
mouseMove in class java.awt.Component

mouseUp

public boolean mouseUp(java.awt.Event e,
                       int x_in,
                       int y_in)
Overrides:
mouseUp in class java.awt.Component

mouseExit

public boolean mouseExit(java.awt.Event event,
                         int x_in,
                         int y_in)
Overrides:
mouseExit in class java.awt.Component

contentsSize

public DDimension contentsSize()
Description copied from class: OffsetCanvas
Return the size of the contents.
Overrides:
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.
Overrides:
setOffsets in class OffsetCanvas
Following copied from class: EDU.auburn.VGJ.gui.OffsetCanvas
Parameters:
xoffset - horizontal offset
yoffset - vertical offset

getOffset

public DPoint getOffset()
Overrides:
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)
Overrides:
handleEvent in class java.awt.Component

keyDown

public boolean keyDown(java.awt.Event e,
                       int key)
Overrides:
keyDown in class java.awt.Component

removeNotify

public void removeNotify()
Overrides:
removeNotify in class java.awt.Component

getFont

public java.awt.Font getFont()
Overrides:
getFont in class java.awt.Component

setFont

public void setFont(java.awt.Font font)
Overrides:
setFont in class java.awt.Component

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)