ucar.unidata.util
Class ContourInfo

java.lang.Object
  extended by ucar.unidata.util.ContourInfo

public class ContourInfo
extends Object

A class to hold and transfer contour level settings, as to and from the dialog box ContLevelDialog.


Field Summary
static int DASH_DOT_STYLE
          Dash-Dot line
static int DASH_STYLE
          Dashed line
static boolean DEFAULT_DASH
          Default contour dashing setting
static int DEFAULT_DASHED_STYLE
          Default contour line style
static boolean DEFAULT_FILL
          Default contour color fill value
static boolean DEFAULT_LABEL
          Default contour labeling setting
static boolean DEFAULT_LABEL_ALIGNMENT
          Default contour labeling alignment setting
static int DEFAULT_LABEL_FREQ
          Default label frequency (per qualifying contour line)
static int DEFAULT_LABEL_SIZE
          Default label size
static int DEFAULT_LINE_WIDTH
          Default contour line width
static int DOT_STYLE
          Dotted line
 
Constructor Summary
ContourInfo()
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog using the default values.
ContourInfo(ContourInfo s)
          Copy constructor.
ContourInfo(double interval, double base, double min, double max)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(double interval, double base, double min, double max, boolean labelOn, boolean dashOn)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(double interval, double base, double min, double max, boolean labelOn, boolean dashOn, int width)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(float[] values)
          Create a ContourInfo from a float array.
ContourInfo(float interval, float base, float min, float max)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(float interval, float base, float min, float max, boolean labelOn, boolean dashOn, boolean isColorFilled)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(float interval, float base, float min, float max, boolean labelOn, boolean dashOn, boolean isColorFilled, int width)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(String params)
          Create a contour info with the parameters encoded in the string
ContourInfo(String levelsString, double base, double min, double max, boolean labelOn, boolean dashOn, boolean isColorFilled, double width)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(String levelsString, float base, float min, float max, boolean labelOn, boolean dashOn, boolean isColorFilled, int width)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(String levelsString, float base, float min, float max, boolean labelOn, boolean dashOn, boolean isColorFilled, int width, int dashedStyle)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
ContourInfo(String levelsString, float base, float min, float max, boolean labelOn, boolean dashOn, boolean isColorFilled, int width, int dashedStyle, int labelFreq, int labelSize, Object font, boolean align)
          Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.
 
Method Summary
 float[] asArray()
          Return the contour parameters as an array.
static String cleanupUserLevelString(String levelString)
          Clean up the user entered levels string
 boolean getAlignLabels()
          Get the label alignment
 float getBase()
          Get the contour base
 boolean getBaseDefined()
          See if the base has been defined.
 float[] getContourLevels()
          Get the contour levels.
 float[] getContourLevels(String levelString)
          Get the contour levels from the given string.
 int getDashedStyle()
          Get the dash style
 boolean getDashOn()
          Get the dashing flag
 Object getFont()
          Get the font.
 float getInterval()
          Get the contour interval
 boolean getIntervalDefined()
          See if an interval has been defined.
 String getIntervalString()
          Get the interval as a string.
 String getIntervalString(boolean useDecimalFormat)
          Get the interval as a string.
 boolean getIsFilled()
          Get the color fill flag.
 boolean getIsLabeled()
          Get the labelling flag
 int getLabelFreq()
          Get the label frequency.
 int getLabelSize()
          Get the label (font) size.
 String getLevelsString()
          Get the contour interval string
 int getLineWidth()
          Get the line width.
 float getMax()
          Get the contour maximum
 boolean getMaxDefined()
          See if the max has been defined.
 float getMin()
          Get the contour minimum
 boolean getMinDefined()
          See if the min has been defined.
 boolean isDefined()
          See if this has been defined
static boolean isIrregularInterval(String intervalString)
          See if a levelsString is an regular or an irregular interval.
 void processParamString(String params)
          Process the params string.
 void set(ContourInfo that)
          Set the contour parameters for this from another contour info.
 void setAlignLabels(boolean align)
          Set the label alignment.
 void setBase(float v)
          Set the contour base
 void setDashedStyle(int v)
          Set the dash style
 void setDashOn(boolean v)
          Set the dashing flag
 void setFont(Object font)
          Set the font.
 void setIfDefined(ContourInfo that)
          Set the parameters if they are defined in the other.
 void setInterval(float v)
          Set the contour interval
 void setIsFilled(boolean fill)
          Set the color fill flag
 void setIsLabeled(boolean v)
          Set the labelling flag
 void setLabelFreq(int freq)
          Get the label frequency
 void setLabelSize(int size)
          Get the label (font) size
 void setLevelsString(String v)
          Set the irregular contour intervals string
 void setLineWidth(int width)
          Set the line width.
 void setMax(float v)
          Set the contour maximum
 void setMin(float v)
          Set the contour minimum
 String toString()
          Return a String representation of this object
 void tweakIntervalForDash()
          Tweak the interval for dashing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_LABEL

public static final boolean DEFAULT_LABEL
Default contour labeling setting

See Also:
Constant Field Values

DEFAULT_LABEL_ALIGNMENT

