Class LabelledLine
java.lang.Object
uk.ac.starlink.ttools.plot2.LabelledLine
Aggregates a line in graphics coordinates and its annotation.
The annotation is intended for human consumption.
- Since:
- 23 Jan 2019
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionLabelledLine(Point2D[] gps, String label) Constructs a labelled line with an arbitrary number of points.LabelledLine(Point2D gp0, Point2D gp1, String label) Constructs a straight labelled line between two points. -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawLabel(Graphics2D g2, Color bg) Draws the label in the middle of the line to a given graphics context.voiddrawLine(Graphics2D g2) Draws the line to a given graphics context.getLabel()Returns the annotation.getPath()Returns a path object corresponding to this line.Point2D[]Returns the array of points defining this line.toString()
-
Constructor Details
-
LabelledLine
-
LabelledLine
Constructs a labelled line with an arbitrary number of points. Null elements may appear in the points array indicating a break in the line. There must be at least two array elements, and the first and last elements must both be non-null.- Parameters:
gps- array of points in graphics space defining the linelabel- human-readable annotation for line (may be null)
-
-
Method Details
-
getPoints
Returns the array of points defining this line.- Returns:
- array of (at least 2) points
-
getLabel
-
drawLine
Draws the line to a given graphics context. The current settings of the graphics context are used.- Parameters:
g2- graphics context
-
getPath
-
drawLabel
Draws the label in the middle of the line to a given graphics context. The current settings of the graphics context are used. If a non-null background colour is supplied, a rectangle corresponding to the label bounds is plotted underneath the label itself.- Parameters:
g2- graphics contextbg- background colour, or null
-
toString
-