Class Label

java.lang.Object
ca.ualberta.stothard.cgview.Label
All Implemented Interfaces:
CgviewConstants
Direct Known Subclasses:
InnerLabel, OuterLabel

public abstract class Label extends Object implements CgviewConstants
This class is used by Cgview objects to facilitate label layout and drawing.
Author:
Paul Stothard
  • Field Details

    • labelText

      protected String labelText
    • color

      protected Color color
    • strand

      protected int strand
    • mouseover

      protected String 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

      protected Rectangle2D unplacedBounds
    • placedBounds

      protected Rectangle2D placedBounds
    • font

      protected Font font
    • descent

      protected float descent
    • ascent

      protected float ascent
    • forceLabel

      protected boolean forceLabel
    • cgview

      protected Cgview 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 or CgviewConstants.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

      protected Point2D 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

      protected Rectangle2D 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 to updateBounds().
      Returns:
      the bounds of this Label.
    • clashes

      protected boolean clashes(Label testLabel)
      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

      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. 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

      protected boolean clashesWithAny(ArrayList labels)
      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

      protected void setHyperlink(String hyperlink)
      Specifies the hyperlink to be associated with this Label.
      Parameters:
      hyperlink - the hyperlink to be associated with this Label.
    • getHyperlink

      protected String getHyperlink()
      Returns the hyperlink to be associated with this Label.
      Returns:
      the hyperlink to be associated with this Label.
    • getLabelText

      protected String getLabelText()
      Returns the text of this Label.
      Returns:
      the text of this Label.
    • setMouseover

      protected void setMouseover(String mouseover)
      The mouseover to be associated with this Label.
      Parameters:
      mouseover - the mouseover to be associated with this Label.
    • getMouseover

      protected String getMouseover()
      Returns the mouseover to be associated with this Label.
      Returns:
      the mouseover to be associated with this Label.