edu.udo.cs.ie.cowbots.util.cluster
Class CowCluster

Package class diagram package CowCluster
java.lang.Object
  extended by edu.udo.cs.ie.cowbots.util.cluster.CowCluster

public class CowCluster
extends java.lang.Object

auxiliary class to build cow clusters. a cow cluster is a set of 1 to n cows that stay within a rectangular area of cells of a specific width.


Nested Class Summary
(package private)  class CowCluster.HullPoint
          auxiliary class that holds a hull point and it's adjacent hull points
 
Field Summary
 boolean acceptedCluster
           
 java.util.List<CowPosition> cows
           
protected  java.util.List<java.awt.Point> drivePoints
           
 int maxX
           
 int maxY
           
 int minX
           
 int minY
           
 java.lang.String[] path
           
 int pathStartX
           
 int pathStartY
           
 boolean targetCluster
           
 
Constructor Summary
CowCluster(CowPosition cp)
          default constructor for a cluster. a cluster always starts with at least one cow.
 
Method Summary
 java.util.List<CowCluster.HullPoint> calculatePinchPoints(int impact)
          this method calculates positions for agents to drive the cluster in the desired direction. the desired direction is taken from the path associated with the cluster.
 int centerX()
          this method returns the x-component of the center of a corral cluster based on the cluster's bounding rectangle center.
 int centerY()
          this method returns the y-component of the center of a corral cluster based on the cluster's bounding rectangle center.
 void draw(java.awt.Graphics2D g2, int cellX, int cellY)
          this method visualizes the cluster on a graphics2d device. used for debug output in the lib_cowbots framework.
 java.util.List<java.awt.Point> getAgPositions()
          returns a list of probably optimal positions for driving the cow cluster in the desired direction.
 int lengthX()
          returns the maximum elongation along the x-axis of the cluster
 int lengthY()
          returns the maximum elongation along the y-axis of the cluster
 boolean tryAdd(CowPosition cp, int maxSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cows

public java.util.List<CowPosition> cows

minX

public int minX

minY

public int minY

maxX

public int maxX

maxY

public int maxY

acceptedCluster

public boolean acceptedCluster

targetCluster

public boolean targetCluster

path

public java.lang.String[] path

pathStartX

public int pathStartX

pathStartY

public int pathStartY

drivePoints

protected java.util.List<java.awt.Point> drivePoints
Constructor Detail

CowCluster

public CowCluster(CowPosition cp)
default constructor for a cluster. a cluster always starts with at least one cow.

Parameters:
cp -
Method Detail

tryAdd

public boolean tryAdd(CowPosition cp,
                      int maxSize)

draw

public void draw(java.awt.Graphics2D g2,
                 int cellX,
                 int cellY)
this method visualizes the cluster on a graphics2d device. used for debug output in the lib_cowbots framework.

Parameters:
g2 -

centerX

public int centerX()
this method returns the x-component of the center of a corral cluster based on the cluster's bounding rectangle center.

Returns:
x-coordinate of cluster center

centerY

public int centerY()
this method returns the y-component of the center of a corral cluster based on the cluster's bounding rectangle center.

Returns:
y-coordinate of cluster center

lengthX

public int lengthX()
returns the maximum elongation along the x-axis of the cluster

Returns:
cluster's horizontal elongation

lengthY

public int lengthY()
returns the maximum elongation along the y-axis of the cluster

Returns:
cluster's vertical elongation

calculatePinchPoints

public java.util.List<CowCluster.HullPoint> calculatePinchPoints(int impact)
this method calculates positions for agents to drive the cluster in the desired direction. the desired direction is taken from the path associated with the cluster.

Parameters:
impact - approximated effective influence radius of an agent against a cow

getAgPositions

public java.util.List<java.awt.Point> getAgPositions()
returns a list of probably optimal positions for driving the cow cluster in the desired direction.

Returns:
list of agent positions