ucar.unidata.ui.symbol
Class TextSymbol

java.lang.Object
  extended by ucar.unidata.ui.drawing.Glyph
      extended by ucar.unidata.ui.drawing.RectangleGlyph
          extended by ucar.unidata.ui.symbol.MetSymbol
              extended by ucar.unidata.ui.symbol.TextSymbol
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
LabelSymbol, ValueSymbol

public class TextSymbol
extends MetSymbol

A representation of a text MetSymbol.

Version:
$Revision: 1.41 $
Author:
Metapps development team

Field Summary
static String[] FONT_SIZES
          Array of default font sizes used for incrementing/decrementing fonts.
protected  String numberFormatString
          Format string for numbers.
 
Fields inherited from class ucar.unidata.ui.symbol.MetSymbol
ATTR_PARAMID, canvas, propertiesDialog
 
Fields inherited from class ucar.unidata.ui.drawing.RectangleGlyph
ATTR_RECTTYPE, bounds, CIRCLE, FCIRCLE, FRECTANGLE, FROUNDRECT, RECTANGLE, ROUNDRECT, TYPE_CIRCLE, TYPE_RECT, TYPE_RRECT
 
Fields inherited from class ucar.unidata.ui.drawing.Glyph
ATTR_BGCOLOR, ATTR_CHILDREN, ATTR_CLASS, ATTR_COLOR, ATTR_FILL, ATTR_HEIGHT, ATTR_IMAGE, ATTR_LINEWIDTH, ATTR_PARENT, ATTR_PTS, ATTR_STRETCHY, ATTR_TEXT, ATTR_TYPE, ATTR_WIDTH, baseline, H_SEL_WIDTH, highlightColor, idToGlyph, MIN_DISTANCE_TO_STRETCH, PT_CENTER, PT_H_LEFT, PT_H_MIDDLE, PT_H_RIGHT, PT_LL, PT_LM, PT_LR, PT_ML, PT_MM, PT_MR, PT_P1, PT_P2, PT_PREFIX, PT_UL, PT_UM, PT_UR, PT_V_LOWER, PT_V_MIDDLE, PT_V_UPPER, RECTPOINTNAMES, RECTPOINTS, SEL_WIDTH, TAG_GLYPH, underline, url
 
Constructor Summary
TextSymbol()
          Default constructor.
TextSymbol(DisplayCanvas canvas, int x, int y)
          Construct a TextSymbol to use on the canvas specified at the position specified.
TextSymbol(DisplayCanvas canvas, int x, int y, String param, String paramDesc)
          Construct a TextSymbol to use on the canvas specified at the position specified.
TextSymbol(int x, int y)
          Construct a TextSymbol at the position specified.
TextSymbol(int x, int y, String param, String paramDesc)
          Construct a TextSymbol at the position specified.
TextSymbol(String param, String paramDesc)
          Construct a TextSymbol with the name specified.
 
Method Summary
 void decrFontSize()
          Decrease the font size by one step in the fontSizes array.
 void draw(Graphics2D g, int x, int y, int width, int height)
          Draw this object to the graphics device.
 String format(double d)
          Format a double values
 String format(float d)
          Format a float
 String format(Real d)
          Format a Real
 String formatNumber(double d)
          Format a number using the format pattern set for this instance.
 int getCurrFontNo()
          Get the current font number
 Font getFont()
          Get the currently used font.
static Font[] getFontList()
          Get a list of fonts to use with this object.
 FontMetrics getFontMetrics()
          Get the metrics of the current font.
 int getFontSize()
          Get the current font size.
 String getLabel()
          Get the label to show the user what I am in the properties
 String getNumberFormatString()
          Get the format pattern for numeric values.
 Object getParamValue(int index)
          Get the parameter value for the index specified.
 String getValue()
          Get the string representation for the value of this object.
protected  String getValueString()
          Get the value string
 void incrFontSize()
          Increase the font size by one step in the FONT_SIZES array.
