com.threerings.miso.client
Class SceneObject

java.lang.Object
  extended by com.threerings.miso.client.SceneObject

public class SceneObject
extends Object

Contains resolved information on an object in a scene.


Field Summary
protected  Polygon _footprint
          Our object footprint as a polygon.
protected static RuntimeAdjust.BooleanAdjust _fprintDebug
          A debug hook that toggles rendering of object footprints.
protected  Rectangle _frect
          Our object as a tile coordinate rectangle.
protected  Point _fspot
          The full-coordinates of our object spot; or null if we have none.
protected static RuntimeAdjust.BooleanAdjust _hideObjects
          A debug hook that toggles rendering of objects.
protected static Polygon _spotTri
          The triangle used to render an object's spot.
protected  Point _sspot
          The screen-coordinates of our object spot; or null if we have none.
protected  boolean _warning
          Used to mark objects with errors.
protected static Composite ALPHA_WARN
          The alpha used to fill our bounds for warning purposes.
 Rectangle bounds
          The screen coordinate bounds of our object tile given its position in the scene.
 ObjectInfo info
          The object's info record.
 ObjectTile tile
          The object tile used to display this object.
 
Constructor Summary
SceneObject(MisoSceneMetrics metrics, ObjectInfo info, ObjectTile tile)
          Creates a scene object for display according to the supplied metrics.
SceneObject(MisoSceneMetrics metrics, TileManager mgr, TileSet.Colorizer colorizer, ObjectInfo info)
           
SceneObject(MisoScenePanel panel, ObjectInfo info)
          Creates a scene object for display by the specified panel.
SceneObject(MisoScenePanel panel, ObjectInfo info, ObjectTile tile)
          Creates a scene object for display by the specified panel.
 
Method Summary
protected  void computeInfo(MisoSceneMetrics metrics)
          Computes our screen bounds, tile footprint and other useful cached metrics.
 Polygon getObjectFootprint()
          Returns a polygon bounding all footprint tiles of this scene object.
 Point getObjectScreenSpot()
          Returns the location associated with this object's "spot" in screen coordinates or null if it has no spot.
 Point getObjectSpot()
          Returns the location associated with this object's "spot" in fine coordinates or null if it has no spot.
 int getPriority()
          Returns the render priority of this scene object.
 boolean objectFootprintOverlaps(Rectangle rect)
          Returns true if this object's footprint overlaps the supplied tile coordinate rectangle.
 boolean objectFootprintOverlaps(SceneObject so)
          Returns true if this object's footprint overlaps that of the specified other object.
 void paint(Graphics2D gfx)
          Requests that this scene object render itself.
 void refreshObjectTile(MisoSceneMetrics metrics, TileManager mgr, TileSet.Colorizer colorizer)
          Reloads and recolorizes our object tile.
 void refreshObjectTile(MisoScenePanel panel)
          Reloads and recolorizes our object tile.
 void relocateObject(MisoSceneMetrics metrics, int tx, int ty)
          Updates this object's origin tile coordinate.
 boolean setHovered(boolean hovered)
          Informs this scene object that the mouse is now hovering over it.
 void setPriority(byte priority)
          Overrides the render priority of this object.
 void setWarning(boolean warning)
          Used to flag overlapping scene objects that have no resolving object priorities.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

info

public ObjectInfo info
The object's info record.


tile

public ObjectTile tile
The object tile used to display this object.


bounds

public Rectangle bounds
The screen coordinate bounds of our object tile given its position in the scene.


_frect

protected Rectangle _frect
Our object as a tile coordinate rectangle.


_footprint

protected Polygon _footprint
Our object footprint as a polygon.


_fspot

protected Point _fspot
The full-coordinates of our object spot; or null if we have none.


_sspot

protected Point _sspot
The screen-coordinates of our object spot; or null if we have none.


_warning

protected boolean _warning
Used to mark objects with errors.


_hideObjects

protected static RuntimeAdjust.BooleanAdjust _hideObjects
A debug hook that toggles rendering of objects.


_fprintDebug

protected static RuntimeAdjust.BooleanAdjust _fprintDebug
A debug hook that toggles rendering of object footprints.


_spotTri

protected static Polygon _spotTri
The triangle used to render an object's spot.


ALPHA_WARN

protected static final Composite ALPHA_WARN
The alpha used to fill our bounds for warning purposes.

Constructor Detail

SceneObject

public SceneObject(MisoScenePanel panel,
                   ObjectInfo info)
Creates a scene object for display by the specified panel. The appropriate object tile is resolved and the object's in-situ bounds are computed.


SceneObject

public SceneObject(MisoSceneMetrics metrics,
                   TileManager mgr,
                   TileSet.Colorizer colorizer,
                   ObjectInfo info)

SceneObject

public SceneObject(MisoScenePanel panel,
                   ObjectInfo info,
                   ObjectTile tile)
Creates a scene object for display by the specified panel.


SceneObject

public SceneObject(MisoSceneMetrics metrics,
                   ObjectInfo info,
                   ObjectTile tile)
Creates a scene object for display according to the supplied metrics.

Method Detail

setWarning

public void setWarning(boolean warning)
Used to flag overlapping scene objects that have no resolving object priorities.


paint

public void paint(Graphics2D gfx)
Requests that this scene object render itself.


getObjectSpot

public Point getObjectSpot()
Returns the location associated with this object's "spot" in fine coordinates or null if it has no spot.


getObjectScreenSpot

public Point getObjectScreenSpot()
Returns the location associated with this object's "spot" in screen coordinates or null if it has no spot.


objectFootprintOverlaps

public boolean objectFootprintOverlaps(SceneObject so)
Returns true if this object's footprint overlaps that of the specified other object.


objectFootprintOverlaps

public boolean objectFootprintOverlaps(Rectangle rect)
Returns true if this object's footprint overlaps the supplied tile coordinate rectangle.


getObjectFootprint

public Polygon getObjectFootprint()
Returns a polygon bounding all footprint tiles of this scene object.

Returns:
the bounding polygon.

getPriority

public int getPriority()
Returns the render priority of this scene object.


setPriority

public void setPriority(byte priority)
Overrides the render priority of this object.


setHovered

public boolean setHovered(boolean hovered)
Informs this scene object that the mouse is now hovering over it. Custom objects may wish to adjust some internal state and return true from this method indicating that they should be repainted.


relocateObject

public void relocateObject(MisoSceneMetrics metrics,
                           int tx,
                           int ty)
Updates this object's origin tile coordinate. Its bounds and other cached screen coordinate information are updated.


refreshObjectTile

public void refreshObjectTile(MisoScenePanel panel)
Reloads and recolorizes our object tile. It is not intended for the actual object tile used by a scene object to change in its lifetime, only attributes of that object like its colorizations. So don't do anything crazy like change our ObjectInfo's tileId and call this method or things might break.


refreshObjectTile

public void refreshObjectTile(MisoSceneMetrics metrics,
                              TileManager mgr,
                              TileSet.Colorizer colorizer)
Reloads and recolorizes our object tile. It is not intended for the actual object tile used by a scene object to change in its lifetime, only attributes of that object like its colorizations. So don't do anything crazy like change our ObjectInfo's tileId and call this method or things might break.


computeInfo

protected void computeInfo(MisoSceneMetrics metrics)
Computes our screen bounds, tile footprint and other useful cached metrics.


toString

public String toString()
Overrides:
toString in class Object