com.threerings.stage.util

## Class PlacementConstraints

- java.lang.Object
- - com.threerings.stage.util.PlacementConstraints

All Implemented Interfaces:
  com.threerings.presents.data.InvocationCodes, StageCodes, com.threerings.util.DirectionCodes

    public class PlacementConstraints
    extends Object
    implements com.threerings.util.DirectionCodes, StageCodes

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.

### Field Summary

### 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

Constructors
Constructor and Description
`PlacementConstraints(com.threerings.media.tile.TileManager tilemgr, StageScene scene)` Default constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`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.
`String` `allowRemoveObject(com.threerings.miso.data.ObjectInfo info)` Determines whether the constraints allow the specified object to be removed from the scene.
`void` `removeObject(com.threerings.miso.data.ObjectInfo info)` Removes the specified object through the constraints.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PlacementConstraints

    public PlacementConstraints(com.threerings.media.tile.TileManager tilemgr,
                                StageScene scene)

Default constructor.

### Method Detail

#### allowAddObject

    public String allowAddObject(com.threerings.miso.data.ObjectInfo info)

Determines whether the constraints allow the specified object to be added to the scene.

Returns:
  `null` if the constraints allow the operation, otherwise a translatable string explaining why the object can't be added

#### addObject

    public void addObject(com.threerings.miso.data.ObjectInfo info)

Adds the specified object through the constraints.

#### allowRemoveObject

    public String allowRemoveObject(com.threerings.miso.data.ObjectInfo info)

Determines whether the constraints allow the specified object to be removed from the scene.

Returns:
  `null` if the constraints allow the operation, otherwise a translatable string explaining why the object can't be removed

#### removeObject

    public void removeObject(com.threerings.miso.data.ObjectInfo info)

Removes the specified object through the constraints.

#### allowModifyObjects

    public 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.

Returns:
  `null` if the constraints allow the operation, otherwise a translatable string explaining why the objects can't be modified