Documentation of 'de.erichseifert.gral.graphics.Label' Java class
Label
de.erichseifert.gral.graphics

Class Label

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


    public class Label
    extends AbstractDrawable
    Class that draws a label to a specific location. A Label is able to manage its settings and to set and get the displayed text, as well as calculating its bounds.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Label()
      Initializes a new empty Label instance.
      Label(java.lang.String text)
      Initializes a new Label instance with the specified text.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void draw(DrawingContext context)
      Draws the object with the specified drawing context.
      boolean equals(java.lang.Object obj) 
      double getAlignmentX()
      Returns the horizontal alignment within the bounding rectangle.
      double getAlignmentY()
      Returns the vertical alignment within the bounding rectangle.
      java.awt.Paint getBackground()
      Returns the background color.
      java.awt.Paint getColor()
      Returns the paint used to draw the label shape.
      java.awt.Font getFont()
      Returns the font used to display the text of this label.
      java.awt.geom.Dimension2D getPreferredSize()
      Returns the preferred size of the Drawable.
      double getRotation()
      Returns the rotation of this label.
      java.lang.String getText()
      Returns the text of this label.
      double getTextAlignment()
      Returns the alignment of text with multiple lines.
      java.awt.geom.Rectangle2D getTextRectangle()
      Returns the bounding rectangle of the text without rotation or word wrapping.
      boolean isWordWrapEnabled()
      Returns whether words of the text should be wrapped to fit the size of the label.
      void setAlignmentX(double alignmentX)
      Sets the horizontal alignment within the bounding rectangle.
      void setAlignmentY(double alignmentY)
      Sets the vertical alignment within the bounding rectangle.
      void setBackground(java.awt.Paint background)
      Sets the background color to the specified value.
      void setBounds(double x, double y, double width, double height)
      Sets the bounds to the specified coordinates, width and height.
      void setColor(java.awt.Paint color)
      Sets the paint used to draw the label shape.
      void setFont(java.awt.Font font)
      Sets the font used to display the text of this label.
      void setRotation(double angle)
      Sets the rotation of this label.
      void setText(java.lang.String text)
      Sets the displayed text to the specified value.
      void setTextAlignment(double textAlignment)
      Sets the alignment of text with multiple lines.
      void setWordWrapEnabled(boolean wordWrapEnabled)
      Sets whether words of the text should be wrapped to fit the size of the label.
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Label

        public Label()
        Initializes a new empty Label instance.
      • Label

        public Label(java.lang.String text)
        Initializes a new Label instance with the specified text.
        Parameters:
        text - Text to be displayed.
    • Method Detail

      • draw

        public void draw(DrawingContext context)
        Draws the object with the specified drawing context.
        Parameters:
        context - Environment used for drawing
      • getTextRectangle

        public java.awt.geom.Rectangle2D getTextRectangle()
        Returns the bounding rectangle of the text without rotation or word wrapping.
        Returns:
        Bounding rectangle.
      • getText

        public java.lang.String getText()
        Returns the text of this label.
        Returns:
        Text.
      • setText

        public void setText(java.lang.String text)
        Sets the displayed text to the specified value.
        Parameters:
        text - Text to be displayed.
      • setBounds

        public void setBounds(double x,
                              double y,
                              double width,
                              double height)
        Description copied from class: AbstractDrawable
        Sets the bounds to the specified coordinates, width and height. This method should be used when overriding functionality.
        Specified by:
        setBounds in interface Drawable
        Overrides:
        setBounds in class AbstractDrawable
        Parameters:
        x - horizontal position of the upper-left corner
        y - vertical position of the upper-left corner
        width - horizontal extent
        height - vertical extent
      • getAlignmentX

        public double getAlignmentX()
        Returns the horizontal alignment within the bounding rectangle. 0.0 means left, 1.0 means right.
        Returns:
        Horizontal label alignment.
      • setAlignmentX

        public void setAlignmentX(double alignmentX)
        Sets the horizontal alignment within the bounding rectangle. 0.0 means left, 1.0 means right.
        Parameters:
        alignmentX - Horizontal label alignment.
      • getAlignmentY

        public double getAlignmentY()
        Returns the vertical alignment within the bounding rectangle. 0.0 means top, 1.0 means bottom.
        Returns:
        Vertical label alignment.
      • setAlignmentY

        public void setAlignmentY(double alignmentY)
        Sets the vertical alignment within the bounding rectangle. 0.0 means top, 1.0 means bottom.
        Parameters:
        alignmentY - Vertical label alignment.
      • getFont

        public java.awt.Font getFont()
        Returns the font used to display the text of this label.
        Returns:
        Font used for text display.
      • setFont

        public void setFont(java.awt.Font font)
        Sets the font used to display the text of this label.
        Parameters:
        font - Font used for text display.
      • getRotation

        public double getRotation()
        Returns the rotation of this label. The rotation will be counterclockwise.
        Returns:
        Rotation in degrees.
      • setRotation

        public void setRotation(double angle)
        Sets the rotation of this label. The rotation will be counterclockwise.
        Parameters:
        angle - Rotation in degrees.
      • getColor

        public java.awt.Paint getColor()
        Returns the paint used to draw the label shape.
        Returns:
        Paint for shape drawing.
      • setColor

        public void setColor(java.awt.Paint color)
        Sets the paint used to draw the label shape.
        Parameters:
        color - Paint for shape drawing.
      • getTextAlignment

        public double getTextAlignment()
        Returns the alignment of text with multiple lines. 0.0 means left, 1.0 means right.
        Returns:
        Relative text alignment.
      • setTextAlignment

        public void setTextAlignment(double textAlignment)
        Sets the alignment of text with multiple lines. 0.0 means left, 1.0 means right.
        Parameters:
        textAlignment - Relative text alignment.
      • isWordWrapEnabled

        public boolean isWordWrapEnabled()
        Returns whether words of the text should be wrapped to fit the size of the label.
        Returns:
        true if the text should be wrapped, false otherwise.
      • setWordWrapEnabled

        public void setWordWrapEnabled(boolean wordWrapEnabled)
        Sets whether words of the text should be wrapped to fit the size of the label.
        Parameters:
        wordWrapEnabled - true if the text should be wrapped, false otherwise.
      • getBackground

        public java.awt.Paint getBackground()
        Returns the background color.
        Returns:
        Background color or null, if no background is defined.
      • setBackground

        public void setBackground(java.awt.Paint background)
        Sets the background color to the specified value.
        Parameters:
        background - Background color.
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.