Documentation of 'edu.rit.numeric.plot.impl.Label' Java class
Label
edu.rit.numeric.plot.impl

Class Label

  • All Implemented Interfaces:
    Drawable, java.io.Externalizable, java.io.Serializable


    public class Label
    extends java.lang.Object
    implements Drawable, java.io.Externalizable
    Class Label provides an object for drawing arbitrary text on a plot. A label has a location, a certain pair of coordinates (x,y) on the plot. A label can be drawn at any one of nine positions relative to its location: above left, above, above right, left, center, right, below left, below, or below right. A label can be offset a certain distance from its location. A label can be not rotated, rotated 90 degrees left, rotated 90 degrees right, or rotated 180 degrees. A label's location can be specified either in plot coordinates or in pixel coordinates.

    Class Label supports a subset of HTML for specifying attributes of characters. The following HTML tags may be embedded in a label's text:

    • <B>Bold</B>
    • <I>Italic</I>
    • <SUP>Superscript</SUP>
    • <SUB>Subscript</SUB>

    To get literal less-than, greater-than, and ampersand characters in the text, use the following HTML character entities:

    • &lt; -- Less-than (<)
    • &gt; -- Greater-than (>)
    • &amp; -- Ampersand (&)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int ABOVE
      The label is positioned above its location.
      static int ABOVE_LEFT
      The label is positioned above and to the left of its location.
      static int ABOVE_RIGHT
      The label is positioned above and to the right of its location.
      static int BELOW
      The label is positioned below its location.
      static int BELOW_LEFT
      The label is positioned below and to the left of its location.
      static int BELOW_RIGHT
      The label is positioned below and to the right of its location.
      static int CENTER
      The label is centered on its location.
      static java.awt.Font DEFAULT_FONT
      The default label font (sanserif, plain, 12 point).
      static java.awt.Color DEFAULT_PAINT
      The default label color (black).
      static int LEFT
      The label is positioned to the left of its location.
      static int PIXEL_COORDINATES
      The label's location is specified in pixel coordinates relative to the lower left corner of the plot area, rather than in plot coordinates.
      static int RIGHT
      The label is positioned to the right of its location.
      static int ROTATE_AROUND
      The label is rotated 180 degrees around.
      static int ROTATE_LEFT
      The label is rotated 90 degrees left (counterclockwise).
      static int ROTATE_RIGHT
      The label is rotated 90 degrees right (clockwise).
    • Constructor Summary

      Constructors 
      Constructor and Description
      Label()
      Construct a new label.
      Label(java.lang.String text, double x, double y)
      Construct a new label with the given text and location.
      Label(java.lang.String text, double x, double y, int position)
      Construct a new label with the given text, location, and positioning.
      Label(java.lang.String text, double x, double y, int position, double offset)
      Construct a new label with the given text, location, positioning, and offset from its location.
      Label(java.lang.String text, double x, double y, int position, double offset, java.awt.Font font)
      Construct a new label with the given text, location, positioning, offset from its location, and font.
      Label(java.lang.String text, double x, double y, int position, double offset, java.awt.Font font, java.awt.Color color)
      Construct a new label with the given text, location, positioning, offset from its location, font, and color.
      Label(java.lang.String text, double x, double y, int position, double offset, java.awt.Font font, java.awt.Color color, java.awt.Color bg)
      Construct a new label with the given text, location, positioning, offset from its location, font, color, and background.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void draw(java.awt.Graphics2D g2d)
      Draw this drawable object in the given graphics context.
      java.awt.Color getBackground()
      Returns the color for drawing this label's background on the display.
      java.awt.Color getColor()
      Returns the color for drawing this label on the display.
      java.awt.Font getFont()
      Returns this label's font.
      double getLocationX()
      Returns the X coordinate of this label's location.
      double getLocationY()
      Returns the Y coordinate of this label's location.
      double getOffset()
      Returns this label's offset from its location on the display (in display units).
      int getPositioning()
      Returns this label's positioning.
      java.lang.String getText()
      Returns this label's text.
      void readExternal(java.io.ObjectInput in)
      Read this label from the given object input stream.
      void writeExternal(java.io.ObjectOutput out)
      Write this label to the given object output stream.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ABOVE_LEFT

        public static final int ABOVE_LEFT
        The label is positioned above and to the left of its location.
        See Also:
        Constant Field Values
      • ABOVE

        public static final int ABOVE
        The label is positioned above its location.
        See Also:
        Constant Field Values
      • ABOVE_RIGHT

        public static final int ABOVE_RIGHT
        The label is positioned above and to the right of its location.
        See Also:
        Constant Field Values
      • LEFT

        public static final int LEFT
        The label is positioned to the left of its location.
        See Also:
        Constant Field Values
      • CENTER

        public static final int CENTER
        The label is centered on its location.
        See Also:
        Constant Field Values
      • RIGHT

        public static final int RIGHT
        The label is positioned to the right of its location.
        See Also:
        Constant Field Values
      • BELOW_LEFT

        public static final int BELOW_LEFT
        The label is positioned below and to the left of its location.
        See Also:
        Constant Field Values
      • BELOW

        public static final int BELOW
        The label is positioned below its location.
        See Also:
        Constant Field Values
      • BELOW_RIGHT

        public static final int BELOW_RIGHT
        The label is positioned below and to the right of its location.
        See Also:
        Constant Field Values
      • ROTATE_LEFT

        public static final int ROTATE_LEFT
        The label is rotated 90 degrees left (counterclockwise).
        See Also:
        Constant Field Values
      • ROTATE_RIGHT

        public static final int ROTATE_RIGHT
        The label is rotated 90 degrees right (clockwise).
        See Also:
        Constant Field Values
      • ROTATE_AROUND

        public static final int ROTATE_AROUND
        The label is rotated 180 degrees around.
        See Also:
        Constant Field Values
      • PIXEL_COORDINATES

        public static final int PIXEL_COORDINATES
        The label's location is specified in pixel coordinates relative to the lower left corner of the plot area, rather than in plot coordinates.
        See Also:
        Constant Field Values
      • DEFAULT_FONT

        public static final java.awt.Font DEFAULT_FONT
        The default label font (sanserif, plain, 12 point).
      • DEFAULT_PAINT

        public static final java.awt.Color DEFAULT_PAINT
        The default label color (black).
    • Constructor Detail

      • Label

        public Label()
        Construct a new label. This constructor is intended for use only by object deserialization.
      • Label

        public Label(java.lang.String text,
                     double x,
                     double y)
        Construct a new label with the given text and location. The label is centered on its location and is not rotated. The default font and color are used. The label has no background.
        Parameters:
        text - Label text.
        x - X coordinate of this label's location.
        y - Y coordinate of this label's location.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if text is null.
      • Label

        public Label(java.lang.String text,
                     double x,
                     double y,
                     int position)
        Construct a new label with the given text, location, and positioning. The default font and color are used. The label has no background.
        Parameters:
        text - Label text.
        x - X coordinate of this label's location.
        y - Y coordinate of this label's location.
        position - This label's positioning, ABOVE_LEFT through BELOW_RIGHT. Optionally, ROTATE_LEFT through ROTATE_AROUND may be added; e.g., LEFT+ROTATE_LEFT. Optionally, PIXEL_COORDINATES may be added.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if text is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if position is invalid.
      • Label

        public Label(java.lang.String text,
                     double x,
                     double y,
                     int position,
                     double offset)
        Construct a new label with the given text, location, positioning, and offset from its location. The default font and color are used. The label has no background. If the label's positioning is CENTER, the offset is not used.
        Parameters:
        text - Label text.
        x - X coordinate of this label's location.
        y - Y coordinate of this label's location.
        position - This label's positioning, ABOVE_LEFT through BELOW_RIGHT. Optionally, ROTATE_LEFT through ROTATE_AROUND may be added; e.g., LEFT+ROTATE_LEFT. Optionally, PIXEL_COORDINATES may be added.
        offset - Offset from this label's location on the display (in display units).
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if text is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if position is invalid. Thrown if offset is less than 0.
      • Label

        public Label(java.lang.String text,
                     double x,
                     double y,
                     int position,
                     double offset,
                     java.awt.Font font)
        Construct a new label with the given text, location, positioning, offset from its location, and font. The default color is used. The label has no background. If the label's positioning is CENTER, the offset is not used.
        Parameters:
        text - Label text.
        x - X coordinate of this label's location.
        y - Y coordinate of this label's location.
        position - This label's positioning, ABOVE_LEFT through BELOW_RIGHT. Optionally, ROTATE_LEFT through ROTATE_AROUND may be added; e.g., LEFT+ROTATE_LEFT. Optionally, PIXEL_COORDINATES may be added.
        offset - Offset from this label's location on the display (in display units).
        font - Font for drawing this label.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if text is null or font is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if position is invalid. Thrown if offset is less than 0.
      • Label

        public Label(java.lang.String text,
                     double x,
                     double y,
                     int position,
                     double offset,
                     java.awt.Font font,
                     java.awt.Color color)
        Construct a new label with the given text, location, positioning, offset from its location, font, and color. The label has no background. If the label's positioning is CENTER, the offset is not used.
        Parameters:
        text - Label text.
        x - X coordinate of this label's location.
        y - Y coordinate of this label's location.
        position - This label's positioning, ABOVE_LEFT through BELOW_RIGHT. Optionally, ROTATE_LEFT through ROTATE_AROUND may be added; e.g., LEFT+ROTATE_LEFT. Optionally, PIXEL_COORDINATES may be added.
        offset - Offset from this label's location on the display (in display units).
        font - Font for drawing this label.
        color - Color for drawing this label.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if text is null, font is null, or color is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if position is invalid. Thrown if offset is less than 0.
      • Label

        public Label(java.lang.String text,
                     double x,
                     double y,
                     int position,
                     double offset,
                     java.awt.Font font,
                     java.awt.Color color,
                     java.awt.Color bg)
        Construct a new label with the given text, location, positioning, offset from its location, font, color, and background. If bg is null, the label has no background. If the label's positioning is CENTER, the offset is not used.
        Parameters:
        text - Label text.
        x - X coordinate of this label's location.
        y - Y coordinate of this label's location.
        position - This label's positioning, ABOVE_LEFT through BELOW_RIGHT. Optionally, ROTATE_LEFT through ROTATE_AROUND may be added; e.g., LEFT+ROTATE_LEFT. Optionally, PIXEL_COORDINATES may be added.
        offset - Offset from this label's location on the display (in display units).
        font - Font for drawing this label.
        color - Color for drawing this label.
        bg - Color for drawing this label's background.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if text is null, font is null, or color is null.
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if position is invalid. Thrown if offset is less than 0.
    • Method Detail

      • getText

        public java.lang.String getText()
        Returns this label's text.
      • getLocationX

        public double getLocationX()
        Returns the X coordinate of this label's location.
      • getLocationY

        public double getLocationY()
        Returns the Y coordinate of this label's location.
      • getPositioning

        public int getPositioning()
        Returns this label's positioning. The return value is ABOVE_LEFT through BELOW_RIGHT. If the label is rotated, one of the values ROTATE_LEFT through ROTATE_AROUND is added. If the pixel's location is specified in pixel coordinates rather than plot coordinates, PIXEL_COORDINATES is added.
      • getOffset

        public double getOffset()
        Returns this label's offset from its location on the display (in display units).
      • getFont

        public java.awt.Font getFont()
        Returns this label's font.
      • getColor

        public java.awt.Color getColor()
        Returns the color for drawing this label on the display.
      • getBackground

        public java.awt.Color getBackground()
        Returns the color for drawing this label's background on the display. If this label has no background, null is returned.
      • draw

        public void draw(java.awt.Graphics2D g2d)
        Draw this drawable object in the given graphics context. Upon return from this method, the given graphics context's state (color, font, transform, clip, and so on) is the same as it was upon entry to this method.

        The label is drawn at position (0,0). It is the caller's responsibility to transform the graphics context so the label ends up at the correct (x,y) coordinates.

        Specified by:
        draw in interface Drawable
        Parameters:
        g2d - 2-D graphics context.
      • writeExternal

        public void writeExternal(java.io.ObjectOutput out)
                           throws java.io.IOException
        Write this label to the given object output stream.
        Specified by:
        writeExternal in interface java.io.Externalizable
        Parameters:
        out - Object output stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
      • readExternal

        public void readExternal(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Read this label from the given object input stream.
        Specified by:
        readExternal in interface java.io.Externalizable
        Parameters:
        in - Object input stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
        java.lang.ClassNotFoundException - Thrown if a class needed to deserialize this label could not be found.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.