Class LegendItem

java.lang.Object
ca.ualberta.stothard.cgview.LegendItem
All Implemented Interfaces:
CgviewConstants

public class LegendItem extends Object implements CgviewConstants
This class is used to add text entries to Legend objects.
Author:
Paul Stothard
  • Constructor Details

    • LegendItem

      public LegendItem(Legend legend)
      Constructs a new LegendItem object.
      Parameters:
      legend - the Legend object to contain this LegendItem.
  • Method Details

    • draw

      protected void draw(Cgview cgview, double x, double y, double swatchHeight)
      Draws the contents of this LegendItem.
      Parameters:
      cgview - the Cgview object that contains this LegendItem.
      x - the x-coordinate for the upper left corner of this LegendItem.
      y - the y-coordinate for the upper left corner of this LegendItem.
      swatchHeight - the swatch height for this LegendItem.
    • getWidth

      protected double getWidth(Cgview cgview, double swatchWidth)
      Returns the width of the text in this LegendItem.
      Parameters:
      cgview - the Cgview object that contains this LegendItem.
    • getHeight

      protected double getHeight(Cgview cgview)
      Returns the height of the text in this LegendItem.
      Parameters:
      cgview - the cgview object to draw on.
    • setFontColor

      public void setFontColor(Color fontColor)
      Sets the color that will be used for the text in this LegendItem.
      Parameters:
      fontColor - the color of the text in this LegendItem.
    • getFontColor

      public Color getFontColor()
      Returns the color that will be used for the text in this LegendItem.
      Returns:
      the color of the text in this LegendItem.
    • setSwatchColor

      public void setSwatchColor(Color swatchColor)
      Sets the swatch color that will be used for this LegendItem.
      Parameters:
      swatchColor - the swatch color for this LegendItem.
    • getSwatchColor

      public Color getSwatchColor()
      Returns the swatch color that will be used for this LegendItem.
      Returns:
      the swatch color for this LegendItem.
    • setDrawSwatch

      public void setDrawSwatch(int drawSwatch)
      Sets whether or not a color swatch should be drawn for this LegendItem.
      Parameters:
      drawSwatch - CgviewConstants.SWATCH_SHOW or CgviewConstants.SWATCH_NO_SHOW.
    • getDrawSwatch

      public int getDrawSwatch()
      Returns whether or not a color swatch should be drawn for this LegendItem.
      Returns:
      CgviewConstants.SWATCH_SHOW or CgviewConstants.SWATCH_NO_SHOW.
    • setLabel

      public void setLabel(String label)
      Sets the text to be used for this LegendItem.
      Parameters:
      label - the text for this LegendItem.
    • getLabel

      public String getLabel()
      Returns the text to be used for this LegendItem.
      Returns:
      the text for this LegendItem.
    • setSwatchOpacity

      public void setSwatchOpacity(float swatchOpacity)
      Sets the opacity of the swatch drawn for this LegendItem.
      Parameters:
      swatchOpacity - the opacity between 0 and 1, with 1 being the most opaque.
    • getSwatchOpacity

      public float getSwatchOpacity()
      Returns the opacity of the swatch drawn for this LegendItem.
      Returns:
      the swatchOpacity between 0 and 1, with 1 being the most opaque.
    • setFont

      public void setFont(Font font)
      Sets the font used for this LegendItem.
      Parameters:
      font - the font used for this LegendItem.
    • getFont

      public Font getFont()
      Returns the font used for this LegendItem.
      Returns:
      the font used for this legendItem.
    • setTextAlignment

      public void setTextAlignment(int textAlignment)
      Sets the alignment of this LegendItem, relative to the Legend object that contains it.
      Parameters:
      textAlignment - CgviewConstants.LEGEND_ITEM_ALIGN_LEFT, CgviewConstants.LEGEND_ITEM_ALIGN_CENTER, or CgviewConstants.LEGEND_ITEM_ALIGN_RIGHT.
    • getTextAlignment

      public int getTextAlignment()
      Returns the alignment of this legendItem, relative to the Legend object that contains it.
      Returns:
      CgviewConstants.LEGEND_ITEM_ALIGN_LEFT, CgviewConstants.LEGEND_ITEM_ALIGN_CENTER, or CgviewConstants.LEGEND_ITEM_ALIGN_RIGHT.