List of usage examples for org.jfree.chart.plot DialShape CHORD
DialShape CHORD
To view the source code for org.jfree.chart.plot DialShape CHORD.
Click Source Link
From source file:org.jfree.chart.demo.MeterChartDemo.java
/** * Starting point for the meter plot demonstration application. * * @param args used to specify the type and value. *///from w w w . j a v a 2s . c o m public static void main(final String[] args) { if (args.length == 0) { System.err.println("Usage: java TestMeter <type> <value>"); System.err.println("Type: 0 = PIE"); System.err.println("Type: 1 = CIRCLE"); System.err.println("Type: 2 = CHORD"); } final MeterChartDemo h = new MeterChartDemo(); double val = 85; DialShape dialShape = DialShape.CIRCLE; if (args.length > 0) { final int type = Integer.parseInt(args[0]); if (type == 0) { dialShape = DialShape.PIE; } else if (type == 1) { dialShape = DialShape.CIRCLE; } else if (type == 0) { dialShape = DialShape.CHORD; } } if (args.length > 1) { val = new Double(args[1]).doubleValue(); } h.displayMeterChart(val, dialShape); }
From source file:org.jfree.chart.demo.MeterChartDemo1.java
private static JFreeChart createChart(ValueDataset valuedataset) { MeterPlot meterplot = new MeterPlot(valuedataset); meterplot.setRange(new Range(0.0D, 60D)); meterplot.addInterval(new MeterInterval("Normal", new Range(0.0D, 35D), Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Warning", new Range(35D, 50D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 255, 0, 64))); meterplot.addInterval(new MeterInterval("Critical", new Range(50D, 60D), Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0, 128))); meterplot.setNeedlePaint(Color.darkGray); meterplot.setDialBackgroundPaint(Color.white); meterplot.setDialOutlinePaint(Color.gray); meterplot.setDialShape(DialShape.CHORD); meterplot.setMeterAngle(260);/*w w w .j av a2 s . c o m*/ meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(5D); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); JFreeChart jfreechart = new JFreeChart("Meter Chart 1", JFreeChart.DEFAULT_TITLE_FONT, meterplot, true); return jfreechart; }
From source file:org.jfree.chart.demo.MeterChartDemo3.java
public static JPanel createDemoPanel() { JPanel jpanel = new JPanel(new GridLayout(1, 3)); DefaultValueDataset defaultvaluedataset = new DefaultValueDataset(23D); ChartPanel chartpanel = new ChartPanel(createChart("DialShape.PIE", defaultvaluedataset, DialShape.PIE)); ChartPanel chartpanel1 = new ChartPanel( createChart("DialShape.CHORD", defaultvaluedataset, DialShape.CHORD)); ChartPanel chartpanel2 = new ChartPanel( createChart("DialShape.CIRCLE", defaultvaluedataset, DialShape.CIRCLE)); jpanel.add(chartpanel);//from w ww. ja va 2 s.c o m jpanel.add(chartpanel1); jpanel.add(chartpanel2); return jpanel; }
From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.Meter.java
/** * Creates the MeterChart ./*ww w . j av a 2s . c o m*/ * * @return A MeterChart . */ public JFreeChart createChart() { logger.debug("IN"); if (dataset == null) { logger.debug("The dataset to be represented is null"); return null; } MeterPlot plot = new MeterPlot((ValueDataset) dataset); logger.debug("Created new plot"); plot.setRange(new Range(lower, upper)); logger.debug("Setted plot range"); for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()), Color.lightGray, new BasicStroke(2.0f), interval.getColor())); logger.debug("Added new interval to the plot"); } plot.setNeedlePaint(Color.darkGray); plot.setDialBackgroundPaint(Color.white); plot.setDialOutlinePaint(Color.gray); plot.setDialShape(DialShape.CHORD); plot.setMeterAngle(260); plot.setTickLabelsVisible(true); Font f = new Font("Arial", Font.PLAIN, 11); plot.setTickLabelFont(f); plot.setTickLabelPaint(Color.darkGray); plot.setTickSize(5.0); plot.setTickPaint(Color.lightGray); plot.setValuePaint(Color.black); plot.setValueFont(new Font("Arial", Font.PLAIN, 14)); logger.debug("Setted all properties of the plot"); JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); logger.debug("Created the chart"); chart.setBackgroundPaint(color); logger.debug("Setted background color of the chart"); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); logger.debug("Setted the title of the chart"); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); logger.debug("Setted the subtitle of the chart"); } logger.debug("OUT"); return chart; }
From source file:org.adempiere.webui.apps.graph.jfreegraph.PerformanceGraphBuilder.java
public JFreeChart createIndicatorChart(IndicatorModel model) { JFreeChart chart = null;// w w w .j ava 2s. c o m DefaultValueDataset data = new DefaultValueDataset((float) model.goalModel.getPercent()); MeterPlot plot = new MeterPlot(data); MColorSchema colorSchema = model.goalModel.getColorSchema(); int rangeLo = 0; int rangeHi = 0; Point2D start = new Point2D.Float(0, 0); Point2D end = new Point2D.Float(50, 50); float[] dist = { 0.0f, 0.2f, 0.45f, 0.75f, 1.0f }; for (int i = 1; i <= 4; i++) { switch (i) { case 1: rangeHi = colorSchema.getMark1Percent(); break; case 2: rangeHi = colorSchema.getMark2Percent(); break; case 3: rangeHi = colorSchema.getMark3Percent(); break; case 4: rangeHi = colorSchema.getMark4Percent(); break; } if (rangeHi == 9999) rangeHi = (int) Math.floor(rangeLo * 1.5); if (rangeLo < rangeHi) { Color[] colors = { colorSchema.getColor(rangeHi).brighter().brighter(), colorSchema.getColor(rangeHi).brighter(), colorSchema.getColor(rangeHi), colorSchema.getColor(rangeHi).darker(), colorSchema.getColor(rangeHi).darker().darker() }; LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors); plot.addInterval(new MeterInterval("Normal", //label new Range(rangeLo, rangeHi), //range p, new BasicStroke(7.0f), model.dialBackground)); rangeLo = rangeHi; } } plot.setRange(new Range(0, rangeLo)); plot.setDialBackgroundPaint(model.dialBackground); plot.setUnits(""); plot.setDialShape(DialShape.CHORD); plot.setNeedlePaint(model.needleColor); plot.setTickSize(2000); plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8)); plot.setValueFont(new Font("SansSerif", Font.BOLD, 8)); plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8)); plot.setTickLabelPaint(model.tickColor); plot.setValuePaint(new Color(0.0f, 0.0f, 0.0f, 0.0f)); plot.setTickPaint(model.tickColor); // chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 9), plot, false); return chart; }
From source file:org.adempiere.webui.apps.graph.WPerformanceIndicator.java
private JFreeChart createChart() { JFreeChart chart = null;//from w w w.j a va 2s. c o m // Set Text StringBuffer text = new StringBuffer(m_goal.getName()); if (m_goal.isTarget()) text.append(": ").append(m_goal.getPercent()).append("%"); else text.append(": ").append(s_format.format(m_goal.getMeasureActual())); m_text = text.toString(); // ToolTip text = new StringBuffer(); if (m_goal.getDescription() != null) text.append(m_goal.getDescription()).append(": "); text.append(s_format.format(m_goal.getMeasureActual())); if (m_goal.isTarget()) text.append(" ").append(Msg.getMsg(Env.getCtx(), "of")).append(" ") .append(s_format.format(m_goal.getMeasureTarget())); setTooltiptext(text.toString()); // DefaultValueDataset data = new DefaultValueDataset((float) m_goal.getPercent()); MeterPlot plot = new MeterPlot(data); MColorSchema colorSchema = m_goal.getColorSchema(); int rangeLo = 0; int rangeHi = 0; for (int i = 1; i <= 4; i++) { switch (i) { case 1: rangeHi = colorSchema.getMark1Percent(); break; case 2: rangeHi = colorSchema.getMark2Percent(); break; case 3: rangeHi = colorSchema.getMark3Percent(); break; case 4: rangeHi = colorSchema.getMark4Percent(); break; } if (rangeHi == 9999) rangeHi = (int) Math.floor(rangeLo * 1.5); if (rangeLo < rangeHi) { plot.addInterval(new MeterInterval("Normal", //label new Range(rangeLo, rangeHi), //range colorSchema.getColor(rangeHi), new BasicStroke(7.0f), new Color(-13091716))); rangeLo = rangeHi; } } plot.setRange(new Range(0, rangeLo)); plot.setDialBackgroundPaint(new Color(-13091716)); plot.setUnits(""); plot.setDialShape(DialShape.CHORD);//CIRCLE); plot.setNeedlePaint(Color.white); plot.setTickSize(2000); plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8)); plot.setValueFont(new Font("SansSerif", Font.BOLD, 8)); plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8)); plot.setTickLabelPaint(Color.white); plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); chart = new JFreeChart(m_text, new Font("SansSerif", Font.BOLD, 9), plot, false); return chart; }
From source file:edu.cuny.cat.ui.ClockPanel.java
@Override public void setup(final ParameterDatabase parameters, final Parameter base) { clock = GameController.getInstance().getClock(); dataset = new DefaultValueDataset(); meterplot = new MyMeterPlot(dataset) { /**//from ww w . ja v a 2s .c o m * */ private static final long serialVersionUID = 1L; @Override protected void drawValueLabel(final Graphics2D g2, final Rectangle2D area) { g2.setFont(getValueFont()); g2.setPaint(getValuePaint()); String valueStr = "No value"; if (dataset != null) { final Number n = dataset.getValue(); if (n != null) { if (n.intValue() == 0) { valueStr = "to start"; } else if (n.intValue() == clock.getGameLen() * clock.getDayLen()) { valueStr = "done"; } else { valueStr = "day " + (n.intValue() / clock.getDayLen()) + ", round " + (n.intValue() % clock.getDayLen()); } } } final float x = (float) area.getCenterX(); final float y = (float) area.getCenterY() + MeterPlot.DEFAULT_CIRCLE_SIZE; TextUtilities.drawAlignedString(valueStr, g2, x, y, TextAnchor.TOP_CENTER); } }; meterplot.setRange(new Range(0, clock.getDayLen() * clock.getGameLen())); meterplot.setNeedlePaint( parameters.getColorWithDefault(base.push(ClockPanel.P_NEEDLE), null, Color.darkGray)); meterplot.setDialBackgroundPaint(new Color(0, 255, 0, 64)); meterplot.setDialOutlinePaint(Color.gray); meterplot.setDialShape(DialShape.CHORD); meterplot.setMeterAngle(parameters.getIntWithDefault(base.push(ClockPanel.P_ANGLE), null, 260)); meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(clock.getDayLen()); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); meterplot.setUnits(""); meterplot.setTickLabelFormat(new NumberFormat() { /** * */ private static final long serialVersionUID = 1L; @Override public StringBuffer format(final double number, final StringBuffer toAppendTo, final FieldPosition pos) { return format((long) number, toAppendTo, pos); } @Override public StringBuffer format(final long number, final StringBuffer toAppendTo, final FieldPosition pos) { if (number % clock.getDayLen() == 0) { toAppendTo.append(String.valueOf(number / clock.getDayLen())); } return toAppendTo; } @Override public Number parse(final String source, final ParsePosition parsePosition) { return null; } }); final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, meterplot, false); final ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(parameters.getIntWithDefault(base.push(ClockPanel.P_WIDTH), null, 200), parameters.getIntWithDefault(base.push(ClockPanel.P_HEIGHT), null, 200))); add(panel, BorderLayout.CENTER); initIterationLabel(); initScoreReport(); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.Meter.java
/** * Creates the chart ./*from w w w. ja v a 2 s. co m*/ * * @param chartTitle the chart title. * @param dataset the dataset. * * @return A chart . */ public JFreeChart createChart(DatasetMap datasets) { Dataset dataset = (Dataset) datasets.getDatasets().get("1"); MeterPlot plot = new MeterPlot((ValueDataset) dataset); plot.setRange(new Range(lower, upper)); for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()), Color.lightGray, new BasicStroke(2.0f), interval.getColor())); } plot.setNeedlePaint(Color.darkGray); plot.setDialBackgroundPaint(Color.white); plot.setDialOutlinePaint(Color.gray); plot.setDialShape(DialShape.CHORD); plot.setMeterAngle(260); plot.setTickLabelsVisible(true); //set tick label style Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize()); plot.setTickLabelFont(tickLabelsFont); plot.setTickLabelPaint(labelsTickStyle.getColor()); plot.setTickSize(5.0); plot.setTickPaint(Color.lightGray); if (units != null) { plot.setUnits(units); } plot.setValuePaint(labelsValueStyle.getColor()); plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize())); JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(color); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }
From source file:org.adempiere.apps.graph.PerformanceIndicator.java
private JFreeChart createChart() { JFreeChart chart = null;//from ww w . j a va 2 s. c om // Set Text StringBuffer text = new StringBuffer(m_goal.getName()); if (m_goal.isTarget()) text.append(": ").append(m_goal.getPercent()).append("%"); else text.append(": ").append(s_format.format(m_goal.getMeasureActual())); m_text = text.toString(); // ToolTip text = new StringBuffer(); if (m_goal.getDescription() != null) text.append(m_goal.getDescription()).append(": "); text.append(s_format.format(m_goal.getMeasureActual())); if (m_goal.isTarget()) text.append(" ").append(Msg.getMsg(Env.getCtx(), "of")).append(" ") .append(s_format.format(m_goal.getMeasureTarget())); setToolTipText(text.toString()); // //setBackground(m_goal.getColor()); setForeground(GraphUtil.getForeground(getBackground())); // Performance Line int percent = m_goal.getPercent(); if (percent > 100) // draw 100% line m_line = s_width100; else // draw Performance Line m_line = s_width100 * m_goal.getGoalPerformanceDouble(); String title = m_text; DefaultValueDataset data = new DefaultValueDataset((float) m_goal.getPercent()); MeterPlot plot = new MeterPlot(data); MColorSchema colorSchema = m_goal.getColorSchema(); int rangeLo = 0; int rangeHi = 0; for (int i = 1; i <= 4; i++) { switch (i) { case 1: rangeHi = colorSchema.getMark1Percent(); break; case 2: rangeHi = colorSchema.getMark2Percent(); break; case 3: rangeHi = colorSchema.getMark3Percent(); break; case 4: rangeHi = colorSchema.getMark4Percent(); break; } if (rangeHi == 9999) rangeHi = (int) Math.floor(rangeLo * 1.5); if (rangeLo < rangeHi) { plot.addInterval(new MeterInterval("Normal", //label new Range(rangeLo, rangeHi), //range colorSchema.getColor(rangeHi), new BasicStroke(7.0f), //Color.lightGray new Color(-13091716) //Color.gray )); rangeLo = rangeHi; } } plot.setRange(new Range(0, rangeLo)); plot.setDialBackgroundPaint(new Color(-13091716));//Color.GRAY); plot.setUnits(m_goal.getName()); plot.setDialShape(DialShape.CHORD);//CIRCLE); //plot.setDialBackgroundPaint(new GradientPaint(0, 0, m_goal.getColor(), 0, 1000, Color.black)); plot.setNeedlePaint(Color.white); plot.setTickSize(2000); plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 12)); plot.setTickLabelPaint(Color.white); plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); chart = new JFreeChart(m_text, new Font("SansSerif", Font.BOLD, 15), plot, false); return chart; }
From source file:org.pentaho.platform.uifoundation.chart.DialWidgetDefinition.java
/** * Create a dial definition object from an XML document * //from w w w . j a va 2 s . com * @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) { Node node = dialNode.selectSingleNode("units"); //$NON-NLS-1$ if (node != null) { String units = node.getText(); widgetDefinition.setUnits(units); } // set the background Paint Paint paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("background-color")); //$NON-NLS-1$ if (paint == null) { Element backgroundNode = (Element) dialNode.selectSingleNode("chart-background"); //$NON-NLS-1$ if (backgroundNode != null) { String backgroundType = backgroundNode.attributeValue("type"); //$NON-NLS-1$ 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(Messages.getInstance().getString("CHART.WARN_DEPRECATED_PROPERTY", //$NON-NLS-1$ "background-color", "chart-background")); //$NON-NLS-1$ //$NON-NLS-2$ DialWidgetDefinition.getLogger().warn( Messages.getInstance().getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", "background-color")); //$NON-NLS-1$ //$NON-NLS-2$ } if (paint != null) { widgetDefinition.setChartBackgroundPaint(paint); } // set the dial background Paint paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("plot-background-color")); //$NON-NLS-1$ if (paint == null) { Element backgroundNode = (Element) dialNode.selectSingleNode("plot-background"); //$NON-NLS-1$ if (backgroundNode != null) { String backgroundType = backgroundNode.attributeValue("type"); //$NON-NLS-1$ 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", //$NON-NLS-1$ "plot-background-color", "plot-background")); //$NON-NLS-1$ //$NON-NLS-2$ DialWidgetDefinition.getLogger().warn(Messages.getInstance() .getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", "plot-background-color")); //$NON-NLS-1$ //$NON-NLS-2$ } if (paint != null) { widgetDefinition.setPlotBackgroundPaint(paint); } // set the needle Paint paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("needle-color")); //$NON-NLS-1$ if (paint != null) { widgetDefinition.setNeedlePaint(paint); } // set the tick Paint paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("tick-color")); //$NON-NLS-1$ if (paint != null) { widgetDefinition.setTickPaint(paint); } Node tmpNode = dialNode.selectSingleNode("tick-interval"); //$NON-NLS-1$ if (tmpNode != null) { widgetDefinition.setTickSize(Integer.parseInt(dialNode.selectSingleNode("tick-interval").getText())); //$NON-NLS-1$ } // set the value Paint paint = JFreeChartEngine.getPaint(dialNode.selectSingleNode("value-color")); //$NON-NLS-1$ if (paint != null) { widgetDefinition.setValuePaint(paint); } // TODO get this from the XML document widgetDefinition.setDialShape(DialShape.CHORD); Node titleFontNode = dialNode.selectSingleNode("title-font"); //$NON-NLS-1$ if (titleFontNode != null) { Node fontNode = titleFontNode.selectSingleNode("font"); //$NON-NLS-1$ if (fontNode != null) { String titleFontStr = fontNode.getText().trim(); if (!"".equals(titleFontStr)) { //$NON-NLS-1$ Node titleFontSizeNode = titleFontNode.selectSingleNode("size"); //$NON-NLS-1$ 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)); } } } Node valueFontNode = dialNode.selectSingleNode("domain-tick-font"); //$NON-NLS-1$ if (valueFontNode != null) { Node fontNode = valueFontNode.selectSingleNode("font"); //$NON-NLS-1$ if (fontNode != null) { String fontStr = fontNode.getText().trim(); if (!"".equals(fontStr)) { //$NON-NLS-1$ Node valueFontSizeNode = valueFontNode.selectSingleNode("size"); //$NON-NLS-1$ 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. List intervals = dialNode.selectNodes("interval"); //$NON-NLS-1$ if ((intervals == null) || (intervals.isEmpty())) { Node intervalsNode = dialNode.selectSingleNode("intervals"); //$NON-NLS-1$ if (intervalsNode != null) { intervals = intervalsNode.selectNodes("interval"); //$NON-NLS-1$ } } else { // log a deprecation warning for this property... DialWidgetDefinition.getLogger() .warn(Messages.getInstance().getString("CHART.WARN_DEPRECATED_CHILD", "interval", "intervals")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ DialWidgetDefinition.getLogger() .warn(Messages.getInstance().getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", "interval")); //$NON-NLS-1$ //$NON-NLS-2$ } if (intervals != null) { Iterator intervalIterator = intervals.iterator(); while (intervalIterator.hasNext()) { // get the interval node Node intervalNode = (Node) intervalIterator.next(); // get the interval name String label = intervalNode.selectSingleNode("label").getText(); //$NON-NLS-1$ // get the range of the interval double minimum = Double.parseDouble(intervalNode.selectSingleNode("minimum").getText()); //$NON-NLS-1$ double maximum = Double.parseDouble(intervalNode.selectSingleNode("maximum").getText()); //$NON-NLS-1$ Range range = new Range(minimum, maximum); Paint backgroundPaint = JFreeChartEngine.getPaint(intervalNode.selectSingleNode("color")); //$NON-NLS-1$ if (backgroundPaint == null) { Element backgroundNode = (Element) intervalNode.selectSingleNode("interval-background"); //$NON-NLS-1$ if (backgroundNode != null) { String backgroundType = backgroundNode.attributeValue("type"); //$NON-NLS-1$ 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 String textColor = intervalNode.selectSingleNode("text-color").getText(); //$NON-NLS-1$ Stroke outlineStroke; if (intervalNode.selectSingleNode("stroke-width") != null) { //$NON-NLS-1$ outlineStroke = new BasicStroke( Float.parseFloat(intervalNode.selectSingleNode("stroke-width").getText())); //$NON-NLS-1$ } 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", //$NON-NLS-1$ ChartDefinition.SUBTITLE_NODE_NAME, ChartDefinition.SUBTITLES_NODE_NAME)); DialWidgetDefinition.getLogger().warn(Messages.getInstance() .getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", ChartDefinition.SUBTITLE_NODE_NAME)); //$NON-NLS-1$ } if (subtitles != null) { widgetDefinition.addSubTitles(subtitles); } }