Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## samples.graph
Class PluggableRendererDemo

    java.lang.Object
      java.awt.Component
          java.awt.Container
              java.awt.Panel
                  java.applet.Applet
                      javax.swing.JApplet
                          samples.graph.PluggableRendererDemo

All Implemented Interfaces:
  Accessible, ActionListener, EventListener, ImageObserver, MenuContainer, RootPaneContainer, Serializable

public class PluggableRendererDemo
extends JApplet
implements ActionListener

Shows off some of the capabilities of `PluggableRenderer`. This code provides examples of different ways to provide and change the various functions that provide property information to the renderer.

This demo creates a random mixed-mode graph with random edge weights using `TestGraph.generateMixedRandomGraph`. It then runs `VoltageRanker` on this graph, using half of the "seed" vertices from the random graph generation as voltage sources, and half of them as voltage sinks.

What the controls do:

Mouse controls:

If your mouse has a scroll wheel, scrolling forward zooms out and scrolling backward zooms in.
Left-clicking on a vertex or edge selects it, and unselects all others.
Middle-clicking on a vertex or edge toggles its selection state.
Right-clicking on a vertex brings up a pop-up menu that allows you to increase or decrease that vertex's transparency.
Left-clicking on the background allows you to drag the image around.
Hovering over a vertex tells you what its voltage is; hovering over an edge shows its identity; hovering over the background shows an informational message.

Vertex stuff:

"vertex seed coloring": if checked, the seed vertices are colored blue, and all other vertices are colored red. Otherwise, all vertices are colored a slightly transparent red (except the currently "picked" vertex, which is colored transparent purple).
"vertex selection stroke highlighting": if checked, the picked vertex and its neighbors are all drawn with heavy borders. Otherwise, all vertices are drawn with light borders.
"show vertex ranks (voltages)": if checked, each vertex is labeled with its calculated 'voltage'. Otherwise, vertices are unlabeled.
"vertex degree shapes": if checked, vertices are drawn with a polygon with number of sides proportional to its degree. Otherwise, vertices are drawn as ellipses.
"vertex voltage size": if checked, vertices are drawn with a size proportional to their voltage ranking. Otherwise, all vertices are drawn at the same size.
"vertex degree ratio stretch": if checked, vertices are drawn with an aspect ratio (height/width ratio) proportional to the ratio of their indegree to their outdegree. Otherwise, vertices are drawn with an aspect ratio of 1.
"filter vertices of degree < 4": if checked, does not display any vertices (or their incident edges) whose degree in the original graph is less than 4; otherwise, all vertices are drawn.

Edge stuff:

"edge shape": selects between lines, wedges, quadratic curves, and cubic curves for drawing edges.
"fill edge shapes": if checked, fills the edge shapes. This will have no effect if "line" is selected.
"edge paint": selects between solid colored edges, and gradient-painted edges. Gradient painted edges are darkest in the middle for undirected edges, and darkest at the destination for directed edges.
"show edges": only edges of the checked types are drawn.
"show arrows": only arrows whose edges are of the checked types are drawn.
"edge weight highlighting": if checked, edges with weight greater than a threshold value are drawn using thick solid lines, and other edges are drawn using thin gray dotted lines. (This combines edge stroke and paint.) Otherwise, all edges are drawn with thin solid lines.
"show edge weights": if checked, edges are labeled with their weights. Otherwise, edges are not labeled.

Miscellaneous (center panel)

"bold text": if checked, all vertex and edge labels are drawn using a boldface font. Otherwise, a normal-weight font is used. (Has no effect if no labels are currently visible.)
zoom controls:

"+" zooms in, "-" zooms out
"zoom at mouse (wheel only)": if checked, zooming (using the mouse scroll wheel) is centered on the location of the mouse pointer; otherwise, it is centered on the center of the visualization pane.

Author:
  Danyel Fisher, Joshua O'Madadhain, Tom Nelson