protected  Font makeDefaultFont()
          Make a font from the size and using the default.
 void setCurrFontNo(int index)
          Set the index into the array of font sizes.
 void setFont(Font font)
          Set the font to use when displaying this symbol.
 void setFontSize(int size)
          Set the font size.
 void setNumberFormatString(String s)
          Set the format pattern for numeric values.
 void setParamValue(int index, Object v)
          Set the parameter value for the index specified.
 void setValue(double d)
          Set the value for this object.
 void setValue(String s)
          Set the value for this object.
 String toString()
          String representation of this object.
 
Methods inherited from class ucar.unidata.ui.symbol.MetSymbol
addPropertyTabs, applyProperties, clone, cloneMe, closePropertiesDialog, decrSize, doAlignmentMenu, doAllObs, draw, getActive, getBounds, getColorMappings, getColorParam, getColorTable, getColorTableParam, getColorTableRange, getColorTableUnit, getColorTableUnitName, getDesc, getDisplayUnit, getDisplayUnitName, getMissing, getName, getParam, getParamDescs, getParamIds, getRectPoint, getRotateInfo, getRotateXInfo, getRotateYInfo, getRotateZInfo, getScale, getScaleDataRange, getScaleParam, getScaleRange, getScaleUnit, getScaleUnitName, getXOffset, getYOffset, incrSize, initialize, initPropertyComponents, makeShapes, makeShapes, paint, paintSelection, rotateOnEarth, setActive, setAttr, setColorMappings, setColorParam, setColorTable, setColorTableParam, setColorTableRange, setColorTableUnitName, setDisplayUnitName, setMissing, setOffset, setParamDescs, setParamIds, setRectPoint, setRotateDataRange, setRotateParam, setRotateRange, setRotateUnitName, setRotateXInfo, setRotateYInfo, setRotateZInfo, setScale, setScaleDataRange, setScaleParam, setScaleRange, setScaleUnitName, setTheDisplayUnit, shouldBeColored, shouldOffsetShape, shouldScaleShape, shouldShowColorTableGui, shouldShowRotateGui, shouldShowScaleGui, showDisplayUnitInProperties, showPropertiesDialog
 
Methods inherited from class ucar.unidata.ui.drawing.RectangleGlyph
distance, getBottom, getBounds, getEqualSides, getLeft, getPoint, getPositionAttr, getStretchPoint, getSymetricReshape, getTop, moveBy, moveTo, setPoints, setSize, setType, stretchTo
 
Methods inherited from class ucar.unidata.ui.drawing.Glyph
boundsChanged, canStretch, distance, doRemove, flipY, getAttrs, getBackground, getBackground, getBeingCreated, getCreateCommand, getCursor, getFilled, getForeground, getId, getLineWidth, getMoveCommand, getPersistent, getPointOnRect, getPointOnRect, getRectPointName, getRepaintBounds, getStretchPoint, getStretchy, getXml, initDone, makeAttr, notifyChange, paintHighlight, paintSelectionPoints, pickable, processAttrs, setBackground, setBeingCreated, setFilled, setForeground, setId, setLineWidth, setParent, setStretchy, stretchTo, stretchTo, toRect, transformOutput, transformOutput, transformOutputX, transformOutputY
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numberFormatString

protected String numberFormatString
Format string for numbers.


FONT_SIZES

public static final String[] FONT_SIZES
Array of default font sizes used for incrementing/decrementing fonts.

See Also:
incrFontSize(), decrFontSize()
Constructor Detail

TextSymbol

public TextSymbol()
Default constructor.


TextSymbol

public TextSymbol(int x,
                  int y)
Construct a TextSymbol at the position specified. Use the default name and long name.

Parameters:
x - x position on the canvas
y - y position on the canvas

TextSymbol

public TextSymbol(DisplayCanvas canvas,
                  int x,
                  int y)
Construct a TextSymbol to use on the canvas specified at the position specified. Use the default name and long name.

Parameters:
canvas - canvas to draw on.
x - x position on the canvas
y - y position on the canvas

TextSymbol

public TextSymbol(String param,
                  String paramDesc)
Construct a TextSymbol with the name specified.

Parameters:
param - parameter to display
paramDesc - description of the parameter (i.e., long name)

