|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.stage.util.PlacementConstraints
public class PlacementConstraints
Maintains extra information on objects in a scene and checks proposed placement operations for constraint violations. When the constraints object is in use, all placement operations (object additions and removals) must go through the constraints object so that the object's internal state remains consistent.
| Nested Class Summary | |
|---|---|
protected static class |
PlacementConstraints.DirectionType
Contains the direction and height of a constraint. |
protected class |
PlacementConstraints.ObjectData
Contains information about an object used in checking constraints. |
| Field Summary | |
|---|---|
protected static Rectangle |
_constrainRect
One rectangle we'll re-use for all constraints ops. |
protected StageMisoSceneModel |
_mmodel
The Miso scene model. |
protected HashMap<com.threerings.miso.data.ObjectInfo,PlacementConstraints.ObjectData> |
_objectData
For all objects in the scene, maps ObjectInfos to PlacementConstraints.ObjectDatas. |
protected StageScene |
_scene
The scene being checked for constraints. |
protected com.threerings.media.tile.TileManager |
_tilemgr
The tile manager to use for object dimensions and constraints. |
| Fields inherited from interface com.threerings.util.DirectionCodes |
|---|
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST |
| Fields inherited from interface com.threerings.stage.data.StageCodes |
|---|
ERR_CANNOT_CLUSTER, ERR_NO_OVERLAP, MODIFY_SCENE_ACCESS, MUTILATE_SCENE_ACCESS, STAGE_MESSAGE_BUNDLE, TILESET_RSRC_SET |
| Fields inherited from interface com.threerings.presents.data.InvocationCodes |
|---|
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR |
| Constructor Summary | |
|---|---|
PlacementConstraints(com.threerings.media.tile.TileManager tilemgr,
StageScene scene)
Default constructor. |
|
| Method Summary | |
|---|---|
void |
addObject(com.threerings.miso.data.ObjectInfo info)
Adds the specified object through the constraints. |
String |
allowAddObject(com.threerings.miso.data.ObjectInfo info)
Determines whether the constraints allow the specified object to be added to the scene. |
String |
allowModifyObjects(com.threerings.miso.data.ObjectInfo[] added,
com.threerings.miso.data.ObjectInfo[] removed)
Determines whether the constraints allow the specified objects to be added and removed simultaneously. |
protected String |
allowModifyObjects(PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
Determines whether the constraints allow the specified objects to be added and removed simultaneously. |
String |
allowRemoveObject(com.threerings.miso.data.ObjectInfo info)
Determines whether the constraints allow the specified object to be removed from the scene. |
protected PlacementConstraints.ObjectData |
createObjectData(com.threerings.miso.data.ObjectInfo info)
Using the tile manager, computes and returns the specified object's data. |
protected Rectangle |
getAdjacentEdge(Rectangle rect,
int dir)
Creates and returns a rectangle that covers the specified rectangle's adjacent edge (the squares one tile beyond the bounds) in the specified direction. |
protected int |
getConstraintDirection(PlacementConstraints.ObjectData data,
String prefix)
Returns the direction in which the specified object is constrained by appending "[NESW]" to the given constraint prefix. |
protected boolean |
getConstraintDirectionType(PlacementConstraints.ObjectData data,
String prefix,
PlacementConstraints.DirectionType dirtype)
Populates the supplied PlacementConstraints.ObjectData object with the direction and height of the
constraint identified by the given prefix. |
protected int |
getConstraintWallType(String constraint)
|
protected String |
getDirectionalConstraint(String prefix,
int dir)
Given a constraint prefix and a direction, returns the directional constraint. |
protected String |
getDirectionalConstraint(String prefix,
int dir,
int type)
Given a constraint prefix, direction, and height, returns the directional constraint. |
protected List<PlacementConstraints.ObjectData> |
getObjectData(Rectangle rect,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
Finds all objects whose bounds intersect the given rectangle and returns a list containing their PlacementConstraints.ObjectData elements. |
protected PlacementConstraints.ObjectData[] |
getObjectDataFromInfo(com.threerings.miso.data.ObjectInfo[] info)
Returns an ObjectData array that corresponds to the supplied ObjectInfo array. |
protected boolean |
hasAttached(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir)
Determines whether the specified wall has anything attached to it that won't be held up if the wall is removed. |
protected boolean |
hasOnSurface(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
Determines whether the specified surface has anything on it that won't be held up if the surface is removed. |
protected boolean |
hasOnWall(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir)
Determines whether the specified wall has anything on it that won't be held up if the wall is removed. |
protected boolean |
hasSpace(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir)
Determines whether the specified object has empty space in the specified direction. |
protected boolean |
hasSpaceConstrainedAdjacent(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
Verifies that the objects adjacent to the given object will still have their space constraints met if the object is added. |
protected boolean |
isAttached(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir,
int type)
Determines whether the specified object is attached to another object in the specified direction and at the specified height. |
protected boolean |
isCovered(Rectangle rect,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
String constraint,
String altstraint)
Given a rectangle, determines whether all of the tiles within the rectangle intersect an object. |
protected boolean |
isOnSurface(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
Determines whether the specified object is on a surface. |
protected boolean |
isOnWall(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir,
int type)
Determines whether the specified object is on a wall facing the specified direction. |
void |
removeObject(com.threerings.miso.data.ObjectInfo info)
Removes the specified object through the constraints. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected com.threerings.media.tile.TileManager _tilemgr
protected StageScene _scene
protected StageMisoSceneModel _mmodel
protected HashMap<com.threerings.miso.data.ObjectInfo,PlacementConstraints.ObjectData> _objectData
ObjectInfos to PlacementConstraints.ObjectDatas.
protected static final Rectangle _constrainRect
| Constructor Detail |
|---|
public PlacementConstraints(com.threerings.media.tile.TileManager tilemgr,
StageScene scene)
| Method Detail |
|---|
public String allowAddObject(com.threerings.miso.data.ObjectInfo info)
null if the constraints allow the operation,
otherwise a translatable string explaining why the object can't be
addedpublic void addObject(com.threerings.miso.data.ObjectInfo info)
public String allowRemoveObject(com.threerings.miso.data.ObjectInfo info)
null if the constraints allow the operation,
otherwise a translatable string explaining why the object can't be
removedpublic void removeObject(com.threerings.miso.data.ObjectInfo info)
public String allowModifyObjects(com.threerings.miso.data.ObjectInfo[] added,
com.threerings.miso.data.ObjectInfo[] removed)
null if the constraints allow the operation,
otherwise a translatable string explaining why the objects can't be
modifiedprotected PlacementConstraints.ObjectData[] getObjectDataFromInfo(com.threerings.miso.data.ObjectInfo[] info)
protected String allowModifyObjects(PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
null if the constraints allow the operation,
otherwise a qualified translatable string explaining why the objects
can't be modified
protected boolean hasOnSurface(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
protected boolean hasOnWall(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir)
protected boolean hasAttached(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir)
protected boolean hasSpaceConstrainedAdjacent(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
protected boolean hasSpace(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir)
protected boolean isOnSurface(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
protected boolean isOnWall(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir,
int type)
protected boolean isAttached(PlacementConstraints.ObjectData data,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
int dir,
int type)
protected boolean isCovered(Rectangle rect,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed,
String constraint,
String altstraint)
protected Rectangle getAdjacentEdge(Rectangle rect,
int dir)
protected int getConstraintDirection(PlacementConstraints.ObjectData data,
String prefix)
NONE if there is no such directional constraint.
protected boolean getConstraintDirectionType(PlacementConstraints.ObjectData data,
String prefix,
PlacementConstraints.DirectionType dirtype)
PlacementConstraints.ObjectData object with the direction and height of the
constraint identified by the given prefix.
protected int getConstraintWallType(String constraint)
protected String getDirectionalConstraint(String prefix,
int dir)
protected String getDirectionalConstraint(String prefix,
int dir,
int type)
protected List<PlacementConstraints.ObjectData> getObjectData(Rectangle rect,
PlacementConstraints.ObjectData[] added,
PlacementConstraints.ObjectData[] removed)
PlacementConstraints.ObjectData elements.
added - an array of objects to add to the searchremoved - an array of objects to exclude from the searchprotected PlacementConstraints.ObjectData createObjectData(com.threerings.miso.data.ObjectInfo info)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||