See Also:
  Serialized Form

Nested Class Summary
`class` | `PluggableRendererDemo.GradientPickedEdgePaintFunction`
`protected class` | `PluggableRendererDemo.PopupGraphMousePlugin` a GraphMousePlugin that offers popup menu support
`class` | `PluggableRendererDemo.VoltageTips`

Nested classes inherited from class javax.swing.JApplet
`JApplet.AccessibleJApplet`

Nested classes inherited from class java.applet.Applet
`Applet.AccessibleApplet`

Nested classes inherited from class java.awt.Panel
`Panel.AccessibleAWTPanel`

Nested classes inherited from class java.awt.Container
`Container.AccessibleAWTContainer`

Nested classes inherited from class java.awt.Component
`Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy`

Field Summary
`protected Transformer` | `affineTransformer`
`protected JRadioButton` | `e_bent`
`protected JCheckBox` | `e_color`
`protected JRadioButton` | `e_cubic`
`protected JCheckBox` | `e_darrow_pred`
`protected JCheckBox` | `e_labels`
`protected JRadioButton` | `e_line`
`protected JRadioButton` | `e_quad`
`protected JCheckBox` | `e_show_d`
`protected JCheckBox` | `e_show_u`
`protected JCheckBox` | `e_uarrow_pred`
`protected JRadioButton` | `e_wedge`
`protected NumberEdgeValue` | `edge_weight`
`protected PluggableRendererDemo.GradientPickedEdgePaintFunction` | `edgePaint`
`protected EdgeStringer` | `es`
`protected EdgeStringer` | `es_none`
`protected samples.graph.PluggableRendererDemo.EdgeWeightStrokeFunction` | `ewcs`
`protected samples.graph.PluggableRendererDemo.FontHandler` | `ff`
`protected JCheckBox` | `fill_edges`
`protected JCheckBox` | `font`
`protected DefaultModalGraphMouse` | `gm`
`protected static int` | `gradient_level`
`protected static int` | `GRADIENT_NONE`
`protected JRadioButton` | `gradient_relative`
`protected static int` | `GRADIENT_RELATIVE`
`protected JRadioButton` | `no_gradient`
`protected PluggableRenderer` | `pr`
`protected samples.graph.PluggableRendererDemo.DirectionDisplayPredicate` | `show_arrow`
`protected samples.graph.PluggableRendererDemo.DirectionDisplayPredicate` | `show_edge`
`protected samples.graph.PluggableRendererDemo.VertexDisplayPredicate` | `show_vertex`
`protected NumberVertexValue` | `transparency`
`protected static Object` | `TRANSPARENCY`
`protected JCheckBox` | `v_aspect`
`protected JCheckBox` | `v_color`
`protected JCheckBox` | `v_labels`
`protected JCheckBox` | `v_shape`
`protected JCheckBox` | `v_size`
`protected JCheckBox` | `v_small`
`protected JCheckBox` | `v_stroke`
`protected samples.graph.PluggableRendererDemo.SeedColor` | `vcf`
`protected static Object` | `VOLTAGE_KEY`
`protected NumberVertexValue` | `voltages`
`protected VertexStringer` | `vs`
`protected VertexStringer` | `vs_none`
`protected samples.graph.PluggableRendererDemo.VertexStrokeHighlight` | `vsh`
`protected samples.graph.PluggableRendererDemo.VertexShapeSizeAspect` | `vssa`
`protected VisualizationViewer` | `vv`
`protected JCheckBox` | `zoom_at_mouse`

Fields inherited from class javax.swing.JApplet
`accessibleContext, rootPane, rootPaneCheckingEnabled`

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
`PluggableRendererDemo()`

Method Summary
`void` | `actionPerformed(ActionEvent e)`
`protected void` | `addBottomControls(JPanel jp)`
`Graph` | `getGraph()` Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.
`static void` | `main(String[] s)`
`void` | `start()`
`JPanel` | `startFunction()`

