Class JungNetworkLayout<T>

  • All Implemented Interfaces:
    edu.uci.ics.jung.visualization.util.ChangeEventSupport, Layout<T,​Network<T>>
    Direct Known Subclasses:

    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
    M. Altaweel
    • Field Detail

      • 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
      • visibleVertices

        protected Set<Object> visibleVertices
      • visibleEdges

        protected Set<Object> visibleEdges
      • xSize

        protected int xSize
      • ySize

        protected int ySize
    • Constructor Detail

      • JungNetworkLayout

        public JungNetworkLayout()
    • Method Detail

      • 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 )) { ... }
        whether this node may be legally moved or not
      • initialize

        public void initialize​(Dimension size)
      • initialize

        public void initialize​(Dimension size,
                               JungVertexLocationFunction v_locations)
        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.
        coord -
        o -
        d -
      • getStatus

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

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

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

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

        public double[] getCoordinates​(Object o)
        Returns the coordinates (float[2]) that stores the vertex' x and y location.
        o - = the object to get coordinates from
        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>>
        obj - you want to find location of
        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.
        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
        o - object to offset
        xOffset -
        yOffset -
      • restart

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

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

        public Object getVertex​(double x,
                                double y,
                                double maxDistance)
        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)
        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)
        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.
        x -
        y -
        maxDistance -
        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
        getGraph in class AbstractNetworkLayout<T>
        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().
        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().
        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
        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
        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
        thisEdges -
        thatEdges -
        the equal vertices between the two compared
      • addEdgesOrVertices

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

        public void resetVisibleEdgesAndVertices()
      • getXSize

        public int getXSize()
      • setXSize

        public void setXSize​(int size)
      • getYSize

        public int getYSize()
      • setYSize

        public void setYSize​(int size)