public class AdjustablePortrayal2D extends SimplePortrayal2D
This portrayal is used simply by wrapping around another portrayal or around null (if the object portrays itself). When the object is selected, an "adjustment ring" will appear overlaid on the object. The ring shows the current orientation of the object. If you drag the ring, you can change the orientation and scale of the object with your mouse.
To simply view orientation with the ring, the object must implement the Oriented2D interface.
To rotate the object, the object must implement the Orientable2D interface (which extends the Oriented2D interface).
To change the scale of the object, the object must implement the Scalable2D interface.
IMPORTANT NOTE: If using AdjustablePortrayal2D in conjunction with MovablePortrayal2D, always wrap the MovablePortrayal2D inside the AdjustablePortrayal2D, not the other way around.
Modifier and Type | Field and Description |
---|---|
SimplePortrayal2D |
child |
static java.awt.geom.Ellipse2D |
circle |
static double |
CIRCLE_RADIUS |
static java.awt.geom.Ellipse2D |
knob |
static double |
KNOB_RADIUS |
static java.awt.Paint |
LOWER_PAINT |
static java.awt.Stroke |
LOWER_STROKE |
static double |
SLOP |
static java.awt.Paint |
UPPER_PAINT |
static java.awt.Stroke |
UPPER_STROKE |
TYPE_HIT_OBJECT, TYPE_SELECTED_OBJECT
Constructor and Description |
---|
AdjustablePortrayal2D(SimplePortrayal2D child) |
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.
|
SimplePortrayal2D |
getChild(java.lang.Object object) |
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.
|
boolean |
handleMouseEvent(GUIState guistate,
Manipulating2D manipulating,
LocationWrapper wrapper,
java.awt.event.MouseEvent event,
DrawInfo2D range,
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.
|
getStatus
public static final double CIRCLE_RADIUS
public static final double KNOB_RADIUS
public static final double SLOP
public static final java.awt.Paint LOWER_PAINT
public static final java.awt.Stroke LOWER_STROKE
public static final java.awt.Paint UPPER_PAINT
public static final java.awt.Stroke UPPER_STROKE
public static final java.awt.geom.Ellipse2D circle
public static final java.awt.geom.Ellipse2D knob
public SimplePortrayal2D child
public AdjustablePortrayal2D(SimplePortrayal2D child)
public SimplePortrayal2D getChild(java.lang.Object object)
public void draw(java.lang.Object object, java.awt.Graphics2D graphics, DrawInfo2D info)
Portrayal2D
draw
in interface Portrayal2D
draw
in class SimplePortrayal2D
public boolean handleMouseEvent(GUIState guistate, Manipulating2D manipulating, LocationWrapper wrapper, java.awt.event.MouseEvent event, DrawInfo2D range, int type)
SimplePortrayal2D
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.
handleMouseEvent
in class SimplePortrayal2D
public boolean hitObject(java.lang.Object object, DrawInfo2D range)
SimplePortrayal2D
hitObject
in class SimplePortrayal2D
public boolean setSelected(LocationWrapper wrapper, boolean selected)
Portrayal
setSelected
in interface Portrayal
setSelected
in class SimplePortrayal2D
public Inspector getInspector(LocationWrapper wrapper, GUIState state)
Portrayal
getInspector
in interface Portrayal
getInspector
in class SimplePortrayal2D
public java.lang.String getName(LocationWrapper wrapper)
Portrayal
getName
in interface Portrayal
getName
in class SimplePortrayal2D