Package org.jzy3d.plot3d.primitives.axis
Class AxisLabelRotator
- java.lang.Object
-
- org.jzy3d.plot3d.primitives.axis.AxisLabelRotator
-
public class AxisLabelRotator extends Object
An helper class to process the orientation of text according to a driving axis defined by 2 3D or 2D points (already resulting from a screen projection).- Author:
- Martin Pernollet
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AxisLabelRotator.TextLayout
-
Constructor Summary
Constructors Constructor Description AxisLabelRotator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
computeSegmentRotation(Coord3d p1, Coord3d p2)
Compute the 2D orientation (rotation) of an axis as it is currently displayed to screen (which may change according to camera viewpoint) Schema sourcefloat
computeSegmentRotation2D(IPainter painter, Coord3d[] axisSegment)
Compute the 2D orientation (rotation) of an axis made of 2 3D points.AxisLabelRotator.TextLayout
computeTextLayout(IPainter painter, Coord3d[] segment3D, Coord3d center3D, Coord3d label3D, float offset)
Compute the 2D offset and rotation required to have axis label cleanly fitting around and axis and being parallel to the axis (as displayed in 2D on screen).
-
-
-
Method Detail
-
computeSegmentRotation2D
public float computeSegmentRotation2D(IPainter painter, Coord3d[] axisSegment)
Compute the 2D orientation (rotation) of an axis made of 2 3D points. The 2D orientation is processed according to the viewpoint on this segment. Schema source- segment[0] : 3D world coordinates of the starting point of the axis segment.
- segment[1] : 3D world coordinates of the ending point of the axis segment.
- Returns:
-
computeSegmentRotation
public float computeSegmentRotation(Coord3d p1, Coord3d p2)
Compute the 2D orientation (rotation) of an axis as it is currently displayed to screen (which may change according to camera viewpoint) Schema source- Parameters:
p1
- 2D screen coordinates of the starting point of the axis segment.p2
- 2D screen coordinates of the ending point of the axis segment. NB : the third dimension of the screen coordinates is the depth of the point compared to camera. This may be usefull for guessing the direction of the axis : going toward or away from the viewer according to point order.- Returns:
- rotation in radian
-
computeTextLayout
public AxisLabelRotator.TextLayout computeTextLayout(IPainter painter, Coord3d[] segment3D, Coord3d center3D, Coord3d label3D, float offset)
Compute the 2D offset and rotation required to have axis label cleanly fitting around and axis and being parallel to the axis (as displayed in 2D on screen). The below schema decypher the axis label rotation processing of this method : Schema source- Parameters:
painter
-segment3D
- a pair of 3D coordinates describing the axis segment.center3D
- the center of the axis collection (for a ternary axis, the center of a bottom or top triangle).label3D
- the initial 3D position of the label that should be rotated and shifted.offset
- the expected axis-label distance in pixels.- Returns:
- a pair of values indicating the (x,y) offset being either positive or negative, and a rotation for the label to remain parallel to the input segment.
-
-