Class JDLabel


public class JDLabel extends JDRectangular
JDraw Label graphic object.
  • Field Details

    • CENTER_ALIGNMENT

      public static final int CENTER_ALIGNMENT
      Text is centered
      See Also:
    • LEFT_ALIGNMENT

      public static final int LEFT_ALIGNMENT
      Left justification for text (H alignement)
      See Also:
    • RIGHT_ALIGNMENT

      public static final int RIGHT_ALIGNMENT
      Right justification for text (H alignement)
      See Also:
    • UP_ALIGNMENT

      public static final int UP_ALIGNMENT
      Up justification for text (V alignement)
      See Also:
    • DOWN_ALIGNMENT

      public static final int DOWN_ALIGNMENT
      Down justification for text (V alignement)
      See Also:
    • LEFT_TO_RIGHT

      public static final int LEFT_TO_RIGHT
      Text orientation
      See Also:
    • BOTTOM_TO_TOP

      public static final int BOTTOM_TO_TOP
      Text orientation
      See Also:
    • RIGHT_TO_LEFT

      public static final int RIGHT_TO_LEFT
      Text orientation
      See Also:
    • TOP_TO_BOTTOM

      public static final int TOP_TO_BOTTOM
      Text orientation
      See Also:
  • Constructor Details

    • JDLabel

      public JDLabel(String objectName, String text, int x, int y)
      Construcxt a label.
      Parameters:
      objectName - Name of this label
      text - Text
      x - Up left corner x coordinate
      y - Up left corner y coordinate
  • Method Details

    • copy

      public JDObject copy(int x, int y)
      Description copied from class: JDObject
      Returns a copy of this object at the specified location.
      Specified by:
      copy in class JDObject
      Parameters:
      x - Horizontal position of the copied object (pixel)
      y - Vertical Position of the copied object (pixel)
      Returns:
      The copy of this object.
    • paint

      public void paint(JDrawEditor parent, Graphics g)
      Description copied from class: JDObject
      Paints this object.
      Overrides:
      paint in class JDRectangular
      Parameters:
      parent - JdrawEditor parent (Can be null except for JDSwingObject)
      g - the specified Graphics window
    • rotate90

      public void rotate90(double x, double y)
      Description copied from class: JDObject
      Rotate the object by 90deg. A call to refresh() is needed after transformation.
      Overrides:
      rotate90 in class JDRectangular
      Parameters:
      x - Rotation center horizontal pos
      y - Rotation center vertical pos
      See Also:
    • restoreTransform

      public void restoreTransform()
      Description copied from class: JDObject
      Restore original shape previously backuped by saveTransform
      Overrides:
      restoreTransform in class JDObject
      See Also:
    • saveTransform

      public void saveTransform()
      Description copied from class: JDObject
      Backup the shape. This can be usefull when making scaling animation, after multiple scale the rounding may result in deformed shape. To avoid this you can use saveTransform() and restoreTransform(). Note: This is done once when JDrawEditor.loadFile() is called().
      Overrides:
      saveTransform in class JDObject
      See Also:
    • setFont

      public void setFont(Font f)
      Sets the Font of this label.
      Parameters:
      f - Font
    • setFont

      public void setFont(Font f, boolean resize)
      Sets the font of this label and resize it if needed and specified.
      Parameters:
      f - Font
      resize - true to resize label when text is out of bounds.
    • getFont

      public Font getFont()
      Returns:
      the current font of this label.
    • setHorizontalAlignment

      public void setHorizontalAlignment(int a)
      Sets the horizontal alignement of this label.
      Parameters:
      a - Alignement value
      See Also:
    • getHorizontalAlignment

      public int getHorizontalAlignment()
      Returns:
      the current horizontal text alignement.
      See Also:
    • setVerticalAlignment

      public void setVerticalAlignment(int a)
      Sets the vertical alignement of this label.
      Parameters:
      a - Alignement value
      See Also:
    • setVerticalAlignment

      public int setVerticalAlignment()
      Returns:
      the current vetical text alignement.
      See Also:
    • setOrientation

      public void setOrientation(int a)
      Sets the text orientation.
      Parameters:
      a - Orientation
      See Also:
    • getOrientation

      public int getOrientation()
      Returns:
      the current text orientation.
      See Also:
    • setText

      public void setText(String s)
      Sets the text of this label.
      Parameters:
      s - Text value
    • setText

      public void setText(String s, boolean resize)
      Sets the text of this label and resize label if desried.
      Parameters:
      s - Text value
      resize - true to resize label when text is out of bounds.
    • getText

      public String getText()
      Returns:
      the current label text.