Class 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.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

      Nested Classes 
      Modifier and Type Class Description
      class  PluggableRendererDemo.GradientPickedEdgePaintFunction<V,​E>  
      protected class  PluggableRendererDemo.PopupGraphMousePlugin
      a GraphMousePlugin that offers popup menu support
      class  PluggableRendererDemo.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
      • Nested classes/interfaces inherited from class java.awt.Panel

        java.awt.Panel.AccessibleAWTPanel
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.swing.JCheckBox e_arrow_centered  
      protected javax.swing.JRadioButton e_bent  
      protected javax.swing.JCheckBox e_color  
      protected javax.swing.JRadioButton e_cubic  
      protected javax.swing.JCheckBox e_darrow_pred  
      protected javax.swing.JCheckBox e_labels  
      protected javax.swing.JRadioButton e_line  
      protected javax.swing.JRadioButton e_ortho  
      protected javax.swing.JRadioButton e_quad  
      protected javax.swing.JCheckBox e_show_d  
      protected javax.swing.JCheckBox e_show_u  
      protected javax.swing.JCheckBox e_uarrow_pred  
      protected javax.swing.JRadioButton e_wedge  
      protected java.util.Map<java.lang.Number,​java.lang.Number> edge_weight  
      protected PluggableRendererDemo.GradientPickedEdgePaintFunction<java.lang.Integer,​java.lang.Number> edgeDrawPaint  
      protected PluggableRendererDemo.GradientPickedEdgePaintFunction<java.lang.Integer,​java.lang.Number> edgeFillPaint  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.EdgeFontTransformer<java.lang.Number> eff  
      protected com.google.common.base.Function<? super java.lang.Number,​java.lang.String> es  
      protected com.google.common.base.Function<? super java.lang.Number,​java.lang.String> es_none  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.EdgeWeightStrokeFunction<java.lang.Number> ewcs  
      protected javax.swing.JCheckBox fill_edges  
      protected javax.swing.JCheckBox font  
      protected DefaultModalGraphMouse<java.lang.Integer,​java.lang.Number> gm  
      protected static int gradient_level  
      protected static int GRADIENT_NONE  
      protected javax.swing.JRadioButton gradient_relative  
      protected static int GRADIENT_RELATIVE  
      protected javax.swing.JRadioButton no_gradient  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.SeedDrawColor<java.lang.Integer> seedDrawColor  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.SeedFillColor<java.lang.Integer> seedFillColor  
      protected java.util.Set<java.lang.Integer> seedVertices  
      protected com.google.common.base.Predicate<Context<Graph<java.lang.Integer,​java.lang.Number>,​java.lang.Number>> self_loop  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.DirectionDisplayPredicate<java.lang.Integer,​java.lang.Number> show_arrow  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.DirectionDisplayPredicate<java.lang.Integer,​java.lang.Number> show_edge  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexDisplayPredicate<java.lang.Integer,​java.lang.Number> show_vertex  
      protected java.util.Map<java.lang.Integer,​java.lang.Number> transparency  
      protected static java.lang.Object TRANSPARENCY  
      protected javax.swing.JCheckBox v_aspect  
      protected javax.swing.JCheckBox v_color  
      protected javax.swing.JCheckBox v_labels  
      protected javax.swing.JCheckBox v_shape  
      protected javax.swing.JCheckBox v_size  
      protected javax.swing.JCheckBox v_small  
      protected javax.swing.JCheckBox v_stroke  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexFontTransformer<java.lang.Integer> vff  
      protected static java.lang.Object VOLTAGE_KEY  
      protected com.google.common.base.Function<java.lang.Integer,​java.lang.Double> voltages  
      protected com.google.common.base.Function<? super java.lang.Integer,​java.lang.String> vs  
      protected com.google.common.base.Function<? super java.lang.Integer,​java.lang.String> vs_none  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexStrokeHighlight<java.lang.Integer,​java.lang.Number> vsh  
      protected edu.uci.ics.jung.samples.PluggableRendererDemo.VertexShapeSizeAspect<java.lang.Integer,​java.lang.Number> vssa  
      protected VisualizationViewer<java.lang.Integer,​java.lang.Number> vv  
      protected javax.swing.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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)  
      protected void addBottomControls​(javax.swing.JPanel jp)  
      Graph<java.lang.Integer,​java.lang.Number> buildGraph()
      Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.
      static void main​(java.lang.String[] s)  
      void start()  
      javax.swing.JPanel startFunction()  
      • 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.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, 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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_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 com.google.common.base.Function<? super java.lang.Integer,​java.lang.String> vs
      • vs_none

        protected com.google.common.base.Function<? super java.lang.Integer,​java.lang.String> vs_none
      • es

        protected com.google.common.base.Function<? super java.lang.Number,​java.lang.String> es
      • es_none

        protected com.google.common.base.Function<? super 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 com.google.common.base.Predicate<Context<Graph<java.lang.Integer,​java.lang.Number>,​java.lang.Number>> self_loop
      • 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 com.google.common.base.Function<java.lang.Integer,​java.lang.Double> voltages
      • transparency

        protected java.util.Map<java.lang.Integer,​java.lang.Number> transparency
      • seedVertices

        protected java.util.Set<java.lang.Integer> seedVertices
    • Constructor Detail

      • PluggableRendererDemo

        public PluggableRendererDemo()
    • Method Detail

      • start

        public void start()
        Overrides:
        start in class java.applet.Applet
      • main

        public static void main​(java.lang.String[] s)
      • startFunction

        public javax.swing.JPanel startFunction()
      • buildGraph

        public Graph<java.lang.Integer,​java.lang.Number> buildGraph()
        Generates a mixed-mode random graph, runs VoltageRanker on it, and returns the resultant graph.
        Returns:
        the generated 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:
        actionPerformed in interface java.awt.event.ActionListener