public static final boolean DEFAULT_LABEL_ALIGNMENT
Default contour labeling alignment setting

See Also:
Constant Field Values

DEFAULT_DASH

public static final boolean DEFAULT_DASH
Default contour dashing setting

See Also:
Constant Field Values

DEFAULT_FILL

public static final boolean DEFAULT_FILL
Default contour color fill value

See Also:
Constant Field Values

DEFAULT_LINE_WIDTH

public static final int DEFAULT_LINE_WIDTH
Default contour line width

See Also:
Constant Field Values

DASH_STYLE

public static final int DASH_STYLE
Dashed line

See Also:
Constant Field Values

DOT_STYLE

public static final int DOT_STYLE
Dotted line

See Also:
Constant Field Values

DASH_DOT_STYLE

public static final int DASH_DOT_STYLE
Dash-Dot line

See Also:
Constant Field Values

DEFAULT_DASHED_STYLE

public static final int DEFAULT_DASHED_STYLE
Default contour line style

See Also:
Constant Field Values

DEFAULT_LABEL_SIZE

public static final int DEFAULT_LABEL_SIZE
Default label size

See Also:
Constant Field Values

DEFAULT_LABEL_FREQ

public static final int DEFAULT_LABEL_FREQ
Default label frequency (per qualifying contour line)

See Also:
Constant Field Values
Constructor Detail

ContourInfo

public ContourInfo(float interval,
                   float base,
                   float min,
                   float max,
                   boolean labelOn,
                   boolean dashOn,
                   boolean isColorFilled)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
interval - the contour interval
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not
isColorFilled - flag for color filling contours

ContourInfo

public ContourInfo(float interval,
                   float base,
                   float min,
                   float max,
                   boolean labelOn,
                   boolean dashOn,
                   boolean isColorFilled,
                   int width)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
interval - the contour interval
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not
isColorFilled - flag for color filling contours
width - line width

ContourInfo

public ContourInfo(String levelsString,
                   float base,
                   float min,
                   float max,
                   boolean labelOn,
                   boolean dashOn,
                   boolean isColorFilled,
                   int width)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
levelsString - the contour levels as a string
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not
isColorFilled - flag for color filling contours
width - line width

ContourInfo

public ContourInfo(String levelsString,
                   float base,
                   float min,
                   float max,
                   boolean labelOn,
                   boolean dashOn,
                   boolean isColorFilled,
                   int width,
                   int dashedStyle)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
levelsString - the contour levels as a string
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not
isColorFilled - flag for color filling contours
width - line width
dashedStyle - dashedStyle;

ContourInfo

public ContourInfo(String levelsString,
                   float base,
                   float min,
                   float max,
                   boolean labelOn,
                   boolean dashOn,
                   boolean isColorFilled,
                   int width,
                   int dashedStyle,
                   int labelFreq,
                   int labelSize,
                   Object font,
                   boolean align)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
levelsString - the contour levels as a string
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not
isColorFilled - flag for color filling contours
width - line width
dashedStyle - dashedStyle
labelSize - the label (font) size
font - the font - Font or HersheyFont
align - the label alignment - true to be along contours

ContourInfo

public ContourInfo()
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog using the default values.


ContourInfo

public ContourInfo(double interval,
                   double base,
                   double min,
                   double max)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
interval - the contour interval
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same

ContourInfo

public ContourInfo(double interval,
                   double base,
                   double min,
                   double max,
                   boolean labelOn,
                   boolean dashOn)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
interval - the contour interval
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not

ContourInfo

public ContourInfo(String levelsString,
                   double base,
                   double min,
                   double max,
                   boolean labelOn,
                   boolean dashOn,
                   boolean isColorFilled,
                   double width)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
levelsString - the contour levels as a string
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not
isColorFilled - flag for color filling contours
width - line width

ContourInfo

public ContourInfo(double interval,
                   double base,
                   double min,
                   double max,
                   boolean labelOn,
                   boolean dashOn,
                   int width)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
interval - the contour interval
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same
labelOn - whether labels are
dashOn - whether lines below base value are dashed or not
width - line width

ContourInfo

public ContourInfo(float interval,
                   float base,
                   float min,
                   float max)
Construct an object to hold and transfer contour level settings, such as to and from the dialog box ContLevelDialog.

Parameters:
interval - the contour interval
base - the contour level below which one line must have
min - the lower limit of plotted contour values
max - the upper limit of same

ContourInfo

public ContourInfo(ContourInfo s)
Copy constructor.

Parameters:
s - ContourInfo to copy.

ContourInfo

public ContourInfo(float[] values)
Create a ContourInfo from a float array.

Parameters:
values - contour values (interval, base, min, max)

ContourInfo

public ContourInfo(String params)
Create a contour info with the parameters encoded in the string

Parameters:
params - The string params
Method Detail

processParamString

public void processParamString(String params)
Process the params string. It can either be of the form:
&interval;base;min;max;
 or made up of any combination of name=value pairs. e.g.:
 
interval=10;min=5;max=100;base=15;dashed=true;labels=false;

Parameters:
params - The string params

