Package edu.uci.ics.jung.samples
Class PluggableRendererDemo
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
edu.uci.ics.jung.samples.PluggableRendererDemo
- All Implemented Interfaces:
ActionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,RootPaneContainer
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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
private static final class
class
protected class
a GraphMousePlugin that offers popup menu supportprivate final class
private final class
private static final class
private static final class
private static final class
Controls the shape, size, and aspect ratio for each vertex.private static final class
class
Nested classes/interfaces inherited from class javax.swing.JApplet
JApplet.AccessibleJApplet
Nested classes/interfaces inherited from class java.applet.Applet
Applet.AccessibleApplet
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JCheckBox
protected JRadioButton
protected JCheckBox
protected JRadioButton
protected JCheckBox
protected JCheckBox
protected JRadioButton
protected JRadioButton
protected JRadioButton
protected JCheckBox
protected JCheckBox
protected JCheckBox
protected JRadioButton
protected PluggableRendererDemo.EdgeFontTransformer
<Number> protected JCheckBox
protected JCheckBox
protected DefaultModalGraphMouse
<Integer, Number> protected static int
protected static final int
protected JRadioButton
protected static final int
protected JRadioButton
protected PluggableRendererDemo.SeedDrawColor
<Integer> protected PluggableRendererDemo.SeedFillColor
<Integer> protected static final Object
protected JCheckBox
protected JCheckBox
protected JCheckBox
protected JCheckBox
protected JCheckBox
protected JCheckBox
protected JCheckBox
protected static final Object
protected VisualizationViewer
<Integer, Number> protected JCheckBox
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.static void
void
start()
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, stop
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, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
v_color
-
e_color
-
v_stroke
-
e_uarrow_pred
-
e_darrow_pred
-
e_arrow_centered
-
v_shape
-
v_size
-
v_aspect
-
v_labels
-
e_line
-
e_bent
-
e_wedge
-
e_quad
-
e_ortho
-
e_cubic
-
e_labels
-
font
-
e_show_d
-
e_show_u
-
v_small
-
zoom_at_mouse
-
fill_edges
-
no_gradient
-
gradient_relative
-
GRADIENT_NONE
protected static final int GRADIENT_NONE- See Also:
-
GRADIENT_RELATIVE
protected static final int GRADIENT_RELATIVE- See Also:
-
gradient_level
protected static int gradient_level -
seedFillColor
-
seedDrawColor
-
ewcs
-
vsh
-
vs
-
vs_none
-
es
-
es_none
-
vff
-
eff
-
vssa
-
show_edge
-
show_arrow
-
show_vertex
-
self_loop
-
edgeDrawPaint
-
edgeFillPaint
-
VOLTAGE_KEY
-
TRANSPARENCY
-
edge_weight
-
voltages
-
transparency
-
vv
-
gm
-
seedVertices
-
graph
-
-
Constructor Details
-
PluggableRendererDemo
public PluggableRendererDemo()
-
-
Method Details
-
start
public void start() -
main
-
startFunction
-
buildGraph
Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.- Returns:
- the generated graph
-
addBottomControls
- Parameters:
jp
- panel to which controls will be added
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-