public class VectorPortrayal2D extends OrientedPortrayal2D
VectorPortrayal2D works in one of two modes:
You specify these grids when constructing the VectorPortrayal2D. Additionally of course you will assign the VectorPortrayal as a portrayal for some ValueGridPortrayal2D attached to a grid of some sort. This grid will be ignored as far as drawing goes, but will be the grid used for all other purposes (such as hit-testing) and thus will be the grid that will determine the inspector that pops up when you double-click on a location. You could naturally use one of your three grids (perhaps the orientation grid) as the attached grid as well.
Object mode also supports Double2D, Double3D, Int2D, and Int3D objects. Here, the x and y values define the vector proper and are converted into appropriate orientation and scale values (which isn't fast, as it requires atan2!). For Double3D and Int3D, the z value is converted into the color.
You can set the scale of the VectorPortrayal2D manually, in which case this value is multiplied by the value provided by the underlying object to get the final scale of the vector. You can also specify a vector shape, one of the OrientedPortrayal2D shapes (since VectorPortrayal2D is its subclass).
VectorPortrayal2D is a subclass of OrientedPortrayal2D mostly because it's convenient for it to use OrientedPortrayal's shapes and auto-rotation. OrentedPortrayal2D has other random features which don't make a whole lot of sense to use in this context, so we suggest you not play with them unless you absolutely must. This inludes mucking with the "offset" instance variable, calling setOrientationShowing(), or changing the "child" instance variable.
Modifier and Type | Field and Description |
---|---|
static int |
SHAPE_LINE_T |
child, DEFAULT_OFFSET, DEFAULT_SCALE, drawFilled, offset, paint, scale, SHAPE_ARROW, SHAPE_COMPASS, SHAPE_INVERTED_T, SHAPE_KITE, SHAPE_LINE, SHAPE_LINE_ARROW, SHAPE_TRIANGLE
TYPE_HIT_OBJECT, TYPE_SELECTED_OBJECT
Constructor and Description |
---|
VectorPortrayal2D()
Creates a VectorPortrayal2D which responds to objects which are
Oriented2D and/or Scaled2D.
|
VectorPortrayal2D(ColorMap map)
Creates a VectorPortrayal2D which responds to objects which are
Valuable (or a Number), Oriented2D, and/or Scaled2D.
|
VectorPortrayal2D(DoubleGrid2D orientationGrid)
Creates a VectorPortrayal with an orientation grid.
|
VectorPortrayal2D(DoubleGrid2D orientationGrid,
DoubleGrid2D sizeGrid)
Creates a VectorPortrayal with an orientation grid and size grid.
|
VectorPortrayal2D(int shape)
Creates a VectorPortrayal2D which responds to objects which are
Oriented2D and/or Scaled2D.
|
VectorPortrayal2D(int shape,
ColorMap map)
Creates a VectorPortrayal2D which responds to objects which are
Valuable (or a Number), Oriented2D, and/or Scaled2D.
|
VectorPortrayal2D(int shape,
DoubleGrid2D orientationGrid,
DoubleGrid2D sizeGrid,
DoubleGrid2D colorGrid,
ColorMap map)
Create a VectorPortrayal with a provided shape (see OrientedPortrayal2D), and with an orientation, size, and color grid,
plus a ColorMap for the color grid.
|
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.
|
double |
filterScale(double objectScale)
Override this method to change the scale of a value to a new one.
|
Inspector |
getInspector(LocationWrapper wrapper,
GUIState state)
Provide an inspector for an object.
|
double |
getOrientation(java.lang.Object object,
DrawInfo2D info)
Returns the orientation of the underlying object, or NaN if there is no such orientation.
|
boolean |
getUsesExactOrientation() |
boolean |
hitObject(java.lang.Object object,
DrawInfo2D range)
Returns true if any part of the 1x1 square surrounding the VectorPortrayal is hit (as opposed
to the shape itself.
|
void |
setShape(int val) |
void |
setUsesExactOrientation(boolean val) |
getChild, getName, getOnlyDrawWhenSelected, getShape, handleMouseEvent, isDrawFilled, isLineShowing, isOrientationHittable, isOrientationShowing, setDrawFilled, setLineShowing, setOnlyDrawWhenSelected, setOrientationHittable, setOrientationShowing, setSelected
getStatus
public static final int SHAPE_LINE_T
public VectorPortrayal2D()
public VectorPortrayal2D(int shape)
public VectorPortrayal2D(ColorMap map)
public VectorPortrayal2D(int shape, ColorMap map)
public VectorPortrayal2D(DoubleGrid2D orientationGrid)
public VectorPortrayal2D(DoubleGrid2D orientationGrid, DoubleGrid2D sizeGrid)
public VectorPortrayal2D(int shape, DoubleGrid2D orientationGrid, DoubleGrid2D sizeGrid, DoubleGrid2D colorGrid, ColorMap map)
public double getOrientation(java.lang.Object object, DrawInfo2D info)
OrientedPortrayal2D
getOrientation
in class OrientedPortrayal2D
public double filterScale(double objectScale)
public void setShape(int val)
setShape
in class OrientedPortrayal2D
public boolean getUsesExactOrientation()
public void setUsesExactOrientation(boolean val)
public void draw(java.lang.Object object, java.awt.Graphics2D graphics, DrawInfo2D info)
Portrayal2D
draw
in interface Portrayal2D
draw
in class OrientedPortrayal2D
public boolean hitObject(java.lang.Object object, DrawInfo2D range)
hitObject
in class OrientedPortrayal2D
public Inspector getInspector(LocationWrapper wrapper, GUIState state)
Portrayal
getInspector
in interface Portrayal
getInspector
in class OrientedPortrayal2D