public class SimplePortrayal2D extends java.lang.Object implements Portrayal2D, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static int |
TYPE_HIT_OBJECT |
static int |
TYPE_SELECTED_OBJECT |
Constructor and Description |
---|
SimplePortrayal2D() |
Modifier and Type | Method and Description |
---|---|
void |
draw(java.lang.Object object,
java.awt.Graphics2D graphics,
DrawInfo2D info)
Draw a the given object with an origin at (info.draw.x, info.draw.y),
and with the coordinate system scaled by so that 1 unit is in the x and
y directions are equal to info.draw.width and info.draw.height respectively
in pixels.
|
Inspector |
getInspector(LocationWrapper wrapper,
GUIState state)
Provide an inspector for an object.
|
java.lang.String |
getName(LocationWrapper wrapper)
Returns a static, one-line name for the given object that is useful for a human
to distinguish it from other objects.
|
java.lang.String |
getStatus(LocationWrapper wrapper)
Returns a simple, informative one-line description of the current status of the object,
which may change at any time to reflect how the object is changing.
|
boolean |
handleMouseEvent(GUIState guistate,
Manipulating2D manipulating,
LocationWrapper wrapper,
java.awt.event.MouseEvent event,
DrawInfo2D fieldPortrayalDrawInfo,
int type)
Optionally handles a mouse event.
|
boolean |
hitObject(java.lang.Object object,
DrawInfo2D range)
Return true if the given object, when drawn, intersects with a provided rectangle, for
hit testing purposes.
|
boolean |
setSelected(LocationWrapper wrapper,
boolean selected)
Change the portrayal state to reflect the fact that you've
been selected or not selected.
|
public static final int TYPE_SELECTED_OBJECT
public static final int TYPE_HIT_OBJECT
public void draw(java.lang.Object object, java.awt.Graphics2D graphics, DrawInfo2D info)
Portrayal2D
draw
in interface Portrayal2D
public boolean hitObject(java.lang.Object object, DrawInfo2D range)
public boolean setSelected(LocationWrapper wrapper, boolean selected)
Portrayal
setSelected
in interface Portrayal
public boolean handleMouseEvent(GUIState guistate, Manipulating2D manipulating, LocationWrapper wrapper, java.awt.event.MouseEvent event, DrawInfo2D fieldPortrayalDrawInfo, int type)
To indicate that the event was handled, return true. The default blank implementation of this method simply returns false. Events are first sent to portrayals selected objects, until one of them handles the event. If none handled the event, then events are sent to portrayals of objects hit by the event, until one of *them* handles the event. If still no one has handled the event, then the Display2D will route the event to built-in mechanisms such selecting the object or inspecting it.
If you're modifying or querying the model as a result of this event, be sure to lock on guistate.state.schedule before you do so.
public Inspector getInspector(LocationWrapper wrapper, GUIState state)
Portrayal
getInspector
in interface Portrayal
public java.lang.String getStatus(LocationWrapper wrapper)
Portrayal
public java.lang.String getName(LocationWrapper wrapper)
Portrayal