Commit f25320e3 authored by Nico Mack's avatar Nico Mack

added rangeSeparator attribute

parent 3ce7fa59
......@@ -3,7 +3,7 @@ BELOW_ELEMENT=below
BLINK_ON_OUT_OF_RANGE_NODE=blinkOnOutOfRange
CAPPED_DISPLAY_NODE=cappedDisplay
COLOUR_SCALE_NODE=colourScale
DECIMALS_NODE=decimals
DECIMALS_ATTRIBUTE=decimals
FACE_IS_TOUCHABLE_NODE=faceIsTouchable
ITEMS_VARIABLE_NODE=itemsVariable
HTML_TEMPLATE_NODE=htmlTemplate
......@@ -16,6 +16,7 @@ MAXIMUM_VALUE_NODE=maximumValue
MINIMUM_VALUE_NODE=minimumValue
MODIFY_VALUE_ON_ROTATION_NODE=modifyValueOnRotation
MULTITURN_NODE=multiTurn
RANGE_SEPARATOR_ATTRIBUTE=rangeSeparator
REFERENCE_NODE=reference
RELATIVE_NODE=relative
SCALES_NODE=scales
......
......@@ -34,7 +34,7 @@ public class CpsNamespace extends NLS {
public static String COLOUR_SCALE_NODE;
public static String FACE_IS_TOUCHABLE_NODE;
public static String DECIMALS_NODE;
public static String DECIMALS_ATTRIBUTE;
public static String HTML_TEMPLATE_NODE;
......@@ -52,6 +52,7 @@ public class CpsNamespace extends NLS {
public static String MODIFY_VALUE_ON_ROTATION_NODE;
public static String MULTITURN_NODE;
public static String RANGE_SEPARATOR_ATTRIBUTE;
public static String REFERENCE_NODE;
public static String RELATIVE_NODE;
......
......@@ -50,6 +50,7 @@ public class ColourScale<T extends Comparable<T>> {
private List<ColourMapping<T>> mappings;
private Color defaultColour;
private String unit;
private String rangeSeparator;
private DecimalFormat format;
// ***************************************************************************
......@@ -57,6 +58,8 @@ public class ColourScale<T extends Comparable<T>> {
// ***************************************************************************
private static final String AUTO = "auto"; //$NON-NLS-1$
private static final String DEFAULT_RANGE_SEPARATOR = "-"; //$NON-NLS-1$
private static final Logger LOGGER = LoggerFactory.getLogger(ColourScale.class.getSimpleName());
......@@ -107,7 +110,8 @@ public class ColourScale<T extends Comparable<T>> {
name = BootstrappingUtils.getAttributeAsString(rootElement, Externalization.NAME_NODE, BootstrappingUtils.MANDATORY, null);
unit = BootstrappingUtils.getAttributeAsString(rootElement, Externalization.UNIT_NODE, BootstrappingUtils.OPTIONAL, Externalization.EMPTY_STRING);
int decimals = BootstrappingUtils.getAttributeAsInteger(rootElement, CpsNamespace.DECIMALS_NODE, BootstrappingUtils.OPTIONAL, -1);
rangeSeparator = BootstrappingUtils.getAttributeAsString(rootElement, CpsNamespace.RANGE_SEPARATOR_ATTRIBUTE, BootstrappingUtils.OPTIONAL, DEFAULT_RANGE_SEPARATOR);
int decimals = BootstrappingUtils.getAttributeAsInteger(rootElement, CpsNamespace.DECIMALS_ATTRIBUTE, BootstrappingUtils.OPTIONAL, -1);
if (decimals >= 0) {
this.format.setMinimumFractionDigits(decimals);
this.format.setMaximumFractionDigits(decimals);
......@@ -249,7 +253,7 @@ public class ColourScale<T extends Comparable<T>> {
} else {
ValueRange<T> range = mapping.getRange();
labelBuilder.append(format.format(range.getLowerValue()));
labelBuilder.append(" - "); //$NON-NLS-1$
labelBuilder.append(" ").append(this.rangeSeparator).append(" "); //$NON-NLS-1$ //$NON-NLS-2$
labelBuilder.append(format.format(range.getUpperValue()));
}
return labelBuilder.toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment