Class JungNetworkLayout<T>

java.lang.Object
repast.simphony.visualization.AbstractNetworkLayout<T>
repast.simphony.visualization.visualization3D.layout.JungNetworkLayout<T>
All Implemented Interfaces:
edu.uci.ics.jung.visualization.util.ChangeEventSupport, Layout<T,Network<T>>
Direct Known Subclasses:
FR3DLayout

public abstract class JungNetworkLayout<T> extends AbstractNetworkLayout<T> implements edu.uci.ics.jung.visualization.util.ChangeEventSupport
Abstract class to construct various types of JUNG graph layouts
Author:
M. Altaweel
  • Field Details

    • changeListeners

      protected List<ChangeListener> changeListeners
    • changeSupport

      protected edu.uci.ics.jung.visualization.util.ChangeEventSupport changeSupport
    • dontmove

      protected Set dontmove
      a set of vertices that should not move in relation to the other vertices
    • visibleGraph

      protected Network visibleGraph
    • vertex_locations

      protected JungVertexLocationFunction vertex_locations
    • visibleVertices

      protected Set<Object> visibleVertices
    • visibleEdges

      protected Set<Object> visibleEdges
    • objectData

      protected Map<Object,Object> objectData
    • xSize

      protected int xSize
    • ySize

      protected int ySize
  • Constructor Details

    • JungNetworkLayout

      public JungNetworkLayout()
  • Method Details

    • dontMove

      public boolean dontMove(Object o)
      The set of nodes that have been locked. When running layout, it is important to check
           if (dontmove( n )) { ... }
       
      Returns:
      whether this node may be legally moved or not
    • initialize

      public void initialize(Dimension size)
    • initialize

      public void initialize(Dimension size, JungVertexLocationFunction v_locations)
      Parameters:
      size - is a given dimension
      v_locations - is the calculated location for the node
    • initialize_local

      protected void initialize_local()
      Initializes all local information, and is called immediately within the initialize() process. The user is responsible for overriding this method to do any construction that may be necessary: for example, to initialize local per-edge or graph-wide data.
    • postInitialize

      protected void postInitialize()
      may be overridden to do something after initializeLocations call
    • initialize_local_vertex

      protected abstract void initialize_local_vertex(Object o)
      Initializes the local information on a single vertex. The user is responsible for overriding this method to do any vertex-level construction that may be necessary: for example, to attach vertex-level information to each vertex.
    • getBaseKey

      public Object getBaseKey()
      Returns a visualization-specific key, not currently used
    • initializeLocations

      protected void initializeLocations()
    • returnMatchingCoordinate

      public double[] returnMatchingCoordinate(Object o)
      Returns a visualization-specific key that can be used to access UserData related to the AbstractLayout. Same as JUNG AbstractLayout.getBaseKey()
    • initializeLocation

      protected void initializeLocation(Object o, double[] coord, Dimension d)
      Sets random locations for a vertex within the dimensions of the space. If you want to initialize in some different way, override this method.
      Parameters:
      coord -
      o -
      d -
    • getStatus

      public String getStatus()
      By default, an AbstractLayout returns null for its status.
    • update

      public void update()
      set update by default to advance positions
      Specified by:
      update in interface Layout<T,Network<T>>
      Overrides:
      update in class AbstractNetworkLayout<T>
    • advancePositions

      public abstract void advancePositions()
      Implementors must override this method in order to create a Layout.
    • getVisibleGraph

      protected Network getVisibleGraph()
      Accessor for the graph that represets all visible vertices
      Returns:
      the current visible graph (i.e. network).
      See Also:
    • getCurrentSize

      public Dimension getCurrentSize()
      Returns the current size of the visualization space, same as JUNG AbstractLayout.getCurrentSize()
      Returns:
      the current size of the screen
    • getAVertex

      protected Object getAVertex(RepastEdge e)
      Utility method, gets a single vertex from this edge
      Parameters:
      an - edge object that you want a vertex from
      Returns:
      a vertex object or null
    • getCoordinates

      public double[] getCoordinates(Object o)
      Returns the coordinates (float[2]) that stores the vertex' x and y location.
      Parameters:
      o - = the object to get coordinates from
      Returns:
      a coordinate float with x and y locations.
    • getX

      public double getX(Object o)
      Returns the x coordinate of the vertex from the Coordinates object.
    • getY

      public double getY(Object o)
      Returns the y coordinate of the vertex from the Coordinates object.
    • getLocation

      public float[] getLocation(Object obj)
      Finds the location of the object
      Specified by:
      getLocation in interface Layout<T,Network<T>>
      Parameters:
      obj - you want to find location of
      Returns:
      the float[] containing the location
    • getLocation

      public float[] getLocation(Object obj, boolean threeD)
    • resize

      public void resize(Dimension size)
      When a visualization is resized, it presumably wants to fix the locations of the vertices and possibly to reinitialize its data.
      Parameters:
      size - represents the dimension that will set the current size
    • offsetVertex

      protected void offsetVertex(Object o, double xOffset, double yOffset)
      Offset the object based on the inputs
      Parameters:
      o - object to offset
      xOffset -
      yOffset -
    • restart

      public void restart()
      See Also:
      • in JUNG
    • getVertex

      public Object getVertex(double x, double y)
      Deprecated.
      Calls get vertex to get object of nearest location to x and y
      Parameters:
      x - and y represent location you want object to be near
    • getVertex

      public Object getVertex(double x, double y, double maxDistance)
      Deprecated.
      Gets the vertex nearest to the location of the (x,y) location selected, within a distance of maxDistance. Iterates through all visible vertices and checks their distance from the click. Override this method to provde a more efficient implementation.
    • getEdge

      public RepastEdge getEdge(double x, double y)
      Deprecated.
      Gets the edge nearest to the location of the (x,y) location selected. Calls the longer form of the call.
    • getEdge

      public RepastEdge getEdge(double x, double y, double maxDistance)
      Deprecated.
      Gets the edge nearest to the location of the (x,y) location selected, within a distance of maxDistance, Iterates through all visible edges and checks their distance from the click. Override this method to provide a more efficient implementation.
      Parameters:
      x -
      y -
      maxDistance -
      Returns:
      Edge closest to the click.
    • getGraph

      public Network getGraph()
      Accessor for the graph that represets all vertices. must match the nodes in the graph with the vertices created
      Overrides:
      getGraph in class AbstractNetworkLayout<T>
      Returns:
      the graph that contains all vertices.
    • getVisibleEdges

      public Set getVisibleEdges()
      Gets edges that are equivalent to the ones passed in from the argument to applyFilter().
      Returns:
      set of edges from the original
    • getVisibleVertices

      public Set getVisibleVertices()
      Gets vertices that are equivalent to the ones passed in from the argument to applyFilter().
      Returns:
      set of vertices from the original
    • forceMove

      public void forceMove(Object picked, double x, double y)
      Forcibly moves a vertex to the (x,y) location by setting its x and y locations to the inputted location. Does not add the vertex to the "dontmove" list, and (in the default implementation) does not make any adjustments to the rest of the graph.
    • forceMove

      public void forceMove(Object picked, double x, double y, double z)
    • lockVertex

      public void lockVertex(Object o)
      Adds the vertex to the DontMove list
    • unlockVertex

      public void unlockVertex(Object o)
      Removes the vertex from the DontMove list
    • applyFilter

      public void applyFilter(Network n)
      Applies the filter to the current network and network g. Shared vertices and edges are set to the visible edges and vertices
    • addChangeListener

      public void addChangeListener(ChangeListener arg0)
      Adds a change listener to listen for change events produced by network layout.
      Specified by:
      addChangeListener in interface edu.uci.ics.jung.visualization.util.ChangeEventSupport
      Parameters:
      arg0 - the listener to add
    • removeChangeListener

      public void removeChangeListener(ChangeListener arg0)
      Removes a change listener
      Specified by:
      removeChangeListener in interface edu.uci.ics.jung.visualization.util.ChangeEventSupport
      Parameters:
      arg0 - the listener to remove
    • getChangeListeners

      public ChangeListener[] getChangeListeners()
      Returns an array of change listener objects
      Specified by:
      getChangeListeners in interface edu.uci.ics.jung.visualization.util.ChangeEventSupport
    • fireStateChanged

      public void fireStateChanged()
      Notifies all listeners that have registered interest for notification on this event type. The primary listeners will be views that need to be repainted because of changes in this model instance
      Specified by:
      fireStateChanged in interface edu.uci.ics.jung.visualization.util.ChangeEventSupport
      See Also:
      • listener list
    • returnEqualSet

      public Set returnEqualSet(Set<Object> thisVertices, Set<Object> thatVertices)
      two vertices or edges to compare to see if they are equal
      Parameters:
      thisEdges -
      thatEdges -
      Returns:
      the equal vertices between the two compared
    • addEdgesOrVertices

      protected Set<Object> addEdgesOrVertices(Iterable it)
      This gets the edges or vertices from the network
      Parameters:
      it - represents the iterable object
      Returns:
      the return set of the object used for edges or vertices
    • setProjection

      public void setProjection(Network projection)
      Description copied from interface: Layout
      Sets the projection associated with this Layout.
      Specified by:
      setProjection in interface Layout<T,Network<T>>
      Overrides:
      setProjection in class AbstractNetworkLayout<T>
      Parameters:
      projection - the associated projection.
    • resetVisibleEdgesAndVertices

      public void resetVisibleEdgesAndVertices()
    • getXSize

      public int getXSize()
    • setXSize

      public void setXSize(int size)
    • getYSize

      public int getYSize()
    • setYSize

      public void setYSize(int size)
    • getName

      public String getName()
      Description copied from interface: Layout
      Gets the name of the layout
      Specified by:
      getName in interface Layout<T,Network<T>>
      Overrides:
      getName in class AbstractNetworkLayout<T>
      Returns:
      name of the layout type