|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.portrayal.SimplePortrayal2D
sim.portrayal.simple.OrientedPortrayal2D
A wrapper for other Portrayal2Ds which provides some kind of pointing object (typically a line) along the object's specified orientation angle. This is a very simple way to show orientation.
For the line to be drawn, the underlying object must adhere to the Oriented2D interface, which provides the orientation2D() method. The line starts at the origin and is of length:
length: (int)(or * max(info.draw.width,info.draw.height)) + dr;
... that is, or is a value which scales when you zoom in, and dr adds additional fixed pixels. The default is or = 0.5, dr = 0, with a red color.
You can specify other shapes than a simple line. We provide two others: kites and compasses.
Note: One oddity of OrientedPortrayal2D is due to the fact that the line is only drawn if the object is being drawn. While most FieldPortrayals ask objects just off-screen to draw themselves just to be careful, if an object is significantly off-screen, it may not be asked to draw itself, and so the orientation line will not be drawn -- even though part of the orientation line could be on-screen at the time! C'est la vie.
Field Summary | |
SimplePortrayal2D |
child
|
static int |
DEFAULT_DR
|
static double |
DEFAULT_OR
|
int |
dr
The post-scaling length offset |
double |
or
The pre-scaling length |
java.awt.Paint |
paint
The Paint or Color of the line |
static int |
SHAPE_COMPASS
|
static int |
SHAPE_KITE
|
static int |
SHAPE_LINE
|
Constructor Summary | |
OrientedPortrayal2D(SimplePortrayal2D child)
Draw a line of length or = 0.5 dr = 0, in red. |
|
OrientedPortrayal2D(SimplePortrayal2D child,
int dr,
double or)
Draw a line of the given length in red. |
|
OrientedPortrayal2D(SimplePortrayal2D child,
int dr,
double or,
java.awt.Paint paint)
If child is null, then the underlying model object is presumed to be a Portrayal2D and will be used. |
|
OrientedPortrayal2D(SimplePortrayal2D child,
int dr,
double or,
java.awt.Paint paint,
int shape)
|
|
OrientedPortrayal2D(SimplePortrayal2D child,
java.awt.Paint paint)
Draw a line of length or = 0.5, dr = 0. |
Method Summary | |
void |
draw(java.lang.Object object,
java.awt.Graphics2D graphics,
DrawInfo2D info)
Draw a portrayed object centered at the origin in info, and with the given scaling factors. |
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 name for the given object that is useful for a human to distinguish it from other objects. |
int |
getShape()
|
boolean |
hitObject(java.lang.Object object,
DrawInfo2D range)
If drawing area intersects selected area, return true. |
boolean |
isLineShowing()
|
void |
setLineShowing(boolean val)
|
boolean |
setSelected(LocationWrapper wrapper,
boolean selected)
Change the portrayal state to reflect the fact that you've been selected or not selected. |
void |
setShape(int val)
|
Methods inherited from class sim.portrayal.SimplePortrayal2D |
move |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final double DEFAULT_OR
public static final int DEFAULT_DR
public static final int SHAPE_LINE
public static final int SHAPE_KITE
public static final int SHAPE_COMPASS
public double or
public int dr
public java.awt.Paint paint
public SimplePortrayal2D child
Constructor Detail |
public OrientedPortrayal2D(SimplePortrayal2D child, int dr, double or, java.awt.Paint paint, int shape)
public OrientedPortrayal2D(SimplePortrayal2D child, int dr, double or, java.awt.Paint paint)
public OrientedPortrayal2D(SimplePortrayal2D child)
public OrientedPortrayal2D(SimplePortrayal2D child, int dr, double or)
public OrientedPortrayal2D(SimplePortrayal2D child, java.awt.Paint paint)
Method Detail |
public void setShape(int val)
public int getShape()
public boolean isLineShowing()
public void setLineShowing(boolean val)
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 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |