data
public class Parameter extends java.lang.Object implements java.io.Serializable
DataSheet
.
It is used to store information about the type of data stored in a column of the DataSheet.
Two data types are supported: Numeric and Discrete.
Numeric parameters are used for columns that only contain numbers. Discrete parameters are used for all columns that contain at least one non-numeric value. All values are stored in a TreeSet and sorted in alphabetical order. This makes it possible to also treat information on parameters that are not quantifiable, such as different shapes of an object or similar.
Constructor and Description |
---|
Parameter(java.lang.String name,
DataSheet dataSheet)
Instantiates a new parameter.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkIfNumeric()
Checks whether the parameter is numeric or discrete by rechecking all designs.
|
void |
checkOccurrenceInDiscreteLevel(java.lang.String stringValueToCheck)
Checks the count of designs for which this parameter is on the discrete level defined by
the given string argument.
|
int |
getDiscreteLevelCount()
Gets the discrete level count in the TreeSet that stores all discrete levels.
|
double |
getDoubleValueOf(java.lang.String string)
Gets a numeric representation of a string value for this parameter.
|
int |
getLongestTicLabelStringLength(java.awt.FontMetrics fm,
java.lang.String numberFormat)
Gets the longest tic label string.
|
double |
getMaxValue()
Finds the maximum value for this parameter in the datasheet.
|
double |
getMinValue()
Finds the minimum value for this parameter in the datasheet.
|
java.lang.String |
getName()
Gets the name.
|
java.lang.String |
getStringValueOf(double value)
Gets the string representation of a given double value for this parameter.
|
boolean |
isMixed()
Checks whether the parameter is mixed.
|
boolean |
isNumeric()
Returns whether the parameter is numeric or discrete from the stored setting.
|
void |
resetDiscreteLevelsAndState()
Reset discrete levels to an empty TreeSet.
|
void |
setAtLeastOneNumeric(boolean atLeastOneNumeric) |
void |
setName(java.lang.String name)
Sets the name.
|
void |
setNumeric(boolean numeric)
Specifies whether the parameter is numeric or dicrete.
|
public Parameter(java.lang.String name, DataSheet dataSheet)
name
- the parameter namepublic java.lang.String getName()
public void setName(java.lang.String name)
name
- the new namepublic boolean isMixed()
public double getMaxValue()
public double getMinValue()
public boolean isNumeric()
public boolean checkIfNumeric()
public void setNumeric(boolean numeric)
numeric
- specifies if the parameter is numericpublic void setAtLeastOneNumeric(boolean atLeastOneNumeric)
atLeastOneNumeric
- specifies whether there is at least one design with a numeric value for this designpublic double getDoubleValueOf(java.lang.String string)
If the parameter is numeric, an attempt is made to parse the string as a Double. If this attempt leads to a ParseException, the parameter is not considered numeric anymore, but is transformed into a discrete parameter.
If the parameter is not numeric, the string is looked up in the TreeSet discreteLevels that should contain all discrete values (that is Strings) that were found in the data sheet for this parameter. If the value is not found it is added as a new discrete level for this parameter. The treeSet is then searched again in order to get the correct index of the new discrete level.
If this second search does not yield the result, something unexpected has gone wrong and a CorruptDataException is thrown.
string
- the stringpublic java.lang.String getStringValueOf(double value)
If the parameter is numeric, the provided value is simply converted to a String and returned.
If it is discrete, the double value is casted to an Integer value and this value is used as an index to look up the corresponding discrete value string in the TreeSet discreteLevels.
If no value is found for the given index the data is assumed to be corrupt and a CorruptDataException is thrown.
value
- the numeric valuepublic int getDiscreteLevelCount()
Only applies to non-numeric parameters.
public void checkOccurrenceInDiscreteLevel(java.lang.String stringValueToCheck)
Only applies to non-numeric parameters.
stringValueToCheck
- the discrete level for which the occurrence count should be returnedpublic void resetDiscreteLevelsAndState()
public int getLongestTicLabelStringLength(java.awt.FontMetrics fm, java.lang.String numberFormat)
fm
- the FontMetrics for which the string width should be calculated