Package hec.gfx2d

Class G2dLabel

All Implemented Interfaces:
G2dToolbarListener, ImageObserver, MenuContainer, Serializable, Observer, Accessible
Direct Known Subclasses:
AxisLabel, G2dTitle

public class G2dLabel extends G2dComponent implements Observer
A component that displays the label of an Axis.
See Also:
  • Field Details

  • Constructor Details

    • G2dLabel

      public G2dLabel(G2dPanel p, int align)
    • G2dLabel

      public G2dLabel(G2dPanel p, int align, int rot)
  • Method Details

    • getPopupMenuTitle

      protected String getPopupMenuTitle()
    • createPopupMenu

      public void createPopupMenu()
      Overrides:
      createPopupMenu in class G2dComponent
    • update

      public void update(Observable o, Object arg)
      Specified by:
      update in interface Observer
    • setProperties

      public void setProperties(G2dLabelDrawProp prop)
    • getProperties

      public G2dLabelDrawProp getProperties()
    • setUseFontScaling

      public void setUseFontScaling(boolean b)
    • getUseFontScaling

      public boolean getUseFontScaling()
    • getFontString

      public String getFontString()
      Gets font information in the form of a font string (([Name],[Style],[Size]))
      Returns:
      The font string
    • setFont

      public void setFont(Font f)
      Sets the font and font information from a Font object
      Overrides:
      setFont in class JComponent
      Parameters:
      f - The Font object
    • setFont

      public void setFont(String fontString)
      Sets font information from a font string ([Name],[Style],[Size])
      Parameters:
      fontString - The font string
    • setFontInfo

      public void setFontInfo(Font f)
      Sets font information from a Font object
      Parameters:
      f - The Font object
    • setFontSize

      public void setFontSize(int sz)
      set the Font Size of this label to sz
      Parameters:
      sz - the new font size
    • getFontSize

      public int getFontSize()
      get the Font Size for this label
      Returns:
      the Font Size
    • setFontSizes

      public void setFontSizes(int sz, int tiny, int min, int max)
      set the font sizes for this label
      Parameters:
      sz - the normal font size
      tiny - the tiny font size
      min - the minimum font size
      max - the maximum font size
    • getFontSizes

      public int[] getFontSizes()
      get the fonts sizes used by this label
      Returns:
      [0] the normal font size
      [1] the tiny font size
      [2] the min font size
      [3] the max font size
    • setFontStyle

      public void setFontStyle(String style)
      set the font style for this G2dLabel
      Parameters:
      style - is one of the four case-insensitive strings: "PLAIN", "BOLD", "BOLDITALIC", or "ITALIC",
    • getFontStyle

      public int getFontStyle()
      get the font style for this label
      Returns:
      the font style
    • getFontStyleString

      public String getFontStyleString()
      return the Font Style as a String
      Returns:
      one of the four strings: "PLAIN", "BOLD", "BOLDITALIC", or "ITALIC",
    • setFontStyle

      public void setFontStyle(int style)
    • setFontFamily

      public void setFontFamily(String fam)
    • getFontFamily

      public String getFontFamily()
      get the font family for this label
      Returns:
      the font family
    • setIcon

      public void setIcon(String iconPath)
      Sets the icon to display.
      Parameters:
      iconPath - the path to the icon
    • setIcon

      public void setIcon(Icon icon)
    • getIcon

      public Icon getIcon()
      return the Icon that this Label displays
      Returns:
      the Icon
    • getIconPath

      public String getIconPath()
      return the path to the Icon file that this label displays
      Returns:
      the Icon's path
    • setText

      public void setText(String txt)
      set the text for this label
      Parameters:
      txt - the new text
    • setText

      public void setText(String txt, String delim)
    • getText

      public String getText()
    • getMinimumSize

      public Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent
    • getMinimumSize

      public Dimension getMinimumSize(Graphics g)
    • getPreferredSizeLocal

      public Dimension getPreferredSizeLocal()
      Compute the preferred size based on label size and orientation
      Overrides:
      getPreferredSizeLocal in class G2dComponent
      Returns:
      Dimension preferred sized of the component
    • getPreferredSize

      public Dimension getPreferredSize(Graphics g)
    • getTextSubstitutionObjects

      public Object[] getTextSubstitutionObjects()
    • paintGfx

      public void paintGfx(Graphics g)
      Description copied from class: G2dComponent
      Paints the contents of the panel.
      Overrides:
      paintGfx in class G2dComponent
    • drawBorder

      protected void drawBorder(Graphics2D g, Dimension dim)
    • getG2dFont

      protected Font getG2dFont()
    • objectPopupMenu

      public boolean objectPopupMenu(LocalPt pt, int modifiers)
      Overrides:
      objectPopupMenu in class G2dComponent
    • addPropertiesOKListener

      public void addPropertiesOKListener(ActionListener listener)
    • editProperties

      public void editProperties()
      Overrides:
      editProperties in class G2dComponent
    • setBackground

      public void setBackground(Color c)
      Overrides:
      setBackground in class JComponent
    • setBackground

      public void setBackground(String colorString)
      Parameters:
      colorString - the color to set the background to
    • getBackgroundString

      public String getBackgroundString()
      get the Background color of this label as a String
      Returns:
      the Background color string
    • setForeground

      public void setForeground(String colorString)
      Parameters:
      colorString - the color to set the foreground to
    • getForegroundString

      public String getForegroundString()
      get the Foreground color of this label as a String
      Returns:
      the Foreground color string
    • setFillColor

      public void setFillColor(Color c)
      set the Fill color of this label
      Parameters:
      c - the fill color as a Color
    • setFillColor

      public void setFillColor(String colorString)
      set the Fill color of this label
      Parameters:
      colorString - the fill color as a String
    • getFillColor

      public Color getFillColor()
      get the Fill color of this label as a Color
      Returns:
      the Fill color
    • getFillColorString

      public String getFillColorString()
      get the Fill color of this label as a String
      Returns:
      the Fill color string
    • setBorderVisible

      public void setBorderVisible(boolean state)
      set the border visibility
      Parameters:
      state -
    • setDrawBorderOn

      @Deprecated public void setDrawBorderOn()
      Deprecated.
      set the border to draw
    • setDrawBorderOff

      @Deprecated public void setDrawBorderOff()
      Deprecated.
      set the border not to draw
    • isBorderVisible

      public boolean isBorderVisible()
      get whether the label border is visible
      Returns:
      whether the label border is visible
    • isBorderDrawn

      @Deprecated public boolean isBorderDrawn()
      Deprecated.
      get whether the label draws it's border or not
      Returns:
    • setBorderColor

      public void setBorderColor(String colorString)
      set the border color for this G2dLabel
      Parameters:
      colorString - the border color
    • setBackgroundVisible

      public void setBackgroundVisible(boolean state)
      set the background visibility
      Parameters:
      state -
    • setDrawBackgroundOn

      @Deprecated public void setDrawBackgroundOn()
      Deprecated.
      set the background to draw
    • setDrawBackgroundOff

      @Deprecated public void setDrawBackgroundOff()
      Deprecated.
      set the background not to draw
    • isBackgroundVisible

      public boolean isBackgroundVisible()
      get whether the background is visible
      Returns:
      whether the background is visible
    • isBackgroundDrawn

      @Deprecated public boolean isBackgroundDrawn()
      Deprecated.
      get whether the background is drawn or not
      Returns:
    • setBorderWeight

      public void setBorderWeight(float weight)
      set the border weight for this G2dLabel
      Parameters:
      weight - the border weight
    • getBorderWeight

      public float getBorderWeight()
      get the border weight for this G2dLabel
      Returns:
      the border weight
    • setFillPattern

      public void setFillPattern(String pattern)
      set the background fill pattern for this label
      Parameters:
      pattern - the fill pattern
      See Also:
    • getFillPatternString

      public String getFillPatternString()
      get the Fill Pattern for this G2dLabel as a String
      Returns:
      the fill pattern String
    • getFillPattern

      public int getFillPattern()
      get the Fill Pattern for this G2dLabel
      Returns:
      the fill pattern
    • setAlignment

      public void setAlignment(String alignment)
      set the text alignment for this G2dLabel
      Parameters:
      alignment - the alignment one of "left", "right" or "center"
    • getAlignmentString

      public String getAlignmentString()
      get the text alignment for this G2dLabel
      Returns:
      one of the three strings: "left", "right" or "center",
    • getAlignment

      public int getAlignment()
      get the text alignment for this G2dLabel
      Overrides:
      getAlignment in class G2dComponent
      Returns:
      the text alignment
    • setRotation

      public void setRotation(int rotation)
      set the text rotation for this G2dLabel
      Parameters:
      rotation - the rotation. one of 0, 90, 180, 270
    • getRotation

      public int getRotation()
      get the text rotation for this G2dLabel
      Returns:
      the text rotation
    • setSpacing

      public void setSpacing(int space)
      set the spacing around this label
      Parameters:
      space - the spacing
    • getSpacing

      public int getSpacing()
      get the spacing around this label
      Returns:
      the spacing
    • setBorderStyle

      public void setBorderStyle(String style)
      set the border style for this G2dLabel
      Parameters:
      style - the border style
    • getBorderStyleString

      public String getBorderStyleString()
      get the border style for this G2dLabel as a String
      Returns:
      the border style string