use of org.jfree.data.general.DefaultValueDataset 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.data.general.DefaultValueDataset in project adempiere by adempiere.
the class PerformanceIndicator method createChart.
// getGoal
private JFreeChart createChart() {
JFreeChart chart = null;
// 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 (// draw 100% line
percent > 100)
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 //label
MeterInterval(//label
"Normal", //range
new Range(rangeLo, rangeHi), colorSchema.getColor(rangeHi), new BasicStroke(7.0f), //Color.lightGray
new Color(-13091716)));
rangeLo = rangeHi;
}
}
plot.setRange(new Range(0, rangeLo));
//Color.GRAY);
plot.setDialBackgroundPaint(new Color(-13091716));
plot.setUnits(m_goal.getName());
//CIRCLE);
plot.setDialShape(DialShape.CHORD);
//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;
}
use of org.jfree.data.general.DefaultValueDataset in project adempiere by adempiere.
the class WPerformanceIndicator method createChart.
// getGoal
private JFreeChart createChart() {
JFreeChart chart = null;
// 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 //label
MeterInterval(//label
"Normal", //range
new Range(rangeLo, rangeHi), colorSchema.getColor(rangeHi), new BasicStroke(7.0f), null));
rangeLo = rangeHi;
}
}
plot.setRange(new Range(0, rangeLo));
// new Color(-13091716)
plot.setDialBackgroundPaint(null);
plot.setUnits("");
//CIRCLE);
plot.setDialShape(DialShape.CHORD);
plot.setDialOutlinePaint(Color.GRAY);
plot.setNeedlePaint(Color.BLACK);
plot.setTickSize(2000);
plot.setTickPaint(Color.DARK_GRAY);
plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8));
plot.setTickLabelPaint(Color.DARK_GRAY);
plot.setValueFont(new Font("SansSerif", Font.BOLD, 8));
plot.setValuePaint(Color.BLUE);
plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8));
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;
}
use of org.jfree.data.general.DefaultValueDataset in project bamboobsc by billchen198318.
the class CommonMeterChartAction method fillChart.
private void fillChart(String title, float value, int lowerBound, int upperBound) throws Exception {
DefaultValueDataset dataset = new DefaultValueDataset();
dataset.setValue(value);
DialPlot plot = new DialPlot();
plot.setView(0.0d, 0.0d, 1.0d, 1.0d);
plot.setDataset(0, dataset);
StandardDialFrame frame = new StandardDialFrame();
plot.setDialFrame(frame);
DialBackground dialBackground = new DialBackground();
dialBackground.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
plot.setBackground(dialBackground);
DialTextAnnotation textAnnotation = new DialTextAnnotation(title);
textAnnotation.setRadius(0.555555555555555555D);
plot.addLayer(textAnnotation);
DialValueIndicator valueIndicator = new DialValueIndicator(0);
plot.addLayer(valueIndicator);
StandardDialScale scale1 = new StandardDialScale();
scale1.setLowerBound(lowerBound);
scale1.setUpperBound(upperBound);
// -120
scale1.setStartAngle(-140);
// -300D
scale1.setExtent(-260D);
scale1.setTickRadius(0.88D);
scale1.setTickLabelOffset(0.14999999999999999D);
scale1.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 14));
plot.addScale(0, scale1);
StandardDialRange standarddialrange0 = new StandardDialRange(lowerBound, (upperBound * 0.6), Color.red);
standarddialrange0.setInnerRadius(0.52000000000000002D);
standarddialrange0.setOuterRadius(0.55000000000000004D);
plot.addLayer(standarddialrange0);
StandardDialRange standarddialrange1 = new StandardDialRange((upperBound * 0.6), (upperBound * 0.8), Color.orange);
standarddialrange1.setInnerRadius(0.52000000000000002D);
standarddialrange1.setOuterRadius(0.55000000000000004D);
plot.addLayer(standarddialrange1);
StandardDialRange standarddialrange2 = new StandardDialRange((upperBound * 0.8), upperBound, Color.green);
standarddialrange2.setInnerRadius(0.52000000000000002D);
standarddialrange2.setOuterRadius(0.55000000000000004D);
plot.addLayer(standarddialrange2);
Pointer pointer = new Pointer(0);
pointer.setFillPaint(new Color(144, 196, 246));
plot.addPointer(pointer);
plot.mapDatasetToScale(0, 0);
DialCap dialcap = new DialCap();
dialcap.setRadius(0.0700000000000001D);
plot.setCap(dialcap);
this.chart = new JFreeChart(plot);
//this.chart.setBackgroundPaint(new Color(234, 244, 253));
this.chart.setBackgroundPaint(Color.white);
}
Aggregations