[Schmitzm-commits] r2416 - trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 2 17:10:58 CEST 2015
Author: mojays
Date: 2015-09-02 17:10:58 +0200 (Wed, 02 Sep 2015)
New Revision: 2416
Modified:
trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java
trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
Log:
ChartAxisStyle: store number format pattern
Modified: trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java
===================================================================
--- trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java 2015-08-31 09:58:04 UTC (rev 2415)
+++ trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartAxisStyle.java 2015-09-02 15:10:58 UTC (rev 2416)
@@ -62,6 +62,8 @@
protected boolean visible = true;
/** Holds the number format to display the axis values. */
protected Format valuesFormat = null;
+ /** Holds the number format pattern to display the axis values. */
+ protected String valuesFormatPattern = null;
/** Holds the font the axis values are formated with. */
protected Font valuesFont = null;
/** Holds the color the axis values are painted with. */
@@ -141,6 +143,7 @@
dest.setValuesPaint(getValuesPaint());
dest.setVisible(isVisible());
dest.setValuesFormat(getValuesFormat());
+ dest.setValuesFormatPattern(getValuesFormatPattern());
dest.setUnitString(getUnitString());
dest.setUnitVisible(isUnitVisible());
dest.setRangeType(getRangeType());
@@ -275,6 +278,20 @@
}
/**
+ * Returns the (number) format pattern for the axis values (may be {@code null}).
+ */
+ public String getValuesFormatPattern() {
+ return valuesFormatPattern;
+ }
+
+ /**
+ * Sets the format pattern for the axis values (may be {@code null}).
+ */
+ public void setValuesFormatPattern(String formatPattern) {
+ this.valuesFormatPattern = formatPattern;
+ }
+
+ /**
* Returns the type of the axis (positive/negative/full). Only
* applicable for {@link NumberAxis}.
*/
@@ -376,7 +393,7 @@
else
// Give a warn if another format should be applied
if (getValuesFormat() != null)
- LOGGER.warn("Only a NumberFormat can not be applied to values of " + LangUtil.getSimpleClassName(axis)
+ LOGGER.warn("Only a NumberFormat can be applied to values of " + LangUtil.getSimpleClassName(axis)
+ ": " + LangUtil.getSimpleClassName(getValuesFormat()));
// Only a 0 or 90 degree angle can be applied to NumberAxis
@@ -407,7 +424,7 @@
else
// Give a warn if another format should be applied
if (getValuesFormat() != null)
- LOGGER.warn("Only a DateFormat can not be applied to values of " + LangUtil.getSimpleClassName(axis) + ": "
+ LOGGER.warn("Only a DateFormat can be applied to values of " + LangUtil.getSimpleClassName(axis) + ": "
+ LangUtil.getSimpleClassName(getValuesFormat()));
// Only a 0 or 90 degree angle can be applied to DateAxis
Modified: trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
===================================================================
--- trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java 2015-08-31 09:58:04 UTC (rev 2415)
+++ trunk/schmitzm-jfree/src/main/java/de/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java 2015-09-02 15:10:58 UTC (rev 2416)
@@ -43,6 +43,7 @@
import java.util.List;
import java.util.Random;
+import org.apache.commons.lang.StringUtils;
import org.jdom.Document;
import org.jdom.Element;
import org.jfree.chart.plot.PlotOrientation;
@@ -327,12 +328,15 @@
if (valuesAngle != null)
style.setValuesAngle(valuesAngle);
String formatStr = XMLUtil.getAttribute(valuesElem, "numberFormat");
- if (formatStr != null)
+ if (!StringUtils.isBlank(formatStr)) {
style.setValuesFormat(new DecimalFormat(formatStr));
- else {
+ style.setValuesFormatPattern(formatStr);
+ } else {
formatStr = XMLUtil.getAttribute(valuesElem, "dateFormat");
- if (formatStr != null)
+ if (!StringUtils.isBlank(formatStr)) {
style.setValuesFormat(new SimpleDateFormat(formatStr));
+ style.setValuesFormatPattern(formatStr);
+ }
}
}
More information about the Schmitzm-commits
mailing list