use of org.jfree.chart.title.TextTitle in project cubrid-manager by CUBRID.
the class ChartCompositePart method createPlotUnit.
/**
* Create plot unit which show the data changing.
*
* @param parent the parent composite
*/
public void createPlotUnit(Composite parent) {
chart = createChart();
int red = parent.getBackground().getRed();
int green = parent.getBackground().getGreen();
int blue = parent.getBackground().getBlue();
chart.setBackgroundPaint(new Color(red, green, blue));
chartComposite = new ChartComposite(parent, SWT.NONE, chart, false, true, false, false, false);
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
chartComposite.setLayout(fillLayout);
chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
if (null != monInstaceData) {
TextTitle title = chart.getTitle();
XYPlot plot = chart.getXYPlot();
// title
String ttlBgColor = monInstaceData.getTitleBgColor();
String ttlFontName = monInstaceData.getTitleFontName();
int ttlFontSize = monInstaceData.getTitleFontSize();
String ttlFontColor = monInstaceData.getTitleFontColor();
// plot
String plotBgColor = monInstaceData.getPlotBgColor();
String plotDomainGridColor = monInstaceData.getPlotDomainGridColor();
String plotRangGridColor = monInstaceData.getPlotRangGridColor();
String plotDateAxisColor = monInstaceData.getPlotDateAxisColor();
String plotNumberAxisColor = monInstaceData.getPlotNumberAxisColor();
// history path
historyPath = monInstaceData.getHistoryPath();
isChangedHistoryPath = true;
if (ttlBgColor != null) {
red = getColorElem(ttlBgColor, 0);
green = getColorElem(ttlBgColor, 1);
blue = getColorElem(ttlBgColor, 2);
title.setBackgroundPaint(new Color(red, green, blue));
}
if (!"".equals(ttlFontName)) {
Font titleFont = new Font(ttlFontName, 0, ttlFontSize);
title.setFont(titleFont);
}
red = getColorElem(ttlFontColor, 0);
green = getColorElem(ttlFontColor, 1);
blue = getColorElem(ttlFontColor, 2);
title.setPaint(new Color(red, green, blue));
red = getColorElem(plotBgColor, 0);
green = getColorElem(plotBgColor, 1);
blue = getColorElem(plotBgColor, 2);
plot.setBackgroundPaint(new Color(red, green, blue));
red = getColorElem(plotDomainGridColor, 0);
green = getColorElem(plotDomainGridColor, 1);
blue = getColorElem(plotDomainGridColor, 2);
plot.setDomainGridlinePaint(new Color(red, green, blue));
red = getColorElem(plotRangGridColor, 0);
green = getColorElem(plotRangGridColor, 1);
blue = getColorElem(plotRangGridColor, 2);
plot.setRangeGridlinePaint(new Color(red, green, blue));
red = getColorElem(plotDateAxisColor, 0);
green = getColorElem(plotDateAxisColor, 1);
blue = getColorElem(plotDateAxisColor, 2);
plot.getRangeAxis().setAxisLinePaint(new Color(red, green, blue));
red = getColorElem(plotNumberAxisColor, 0);
green = getColorElem(plotNumberAxisColor, 1);
blue = getColorElem(plotNumberAxisColor, 2);
plot.getDomainAxis().setAxisLinePaint(new Color(red, green, blue));
}
}
use of org.jfree.chart.title.TextTitle in project bamboobsc by billchen198318.
the class CommonPieChartAction method fillChart.
private void fillChart(String title, List<String> names, List<String> colors, List<Float> values) throws Exception {
DefaultPieDataset data = new DefaultPieDataset();
for (int ix = 0; ix < names.size(); ix++) {
data.setValue(names.get(ix), values.get(ix));
}
this.chart = ChartFactory.createPieChart3D(title, data, true, true, false);
LegendTitle legend = this.chart.getLegend();
legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9));
PiePlot plot = (PiePlot) this.chart.getPlot();
plot.setCircular(true);
plot.setBackgroundAlpha(0.9f);
plot.setForegroundAlpha(0.5f);
plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
this.setPlotColor(plot, names, colors);
this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9)));
}
use of org.jfree.chart.title.TextTitle in project jgnash by ccavanaugh.
the class PayeePieChart method createPieChart.
private JFreeChart createPieChart(Account a, PieDataset[] data, int index) {
PiePlot plot = new PiePlot(data[index]);
// rebuilt each time because they're based on the account's commodity
NumberFormat valueFormat = CommodityFormat.getFullNumberFormat(a.getCurrencyNode());
NumberFormat percentFormat = new DecimalFormat("0.0#%");
defaultLabels = new StandardPieSectionLabelGenerator("{0} = {1}", valueFormat, percentFormat);
percentLabels = new StandardPieSectionLabelGenerator("{0} = {1}\n{2}", valueFormat, percentFormat);
plot.setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels);
plot.setLabelGap(.02);
plot.setInteriorGap(.1);
BigDecimal thisTotal = BigDecimal.ZERO;
for (int i = 0; i < data[index].getItemCount(); i++) {
thisTotal = thisTotal.add((BigDecimal) (data[index].getValue(i)));
}
BigDecimal acTotal = a.getTreeBalance(startField.getLocalDate(), endField.getLocalDate()).abs();
String title = "";
String subtitle = "";
// pick an appropriate title(s)
if (index == CREDIT) {
title = a.getPathName();
subtitle = rb.getString("Column.Credit") + " : " + valueFormat.format(thisTotal);
} else if (index == DEBIT) {
title = rb.getString("Column.Balance") + " : " + valueFormat.format(acTotal);
subtitle = rb.getString("Column.Debit") + " : " + valueFormat.format(thisTotal);
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.addSubtitle(new TextTitle(subtitle));
chart.setBackgroundPaint(null);
return chart;
}
use of org.jfree.chart.title.TextTitle in project jgnash by ccavanaugh.
the class IncomeExpensePieChart method createPieChart.
private JFreeChart createPieChart(final Account a) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
Objects.requireNonNull(a);
PieDataset data = createPieDataSet(a);
PiePlot plot = new PiePlot(data);
// rebuilt each time because they're based on the account's commodity
CurrencyNode defaultCurrency = engine.getDefaultCurrency();
NumberFormat valueFormat = CommodityFormat.getFullNumberFormat(a.getCurrencyNode());
NumberFormat percentFormat = new DecimalFormat("0.0#%");
defaultLabels = new StandardPieSectionLabelGenerator("{0} = {1}", valueFormat, percentFormat);
percentLabels = new StandardPieSectionLabelGenerator("{0} = {1}\n{2}", valueFormat, percentFormat);
plot.setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels);
plot.setLabelGap(.02);
plot.setInteriorGap(.1);
// own transactions, not just child accounts), separate it from children.
if (data.getIndex(a) != -1) {
plot.setExplodePercent(a, .10);
}
String title;
// pick an appropriate title
if (a.getAccountType() == AccountType.EXPENSE) {
title = rb.getString("Title.PercentExpense");
} else if (a.getAccountType() == AccountType.INCOME) {
title = rb.getString("Title.PercentIncome");
} else {
title = rb.getString("Title.PercentDist");
}
title = title + " - " + a.getPathName();
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
BigDecimal total = a.getTreeBalance(startField.getLocalDate(), endField.getLocalDate()).abs();
String subtitle = valueFormat.format(total);
if (!defaultCurrency.equals(a.getCurrencyNode())) {
BigDecimal totalDefaultCurrency = total.multiply(a.getCurrencyNode().getExchangeRate(defaultCurrency));
NumberFormat defaultValueFormat = CommodityFormat.getFullNumberFormat(defaultCurrency);
subtitle += " - " + defaultValueFormat.format(totalDefaultCurrency);
}
chart.addSubtitle(new TextTitle(subtitle));
chart.setBackgroundPaint(null);
return chart;
}
use of org.jfree.chart.title.TextTitle in project processdash by dtuma.
the class CGIChartBase method writeContents.
/** Generate CGI chart output. */
@Override
protected void writeContents() throws IOException {
// get the data for display
buildData();
chromeless = (parameters.get("chromeless") != null);
JFreeChart chart = createChart();
int width = getIntSetting("width");
int height = getIntSetting("height");
Color initGradColor = getColorSetting("initGradColor");
Color finalGradColor = getColorSetting("finalGradColor");
chart.setBackgroundPaint(new GradientPaint(0, 0, initGradColor, width, height, finalGradColor));
if (parameters.get("hideOutline") != null)
chart.getPlot().setOutlinePaint(INVISIBLE);
String title = getSetting("title");
if (chromeless || title == null || title.length() == 0)
chart.setTitle((TextTitle) null);
else {
chart.setTitle(Translator.translate(title));
String titleFontSize = getSetting("titleFontSize");
if (titleFontSize != null)
try {
float fontSize = Float.parseFloat(titleFontSize);
TextTitle t = chart.getTitle();
t.setFont(t.getFont().deriveFont(fontSize));
} catch (Exception tfe) {
}
}
if (chromeless || parameters.get("hideLegend") != null)
chart.removeLegend();
else {
LegendTitle l = chart.getLegend();
String legendFontSize = getSetting("legendFontSize");
if (l != null && legendFontSize != null)
try {
float fontSize = Float.parseFloat(legendFontSize);
l.setItemFont(l.getItemFont().deriveFont(fontSize));
} catch (Exception lfe) {
}
}
chart.getPlot().setNoDataMessage(resources.getString("No_Data_Message"));
Axis xAxis = getHorizontalAxis(chart);
if (xAxis != null) {
if (parameters.get("hideTickLabels") != null || parameters.get("hideXTickLabels") != null) {
xAxis.setTickLabelsVisible(false);
} else if (parameters.get("tickLabelFontSize") != null || parameters.get("xTickLabelFontSize") != null) {
String tfs = getParameter("xTickLabelFontSize");
if (tfs == null)
tfs = getParameter("tickLabelFontSize");
float fontSize = Float.parseFloat(tfs);
xAxis.setTickLabelFont(xAxis.getTickLabelFont().deriveFont(fontSize));
}
}
Axis yAxis = getVerticalAxis(chart);
if (yAxis != null) {
if (parameters.get("hideTickLabels") != null || parameters.get("hideYTickLabels") != null) {
yAxis.setTickLabelsVisible(false);
} else if (parameters.get("tickLabelFontSize") != null || parameters.get("yTickLabelFontSize") != null) {
String tfs = getParameter("yTickLabelFontSize");
if (tfs == null)
tfs = getParameter("tickLabelFontSize");
float fontSize = Float.parseFloat(tfs);
yAxis.setTickLabelFont(yAxis.getTickLabelFont().deriveFont(fontSize));
}
}
String axisFontSize = getSetting("axisLabelFontSize");
if (axisFontSize != null)
try {
float fontSize = Float.parseFloat(axisFontSize);
if (xAxis != null)
xAxis.setLabelFont(xAxis.getLabelFont().deriveFont(fontSize));
if (yAxis != null)
yAxis.setLabelFont(yAxis.getLabelFont().deriveFont(fontSize));
} catch (Exception afs) {
}
ChartRenderingInfo info = (isHtmlMode() ? new ChartRenderingInfo() : null);
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = img.createGraphics();
if ("auto".equals(getSetting("titleFontSize")))
maybeAdjustTitleFontSize(chart, g2, width);
chart.draw(g2, new Rectangle2D.Double(0, 0, width, height), info);
g2.dispose();
String outputFormat = getSetting("outputFormat");
OutputStream imgOut;
if (isHtmlMode()) {
imgOut = PngCache.getOutputStream();
} else {
imgOut = outStream;
}
ImageIO.write(img, outputFormat, imgOut);
imgOut.flush();
imgOut.close();
if (isHtmlMode())
writeImageHtml(width, height, imgOut.hashCode(), info);
}
Aggregations