Class InterfaceGraphDisplay

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
All Implemented Interfaces:
edu.uci.ics.jung.graph.event.GraphEventListener<AbstractGraphNode,​AbstractGraphEdge>, java.awt.event.ComponentListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Comparable<InterfaceGraphic<ToolGraph>>, java.util.EventListener, javax.accessibility.Accessible, AttributeListener, AttributeObject, DisplayListener, InterfaceGraphListener, InterfaceMouseObject, InterfaceObject, CategoryObject, MapListener, PopupMenuObject, NamedObject, ShapeListener, Toolable<ToolGraph>, ToolListener, TreeObject, CleanableObject, XMLObject, IconObject

public class InterfaceGraphDisplay
extends InterfaceGraphic<ToolGraph>
implements InterfaceGraphListener, edu.uci.ics.jung.graph.event.GraphEventListener<AbstractGraphNode,​AbstractGraphEdge>
Displays graphs and allows user interaction with them. Interfaces with the JUNG API (http://jung.sourceforge.net/)
Version:
1.0
Author:
Andrew Reid
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • InterfaceGraphDisplay

      public InterfaceGraphDisplay()
    • InterfaceGraphDisplay

      public InterfaceGraphDisplay​(InterfaceAbstractGraph graph, java.lang.String layout)
  • Method Details

    • getViewer

      public edu.uci.ics.jung.visualization.VisualizationViewer<AbstractGraphNode,​AbstractGraphEdge> getViewer()
      Gets the VisualizationViewer for this window.
      Returns:
      the viewer, or null if none is set.
    • getObjectIcon

      public javax.swing.Icon getObjectIcon()
      Description copied from interface: IconObject
      Returns the Icon associated with this object.
      Specified by:
      getObjectIcon in interface IconObject
      Overrides:
      getObjectIcon in class InterfaceGraphic<ToolGraph>
      Returns:
    • updateStatusBox

      public int updateStatusBox​(InterfaceGraphicTextBox box, java.awt.event.MouseEvent e)
      Description copied from class: InterfaceGraphic
      Notifies this window to update the given status text box with information as it sees fit. Boxes are mapped to indices within this class; By default, if the box's index is 1, the value will be set to the name of the current window; otherwise it will be set to an empty string. Overriding classes should call this super method first.
      Overrides:
      updateStatusBox in class InterfaceGraphic<ToolGraph>
      Parameters:
      box - Text box to update
      Returns:
      The index of the box; mostly useful for internal purposes
    • addPropertyChangeListener

      public void addPropertyChangeListener​(java.beans.PropertyChangeListener thisListener)
      Overrides:
      addPropertyChangeListener in class java.awt.Container
    • removePropertyChangeListener

      public void removePropertyChangeListener​(java.beans.PropertyChangeListener thisListener)
      Overrides:
      removePropertyChangeListener in class java.awt.Component
    • getNodeLabelFont

      public java.awt.Font getNodeLabelFont()
    • isDisplayable

      public boolean isDisplayable​(java.lang.Object obj)
      Overrides:
      isDisplayable in class InterfaceGraphic<ToolGraph>
    • handlePopupEvent

      public void handlePopupEvent​(java.awt.event.ActionEvent e)
      Description copied from interface: PopupMenuObject
      Handles an event on this object's popup menu.
      Specified by:
      handlePopupEvent in interface PopupMenuObject
      Overrides:
      handlePopupEvent in class InterfaceGraphic<ToolGraph>
    • writeSnapshotToFile

      public boolean writeSnapshotToFile​(java.io.File file)
      Description copied from class: InterfaceGraphic
      Writes a snapshot of this window to file as a Portable Network Graphics (png) image.
      Overrides:
      writeSnapshotToFile in class InterfaceGraphic<ToolGraph>
      Returns:
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu()
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Overrides:
      getPopupMenu in class InterfaceGraphic<ToolGraph>
      Returns:
    • getMouseCoords

      public org.jogamp.vecmath.Point2f getMouseCoords​(java.awt.Point p)
      Description copied from class: InterfaceGraphic
      Return the mapped coordinates, depending on the InterfaceGraphic window, for the given screen coordinates.
      Overrides:
      getMouseCoords in class InterfaceGraphic<ToolGraph>
      Returns:
      mapped coordinates; or null if not applicable.
    • getGraphLayoutInstance

      public edu.uci.ics.jung.algorithms.layout.Layout<AbstractGraphNode,​AbstractGraphEdge> getGraphLayoutInstance() throws GraphException
      Throws:
      GraphException
    • getLayoutClass

      public java.lang.Class<?> getLayoutClass()
    • getDisplayObjectsNode

      public javax.swing.tree.DefaultMutableTreeNode getDisplayObjectsNode()
      Description copied from class: InterfaceGraphic
      Returns a tree node containing a list of objects displayable by a class of InterfaceGraphic. Must therefore be overriden by that class.
      Overrides:
      getDisplayObjectsNode in class InterfaceGraphic<ToolGraph>
      Returns:
      DefaultMutableTreeNode with a tree list of displayable objects
    • attributeUpdated

      public void attributeUpdated​(AttributeEvent e)
      Description copied from interface: AttributeListener
      Called when an Attribute's value has been updated.
      Specified by:
      attributeUpdated in interface AttributeListener
      Overrides:
      attributeUpdated in class InterfacePanel
    • requiresRedraw

      protected boolean requiresRedraw​(java.lang.String attribute)
      Returns true is an update to the attribute attribute requires the display window to redraw itself.
      Parameters:
      name -
      Returns:
    • updateViewer

      protected void updateViewer()
    • setViewer

      public void setViewer() throws GraphException
      Throws:
      GraphException
    • getLabelPosition

      protected edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position getLabelPosition()
    • setGraph

      public void setGraph​(InterfaceAbstractGraph graph) throws GraphException
      Throws:
      GraphException
    • setGraphLayout

      public boolean setGraphLayout​(java.lang.String name)
    • setSource

      public boolean setSource​(java.lang.Object obj)
      Description copied from class: InterfacePanel
      Sets the source object for this panel.
      Overrides:
      setSource in class InterfacePanel
      Returns:
    • setTreeNode

      public void setTreeNode​(InterfaceTreeNode treeNode)
      Description copied from interface: TreeObject
      Sets the children for this node's InterfaceTreeNode.
      Specified by:
      setTreeNode in interface TreeObject
      Overrides:
      setTreeNode in class InterfacePanel
    • getToolLock

      public boolean getToolLock()
    • setToolLock

      public void setToolLock​(boolean lock)
    • addPropertyChangeObject

      public void addPropertyChangeObject​(GraphicPropertyListener thisObj)
    • getCurrentTool

      public ToolGraph getCurrentTool()
      Specified by:
      getCurrentTool in interface Toolable<ToolGraph>
      Overrides:
      getCurrentTool in class InterfaceGraphic<ToolGraph>
    • setCurrentTool

      public boolean setCurrentTool​(ToolGraph tool)
      Specified by:
      setCurrentTool in interface Toolable<ToolGraph>
      Overrides:
      setCurrentTool in class InterfaceGraphic<ToolGraph>
    • finishTool

      public void finishTool()
    • setDefaultTool

      public boolean setDefaultTool​(ToolGraph tool)
      Specified by:
      setDefaultTool in interface Toolable<ToolGraph>
      Overrides:
      setDefaultTool in class InterfaceGraphic<ToolGraph>
    • isToolable

      public boolean isToolable​(Tool tool)
      Description copied from interface: Toolable
      Tests whether this object is toolable by tool
      Specified by:
      isToolable in interface Toolable<ToolGraph>
      Overrides:
      isToolable in class InterfaceGraphic<ToolGraph>
      Returns:
    • getDisplayObjectsNode

      public javax.swing.tree.DefaultMutableTreeNode getDisplayObjectsNode​(InterfaceDisplayPanel p)
    • updateFromGraph

      public void updateFromGraph()
    • updateFromGraph

      public void updateFromGraph​(int code)
    • appendPaintable

      public void appendPaintable​(edu.uci.ics.jung.visualization.VisualizationServer.Paintable paintable)
    • insertPaintable

      public void insertPaintable​(edu.uci.ics.jung.visualization.VisualizationServer.Paintable paintable)
    • handleGraphEvent

      public void handleGraphEvent​(edu.uci.ics.jung.graph.event.GraphEvent<AbstractGraphNode,​AbstractGraphEdge> evt)
      Handle a graph event on the current ObservableGraph.
      Specified by:
      handleGraphEvent in interface edu.uci.ics.jung.graph.event.GraphEventListener<AbstractGraphNode,​AbstractGraphEdge>
    • graphUpdated

      public void graphUpdated​(InterfaceGraphEvent e)
      Specified by:
      graphUpdated in interface InterfaceGraphListener
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.awt.Component
    • getTitle

      public java.lang.String getTitle()
      Overrides:
      getTitle in class InterfacePanel
    • getEdgeWeightColourMap

      public ColourMap getEdgeWeightColourMap()
    • getDTD

      public java.lang.String getDTD()
      Description copied from interface: XMLObject
      Returns the Data Type Declaration (DTD) for this object's XML representation

      See http://en.wikipedia.org/wiki/Document_Type_Definition for a description.

      Specified by:
      getDTD in interface XMLObject
      Returns:
    • getLocalName

      public java.lang.String getLocalName()
      Description copied from interface: XMLObject
      Returns the local name associated with this XML object.
      Specified by:
      getLocalName in interface XMLObject
      Returns:
    • getShortXML

      public java.lang.String getShortXML​(int tab)
      Description copied from interface: XMLObject
      Returns a short XML representation of this object.
      Specified by:
      getShortXML in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML()
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Returns:
    • getXML

      public java.lang.String getXML​(int tab)
      Description copied from interface: XMLObject
      Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use the XMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater) functions to write larger objects to file.
      Specified by:
      getXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the opening XML wrapper
      Returns:
    • getXMLSchema

      public java.lang.String getXMLSchema()
      Description copied from interface: XMLObject
      Returns the XML schema for this object's XML representation

      See http://en.wikipedia.org/wiki/XML_schema.

      Specified by:
      getXMLSchema in interface XMLObject
      Returns:
    • handleXMLElementEnd

      public void handleXMLElementEnd​(java.lang.String localName)
      Description copied from interface: XMLObject
      Handles the end of an XML element.
      Specified by:
      handleXMLElementEnd in interface XMLObject
      Parameters:
      localName - Local name of the element
    • handleXMLElementStart

      public void handleXMLElementStart​(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
      Description copied from interface: XMLObject
      Handles the start of an XML element.
      Specified by:
      handleXMLElementStart in interface XMLObject
      Parameters:
      localName - Local name of the element
      attributes - Set of element attributes
      type - The XMLType of this element
    • handleXMLString

      public void handleXMLString​(java.lang.String s)
      Description copied from interface: XMLObject
      Handles a string within an XML element.
      Specified by:
      handleXMLString in interface XMLObject
      Parameters:
      s - String to handle
    • writeXML

      public void writeXML​(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOException
      Description copied from interface: XMLObject
      Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format of XMLFormat.Ascii will be used.
      Specified by:
      writeXML in interface XMLObject
      Parameters:
      tab - The number of tabs to place before the XML text
      writer - The writer
      options - XMLOutputOptions defining the write parameters
      progress_bar - Optional progress updater (may be null)
      Throws:
      java.io.IOException