|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.kzoo.grid.gui.GridPkgFactory
Grid GUI Support Package:
The GridPkgFactory
class provides a set of static methods
for constructing grids and the objects they contain, and for keeping
track of what types of grids or grid objects are available to a
specific application.
The GridPkgFactory
class is based on the
College Board's MBSFactory
class,
as allowed by the GNU General Public License.
Constructor Summary | |
GridPkgFactory()
|
Method Summary | |
static void |
addBoundedGridClassNames(java.lang.String[] classNames)
Adds bounded grid classes to the set maintained by the factory. |
protected static void |
addClassesToFactory(java.lang.String[] classNames,
java.lang.String whichCategory)
Helper to add new classes to the factory. |
static void |
addGridObjClassNames(java.lang.String[] classNames)
Adds grid object classes to the set maintained by the factory. |
static void |
addUnboundedGridClassNames(java.lang.String[] classNames)
Adds unbounded grid classes to the set maintained by the factory. |
static java.util.Set |
boundedGridClasses()
Returns the set of bounded grid classes known to the factory. |
static Grid |
constructGrid(java.lang.Class cls)
Creates an instance of a Grid using the default constructor of the given class. |
static Grid |
constructGrid(java.lang.Class cls,
int numRows,
int numCols)
Creates an instance of a Grid using the 2-argument constructor of the given class. |
static java.lang.Object |
constructGridObject(java.lang.Class cls,
Grid grid,
Location loc)
Creates an instance of the given grid object class using a two-argument constructor that takes a grid and a location. |
static java.lang.Object |
constructGridObject(java.lang.Class cls,
Grid grid,
Location loc,
Direction dir)
Creates an instance of the given grid object class using a three-argument constructor that takes a grid, a location, and a direction. |
static java.lang.Object |
constructGridObject(java.lang.Class cls,
Grid grid,
Location loc,
Direction dir,
java.awt.Color color)
Creates an instance of the given grid object class using a four-argument constructor that takes a grid, a location, a direction, and a color. |
static java.lang.Object |
constructObject(java.lang.Class cls,
java.lang.Class[] parameterTypes,
java.lang.Object[] parameters)
Creates an object of the given class. |
static java.util.Set |
gridObjectClasses()
Returns the set of grid object classes known to the factory. |
protected static boolean |
hasCorrectCtor(java.lang.Class cls,
java.lang.Class requiredCls,
java.lang.Class[] ctorParameters)
Verifies that a class has the required constructor and is properly assignable. |
static boolean |
hasFourArgCtor(java.lang.Class cls)
Reports wehther a given grid object class has an accessible four-arg constructor that takes Grid, Location, Direction, and Color. |
static boolean |
isValidGridClass(java.lang.Class cls,
java.lang.Class[] ctorParameters)
Verifies that a class has the required constructor and is properly assignable to Grid. |
static boolean |
isValidGridObjectClass(java.lang.Class cls,
java.lang.Class[] ctorParameters)
Verifies that a class has the required constructor and is properly assignable to GridObject. |
static java.util.Set |
unboundedGridClasses()
Returns the set of unbounded grid classes known to the factory. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GridPkgFactory()
Method Detail |
public static java.lang.Object constructObject(java.lang.Class cls, java.lang.Class[] parameterTypes, java.lang.Object[] parameters)
cls
- class of new objectparameterTypes
- parameter types expected by constructor
for classparameters
- actual parameters to pass to constructor
java.lang.RuntimeException
- if an object of the specified class cannot
be constructed with the specified
parameterspublic static java.lang.Object constructGridObject(java.lang.Class cls, Grid grid, Location loc)
cls
- class of new grid objectgrid
- grid in which this object will actloc
- location the object will occupy
MBSException
- if an object of the specified class cannot be
constructed with the specified parameterspublic static java.lang.Object constructGridObject(java.lang.Class cls, Grid grid, Location loc, Direction dir)
cls
- class of new grid objectgrid
- grid in which this object will actloc
- location the object will occupydir
- direction the object will face
MBSException
- if an object of the specified class cannot be
constructed with the specified parameterspublic static java.lang.Object constructGridObject(java.lang.Class cls, Grid grid, Location loc, Direction dir, java.awt.Color color)
cls
- class of new grid objectgrid
- grid in which this object will actloc
- location the object will occupydir
- direction the object will facecolor
- color of the object
MBSException
- if an object of the specified class cannot be
constructed with the specified parameterspublic static Grid constructGrid(java.lang.Class cls)
cls
- class of new grid
MBSException
- if a grid of the specified class cannot be
constructedpublic static Grid constructGrid(java.lang.Class cls, int numRows, int numCols)
cls
- class of new grid
MBSException
- if an grid of the specified class cannot be
constructed with the given number of rows and columnspublic static java.util.Set gridObjectClasses()
addGridObjClassNames
method.
public static java.util.Set boundedGridClasses()
addBoundedClassNames
method.
public static java.util.Set unboundedGridClasses()
addUnboundedClassNames
method.
protected static void addClassesToFactory(java.lang.String[] classNames, java.lang.String whichCategory)
classNames
- an array of class nameswhichCategory
- descriptive name for category
(e.g., "bounded grid")public static void addGridObjClassNames(java.lang.String[] classNames)
classNames
- an array of grid object class namespublic static void addBoundedGridClassNames(java.lang.String[] classNames)
classNames
- an array of bounded grid class namespublic static void addUnboundedGridClassNames(java.lang.String[] classNames)
classNames
- an array of unbounded grid class namespublic static boolean isValidGridClass(java.lang.Class cls, java.lang.Class[] ctorParameters) throws java.lang.NoSuchMethodException
java.lang.NoSuchMethodException
public static boolean isValidGridObjectClass(java.lang.Class cls, java.lang.Class[] ctorParameters) throws java.lang.NoSuchMethodException
java.lang.NoSuchMethodException
protected static boolean hasCorrectCtor(java.lang.Class cls, java.lang.Class requiredCls, java.lang.Class[] ctorParameters) throws java.lang.NoSuchMethodException
java.lang.NoSuchMethodException
public static boolean hasFourArgCtor(java.lang.Class cls)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |