|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.portrayal.SimplePortrayal2D
sim.portrayal.simple.CircledPortrayal2D
A wrapper for other Portrayal2Ds which also draws a big circle around them -- useful for distinguishing one object from other similar-looking objects. When you create this CirclePortrayal2D, you will pass in an underlying Portrayal2D which is supposed to draw the actual object; CirclePortrayal2D will then add on the circle. If the object will draw itself (it's its own Portrayal2D), you can signify this by passing in null for the underlying Portrayal2D.
There are certain guidelines you can specify for when the circle is to be drawn. At construction time you can state that the circle should only be drawn when the object is selected. Additionally if you call the setCircleShowing(...) function, you can turn off or on circle drawing entirely for this CirclePortrayal2D.
You may specify a color or paint for the circle (the default is blue).
The circle is drawn centered at the object's [info.draw.x, info.draw.y] origin and with the radius:
radius: (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 = 1.0, dr = 0. This draws the circle at twice the expected width and height of the object.
Note: One oddity of CircledPortrayal2D is due to the fact that the circle 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 circle will not be drawn -- even though part of the circle 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 radius offset |
double |
or
The pre-scaling radius |
java.awt.Paint |
paint
The Paint or Color of the circle |
Constructor Summary | |
CircledPortrayal2D(SimplePortrayal2D child)
Draw a circle of radius or = 1.0, dr = 0, in blue. |
|
CircledPortrayal2D(SimplePortrayal2D child,
int dr,
double or,
java.awt.Paint paint,
boolean onlyCircleWhenSelected)
If child is null, then the underlying model object is presumed to be a Portrayal2D and will be used. |
|
CircledPortrayal2D(SimplePortrayal2D child,
java.awt.Paint paint,
boolean onlyCircleWhenSelected)
Draw a circle of radius or = 1.0, 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 static, one-line name for the given object that is useful for a human to distinguish it from other objects. |
boolean |
getOnlyCircleWhenSelected()
|
boolean |
hitObject(java.lang.Object object,
DrawInfo2D range)
If drawing area intersects selected area, return true. |
boolean |
isCircleShowing()
|
void |
setCircleShowing(boolean val)
|
void |
setOnlyCircleWhenSelected(boolean val)
|
boolean |
setSelected(LocationWrapper wrapper,
boolean selected)
Change the portrayal state to reflect the fact that you've been selected or not selected. |
Methods inherited from class sim.portrayal.SimplePortrayal2D |
getStatus, 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 double or
public int dr
public java.awt.Paint paint
public SimplePortrayal2D child
Constructor Detail |
public CircledPortrayal2D(SimplePortrayal2D child, int dr, double or, java.awt.Paint paint, boolean onlyCircleWhenSelected)
public CircledPortrayal2D(SimplePortrayal2D child)
public CircledPortrayal2D(SimplePortrayal2D child, java.awt.Paint paint, boolean onlyCircleWhenSelected)
Method Detail |
public void setOnlyCircleWhenSelected(boolean val)
public boolean getOnlyCircleWhenSelected()
public boolean isCircleShowing()
public void setCircleShowing(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 |