TextSymbol

public TextSymbol(int x,
                  int y,
                  String param,
                  String paramDesc)
Construct a TextSymbol at the position specified.

Parameters:
x - x position on the canvas
y - y position on the canvas
param - parameter to display
paramDesc - description of the parameter (i.e., long name)

TextSymbol

public TextSymbol(DisplayCanvas canvas,
                  int x,
                  int y,
                  String param,
                  String paramDesc)
Construct a TextSymbol to use on the canvas specified at the position specified.

Parameters:
canvas - canvas to draw on.
x - x position on the canvas
y - y position on the canvas
param - parameter to display
paramDesc - description of the parameter (i.e., long name)
Method Detail

getLabel

public String getLabel()
Get the label to show the user what I am in the properties

Overrides:
getLabel in class MetSymbol
Returns:
label

setFont

public void setFont(Font font)
Set the font to use when displaying this symbol.

Parameters:
font - font to use.

getFont

public Font getFont()
Get the currently used font.

Returns:
current font. May be null

incrFontSize

public void incrFontSize()
Increase the font size by one step in the FONT_SIZES array.


decrFontSize

public void decrFontSize()
Decrease the font size by one step in the fontSizes array.


getFontList

public static Font[] getFontList()
Get a list of fonts to use with this object.

Returns:
array of fonts

setCurrFontNo

public void setCurrFontNo(int index)
Set the index into the array of font sizes.

Parameters:
index - index into the FONT_SIZES array

getCurrFontNo

public int getCurrFontNo()
Get the current font number

Returns:
index of current font in the FONT_SIZES array.

getFontMetrics

public FontMetrics getFontMetrics()
Get the metrics of the current font.

Returns:
current font metrics.

setFontSize

public void setFontSize(int size)
Set the font size.

Parameters:
size - point size of font.

getFontSize

public int getFontSize()
Get the current font size.

Returns:
currentFontSize

getValueString

protected String getValueString()
Get the value string

Returns:
a string representation of the size

getNumberFormatString

public String getNumberFormatString()
Get the format pattern for numeric values.

Returns:
formatting pattern string.
See Also:
DecimalFormat

setNumberFormatString

public void setNumberFormatString(String s)
Set the format pattern for numeric values.

Parameters:
s - formatting pattern string.
See Also:
DecimalFormat

formatNumber

public String formatNumber(double d)
Format a number using the format pattern set for this instance.

Parameters:
d - double to format
Returns:
formatted number as a String
See Also:
setNumberFormatString(String)

format

public String format(Real d)
Format a Real

Parameters:
d - the Real
Returns:
the formatted value

format

public String format(double d)
Format a double values

Parameters:
d - the double
Returns:
formatted number

format

public String format(float d)
Format a float

Parameters:
d - float
Returns:
the formatted number

getValue

public String getValue()
Get the string representation for the value of this object.

Returns:
String representation of number.

setValue

public void setValue(double d)
Set the value for this object.

Parameters:
d - value

setValue

public void setValue(String s)
Set the value for this object.

Parameters:
s - String representation of the value for this object.

getParamValue

public Object getParamValue(int index)
Get the parameter value for the index specified.

Overrides:
getParamValue in class MetSymbol
Parameters:
index - index of the parameter (ignored for this instance)
Returns:
String value associated with this instance.

setParamValue

public void setParamValue(int index,
                          Object v)
Set the parameter value for the index specified.

Overrides:
setParamValue in class MetSymbol
Parameters:
index - index of the parameter (ignored for this instance)
v - Object that this should represent

draw

public void draw(Graphics2D g,
                 int x,
                 int y,
                 int width,
                 int height)
Draw this object to the graphics device.

Specified by:
draw in class MetSymbol
Parameters:
g - Graphics object
x - x position of the object
y - y position of the object
width - width to draw
height - height to draw

toString

public String toString()
String representation of this object.

Overrides:
toString in class MetSymbol
Returns:
String version of this object.

makeDefaultFont

protected Font makeDefaultFont()
Make a font from the size and using the default.

Returns:
a default Font