Package ca.ualberta.stothard.cgview
Class Label
java.lang.Object
ca.ualberta.stothard.cgview.Label
- All Implemented Interfaces:
CgviewConstants
- Direct Known Subclasses:
InnerLabel
,OuterLabel
This class is used by Cgview objects to facilitate label layout and drawing.
- Author:
- Paul Stothard
-
Field Summary
Modifier and TypeFieldDescriptionprotected double
protected float
protected Cgview
protected Color
protected float
protected double
protected double
protected boolean
protected boolean
protected Font
protected boolean
protected String
protected String
protected double
protected double
protected double
protected double
protected String
protected Rectangle2D
protected static double
protected static double
protected static double
protected static double
protected int
protected Rectangle2D
Fields inherited from interface ca.ualberta.stothard.cgview.CgviewConstants
BASES, BOUNDS_BUTTON, BOUNDS_FEATURE, BOUNDS_RULER, CENTISOMES, DECORATION_CLOCKWISE_ARROW, DECORATION_COUNTERCLOCKWISE_ARROW, DECORATION_HIDDEN, DECORATION_STANDARD, DIRECT_STRAND, INNER_LABELS_AUTO, INNER_LABELS_NO_SHOW, INNER_LABELS_SHOW, LABEL, LABEL_FORCE, LABEL_NONE, LABEL_ZOOMED, LEGEND_DRAW_ZOOMED, LEGEND_ITEM_ALIGN_CENTER, LEGEND_ITEM_ALIGN_LEFT, LEGEND_ITEM_ALIGN_RIGHT, LEGEND_LOWER_CENTER, LEGEND_LOWER_LEFT, LEGEND_LOWER_RIGHT, LEGEND_MIDDLE_CENTER, LEGEND_MIDDLE_LEFT, LEGEND_MIDDLE_LEFT_OF_CENTER, LEGEND_MIDDLE_RIGHT, LEGEND_MIDDLE_RIGHT_OF_CENTER, LEGEND_NO_DRAW_ZOOMED, LEGEND_UPPER_CENTER, LEGEND_UPPER_LEFT, LEGEND_UPPER_RIGHT, POSITIONS_AUTO, POSITIONS_NO_SHOW, POSITIONS_SHOW, REVERSE_STRAND, SWATCH_NO_SHOW, SWATCH_SHOW
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Returns a boolean specifying whether or not this Label clashes with the supplied Label.protected abstract boolean
protected boolean
clashesWithAny
(ArrayList labels) Returns a boolean specifying whether or not this Label clashes with any of the labels in the supplied ArrayList.protected abstract void
protected abstract void
protected void
drawLine
(double startRadius, double startRadians, double endRadius, double endRadians) Draws a line between two points described by radius and radian values.protected void
Draws a line between two points described by radius and radian values.protected abstract boolean
protected abstract boolean
protected Rectangle2D
Returns a rectangle that represents the bounds of this Label.protected double
Returns the radius of the outermost point in the second line (the extended line) extending from the feature to this Label.protected boolean
Returns a boolean specifying whether or not this label should be drawn even if it cannot be placed such that it does not clash with other labels.protected String
Returns the hyperlink to be associated with this Label.protected String
Returns the text of this Label.protected Area
getLineAsArea
(double startRadius, double startRadians, double endRadius, double endRadians) Returns an Area representing a line between two points described by radius and radian values.protected double
Returns the radians of the outermost point in the line extending from the feature to this Label.protected double
Returns the radius of the outermost point in the line extending from the feature to this Label.protected Point2D
Returns the starting point of the line drawn to this Label.protected double
Returns the radians of the innermost point in the line extending from the feature to this Label.protected double
Returns the radius of the innermost point in the line extending from the feature to this Label.protected String
Returns the mouseover to be associated with this Label.protected boolean
Returns a boolean specifying whether or not the line between the feature and this Label has been extended to prevent label clashes.protected void
setHyperlink
(String hyperlink) Specifies the hyperlink to be associated with this Label.protected abstract void
setLineStartRadius
(double lineStartRadius) protected void
setMouseover
(String mouseover) The mouseover to be associated with this Label.protected final boolean
Attempts to move this Label by increasing its radians value.protected final boolean
Attempts to move this Label by decreasing its radians value.protected boolean
shiftRadiansToOriginal
(ArrayList labels) Attempts to move this Label by adjusting its radians value such that it is closer to its original radians value.protected abstract void
protected abstract void
updateBounds
(double padding)
-
Field Details
-
labelText
-
color
-
strand
protected int strand -
hyperlink
-
mouseover
-
lineStartRadians
protected double lineStartRadians -
lineStartRadius
protected double lineStartRadius -
lineEndRadians
protected double lineEndRadians -
lineEndRadius
protected double lineEndRadius -
extendedRadius
protected boolean extendedRadius -
extendedLineStartRadius
protected double extendedLineStartRadius -
extendedLineEndRadius
protected double extendedLineEndRadius -
fixedInPlace
protected boolean fixedInPlace -
allowedRadiansDelta
protected double allowedRadiansDelta -
radiusShiftAmount
protected static double radiusShiftAmount -
radiansShiftAmount
protected static double radiansShiftAmount -
unplacedBounds
-
placedBounds
-
font
-
descent
protected float descent -
ascent
protected float ascent -
forceLabel
protected boolean forceLabel -
cgview
-
smallestDimension
protected static double smallestDimension -
RADIAN_SHIFT_PADDING
protected static double RADIAN_SHIFT_PADDING
-
-
Constructor Details
-
Label
protected Label(Cgview cgview, String labelText, String hyperlink, String mouseover, Font font, Color color, boolean forceLabel, double lineStartRadians, int strand) Constructs a new Label object.- Parameters:
cgview
- the Cgview object to contain this Label.labelText
- the text that is to be drawn.hyperlink
- a hyperlink to be associated with this Label.mouseover
- mouseover information to be associated with this Label.font
- the font to use when drawing this Label.color
- the color to use when drawing this Label.forceLabel
- whether or not this Label should be drawn even if it cannot be placed such that it does not clash with other labels.lineStartRadians
- the angle in radians of the line extending from the feature to this Label.strand
- the strand of this Label (CgviewConstants.DIRECT_STRAND
orCgviewConstants.REVERSE_STRAND
).
-
-
Method Details
-
drawLabelText
protected abstract void drawLabelText() -
drawLabelLine
protected abstract void drawLabelLine() -
drawLine
protected void drawLine(double startRadius, double startRadians, double endRadius, double endRadians) Draws a line between two points described by radius and radian values.- Parameters:
startRadius
- the radius of the first point.startRadians
- the radians of the first point.endRadius
- the radius of the second point.endRadians
- the radians of the second point.
-
drawLine
protected void drawLine(double startRadius, double startRadians, double endRadius, double endRadians, Area area) Draws a line between two points described by radius and radian values.- Parameters:
startRadius
- the radius of the first point.startRadians
- the radians of the first point.endRadius
- the radius of the second point.endRadians
- the radians of the second point.area
- an area to add to the line.
-
getLineAsArea
protected Area getLineAsArea(double startRadius, double startRadians, double endRadius, double endRadians) Returns an Area representing a line between two points described by radius and radian values.- Parameters:
startRadius
- the radius of the first point.startRadians
- the radians of the first point.endRadius
- the radius of the second point.endRadians
- the radians of the second point.- Returns:
- an Area to add to the line.
-
getLineStart
Returns the starting point of the line drawn to this Label.- Returns:
- the starting point of the line drawn to this Label.
-
getLineStartRadians
protected double getLineStartRadians()Returns the radians of the innermost point in the line extending from the feature to this Label.- Returns:
- the radians of the innermost point in the label line.
-
getLineEndRadians
protected double getLineEndRadians()Returns the radians of the outermost point in the line extending from the feature to this Label.- Returns:
- the radians of the outermost point in the label line.
-
isExtendedRadius
protected boolean isExtendedRadius()Returns a boolean specifying whether or not the line between the feature and this Label has been extended to prevent label clashes.- Returns:
- a
boolean
representing whether or not the line between the feature and this Label has been extended to prevent label clashes.
-
getLineStartRadius
protected double getLineStartRadius()Returns the radius of the innermost point in the line extending from the feature to this Label.- Returns:
- the radius of the innermost point in the label line.
-
getLineEndRadius
protected double getLineEndRadius()Returns the radius of the outermost point in the line extending from the feature to this Label.- Returns:
- the radius of the outermost point in the label line.
-
getExtendedLineEndRadius
protected double getExtendedLineEndRadius()Returns the radius of the outermost point in the second line (the extended line) extending from the feature to this Label.- Returns:
- the radius of the outermost point in the second label line.
-
getForceLabel
protected boolean getForceLabel()Returns a boolean specifying whether or not this label should be drawn even if it cannot be placed such that it does not clash with other labels.- Returns:
- a
boolean
specifying whether or not this Label should be drawn even if it cannot be placed such that it does not clash with other labels.
-
updateBounds
protected abstract void updateBounds() -
updateBounds
protected abstract void updateBounds(double padding) -
getBounds
Returns a rectangle that represents the bounds of this Label.updateBounds()
should be used to calculate the bounds if the Label has been moved since the last call toupdateBounds()
.- Returns:
- the bounds of this Label.
-
clashes
Returns a boolean specifying whether or not this Label clashes with the supplied Label.- Parameters:
testLabel
- a Label object.- Returns:
- a
boolean
specifying whether this label clashes with the supplied label.
-
clashesWithAny
protected abstract boolean clashesWithAny() -
shiftRadiansLower
protected final boolean shiftRadiansLower()Attempts to move this Label by decreasing its radians value. If the angle between the the start of the label line and the label text is at the maximum acceptable value the label is not moved.- Returns:
- a
boolean
specifing whether or not this Label was moved.
-
shiftRadiansHigher
protected final boolean shiftRadiansHigher()Attempts to move this Label by increasing its radians value. If the angle between the the start of the label line and the label text is at the maximum acceptable value the label is not moved.- Returns:
- a
boolean
specifing whether or not this Label was moved.
-
shiftRadiansToOriginal
Attempts to move this Label by adjusting its radians value such that it is closer to its original radians value. If the adjustment introduces a conflict for space with other labels, this Label is not moved.- Returns:
- a
boolean
specifing whether or not this Label was moved.
-
extendRadius
protected abstract boolean extendRadius() -
setLineStartRadius
protected abstract void setLineStartRadius(double lineStartRadius) -
clashesWithAny
Returns a boolean specifying whether or not this Label clashes with any of the labels in the supplied ArrayList.- Parameters:
labels
- a list of Label objects.- Returns:
- a
boolean
specifying whether or not this Label clashes with any of the Label objects in the supplied list.
-
fitsInBackground
protected abstract boolean fitsInBackground() -
setHyperlink
Specifies the hyperlink to be associated with this Label.- Parameters:
hyperlink
- the hyperlink to be associated with this Label.
-
getHyperlink
Returns the hyperlink to be associated with this Label.- Returns:
- the hyperlink to be associated with this Label.
-
getLabelText
Returns the text of this Label.- Returns:
- the text of this Label.
-
setMouseover
The mouseover to be associated with this Label.- Parameters:
mouseover
- the mouseover to be associated with this Label.
-
getMouseover
Returns the mouseover to be associated with this Label.- Returns:
- the mouseover to be associated with this Label.
-