Package ca.ualberta.stothard.cgview
Class LegendItem
java.lang.Object
ca.ualberta.stothard.cgview.LegendItem
- All Implemented Interfaces:
CgviewConstants
This class is used to add text entries to Legend objects.
- Author:
- Paul Stothard
-
Field Summary
Fields inherited from interface ca.ualberta.stothard.cgview.CgviewConstants
BASES, BOUNDS_BUTTON, BOUNDS_FEATURE, BOUNDS_RULER, CENTISOMES, DECORATION_CLOCKWISE_ARROW, DECORATION_COUNTERCLOCKWISE_ARROW, DECORATION_HIDDEN, DECORATION_STANDARD, DIRECT_STRAND, INNER_LABELS_AUTO, INNER_LABELS_NO_SHOW, INNER_LABELS_SHOW, LABEL, LABEL_FORCE, LABEL_NONE, LABEL_ZOOMED, LEGEND_DRAW_ZOOMED, LEGEND_ITEM_ALIGN_CENTER, LEGEND_ITEM_ALIGN_LEFT, LEGEND_ITEM_ALIGN_RIGHT, LEGEND_LOWER_CENTER, LEGEND_LOWER_LEFT, LEGEND_LOWER_RIGHT, LEGEND_MIDDLE_CENTER, LEGEND_MIDDLE_LEFT, LEGEND_MIDDLE_LEFT_OF_CENTER, LEGEND_MIDDLE_RIGHT, LEGEND_MIDDLE_RIGHT_OF_CENTER, LEGEND_NO_DRAW_ZOOMED, LEGEND_UPPER_CENTER, LEGEND_UPPER_LEFT, LEGEND_UPPER_RIGHT, POSITIONS_AUTO, POSITIONS_NO_SHOW, POSITIONS_SHOW, REVERSE_STRAND, SWATCH_NO_SHOW, SWATCH_SHOW
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Draws the contents of this LegendItem.int
Returns whether or not a color swatch should be drawn for this LegendItem.getFont()
Returns the font used for this LegendItem.Returns the color that will be used for the text in this LegendItem.protected double
Returns the height of the text in this LegendItem.getLabel()
Returns the text to be used for this LegendItem.Returns the swatch color that will be used for this LegendItem.float
Returns the opacity of the swatch drawn for this LegendItem.int
Returns the alignment of this legendItem, relative to the Legend object that contains it.protected double
Returns the width of the text in this LegendItem.void
setDrawSwatch
(int drawSwatch) Sets whether or not a color swatch should be drawn for this LegendItem.void
Sets the font used for this LegendItem.void
setFontColor
(Color fontColor) Sets the color that will be used for the text in this LegendItem.void
Sets the text to be used for this LegendItem.void
setSwatchColor
(Color swatchColor) Sets the swatch color that will be used for this LegendItem.void
setSwatchOpacity
(float swatchOpacity) Sets the opacity of the swatch drawn for this LegendItem.void
setTextAlignment
(int textAlignment) Sets the alignment of this LegendItem, relative to the Legend object that contains it.
-
Constructor Details
-
LegendItem
Constructs a new LegendItem object.- Parameters:
legend
- the Legend object to contain this LegendItem.
-
-
Method Details
-
draw
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
Returns the width of the text in this LegendItem.- Parameters:
cgview
- the Cgview object that contains this LegendItem.
-
getHeight
Returns the height of the text in this LegendItem.- Parameters:
cgview
- the cgview object to draw on.
-
setFontColor
Sets the color that will be used for the text in this LegendItem.- Parameters:
fontColor
- the color of the text in this LegendItem.
-
getFontColor
Returns the color that will be used for the text in this LegendItem.- Returns:
- the color of the text in this LegendItem.
-
setSwatchColor
Sets the swatch color that will be used for this LegendItem.- Parameters:
swatchColor
- the swatch color for this LegendItem.
-
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
orCgviewConstants.SWATCH_NO_SHOW
.
-
getDrawSwatch
public int getDrawSwatch()Returns whether or not a color swatch should be drawn for this LegendItem. -
setLabel
Sets the text to be used for this LegendItem.- Parameters:
label
- the text for this LegendItem.
-
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 between0
and1
, with1
being the most opaque.
-
getSwatchOpacity
public float getSwatchOpacity()Returns the opacity of the swatch drawn for this LegendItem.- Returns:
- the swatchOpacity between
0
and1
, with1
being the most opaque.
-
setFont
Sets the font used for this LegendItem.- Parameters:
font
- the font used for this LegendItem.
-
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
, orCgviewConstants.LEGEND_ITEM_ALIGN_RIGHT
.
-
getTextAlignment
public int getTextAlignment()Returns the alignment of this legendItem, relative to the Legend object that contains it.
-