Documentation of 'medusa.display.BasicGraphPanel' Java class
BasicGraphPanel
medusa.display

Class BasicGraphPanel

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible
    Direct Known Subclasses:
    DisplayPanel, EditableGraphPanel, ExamplePanel, MedusaAppletPanel, SamplePanel


    public class BasicGraphPanel
    extends BasicGraphRenderer
    implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.lang.Runnable
    A panel that handles graphs, loads and saves them (I may move this to a higher level soon) and displays them Most often, any extending classes will override the display methods, especially paintNode and paintEdge.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.BaselineResizeBehavior
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void autoFixOrientation()
      Automatically fixes orientations
      void calculateEdgeLength() 
      void changeFont(int size)
      Set font size
      void changeNodeColor(java.awt.Color color) 
      void changeNodeColor(int red, int green, int blue) 
      java.lang.String colorToString(java.awt.Color color)
      Gets a color as a string
      void energy() 
      boolean findLabel(java.lang.String expression)
      Finds the node matching the regular expression
      java.awt.Color getColor(java.lang.Integer i)
      Returns the color for interaction i
      java.awt.Rectangle getCurrentRect() 
      double getEdgeLen()
      Returns the current edge length
      Node getPick() 
      java.lang.String getToolTipText(java.awt.event.MouseEvent e) 
      Graph getVisibleGraph() 
      void handleLeftMouseDragged(java.awt.event.MouseEvent e) 
      void handlePressLeftButton_backup(java.awt.event.MouseEvent e) 
      void handlePressLeftButton(java.awt.event.MouseEvent e) 
      void initEdges()
      Inits edges, fixes orientation
      void invertFix() 
      boolean isBox() 
      boolean isRunning() 
      void mirror(boolean xFlip, boolean yFlip)
      Mirrors graph vertically or horizontally (or both)
      void mouseClicked(java.awt.event.MouseEvent e) 
      void mouseDragged(java.awt.event.MouseEvent e) 
      void mouseEntered(java.awt.event.MouseEvent e) 
      void mouseExited(java.awt.event.MouseEvent e) 
      void mouseMoved(java.awt.event.MouseEvent e) 
      void mousePressed(java.awt.event.MouseEvent e) 
      void mouseReleased(java.awt.event.MouseEvent e) 
      void paintComponent(java.awt.Graphics g)
      Paints the component
      void paintPick(java.awt.Graphics2D g)
      Paints the selected node
      void randomGraph(int nNodes, int nEdges)
      Creates a random graph
      void rotate(double t)
      Rotates graph
      void run() 
      void saveImage(java.lang.String path, int param)
      Saves graph as an image
      void setAbsoluteScale(double scale) 
      void setAlpha(boolean trueOrFalse)
      Setting this to true results in a composite effect on edges based on the confidence level of the edge.
      void setAnnotation(boolean trueOrFalse)
      Show annotation instead of node names
      void setArrows(boolean trueOrFalse)
      Set true if you want to show edges as directed.
      void setBackgroundColor(java.awt.Color c)
      Background color
      void setBasicEdgeColor(java.awt.Color color)
      Sets the basic edge color.
      void setColor(java.lang.Integer i, java.awt.Color color)
      Sets the color for interaction i in MedusaSettings.
      void setConfidence(boolean trueOrFalse)
      Show confidence of edges using either alpha or patterns
      void setCool(boolean trueOrFalse)
      Allows cooling of relaxation.
      void setEdgeLen(double newEdgeLen)
      Manually sets the edge length.
      void setFix(boolean trueOrFalse)
      Fix or unfix all nodes
      void setFontColor(java.awt.Color color)
      Sets the font color
      void setGraph(Graph g)
      todo: move all load functions to the frame!!! enough to set the graph
      void setHideWhenMove(boolean trueOrFalse)
      If true, only the moving nodes will be displayed.
      void setLabel(boolean trueOrFalse)
      Show labels or hide them
      void setNodeFixed(java.lang.String lbl, boolean fixed) 
      void setNodeSize(int nodeSize)
      Set node size
      void setPretty(boolean trueOrFalse)
      If pretty is selected, multiple edges will be drawn in colors.
      void setScale(double scale)
      Sets the scale of the graph.
      void setTimeFrameXY(java.awt.Dimension d) 
      void setTimeFrameXY(int x, int y)
      Sets the x and y parameters for the drawing area
      void start() 
      void stop() 
      void updateNodes()
      Updates the nodes for quicker repainting
      void updateStringSettings(MedusaSettings ss)
      Sets new MedusaSettings
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • running

        public boolean running
    • Constructor Detail

      • BasicGraphPanel

        public BasicGraphPanel(MedusaSettings stringSettings)
        Constructs a new BasicGraphPanel with settings
        Parameters:
        stringSettings - settings
      • BasicGraphPanel

        public BasicGraphPanel()
    • Method Detail

      • setGraph

        public void setGraph(Graph g)
        todo: move all load functions to the frame!!! enough to set the graph
      • updateNodes

        public void updateNodes()
        Updates the nodes for quicker repainting
      • getPick

        public Node getPick()
      • isRunning

        public boolean isRunning()
      • setHideWhenMove

        public void setHideWhenMove(boolean trueOrFalse)
        If true, only the moving nodes will be displayed. This can be good if you have a large graph, since repainting will occur.
        Parameters:
        trueOrFalse - True if hide, False (default) if show all nodes while moving
      • setAlpha

        public void setAlpha(boolean trueOrFalse)
        Setting this to true results in a composite effect on edges based on the confidence level of the edge.
        Parameters:
        trueOrFalse - True if edges are displayed with alpha
      • changeFont

        public void changeFont(int size)
        Set font size
        Parameters:
        size - Font size
      • setNodeSize

        public void setNodeSize(int nodeSize)
        Set node size
        Parameters:
        nodeSize - Node size in pixels
      • setBackgroundColor

        public void setBackgroundColor(java.awt.Color c)
        Background color
        Parameters:
        c - Color c
      • colorToString

        public java.lang.String colorToString(java.awt.Color color)
        Gets a color as a string
        Parameters:
        color - Color color
        Returns:
        String representation of color
      • setPretty

        public void setPretty(boolean trueOrFalse)
        If pretty is selected, multiple edges will be drawn in colors. If not selected, edges are drawn as unique edges and in grey.
        Parameters:
        trueOrFalse - Boolean pretty
      • setArrows

        public void setArrows(boolean trueOrFalse)
        Set true if you want to show edges as directed.
        Parameters:
        trueOrFalse - Boolean arrows or not
      • setLabel

        public void setLabel(boolean trueOrFalse)
        Show labels or hide them
        Parameters:
        trueOrFalse - Boolean true if show labels
      • setConfidence

        public void setConfidence(boolean trueOrFalse)
        Show confidence of edges using either alpha or patterns
        Parameters:
        trueOrFalse - true if confidence is to be shown
      • setAnnotation

        public void setAnnotation(boolean trueOrFalse)
        Show annotation instead of node names
        Parameters:
        trueOrFalse - true: shows annotation. false: shows node label
      • setBasicEdgeColor

        public void setBasicEdgeColor(java.awt.Color color)
        Sets the basic edge color.
        Parameters:
        color - The color that will be used when interactions are not shown
      • setFontColor

        public void setFontColor(java.awt.Color color)
        Sets the font color
        Parameters:
        color - Font color
      • getColor

        public java.awt.Color getColor(java.lang.Integer i)
        Returns the color for interaction i
        Parameters:
        i - Interaction type
        Returns:
        The color as defined
      • setColor

        public void setColor(java.lang.Integer i,
                             java.awt.Color color)
        Sets the color for interaction i in MedusaSettings. This should really be handled at a higher level...
        Parameters:
        i - Interaction type
        color - Edge color for interaction i
      • getEdgeLen

        public double getEdgeLen()
        Returns the current edge length
        Returns:
        edge length
      • calculateEdgeLength

        public void calculateEdgeLength()
      • setEdgeLen

        public void setEdgeLen(double newEdgeLen)
        Manually sets the edge length. This is the steady-state length between two nodes. Don't expect this as an exact value, since most graphs are more complex than two nodes connected by an edge.
        Parameters:
        newEdgeLen - New edge length
      • setScale

        public void setScale(double scale)
        Sets the scale of the graph. large scales will zoom in on the graph, while scales < 1 zoom out.
        Parameters:
        scale - scale factor
      • setAbsoluteScale

        public void setAbsoluteScale(double scale)
      • setTimeFrameXY

        public void setTimeFrameXY(int x,
                                   int y)
        Sets the x and y parameters for the drawing area
        Parameters:
        x - width
        y - height
      • setTimeFrameXY

        public void setTimeFrameXY(java.awt.Dimension d)
        Parameters:
        d -
      • getToolTipText

        public java.lang.String getToolTipText(java.awt.event.MouseEvent e)
        Overrides:
        getToolTipText in class javax.swing.JComponent
      • initEdges

        public void initEdges()
        Inits edges, fixes orientation
      • updateStringSettings

        public void updateStringSettings(MedusaSettings ss)
        Sets new MedusaSettings
        Parameters:
        ss - new settings
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • start

        public void start()
      • stop

        public void stop()
      • energy

        public void energy()
      • setFix

        public void setFix(boolean trueOrFalse)
        Fix or unfix all nodes
        Parameters:
        trueOrFalse - true fixes all nodes. false unfixes all
      • invertFix

        public void invertFix()
      • setCool

        public void setCool(boolean trueOrFalse)
        Allows cooling of relaxation. If cooling is on, attraction and repellation energies will slow if the mouse is not dragging nodes.
        Parameters:
        trueOrFalse - true: cooling
      • rotate

        public void rotate(double t)
        Rotates graph
        Parameters:
        t - rotation factor
      • mirror

        public void mirror(boolean xFlip,
                           boolean yFlip)
        Mirrors graph vertically or horizontally (or both)
        Parameters:
        xFlip - true if flip
        yFlip - true if flip
      • changeNodeColor

        public void changeNodeColor(int red,
                                    int green,
                                    int blue)
      • changeNodeColor

        public void changeNodeColor(java.awt.Color color)
      • saveImage

        public void saveImage(java.lang.String path,
                              int param)
        Saves graph as an image
        Parameters:
        path - file to save as
        param - type of picture. Currently, 0=jpg 1=png
      • setNodeFixed

        public void setNodeFixed(java.lang.String lbl,
                                 boolean fixed)
      • mouseClicked

        public void mouseClicked(java.awt.event.MouseEvent e)
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mousePressed

        public void mousePressed(java.awt.event.MouseEvent e)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • handlePressLeftButton

        public void handlePressLeftButton(java.awt.event.MouseEvent e)
      • handlePressLeftButton_backup

        public void handlePressLeftButton_backup(java.awt.event.MouseEvent e)
      • findLabel

        public boolean findLabel(java.lang.String expression)
        Finds the node matching the regular expression
        Parameters:
        expression - pattern to match
        Returns:
        true if nodes were found, false if no nodes matched the pattern
      • mouseReleased

        public void mouseReleased(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered(java.awt.event.MouseEvent e)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent e)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • handleLeftMouseDragged

        public void handleLeftMouseDragged(java.awt.event.MouseEvent e)
      • mouseMoved

        public void mouseMoved(java.awt.event.MouseEvent e)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • autoFixOrientation

        public void autoFixOrientation()
        Automatically fixes orientations
      • randomGraph

        public void randomGraph(int nNodes,
                                int nEdges)
        Creates a random graph
        Parameters:
        nNodes - number of nodes
        nEdges - number of edges
      • paintComponent

        public void paintComponent(java.awt.Graphics g)
        Paints the component
        Overrides:
        paintComponent in class BasicGraphRenderer
        Parameters:
        g - current graphics
      • paintPick

        public void paintPick(java.awt.Graphics2D g)
        Paints the selected node
        Parameters:
        g - Graphics2D
      • getCurrentRect

        public java.awt.Rectangle getCurrentRect()
      • isBox

        public boolean isBox()
      • getVisibleGraph

        public Graph getVisibleGraph()

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.