Package uk.ac.starlink.ttools.plot2
Class Anchor
java.lang.Object
uk.ac.starlink.ttools.plot2.Anchor
- Direct Known Subclasses:
Anchor.HorizontalAnchor
Positioning constraint for plotted text.
An anchor takes care of text alignment and positioning given a
reference point.
- Since:
- 12 Feb 2013
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAnchor for drawing horizontal text. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic AnchorCenter - reference point is the center of the text.static AnchorEast - reference point is to right of horizontal text.static AnchorNorth - reference point is above centre of horizontal text.static AnchorSouth - reference point is below center of horizontal text.static AnchorWest - reference point is to left of horizontal text. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AnchorcreateAngledAnchor(double theta, Anchor baseAnchor) Returns a new anchor for drawing text at a non-horizontal angle.abstract voiddrawCaption(Caption label, int px, int py, Captioner captioner, Graphics g) Draws a text label onto a given graphics context.abstract RectanglegetCaptionBounds(Caption label, int px, int py, Captioner captioner) Returns a rectangle within which all of the given label will fall.
-
Field Details
-
N
North - reference point is above centre of horizontal text. -
E
East - reference point is to right of horizontal text. -
W
West - reference point is to left of horizontal text. -
S
South - reference point is below center of horizontal text. -
C
Center - reference point is the center of the text.
-
-
Constructor Details
-
Anchor
public Anchor()
-
-
Method Details
-
getCaptionBounds
Returns a rectangle within which all of the given label will fall.- Parameters:
label- textpx- reference point X positionpy- reference point Y positioncaptioner- object that can turn text into graphics- Returns:
- plotted text bounding box
-
drawCaption
Draws a text label onto a given graphics context.- Parameters:
label- textpx- reference point X positionpy- reference point Y positioncaptioner- object that can turn text into graphicsg- graphics context
-
createAngledAnchor
Returns a new anchor for drawing text at a non-horizontal angle.- Parameters:
theta- rotation angle anticlockwise from X axis in radiansbaseAnchor- anchor supplying positioning constraints for horizontal text- Returns:
- new anchor
-