use of org.jfree.chart.JFreeChart in project cubrid-manager by CUBRID.
the class HostDashboardHistoryViewPart method loadBrokerChart.
/**
* Load an instance of ChartCompositePart stand for broker monitor info
*
* @param parent the instance of Composite
*/
private void loadBrokerChart(Composite parent) {
brokerComp = new Composite(parent, SWT.NULL);
brokerComp.setLayout(new GridLayout());
brokerComp.setLayoutData(new GridData(GridData.FILL_BOTH));
Group brokerGrp = new Group(brokerComp, SWT.NONE);
brokerGrp.setText(Messages.hostBrokerSeriesGroupName);
GridLayout layoutGrp = new GridLayout();
layoutGrp.verticalSpacing = 0;
layoutGrp.horizontalSpacing = 0;
layoutGrp.marginLeft = 0;
layoutGrp.marginRight = 0;
layoutGrp.marginTop = 0;
layoutGrp.marginBottom = 0;
brokerGrp.setLayout(layoutGrp);
GridData gridData = new GridData(GridData.FILL_BOTH);
brokerGrp.setLayoutData(gridData);
BrokerDiagData brokerDiagData = new BrokerDiagData();
TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
brokerChartPart = new ChartCompositePart(brokerGrp, map);
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
ShowSetting showSetting = brokerChartPart.getSettingMap().get(key);
ShowSettingMatching.match(key, showSetting, MonitorType.BROKER);
}
brokerChartPart.loadContent();
JFreeChart chart = (JFreeChart) brokerChartPart.getChart();
chart.setBorderVisible(false);
XYPlot xyplot = (XYPlot) brokerChartPart.getChart().getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setFixedAutoRange(300000d);
dateaxis.setLowerMargin(0.0D);
dateaxis.setUpperMargin(0.0D);
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
renderer.setURLGenerator(null);
renderer.setBaseToolTipGenerator(null);
}
use of org.jfree.chart.JFreeChart in project jgnash by ccavanaugh.
the class BudgetSparkline method getSparklineImage.
public static Icon getSparklineImage(final List<BigDecimal> amounts) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
final boolean[] negate = new boolean[amounts.size()];
for (int i = 0; i < amounts.size(); i++) {
dataset.addValue(amounts.get(i), CATEGORY, i);
negate[i] = amounts.get(i).signum() == -1;
}
CategoryAxis xAxis = new CategoryAxis();
xAxis.setTickLabelsVisible(false);
xAxis.setTickMarksVisible(false);
xAxis.setAxisLineVisible(false);
xAxis.setVisible(false);
NumberAxis yAxis = new NumberAxis();
yAxis.setTickLabelsVisible(false);
yAxis.setTickMarksVisible(false);
yAxis.setAxisLineVisible(false);
yAxis.setNegativeArrowVisible(false);
yAxis.setPositiveArrowVisible(false);
yAxis.setAutoRangeIncludesZero(true);
yAxis.setAutoRange(true);
yAxis.setVisible(false);
BarRenderer renderer = new BarRenderer() {
@Override
public Paint getItemPaint(final int row, final int column) {
return negate[column] ? Color.RED : Color.BLACK;
}
};
renderer.setShadowVisible(false);
renderer.setBarPainter(new StandardBarPainter());
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
plot.setInsets(INSETS);
plot.setDomainGridlinesVisible(false);
plot.setDomainCrosshairVisible(false);
plot.setRangeGridlinesVisible(false);
plot.setRangeCrosshairVisible(false);
plot.setBackgroundPaint(CLEAR);
JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBorderVisible(false);
chart.setBackgroundPaint(CLEAR);
Icon icon = EMPTY_ICON;
try {
byte[] image = ENCODER.encode(chart.createBufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.BITMASK, null));
icon = new ImageIcon(image);
} catch (IOException ex) {
Logger.getLogger(BudgetSparkline.class.getName()).log(Level.SEVERE, null, ex);
}
return icon;
}
use of org.jfree.chart.JFreeChart in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChart method createVerticalXYBarChart.
private JFreeChart createVerticalXYBarChart(Account a) {
DateFormat df = new SimpleDateFormat("MM/yy");
TimeSeriesCollection data = createTimeSeriesCollection(a);
DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
// if (a.getTransactionCount() > 0) {
Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()));
Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()));
dateAxis.setRange(start, end);
// }
NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance"));
StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
XYBarRenderer renderer = new XYBarRenderer(0.2);
renderer.setBaseToolTipGenerator(tooltipGenerator);
XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
String title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(null);
return chart;
}
use of org.jfree.chart.JFreeChart in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChart method createPanel.
private JPanel createPanel() {
LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate());
LocalDate start = end.minusYears(1);
startDateField.setDate(start);
JButton refreshButton = new JButton(rb.getString("Button.Refresh"));
refreshButton.setIcon(IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
subAccountCheckBox = new JCheckBox(rb.getString("Button.IncludeSubAccounts"));
subAccountCheckBox.setSelected(true);
hideLockedAccountCheckBox = new JCheckBox(rb.getString("Button.HideLockedAccount"));
hidePlaceholderAccountCheckBox = new JCheckBox(rb.getString("Button.HidePlaceholderAccount"));
Account a = combo.getSelectedAccount();
JFreeChart chart = createVerticalXYBarChart(a);
final ChartPanel chartPanel = new ChartPanel(chart);
FormLayout layout = new FormLayout("p, 4dlu, p:g", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
FormLayout dLayout = new FormLayout("p, 4dlu, p, 8dlu, p, 4dlu, p, 8dlu, p", "");
DefaultFormBuilder dBuilder = new DefaultFormBuilder(dLayout);
dBuilder.append(rb.getString("Label.StartDate"), startDateField);
dBuilder.append(rb.getString("Label.EndDate"), endDateField);
dBuilder.append(refreshButton);
FormLayout cbLayout = new FormLayout("p, 4dlu, p, 4dlu, p, 4dlu", "");
DefaultFormBuilder cbBuilder = new DefaultFormBuilder(cbLayout);
cbBuilder.append(subAccountCheckBox);
cbBuilder.append(hideLockedAccountCheckBox);
cbBuilder.append(hidePlaceholderAccountCheckBox);
builder.append(rb.getString("Label.Account"), combo);
builder.nextLine();
builder.append(" ");
builder.append(cbBuilder.getPanel());
builder.nextLine();
builder.appendRelatedComponentsGapRow();
builder.nextLine();
builder.append(dBuilder.getPanel(), 3);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
builder.nextLine();
builder.appendRow(RowSpec.decode("fill:p:g"));
builder.append(chartPanel, 3);
final JPanel panel = builder.getPanel();
ActionListener listener = e -> {
try {
Account account = combo.getSelectedAccount();
if (account == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
};
combo.addActionListener(listener);
hideLockedAccountCheckBox.addActionListener(e -> {
combo.setHideLocked(hideLockedAccountCheckBox.isSelected());
try {
Account account = combo.getSelectedAccount();
if (account == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
hidePlaceholderAccountCheckBox.addActionListener(e -> {
combo.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected());
try {
Account account = combo.getSelectedAccount();
if (account == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
refreshButton.addActionListener(listener);
updateSubAccountBox();
return panel;
}
use of org.jfree.chart.JFreeChart in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChartCompare method createVerticalXYBarChart.
private JFreeChart createVerticalXYBarChart(final Account a, final Account a2) {
DateFormat df = new SimpleDateFormat("MM/yy");
TimeSeriesCollection data = createTimeSeriesCollection(a, a2);
DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
// if (a.getTransactionCount() > 0) {
Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()));
Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()));
dateAxis.setRange(start, end);
// }
NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance") + "-" + a.getCurrencyNode().getSymbol());
StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(0.2, false);
renderer.setBaseToolTipGenerator(tooltipGenerator);
XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
String title;
if (jcb_compare.isSelected()) {
title = a.getPathName() + " vs " + a2.getPathName();
} else {
title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(null);
return chart;
}
Aggregations