zinger.bsheet
Class Dependencies

java.lang.Object
  extended by zinger.bsheet.Dependencies

public class Dependencies
extends java.lang.Object

One- or two-way dependecies collection. This class implements tracking of forward or forward and backward dependencies using of points on a two-dimensional plane using conventional x and y coordinates and Point objects. A Dependencies object can be set to keep track of backward dependencies or not at creation time.

Author:
Alexey Zinger (inline_four@yahoo.com)
See Also:
Dependencies(int, int, boolean)

Constructor Summary
Dependencies(int width, int height, boolean doBackwardDependencies)
          Constructs an instance with given dimensions.
 
Method Summary
 void addDependency(int causeX, int causeY, int effectX, int effectY)
          Adds a dependency.
 java.util.Set getDependencies(int x, int y, boolean backward)
          Returns a set of unmodifiable dependencies for a given point.
protected  java.util.Set getDependencies(int x, int y, boolean backward, boolean mutable)
          Returns a set of dependencies for a given point.
 void removeDependency(int causeX, int causeY, int effectX, int effectY)
          Removes a dependency.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dependencies

public Dependencies(int width,
                    int height,
                    boolean doBackwardDependencies)
Constructs an instance with given dimensions.

Parameters:
width - width of two-dimensional plane
height - height of two-dimensional plane
doBackwardDependencies - if true, backwardGrid will be created and dependencies will be kept in a two-way form (forward and backward dependencies). Otherwise, only forward dependencies will be tracked.
See Also:
backwardGrid
Method Detail

addDependency

public void addDependency(int causeX,
                          int causeY,
                          int effectX,
                          int effectY)
Adds a dependency. If backward dependencies are being tracked, a backward dependency is also added.


removeDependency

public void removeDependency(int causeX,
                             int causeY,
                             int effectX,
                             int effectY)
Removes a dependency. If backward dependencies are being tracked, a backward dependency is also removed.


getDependencies

protected java.util.Set getDependencies(int x,
                                        int y,
                                        boolean backward,
                                        boolean mutable)
Returns a set of dependencies for a given point.

Parameters:
backward - if true, the set of backward dependencies is returned if available, otherwise a set of forward dependencies is returned.
mutable - if true, an internal non-null instance of Set is guaranteed to be returned. Even if it's false, an internal Set may be returned and therefore should not be modified if modifications to it are not meant to be persisted in this instance. In this case, use getDependencies(int, int, boolean)
See Also:
getDependencies(int, int, boolean)

getDependencies

public java.util.Set getDependencies(int x,
                                     int y,
                                     boolean backward)
Returns a set of unmodifiable dependencies for a given point. This method calls getDependencies(int, int, boolean, boolean). The resulting Set, however, is wrapped in an unmodifiable proxy.

See Also:
getDependencies(int, int, boolean, boolean)