use of org.jfree.ui.RectangleInsets 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.ui.RectangleInsets in project jgnash by ccavanaugh.
the class SecuritiesHistoryDialog method createChart.
private static JFreeChart createChart(final SecurityNode node) {
Objects.requireNonNull(node);
final List<SecurityHistoryNode> hNodes = node.getHistoryNodes();
final Date max = DateUtils.asDate(hNodes.get(hNodes.size() - 1).getLocalDate());
final Date min = DateUtils.asDate(hNodes.get(0).getLocalDate());
final DateAxis timeAxis = new DateAxis(null);
timeAxis.setVisible(false);
timeAxis.setAutoRange(false);
timeAxis.setRange(min, max);
final NumberAxis valueAxis = new NumberAxis(null);
valueAxis.setAutoRangeIncludesZero(false);
valueAxis.setVisible(false);
final XYAreaRenderer renderer = new XYAreaRenderer();
renderer.setBaseToolTipGenerator(new SecurityItemLabelGenerator(node));
renderer.setOutline(true);
renderer.setSeriesPaint(0, new Color(225, 247, 223));
final XYPlot plot = new XYPlot(null, timeAxis, valueAxis, renderer);
final List<List<SecurityHistoryNode>> groups = node.getHistoryNodeGroupsBySplits();
for (int i = 0; i < groups.size(); i++) {
int size = groups.get(i).size();
Date[] date = new Date[size];
double[] high = new double[size];
double[] low = new double[size];
double[] open = new double[size];
double[] close = new double[size];
double[] volume = new double[size];
for (int j = 0; j < size; j++) {
final SecurityHistoryNode hNode = groups.get(i).get(j);
date[j] = DateUtils.asDate(hNode.getLocalDate());
high[j] = hNode.getAdjustedHigh().doubleValue();
low[j] = hNode.getAdjustedLow().doubleValue();
open[j] = hNode.getAdjustedPrice().doubleValue();
close[j] = hNode.getAdjustedPrice().doubleValue();
volume[j] = hNode.getVolume();
}
final AbstractXYDataset data = new DefaultHighLowDataset(node.getDescription() + i, date, high, low, open, close, volume);
plot.setDataset(i, data);
}
plot.setInsets(new RectangleInsets(1, 1, 1, 1));
final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(null);
return chart;
}
use of org.jfree.ui.RectangleInsets in project dhis2-core by dhis2.
the class DefaultChartService method getMarker.
/**
* Returns a horizontal line marker for the given x value and label.
*/
private Marker getMarker(Double value, String label) {
Marker marker = new ValueMarker(value);
marker.setPaint(Color.BLACK);
marker.setStroke(new BasicStroke(1.1f));
marker.setLabel(label);
marker.setLabelOffset(new RectangleInsets(-10, 50, 0, 0));
marker.setLabelFont(SUB_TITLE_FONT);
return marker;
}
Aggregations