isDefined

public boolean isDefined()
See if this has been defined

Returns:
true if int/max/min/base values have been set

getIntervalDefined

public boolean getIntervalDefined()
See if an interval has been defined.

Returns:
true if the interval is not a NaN

getBaseDefined

public boolean getBaseDefined()
See if the base has been defined.

Returns:
true if the base is not a NaN

getMinDefined

public boolean getMinDefined()
See if the min has been defined.

Returns:
true if the min is not a NaN

getMaxDefined

public boolean getMaxDefined()
See if the max has been defined.

Returns:
true if the max is not a NaN

getInterval

public float getInterval()
Get the contour interval

Returns:
the contour interval

getBase

public float getBase()
Get the contour base

Returns:
the contour base

getMin

public float getMin()
Get the contour minimum

Returns:
the contour minimum

getMax

public float getMax()
Get the contour maximum

Returns:
the contour maximum

setIsLabeled

public void setIsLabeled(boolean v)
Set the labelling flag

Parameters:
v - true to label

getIsLabeled

public boolean getIsLabeled()
Get the labelling flag

Returns:
true if labeled

setDashOn

public void setDashOn(boolean v)
Set the dashing flag

Parameters:
v - true to dash

getDashOn

public boolean getDashOn()
Get the dashing flag

Returns:
true to dash

setInterval

public void setInterval(float v)
Set the contour interval

Parameters:
v - new interval

setLevelsString

public void setLevelsString(String v)
Set the irregular contour intervals string

Parameters:
v - new interval string

getLevelsString

public String getLevelsString()
Get the contour interval string

Returns:
a string representation of the levels in this

setBase

public void setBase(float v)
Set the contour base

Parameters:
v - new base

setMin

public void setMin(float v)
Set the contour minimum

Parameters:
v - new minimum

setMax

public void setMax(float v)
Set the contour maximum

Parameters:
v - new maximum

set

public void set(ContourInfo that)
Set the contour parameters for this from another contour info.

Parameters:
that - other ContourInfo

setIfDefined

public void setIfDefined(ContourInfo that)
Set the parameters if they are defined in the other.

Parameters:
that - other to use

asArray

public float[] asArray()
Return the contour parameters as an array.

Returns:
contour values (interval, base, min, max)

tweakIntervalForDash

public void tweakIntervalForDash()
Tweak the interval for dashing.


getIntervalString

public String getIntervalString()
Get the interval as a string. If interval is undefined, return the levelsString.

Returns:
interval as String in Locale format or levelsString.

getIntervalString

public String getIntervalString(boolean useDecimalFormat)
Get the interval as a string. If interval is undefined, return the levelsString.

Parameters:
useDecimalFormat - format as decimal for XML storage
Returns:
interval as String or levelsString.

toString

public String toString()
Return a String representation of this object

Overrides:
toString in class Object
Returns:
a String representation of this object

setIsFilled

public void setIsFilled(boolean fill)
Set the color fill flag

Parameters:
fill - true to color fill

getIsFilled

public boolean getIsFilled()
Get the color fill flag.

Returns:
true to color fill

setLineWidth

public void setLineWidth(int width)
Set the line width.

Parameters:
width - line width (pixels)

getLineWidth

public int getLineWidth()
Get the line width.

Returns:
line width (pixels)

setDashedStyle

public void setDashedStyle(int v)
Set the dash style

Parameters:
v - new dash style

getDashedStyle

public int getDashedStyle()
Get the dash style

Returns:
dash style

getContourLevels

public float[] getContourLevels()
Get the contour levels. If setLevels has been called with a non-null array, that array is returned, otherwise, levels are calculated from the interval, max, min and base.

Returns:
the contour levels

getContourLevels

public float[] getContourLevels(String levelString)
Get the contour levels from the given string.

Parameters:
levelString - string representation of the levels
Returns:
the contour levels

getLabelFreq

public int getLabelFreq()
Get the label frequency.

Returns:
the label frequency

setLabelFreq

public void setLabelFreq(int freq)
Get the label frequency

Parameters:
freq - the label frequency

getLabelSize

public int getLabelSize()
Get the label (font) size.

Returns:
the label (font) size

setLabelSize

public void setLabelSize(int size)
Get the label (font) size

Parameters:
size - the label (font) size

getFont

public Object getFont()
Get the font.

Returns:
the font - null, Font, or HersheyFont

setFont

public void setFont(Object font)
Set the font.

Parameters:
font - the font to set - must be a Font or HersheyFont

getAlignLabels

public boolean getAlignLabels()
Get the label alignment

Returns:
true for along contours

setAlignLabels

public void setAlignLabels(boolean align)
Set the label alignment.

Parameters:
align - - true for along contours

cleanupUserLevelString

public static String cleanupUserLevelString(String levelString)
Clean up the user entered levels string

Parameters:
levelString - string representation of the levels
Returns:
The level string un-localized

isIrregularInterval

public static boolean isIrregularInterval(String intervalString)
See if a levelsString is an regular or an irregular interval.

Parameters:
intervalString - to check
Returns:
true if this is not a regular interval (single value)