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:
java.awt.event.ActionListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,javax.swing.RootPaneContainer
public class PluggableRendererDemo extends javax.swing.JApplet implements java.awt.event.ActionListenerShows off some of the capabilities ofPluggableRenderer. 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 runsVoltageRankeron 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 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 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.
-
"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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classPluggableRendererDemo.GradientPickedEdgePaintFunction<V,E>protected classPluggableRendererDemo.PopupGraphMousePlugina GraphMousePlugin that offers popup menu supportclassPluggableRendererDemo.VoltageTips<E>-
Nested classes/interfaces inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
-
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.JCheckBoxe_arrow_centeredprotected javax.swing.JRadioButtone_bentprotected javax.swing.JCheckBoxe_colorprotected javax.swing.JRadioButtone_cubicprotected javax.swing.JCheckBoxe_darrow_predprotected javax.swing.JCheckBoxe_labelsprotected javax.swing.JRadioButtone_lineprotected javax.swing.JRadioButtone_orthoprotected javax.swing.JRadioButtone_quadprotected javax.swing.JCheckBoxe_show_dprotected javax.swing.JCheckBoxe_show_uprotected javax.swing.JCheckBoxe_uarrow_predprotected javax.swing.JRadioButtone_wedgeprotected java.util.Map<java.lang.Number,java.lang.Number>edge_weightprotected PluggableRendererDemo.GradientPickedEdgePaintFunction<java.lang.Integer,java.lang.Number>edgeDrawPaintprotected PluggableRendererDemo.GradientPickedEdgePaintFunction<java.lang.Integer,java.lang.Number>edgeFillPaintprotected edu.uci.ics.jung.samples.PluggableRendererDemo.EdgeFontTransformer<java.lang.Number>effprotected org.apache.commons.collections4.Transformer<java.lang.Number,java.lang.String>esprotected org.apache.commons.collections4.Transformer<java.lang.Number,java.lang.String>es_noneprotected edu.uci.ics.jung.samples.PluggableRendererDemo.EdgeWeightStrokeFunction<java.lang.Number>ewcsprotected javax.swing.JCheckBoxfill_edgesprotected javax.swing.JCheckBoxfontprotected edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse<java.lang.Integer,java.lang.Number>gmprotected static intgradient_levelprotected static intGRADIENT_NONEprotected javax.swing.JRadioButtongradient_relativeprotected static intGRADIENT_RELATIVEprotected javax.swing.JRadioButtonno_gradientprotected edu.uci.ics.jung.samples.PluggableRendererDemo.SeedDrawColor<java.lang.Integer>seedDrawColorprotected edu.uci.ics.jung.samples.PluggableRendererDemo.SeedFillColor<java.lang.Integer>seedFillColorprotected java.util.Set<java.lang.Integer>seedVerticesprotected org.apache.commons.collections4.Predicate<edu.uci.ics.jung.graph.util.Context<edu.uci.ics.jung.graph.Graph<java.lang.Integer,java.lang.Number>,java.lang.Number>>self_loopprotected edu.uci.ics.jung.samples.PluggableRendererDemo.DirectionDisplayPredicate<java.lang.Integer,java.lang.Number>show_arrowprotected edu.uci.ics.jung.samples.PluggableRendererDemo.DirectionDisplayPredicate<java.lang.Integer,java.lang.Number>show_edgeprotected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexDisplayPredicate<java.lang.Integer,java.lang.Number>show_vertexprotected java.util.Map<java.lang.Integer,java.lang.Number>transparencyprotected static java.lang.ObjectTRANSPARENCYprotected javax.swing.JCheckBoxv_aspectprotected javax.swing.JCheckBoxv_colorprotected javax.swing.JCheckBoxv_labelsprotected javax.swing.JCheckBoxv_shapeprotected javax.swing.JCheckBoxv_sizeprotected javax.swing.JCheckBoxv_smallprotected javax.swing.JCheckBoxv_strokeprotected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexFontTransformer<java.lang.Integer>vffprotected static java.lang.ObjectVOLTAGE_KEYprotected org.apache.commons.collections4.Transformer<java.lang.Integer,java.lang.Double>voltagesprotected org.apache.commons.collections4.Transformer<java.lang.Integer,java.lang.String>vsprotected org.apache.commons.collections4.Transformer<java.lang.Integer,java.lang.String>vs_noneprotected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexStrokeHighlight<java.lang.Integer,java.lang.Number>vshprotected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexShapeSizeAspect<java.lang.Integer,java.lang.Number>vssaprotected edu.uci.ics.jung.visualization.VisualizationViewer<java.lang.Integer,java.lang.Number>vvprotected javax.swing.JCheckBoxzoom_at_mouse-
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
-
-
Constructor Summary
Constructors Constructor Description PluggableRendererDemo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)protected voidaddBottomControls(javax.swing.JPanel jp)edu.uci.ics.jung.graph.Graph<java.lang.Integer,java.lang.Number>getGraph()Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.static voidmain(java.lang.String[] s)voidstart()javax.swing.JPanelstartFunction()-
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 Detail
-
v_color
protected javax.swing.JCheckBox v_color
-
e_color
protected javax.swing.JCheckBox e_color
-
v_stroke
protected javax.swing.JCheckBox v_stroke
-
e_uarrow_pred
protected javax.swing.JCheckBox e_uarrow_pred
-
e_darrow_pred
protected javax.swing.JCheckBox e_darrow_pred
-
e_arrow_centered
protected javax.swing.JCheckBox e_arrow_centered
-
v_shape
protected javax.swing.JCheckBox v_shape
-
v_size
protected javax.swing.JCheckBox v_size
-
v_aspect
protected javax.swing.JCheckBox v_aspect
-
v_labels
protected javax.swing.JCheckBox v_labels
-
e_line
protected javax.swing.JRadioButton e_line
-
e_bent
protected javax.swing.JRadioButton e_bent
-
e_wedge
protected javax.swing.JRadioButton e_wedge
-
e_quad
protected javax.swing.JRadioButton e_quad
-
e_ortho
protected javax.swing.JRadioButton e_ortho
-
e_cubic
protected javax.swing.JRadioButton e_cubic
-
e_labels
protected javax.swing.JCheckBox e_labels
-
font
protected javax.swing.JCheckBox font
-
e_show_d
protected javax.swing.JCheckBox e_show_d
-
e_show_u
protected javax.swing.JCheckBox e_show_u
-
v_small
protected javax.swing.JCheckBox v_small
-
zoom_at_mouse
protected javax.swing.JCheckBox zoom_at_mouse
-
fill_edges
protected javax.swing.JCheckBox fill_edges
-
no_gradient
protected javax.swing.JRadioButton no_gradient
-
gradient_relative
protected javax.swing.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
-
seedFillColor
protected edu.uci.ics.jung.samples.PluggableRendererDemo.SeedFillColor<java.lang.Integer> seedFillColor
-
seedDrawColor
protected edu.uci.ics.jung.samples.PluggableRendererDemo.SeedDrawColor<java.lang.Integer> seedDrawColor
-
ewcs
protected edu.uci.ics.jung.samples.PluggableRendererDemo.EdgeWeightStrokeFunction<java.lang.Number> ewcs
-
vsh
protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexStrokeHighlight<java.lang.Integer,java.lang.Number> vsh
-
vs
protected org.apache.commons.collections4.Transformer<java.lang.Integer,java.lang.String> vs
-
vs_none
protected org.apache.commons.collections4.Transformer<java.lang.Integer,java.lang.String> vs_none
-
es
protected org.apache.commons.collections4.Transformer<java.lang.Number,java.lang.String> es
-
es_none
protected org.apache.commons.collections4.Transformer<java.lang.Number,java.lang.String> es_none
-
vff
protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexFontTransformer<java.lang.Integer> vff
-
eff
protected edu.uci.ics.jung.samples.PluggableRendererDemo.EdgeFontTransformer<java.lang.Number> eff
-
vssa
protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexShapeSizeAspect<java.lang.Integer,java.lang.Number> vssa
-
show_edge
protected edu.uci.ics.jung.samples.PluggableRendererDemo.DirectionDisplayPredicate<java.lang.Integer,java.lang.Number> show_edge
-
show_arrow
protected edu.uci.ics.jung.samples.PluggableRendererDemo.DirectionDisplayPredicate<java.lang.Integer,java.lang.Number> show_arrow
-
show_vertex
protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexDisplayPredicate<java.lang.Integer,java.lang.Number> show_vertex
-
self_loop
protected org.apache.commons.collections4.Predicate<edu.uci.ics.jung.graph.util.Context<edu.uci.ics.jung.graph.Graph<java.lang.Integer,java.lang.Number>,java.lang.Number>> self_loop
-
edgeDrawPaint
protected PluggableRendererDemo.GradientPickedEdgePaintFunction<java.lang.Integer,java.lang.Number> edgeDrawPaint
-
edgeFillPaint
protected PluggableRendererDemo.GradientPickedEdgePaintFunction<java.lang.Integer,java.lang.Number> edgeFillPaint
-
VOLTAGE_KEY
protected static final java.lang.Object VOLTAGE_KEY
-
TRANSPARENCY
protected static final java.lang.Object TRANSPARENCY
-
edge_weight
protected java.util.Map<java.lang.Number,java.lang.Number> edge_weight
-
voltages
protected org.apache.commons.collections4.Transformer<java.lang.Integer,java.lang.Double> voltages
-
transparency
protected java.util.Map<java.lang.Integer,java.lang.Number> transparency
-
vv
protected edu.uci.ics.jung.visualization.VisualizationViewer<java.lang.Integer,java.lang.Number> vv
-
gm
protected edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse<java.lang.Integer,java.lang.Number> gm
-
seedVertices
protected java.util.Set<java.lang.Integer> seedVertices
-
-
Method Detail
-
start
public void start()
- Overrides:
startin classjava.applet.Applet
-
main
public static void main(java.lang.String[] s)
-
startFunction
public javax.swing.JPanel startFunction()
-
getGraph
public edu.uci.ics.jung.graph.Graph<java.lang.Integer,java.lang.Number> getGraph()
Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.
-
addBottomControls
protected void addBottomControls(javax.swing.JPanel jp)
- Parameters:
jp- panel to which controls will be added
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
-