use of org.jfree.chart.plot.MeterInterval in project pentaho-platform by pentaho.
the class JFreeChartEngine method updatePlot.
private static void updatePlot(final Plot plot, final ChartDefinition chartDefinition) {
plot.setBackgroundPaint(chartDefinition.getPlotBackgroundPaint());
plot.setBackgroundImage(chartDefinition.getPlotBackgroundImage());
plot.setNoDataMessage(chartDefinition.getNoDataMessage());
// create a custom palette if it was defined
if (chartDefinition.getPaintSequence() != null) {
DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(chartDefinition.getPaintSequence(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
plot.setDrawingSupplier(drawingSupplier);
}
// TODO define outline stroke
plot.setOutlineStroke(null);
if (plot instanceof CategoryPlot) {
CategoryPlot categoryPlot = (CategoryPlot) plot;
CategoryDatasetChartDefinition categoryDatasetChartDefintion = (CategoryDatasetChartDefinition) chartDefinition;
categoryPlot.setOrientation(categoryDatasetChartDefintion.getOrientation());
CategoryAxis domainAxis = categoryPlot.getDomainAxis();
if (domainAxis != null) {
domainAxis.setLabel(categoryDatasetChartDefintion.getDomainTitle());
domainAxis.setLabelFont(categoryDatasetChartDefintion.getDomainTitleFont());
if (categoryDatasetChartDefintion.getDomainTickFont() != null) {
domainAxis.setTickLabelFont(categoryDatasetChartDefintion.getDomainTickFont());
}
domainAxis.setCategoryLabelPositions(categoryDatasetChartDefintion.getCategoryLabelPositions());
}
NumberAxis numberAxis = (NumberAxis) categoryPlot.getRangeAxis();
if (numberAxis != null) {
numberAxis.setLabel(categoryDatasetChartDefintion.getRangeTitle());
numberAxis.setLabelFont(categoryDatasetChartDefintion.getRangeTitleFont());
if (categoryDatasetChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
numberAxis.setLowerBound(categoryDatasetChartDefintion.getRangeMinimum());
}
if (categoryDatasetChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
numberAxis.setUpperBound(categoryDatasetChartDefintion.getRangeMaximum());
}
if (categoryDatasetChartDefintion.getRangeTickFormat() != null) {
numberAxis.setNumberFormatOverride(categoryDatasetChartDefintion.getRangeTickFormat());
}
if (categoryDatasetChartDefintion.getRangeTickFont() != null) {
numberAxis.setTickLabelFont(categoryDatasetChartDefintion.getRangeTickFont());
}
if (categoryDatasetChartDefintion.getRangeTickUnits() != null) {
numberAxis.setTickUnit(new NumberTickUnit(categoryDatasetChartDefintion.getRangeTickUnits()));
}
}
}
if (plot instanceof PiePlot) {
PiePlot pie = (PiePlot) plot;
PieDatasetChartDefinition pieDefinition = (PieDatasetChartDefinition) chartDefinition;
pie.setInteriorGap(pieDefinition.getInteriorGap());
pie.setStartAngle(pieDefinition.getStartAngle());
pie.setLabelFont(pieDefinition.getLabelFont());
if (pieDefinition.getLabelPaint() != null) {
pie.setLabelPaint(pieDefinition.getLabelPaint());
}
pie.setLabelBackgroundPaint(pieDefinition.getLabelBackgroundPaint());
if (pieDefinition.isLegendIncluded()) {
// $NON-NLS-1$
StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator("{0}");
pie.setLegendLabelGenerator(labelGen);
}
if (pieDefinition.getExplodedSlices() != null) {
for (Iterator iter = pieDefinition.getExplodedSlices().iterator(); iter.hasNext(); ) {
pie.setExplodePercent((Comparable) iter.next(), .30);
}
}
pie.setLabelGap(pieDefinition.getLabelGap());
if (!pieDefinition.isDisplayLabels()) {
pie.setLabelGenerator(null);
} else {
if (pieDefinition.isLegendIncluded()) {
// $NON-NLS-1$
StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator("{1} ({2})");
pie.setLabelGenerator(labelGen);
} else {
// $NON-NLS-1$
StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator("{0} = {1} ({2})");
pie.setLabelGenerator(labelGen);
}
}
}
if (plot instanceof MultiplePiePlot) {
MultiplePiePlot pies = (MultiplePiePlot) plot;
CategoryDatasetChartDefinition categoryDatasetChartDefintion = (CategoryDatasetChartDefinition) chartDefinition;
pies.setDataset(categoryDatasetChartDefintion);
}
if (plot instanceof MeterPlot) {
MeterPlot meter = (MeterPlot) plot;
DialWidgetDefinition widget = (DialWidgetDefinition) chartDefinition;
List intervals = widget.getIntervals();
Iterator intervalIterator = intervals.iterator();
while (intervalIterator.hasNext()) {
MeterInterval interval = (MeterInterval) intervalIterator.next();
meter.addInterval(interval);
}
meter.setNeedlePaint(widget.getNeedlePaint());
meter.setDialShape(widget.getDialShape());
meter.setDialBackgroundPaint(widget.getPlotBackgroundPaint());
meter.setRange(new Range(widget.getMinimum(), widget.getMaximum()));
}
if (plot instanceof XYPlot) {
XYPlot xyPlot = (XYPlot) plot;
if (chartDefinition instanceof XYSeriesCollectionChartDefinition) {
XYSeriesCollectionChartDefinition xySeriesCollectionChartDefintion = (XYSeriesCollectionChartDefinition) chartDefinition;
xyPlot.setOrientation(xySeriesCollectionChartDefintion.getOrientation());
ValueAxis domainAxis = xyPlot.getDomainAxis();
if (domainAxis != null) {
domainAxis.setLabel(xySeriesCollectionChartDefintion.getDomainTitle());
domainAxis.setLabelFont(xySeriesCollectionChartDefintion.getDomainTitleFont());
domainAxis.setVerticalTickLabels(xySeriesCollectionChartDefintion.isDomainVerticalTickLabels());
if (xySeriesCollectionChartDefintion.getDomainTickFormat() != null) {
((NumberAxis) domainAxis).setNumberFormatOverride(xySeriesCollectionChartDefintion.getDomainTickFormat());
}
if (xySeriesCollectionChartDefintion.getDomainTickFont() != null) {
domainAxis.setTickLabelFont(xySeriesCollectionChartDefintion.getDomainTickFont());
}
if (xySeriesCollectionChartDefintion.getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
domainAxis.setLowerBound(xySeriesCollectionChartDefintion.getDomainMinimum());
}
if (xySeriesCollectionChartDefintion.getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
domainAxis.setUpperBound(xySeriesCollectionChartDefintion.getDomainMaximum());
}
}
ValueAxis rangeAxis = xyPlot.getRangeAxis();
if (rangeAxis != null) {
rangeAxis.setLabel(xySeriesCollectionChartDefintion.getRangeTitle());
rangeAxis.setLabelFont(xySeriesCollectionChartDefintion.getRangeTitleFont());
if (xySeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
rangeAxis.setLowerBound(xySeriesCollectionChartDefintion.getRangeMinimum());
}
if (xySeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
rangeAxis.setUpperBound(xySeriesCollectionChartDefintion.getRangeMaximum());
}
if (xySeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
rangeAxis.setLowerBound(xySeriesCollectionChartDefintion.getRangeMinimum());
}
if (xySeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
rangeAxis.setUpperBound(xySeriesCollectionChartDefintion.getRangeMaximum());
}
if (xySeriesCollectionChartDefintion.getRangeTickFormat() != null) {
((NumberAxis) rangeAxis).setNumberFormatOverride(xySeriesCollectionChartDefintion.getRangeTickFormat());
}
if (xySeriesCollectionChartDefintion.getRangeTickFont() != null) {
rangeAxis.setTickLabelFont(xySeriesCollectionChartDefintion.getRangeTickFont());
}
}
} else if (chartDefinition instanceof TimeSeriesCollectionChartDefinition) {
TimeSeriesCollectionChartDefinition timeSeriesCollectionChartDefintion = (TimeSeriesCollectionChartDefinition) chartDefinition;
xyPlot.setOrientation(timeSeriesCollectionChartDefintion.getOrientation());
ValueAxis domainAxis = xyPlot.getDomainAxis();
if (domainAxis != null) {
domainAxis.setLabel(timeSeriesCollectionChartDefintion.getDomainTitle());
domainAxis.setLabelFont(timeSeriesCollectionChartDefintion.getDomainTitleFont());
domainAxis.setVerticalTickLabels(timeSeriesCollectionChartDefintion.isDomainVerticalTickLabels());
if (domainAxis instanceof DateAxis) {
DateAxis da = (DateAxis) domainAxis;
if (timeSeriesCollectionChartDefintion.getDateMinimum() != null) {
da.setMinimumDate(timeSeriesCollectionChartDefintion.getDateMinimum());
}
if (timeSeriesCollectionChartDefintion.getDateMaximum() != null) {
da.setMaximumDate(timeSeriesCollectionChartDefintion.getDateMaximum());
}
}
}
ValueAxis rangeAxis = xyPlot.getRangeAxis();
if (rangeAxis != null) {
rangeAxis.setLabel(timeSeriesCollectionChartDefintion.getRangeTitle());
rangeAxis.setLabelFont(timeSeriesCollectionChartDefintion.getRangeTitleFont());
if (timeSeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
rangeAxis.setLowerBound(timeSeriesCollectionChartDefintion.getRangeMinimum());
}
if (timeSeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
rangeAxis.setUpperBound(timeSeriesCollectionChartDefintion.getRangeMaximum());
}
}
} else if (chartDefinition instanceof XYZSeriesCollectionChartDefinition) {
XYZSeriesCollectionChartDefinition xyzSeriesCollectionChartDefintion = (XYZSeriesCollectionChartDefinition) chartDefinition;
xyPlot.setOrientation(xyzSeriesCollectionChartDefintion.getOrientation());
ValueAxis domainAxis = xyPlot.getDomainAxis();
if (domainAxis != null) {
domainAxis.setLabel(xyzSeriesCollectionChartDefintion.getDomainTitle());
domainAxis.setLabelFont(xyzSeriesCollectionChartDefintion.getDomainTitleFont());
domainAxis.setVerticalTickLabels(xyzSeriesCollectionChartDefintion.isDomainVerticalTickLabels());
if (xyzSeriesCollectionChartDefintion.getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
domainAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getDomainMinimum());
}
if (xyzSeriesCollectionChartDefintion.getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
domainAxis.setUpperBound(xyzSeriesCollectionChartDefintion.getDomainMaximum());
}
if (xyzSeriesCollectionChartDefintion.getDomainTickFormat() != null) {
((NumberAxis) domainAxis).setNumberFormatOverride(xyzSeriesCollectionChartDefintion.getDomainTickFormat());
}
if (xyzSeriesCollectionChartDefintion.getDomainTickFont() != null) {
domainAxis.setTickLabelFont(xyzSeriesCollectionChartDefintion.getDomainTickFont());
}
}
ValueAxis rangeAxis = xyPlot.getRangeAxis();
if (rangeAxis != null) {
rangeAxis.setLabel(xyzSeriesCollectionChartDefintion.getRangeTitle());
rangeAxis.setLabelFont(xyzSeriesCollectionChartDefintion.getRangeTitleFont());
rangeAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getRangeMinimum());
if (xyzSeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
rangeAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getRangeMinimum());
}
if (xyzSeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
rangeAxis.setUpperBound(xyzSeriesCollectionChartDefintion.getRangeMaximum());
}
if (xyzSeriesCollectionChartDefintion.getRangeTickFormat() != null) {
((NumberAxis) rangeAxis).setNumberFormatOverride(xyzSeriesCollectionChartDefintion.getRangeTickFormat());
}
if (xyzSeriesCollectionChartDefintion.getRangeTickFont() != null) {
rangeAxis.setTickLabelFont(xyzSeriesCollectionChartDefintion.getRangeTickFont());
}
}
}
}
}
use of org.jfree.chart.plot.MeterInterval in project SIMVA-SoS by SESoS.
the class MeterChartTest method testDrawWithNullInfo.
/**
* Draws the chart with a single range. At one point, this caused a null
* pointer exception (fixed now).
*/
@Test
public void testDrawWithNullInfo() {
MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0));
plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0)));
JFreeChart chart = new JFreeChart(plot);
BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
// FIXME we should really assert a value here
}
use of org.jfree.chart.plot.MeterInterval in project dhis2-core by dhis2.
the class DefaultChartService method getGaugeChart.
private JFreeChart getGaugeChart(PlotData plotData, ValueDataset dataSet) {
MeterPlot meterPlot = new MeterPlot(dataSet);
meterPlot.setUnits("");
meterPlot.setRange(new Range(0.0d, 100d));
for (int i = 0; i < 10; i++) {
double start = i * 10d;
double end = start + 10d;
String label = String.valueOf(start);
meterPlot.addInterval(new MeterInterval(label, new Range(start, end), COLOR_LIGHT_GRAY, null, COLOR_LIGHT_GRAY));
}
meterPlot.setMeterAngle(180);
meterPlot.setDialBackgroundPaint(COLOR_LIGHT_GRAY);
meterPlot.setDialShape(DialShape.CHORD);
meterPlot.setNeedlePaint(COLORS[0]);
meterPlot.setTickLabelsVisible(true);
meterPlot.setTickLabelFont(LABEL_FONT);
meterPlot.setTickLabelPaint(Color.BLACK);
meterPlot.setTickPaint(COLOR_LIGHTER_GRAY);
meterPlot.setValueFont(TITLE_FONT);
meterPlot.setValuePaint(Color.BLACK);
JFreeChart meterChart = new JFreeChart(plotData.getName(), meterPlot);
setBasicConfig(meterChart, plotData);
meterChart.removeLegend();
return meterChart;
}
use of org.jfree.chart.plot.MeterInterval in project pentaho-platform by pentaho.
the class DialWidgetDefinition method createDial.
/*
* public ThermometerWidgetDefinition createThermometer( Document doc ) { // TODO implement this to return a
* ThermometerWidgetDefinition object return null; }
*/
/**
* Create a dial definition object from an XML document
*
* @param doc
* definition XML document
* @return Dial definition object
*/
public static void createDial(final DialWidgetDefinition widgetDefinition, final Node dialNode, final int width, final int height, final IPentahoSession session) {
// $NON-NLS-1$
Node node = dialNode.selectSingleNode("units");
if (node != null) {
String units = node.getText();
widgetDefinition.setUnits(units);
}
// set the background Paint
// $NON-NLS-1$
Paint paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("background-color"));
if (paint == null) {
// $NON-NLS-1$
Element backgroundNode = (Element) dialNode.selectSingleNode("chart-background");
if (backgroundNode != null) {
// $NON-NLS-1$
String backgroundType = backgroundNode.attributeValue("type");
if ("texture".equals(backgroundType)) {
// $NON-NLS-1$
paint = JFreeChartEngine.getTexturePaint(backgroundNode, width, height, session);
} else if ("gradient".equals(backgroundType)) {
// $NON-NLS-1$
paint = JFreeChartEngine.getGradientPaint(backgroundNode, width, height);
}
}
} else {
// log a deprecation warning for background-color ...
DialWidgetDefinition.getLogger().warn(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getInstance().getString("CHART.WARN_DEPRECATED_PROPERTY", "background-color", "chart-background"));
DialWidgetDefinition.getLogger().warn(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getInstance().getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", "background-color"));
}
if (paint != null) {
widgetDefinition.setChartBackgroundPaint(paint);
}
// set the dial background Paint
// $NON-NLS-1$
paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("plot-background-color"));
if (paint == null) {
// $NON-NLS-1$
Element backgroundNode = (Element) dialNode.selectSingleNode("plot-background");
if (backgroundNode != null) {
// $NON-NLS-1$
String backgroundType = backgroundNode.attributeValue("type");
if ("texture".equals(backgroundType)) {
// $NON-NLS-1$
paint = JFreeChartEngine.getTexturePaint(backgroundNode, width, height, session);
} else if ("gradient".equals(backgroundType)) {
// $NON-NLS-1$
paint = JFreeChartEngine.getGradientPaint(backgroundNode, width, height);
}
}
} else {
// log a deprecation warning for plot-background-color ...
DialWidgetDefinition.getLogger().warn(Messages.getInstance().getString("CHART.WARN_DEPRECATED_PROPERTY", "plot-background-color", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"plot-background"));
DialWidgetDefinition.getLogger().warn(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getInstance().getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", "plot-background-color"));
}
if (paint != null) {
widgetDefinition.setPlotBackgroundPaint(paint);
}
// set the needle Paint
// $NON-NLS-1$
paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("needle-color"));
if (paint != null) {
widgetDefinition.setNeedlePaint(paint);
}
// set the tick Paint
// $NON-NLS-1$
paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("tick-color"));
if (paint != null) {
widgetDefinition.setTickPaint(paint);
}
// $NON-NLS-1$
Node tmpNode = dialNode.selectSingleNode("tick-interval");
if (tmpNode != null) {
// $NON-NLS-1$
widgetDefinition.setTickSize(Integer.parseInt(dialNode.selectSingleNode("tick-interval").getText()));
}
// set the value Paint
// $NON-NLS-1$
paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("value-color"));
if (paint != null) {
widgetDefinition.setValuePaint(paint);
}
// TODO get this from the XML document
widgetDefinition.setDialShape(DialShape.CHORD);
// $NON-NLS-1$
Node titleFontNode = dialNode.selectSingleNode("title-font");
if (titleFontNode != null) {
// $NON-NLS-1$
Node fontNode = titleFontNode.selectSingleNode("font");
if (fontNode != null) {
String titleFontStr = fontNode.getText().trim();
if (!"".equals(titleFontStr)) {
// $NON-NLS-1$
// $NON-NLS-1$
Node titleFontSizeNode = titleFontNode.selectSingleNode("size");
int size = titleFontSizeNode != null ? Integer.parseInt(titleFontSizeNode.getText()) : 12;
widgetDefinition.setTitleFont(new Font(titleFontStr, Font.BOLD, size));
}
} else {
String titleFontStr = titleFontNode.getText().trim();
if (!"".equals(titleFontStr)) {
// $NON-NLS-1$
widgetDefinition.setTitleFont(new Font(titleFontStr, Font.ITALIC, 24));
}
}
}
// $NON-NLS-1$
Node valueFontNode = dialNode.selectSingleNode("domain-tick-font");
if (valueFontNode != null) {
// $NON-NLS-1$
Node fontNode = valueFontNode.selectSingleNode("font");
if (fontNode != null) {
String fontStr = fontNode.getText().trim();
if (!"".equals(fontStr)) {
// $NON-NLS-1$
// $NON-NLS-1$
Node valueFontSizeNode = valueFontNode.selectSingleNode("size");
int size = valueFontSizeNode != null ? Integer.parseInt(valueFontSizeNode.getText()) : 12;
widgetDefinition.setValueFont(new Font(fontStr, Font.BOLD, size));
}
} else {
String fontStr = valueFontNode.getText().trim();
if (!"".equals(fontStr)) {
// $NON-NLS-1$
widgetDefinition.setValueFont(new Font(fontStr, Font.ITALIC, 24));
}
}
}
// set any intervals that are defined in the document
// A list of interval nodes should not be allowed to exist as a child of the main XML element (for XML schema
// to
// be well constructed and validate the XML .
// We have deprecated <interval> as a child of the main node , and now require an <intervals> parent node
// under which <intervals> can exist.
// $NON-NLS-1$
List intervals = dialNode.selectNodes("interval");
if ((intervals == null) || (intervals.isEmpty())) {
// $NON-NLS-1$
Node intervalsNode = dialNode.selectSingleNode("intervals");
if (intervalsNode != null) {
// $NON-NLS-1$
intervals = intervalsNode.selectNodes("interval");
}
} else {
// log a deprecation warning for this property...
DialWidgetDefinition.getLogger().warn(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getInstance().getString("CHART.WARN_DEPRECATED_CHILD", "interval", "intervals"));
DialWidgetDefinition.getLogger().warn(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getInstance().getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", "interval"));
}
if (intervals != null) {
Iterator intervalIterator = intervals.iterator();
while (intervalIterator.hasNext()) {
// get the interval node
Node intervalNode = (Node) intervalIterator.next();
// get the interval name
// $NON-NLS-1$
String label = intervalNode.selectSingleNode("label").getText();
// get the range of the interval
// $NON-NLS-1$
double minimum = Double.parseDouble(intervalNode.selectSingleNode("minimum").getText());
// $NON-NLS-1$
double maximum = Double.parseDouble(intervalNode.selectSingleNode("maximum").getText());
Range range = new Range(minimum, maximum);
// $NON-NLS-1$
Paint backgroundPaint = JFreeChartEngine.getPaint(intervalNode.selectSingleNode("color"));
if (backgroundPaint == null) {
// $NON-NLS-1$
Element backgroundNode = (Element) intervalNode.selectSingleNode("interval-background");
if (backgroundNode != null) {
// $NON-NLS-1$
String backgroundType = backgroundNode.attributeValue("type");
if ("texture".equals(backgroundType)) {
// $NON-NLS-1$
backgroundPaint = JFreeChartEngine.getTexturePaint(backgroundNode, width, height, session);
} else if ("gradient".equals(backgroundType)) {
// $NON-NLS-1$
backgroundPaint = JFreeChartEngine.getGradientPaint(backgroundNode, width, height);
}
}
}
// get the text color of the interval
// $NON-NLS-1$
String textColor = intervalNode.selectSingleNode("text-color").getText();
Stroke outlineStroke;
if (intervalNode.selectSingleNode("stroke-width") != null) {
// $NON-NLS-1$
outlineStroke = // $NON-NLS-1$
new BasicStroke(Float.parseFloat(intervalNode.selectSingleNode("stroke-width").getText()));
} else {
outlineStroke = new BasicStroke();
}
Paint outlinePaint = JFreeChartEngine.getPaint(textColor);
// create the interval object
MeterInterval interval = new MeterInterval(label, range, outlinePaint, outlineStroke, backgroundPaint);
// add the interval to the widget
widgetDefinition.addInterval(interval);
}
}
// get the chart subtitles
// A list of <subtitle> nodes should not be allowed to exist as a child of the main XML element (for XML schema
// to
// be well constructed and validate the XML .
// We have deprecated <subtitle> as a child of the main node , and now require a <subtitles> parent node
// under which <subtitle> can exist.
List subtitles = dialNode.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);
if ((subtitles == null) || (subtitles.isEmpty())) {
Node subTitlesNode = dialNode.selectSingleNode(ChartDefinition.SUBTITLES_NODE_NAME);
if (subTitlesNode != null) {
subtitles = subTitlesNode.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);
}
} else {
// log a deprecation warning for this property...
DialWidgetDefinition.getLogger().warn(Messages.getInstance().getString("CHART.WARN_DEPRECATED_CHILD", ChartDefinition.SUBTITLE_NODE_NAME, // $NON-NLS-1$
ChartDefinition.SUBTITLES_NODE_NAME));
DialWidgetDefinition.getLogger().warn(Messages.getInstance().getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", // $NON-NLS-1$
ChartDefinition.SUBTITLE_NODE_NAME));
}
if (subtitles != null) {
widgetDefinition.addSubTitles(subtitles);
}
}
Aggregations