Methods inherited from class javax.swing.JApplet
`addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update`

Methods inherited from class java.applet.Applet
`destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, stop`

Methods inherited from class java.awt.Panel
`addNotify`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, 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, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### v_color

    protected JCheckBox v_color

### e_color

    protected JCheckBox e_color

### v_stroke

    protected JCheckBox v_stroke

### e_uarrow_pred

    protected JCheckBox e_uarrow_pred

### e_darrow_pred

    protected JCheckBox e_darrow_pred

### v_shape

    protected JCheckBox v_shape

### v_size

    protected JCheckBox v_size

### v_aspect

    protected JCheckBox v_aspect

### v_labels

    protected JCheckBox v_labels

### e_line

    protected JRadioButton e_line

### e_bent

    protected JRadioButton e_bent

### e_wedge

    protected JRadioButton e_wedge

### e_quad

    protected JRadioButton e_quad

### e_cubic

    protected JRadioButton e_cubic

### e_labels

    protected JCheckBox e_labels

### font

    protected JCheckBox font

### e_show_d

    protected JCheckBox e_show_d

### e_show_u

    protected JCheckBox e_show_u

### v_small

    protected JCheckBox v_small

### zoom_at_mouse

    protected JCheckBox zoom_at_mouse

### fill_edges

    protected JCheckBox fill_edges

### no_gradient

    protected JRadioButton no_gradient

### gradient_relative

    protected JRadioButton gradient_relative

### GRADIENT_NONE

    protected static final int GRADIENT_NONE

See Also:
  Constant Field Values

### GRADIENT_RELATIVE

    protected static final int GRADIENT_RELATIVE

See Also:
  Constant Field Values

### gradient_level

    protected static int gradient_level

### pr

    protected PluggableRenderer pr

### vcf

    protected samples.graph.PluggableRendererDemo.SeedColor vcf

### ewcs

    protected samples.graph.PluggableRendererDemo.EdgeWeightStrokeFunction ewcs

### vsh

    protected samples.graph.PluggableRendererDemo.VertexStrokeHighlight vsh

### vs

    protected VertexStringer vs

### vs_none

    protected VertexStringer vs_none

### es

    protected EdgeStringer es

### es_none

    protected EdgeStringer es_none

### ff

    protected samples.graph.PluggableRendererDemo.FontHandler ff

### vssa

    protected samples.graph.PluggableRendererDemo.VertexShapeSizeAspect vssa

### show_edge

    protected samples.graph.PluggableRendererDemo.DirectionDisplayPredicate show_edge

### show_arrow

    protected samples.graph.PluggableRendererDemo.DirectionDisplayPredicate show_arrow

### show_vertex

    protected samples.graph.PluggableRendererDemo.VertexDisplayPredicate show_vertex

### edgePaint

    protected PluggableRendererDemo.GradientPickedEdgePaintFunction edgePaint

### VOLTAGE_KEY

    protected static final Object VOLTAGE_KEY

### TRANSPARENCY

    protected static final Object TRANSPARENCY

### edge_weight

    protected NumberEdgeValue edge_weight

### voltages

    protected NumberVertexValue voltages

### transparency

    protected NumberVertexValue transparency

### vv

    protected VisualizationViewer vv

### gm

    protected DefaultModalGraphMouse gm

### affineTransformer

    protected Transformer affineTransformer

Constructor Detail

### PluggableRendererDemo

    public PluggableRendererDemo()

Method Detail

### start

    public void start()

### main

    public static void main(String[] s)

### startFunction

    public JPanel startFunction()

### getGraph

    public Graph getGraph()

  Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.

### addBottomControls

    protected void addBottomControls(JPanel jp)

  Parameters:
    `jp` - panel to which controls will be added

### actionPerformed

    public void actionPerformed(ActionEvent e)

  Specified by:
    `actionPerformed` in interface `ActionListener`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD