Package sim.portrayal.network
Class SimpleEdgePortrayal2D
java.lang.Object
sim.portrayal.SimplePortrayal2D
sim.portrayal.network.SimpleEdgePortrayal2D
- All Implemented Interfaces:
Serializable
,Portrayal
,Portrayal2D
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
double
static final int
static final int
protected Font
int
static final int
Deprecated.Use SHAPE_LINE_ROUND_ENDSstatic final int
static final int
static final int
static final int
static final int
Fields inherited from class sim.portrayal.SimplePortrayal2D
TYPE_HIT_OBJECT, TYPE_SELECTED_OBJECT
-
Constructor Summary
ConstructorDescriptionDraws a single-color, undirected black line (or triangle) with no label.SimpleEdgePortrayal2D
(Paint edgePaint, Paint labelPaint) One single color line will be drawn, and if labelPaint is null, no label is drawn.SimpleEdgePortrayal2D
(Paint fromPaint, Paint toPaint, Paint labelPaint) If fromPaint == toPaint, one single color line will be drawn, and if labelPaint is null, no label is drawn.SimpleEdgePortrayal2D
(Paint fromPaint, Paint toPaint, Paint labelPaint, Font labelFont) If fromPaint == toPaint, one single color line will be drawn, and if labelPaint is null, no label is drawn. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(Object object, 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.boolean
double
getBasicStroke
(float thickness) getLabel
(Edge edge, EdgeDrawInfo2D info) Returns a name appropriate for the edge.int
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.protected double
getPositiveWeight
(Object edge, EdgeDrawInfo2D info) Returns a weight appropriate to scale the edge.int
int
getShape()
Returns the shape of the edge.boolean
hitObject
(Object object, DrawInfo2D range) Return true if the given object, when drawn, intersects with a provided rectangle, for hit testing purposes.void
setAdjustsThickness
(boolean val) void
setBaseWidth
(double val) Sets the width of the base of the triangle used in drawing the directed edge -- by default, this is 0 (a simple line is drawn).void
setLabelScaling
(int val) void
setScaling
(int val) void
setShape
(int shape) Sets the shape of the edge.Methods inherited from class sim.portrayal.SimplePortrayal2D
getInspector, getStatus, handleMouseEvent, setSelected
-
Field Details
-
fromPaint
-
toPaint
-
labelPaint
-
labelFont
-
scaledFont
-
NEVER_SCALE
public static final int NEVER_SCALE- See Also:
-
SCALE_WHEN_SMALLER
public static final int SCALE_WHEN_SMALLER- See Also:
-
ALWAYS_SCALE
public static final int ALWAYS_SCALE- See Also:
-
baseWidth
public double baseWidth -
SHAPE_THIN_LINE
public static final int SHAPE_THIN_LINE- See Also:
-
SHAPE_LINE
public static final int SHAPE_LINEDeprecated.Use SHAPE_LINE_ROUND_ENDS- See Also:
-
SHAPE_LINE_ROUND_ENDS
public static final int SHAPE_LINE_ROUND_ENDS- See Also:
-
SHAPE_LINE_SQUARE_ENDS
public static final int SHAPE_LINE_SQUARE_ENDS- See Also:
-
SHAPE_LINE_BUTT_ENDS
public static final int SHAPE_LINE_BUTT_ENDS- See Also:
-
SHAPE_TRIANGLE
public static final int SHAPE_TRIANGLE- See Also:
-
shape
public int shape
-
-
Constructor Details
-
SimpleEdgePortrayal2D
public SimpleEdgePortrayal2D()Draws a single-color, undirected black line (or triangle) with no label. -
SimpleEdgePortrayal2D
One single color line will be drawn, and if labelPaint is null, no label is drawn. -
SimpleEdgePortrayal2D
If fromPaint == toPaint, one single color line will be drawn, and if labelPaint is null, no label is drawn. -
SimpleEdgePortrayal2D
If fromPaint == toPaint, one single color line will be drawn, and if labelPaint is null, no label is drawn.
-
-
Method Details
-
getAdjustsThickness
public boolean getAdjustsThickness() -
setAdjustsThickness
public void setAdjustsThickness(boolean val) -
getShape
public int getShape()Returns the shape of the edge. At present there are two shapes: a straight line (SHAPE_LINE) and a triangle (SHAPE_TRIANGLE). -
setShape
public void setShape(int shape) Sets the shape of the edge. At present there are two shapes: a straight line (SHAPE_LINE) and a triangle (SHAPE_TRIANGLE) -
getBaseWidth
public double getBaseWidth() -
setBaseWidth
public void setBaseWidth(double val) Sets the width of the base of the triangle used in drawing the directed edge -- by default, this is 0 (a simple line is drawn). The triangle is drawn with its base at the "from" node and its point at the "to" node. -
getScaling
public int getScaling() -
setScaling
public void setScaling(int val) -
getLabelScaling
public int getLabelScaling() -
setLabelScaling
public void setLabelScaling(int val) -
getPositiveWeight
Returns a weight appropriate to scale the edge. This weight must be >= 0. By default, this returns 1.0 of adjustsThickness() is false or if edge.getInfo() cannot be converted into a weight, else 0.0 if edge.getInfo() is null, else converts edge.getInfo() and returns the absolute value. -
getLabel
Returns a name appropriate for the edge. By default, this returns (edge.getInfo() == null ? "" : "" + edge.getInfo()). Override this to make a more customized label to display for the edge on-screen. -
getBasicStroke
-
draw
Description copied from interface:Portrayal2D
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. The rectangle given by info.clip specifies the only region in which it is necessary to draw. If info.precise is true, try to draw using real-valued high-resolution drawing rather than faster integer drawing. It is possible that object is null. The location of the object in the field may (and may not) be stored in info.location. The form of that location varies depending on the kind of field used.- Specified by:
draw
in interfacePortrayal2D
- Overrides:
draw
in classSimplePortrayal2D
-
hitObject
Description copied from class:SimplePortrayal2D
Return true if the given object, when drawn, intersects with a provided rectangle, for hit testing purposes. The object is drawn 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. The rectangle given by info.clip specifies the region to do hit testing in; often this region is actually of 0 width or height, which might represent a single point. It is possible that object is null. The location of the object in the field may (and may not) be stored in info.location. The form of that location varies depending on the kind of field used.- Overrides:
hitObject
in classSimplePortrayal2D
-
getName
Description copied from interface:Portrayal
Returns a static, one-line name for the given object that is useful for a human to distinguish it from other objects. A simple default would be just to return "" + object.- Specified by:
getName
in interfacePortrayal
- Overrides:
getName
in classSimplePortrayal2D
-