use of org.jfree.chart.ChartPanel in project adempiere by adempiere.
the class VCRPDetail method handleActionEvent.
private void handleActionEvent(ActionEvent e) {
Timestamp df = getDateFrom();
Timestamp dt = getDateTo();
MResource r = getResource(resource.getValue());
if (df != null && dt != null && r != null) {
model = CRPDatasetFactory.get(df, dt, r);
JFreeChart jfreechart = createChart(model.getDataset(), getChartTitle(), getSourceUOM(resource.getValue()));
chartPanel = new ChartPanel(jfreechart, false);
contentPanel.setLeftComponent(chartPanel);
JTree tree = model.getTree();
tree.addMouseListener(new TreeHandler());
contentPanel.setRightComponent(new JScrollPane(tree));
popup = createPopup(tree);
contentPanel.setDividerLocation(0.70);
contentPanel.setVisible(true);
contentPanel.validate();
contentPanel.repaint();
}
SwingTool.setCursorsFromParent(m_form.getWindow(), false);
}
use of org.jfree.chart.ChartPanel in project adempiere by adempiere.
the class Graph method loadData.
private void loadData() {
list = builder.loadData();
JFreeChart chart = builder.createChart(builder.getMGoal().getChartType());
if (chartPanel != null)
remove(chartPanel);
chartPanel = new ChartPanel(chart);
chartPanel.setSize(getSize());
chartPanel.addChartMouseListener(this);
add(chartPanel, BorderLayout.CENTER);
if (m_userSelection) {
int AD_Reference_Value_ID = DB.getSQLValue(null, "SELECT AD_Reference_ID FROM AD_Reference WHERE Name = ?", "PA_Goal ChartType");
MLookupInfo info = MLookupFactory.getLookup_List(Env.getLanguage(Env.getCtx()), AD_Reference_Value_ID);
MLookup mLookup = new MLookup(info, 0);
VLookup lookup = new VLookup("ChartType", false, false, true, mLookup);
lookup.addVetoableChangeListener(new VetoableChangeListener() {
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
Object value = evt.getNewValue();
if (value == null)
return;
JFreeChart chart = null;
chart = builder.createChart(value.toString());
if (chart != null) {
if (chartPanel != null)
remove(chartPanel);
chartPanel = new ChartPanel(chart);
chartPanel.setSize(getSize());
chartPanel.addChartMouseListener(Graph.this);
add(chartPanel, BorderLayout.CENTER);
getParent().validate();
}
}
});
add(lookup, BorderLayout.NORTH);
}
this.setMinimumSize(paneldimension);
}
use of org.jfree.chart.ChartPanel 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.ChartPanel in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChartCompare 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"));
jcb_compare = new JCheckBox(rb.getString("Button.Compare"));
jcb_compare.setSelected(true);
Account a = combo1.getSelectedAccount();
Account a2 = combo2.getSelectedAccount();
JFreeChart chart = createVerticalXYBarChart(a, a2);
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"), combo1);
builder.nextLine();
builder.append(rb.getString("Label.Compare"), combo2);
builder.nextLine();
builder.append(jcb_compare);
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 {
if (e.getSource() == jcb_compare) {
combo2.setEnabled(jcb_compare.isSelected());
}
Account account = combo1.getSelectedAccount();
if (account == null) {
return;
}
Account account2 = combo2.getSelectedAccount();
if (jcb_compare.isSelected() && account2 == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account, account2));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
};
combo1.addActionListener(listener);
combo2.addActionListener(listener);
jcb_compare.addActionListener(listener);
subAccountCheckBox.addActionListener(listener);
hideLockedAccountCheckBox.addActionListener(e -> {
combo1.setHideLocked(hideLockedAccountCheckBox.isSelected());
combo2.setHideLocked(hideLockedAccountCheckBox.isSelected());
try {
Account account = combo1.getSelectedAccount();
if (account == null) {
return;
}
Account account2 = combo2.getSelectedAccount();
if (jcb_compare.isSelected() && account2 == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account, account2));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
hidePlaceholderAccountCheckBox.addActionListener(e -> {
combo1.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected());
combo2.setHidePlaceholder(hidePlaceholderAccountCheckBox.isSelected());
try {
Account account = combo1.getSelectedAccount();
if (account == null) {
return;
}
Account account2 = combo2.getSelectedAccount();
if (jcb_compare.isSelected() && account2 == null) {
return;
}
updateSubAccountBox();
chartPanel.setChart(createVerticalXYBarChart(account, account2));
panel.validate();
} catch (final Exception ex) {
Logger.getLogger(MonthlyAccountBalanceChartCompare.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
});
refreshButton.addActionListener(listener);
updateSubAccountBox();
return panel;
}
use of org.jfree.chart.ChartPanel in project jgnash by ccavanaugh.
the class IncomeExpensePieChart method createPanel.
private JPanel createPanel() {
EnumSet<AccountType> set = EnumSet.of(AccountType.INCOME, AccountType.EXPENSE);
JButton refreshButton = new JButton(rb.getString("Button.Refresh"));
startField = new DatePanel();
endField = new DatePanel();
showEmptyCheck = new JCheckBox(rb.getString("Label.ShowEmptyAccounts"));
showPercentCheck = new JCheckBox(rb.getString("Button.ShowPercentValues"));
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
combo = AccountListComboBox.getParentTypeInstance(engine.getRootAccount(), set);
final LocalDate dStart = DateUtils.getFirstDayOfTheMonth(LocalDate.now()).minusYears(1);
long start = pref.getLong(START_DATE, DateUtils.asEpochMilli(dStart));
startField.setDate(DateUtils.asLocalDate(start));
currentAccount = combo.getSelectedAccount();
JFreeChart chart = createPieChart(currentAccount);
chartPanel = new ChartPanel(chart, true, true, true, false, true);
// (chart, properties, save, print, zoom, tooltips)
FormLayout layout = new FormLayout("p, 4dlu, 70dlu, 8dlu, p, 4dlu, 70dlu, 8dlu, p, 4dlu:g, left:p", "f:d, 3dlu, f:d, 6dlu, f:p:g");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
layout.setRowGroups(new int[][] { { 1, 3 } });
builder.append(combo, 9);
builder.append(showEmptyCheck);
builder.nextLine();
builder.nextLine();
builder.append(rb.getString("Label.StartDate"), startField);
builder.append(rb.getString("Label.EndDate"), endField);
builder.append(refreshButton);
builder.append(showPercentCheck);
builder.nextLine();
builder.nextLine();
builder.append(chartPanel, 11);
JPanel panel = builder.getPanel();
combo.addActionListener(e -> {
setCurrentAccount(combo.getSelectedAccount());
pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate()));
});
refreshButton.addActionListener(e -> {
setCurrentAccount(currentAccount);
pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate()));
});
showEmptyCheck.addActionListener(e -> setCurrentAccount(currentAccount));
showPercentCheck.addActionListener(e -> ((PiePlot) chartPanel.getChart().getPlot()).setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels));
ChartMouseListener mouseListener = new ChartMouseListener() {
@Override
public void chartMouseClicked(final ChartMouseEvent event) {
MouseEvent me = event.getTrigger();
if (me.getID() == MouseEvent.MOUSE_CLICKED && me.getClickCount() == 1) {
try {
ChartEntity entity = event.getEntity();
// expand sections if interesting, back out if in nothing
if (entity instanceof PieSectionEntity) {
Account a = (Account) ((PieSectionEntity) entity).getSectionKey();
if (a.getChildCount() > 0) {
setCurrentAccount(a);
}
} else if (entity == null) {
Account parent = currentAccount;
if (parent == null) {
return;
}
parent = parent.getParent();
if (parent == null || parent instanceof RootAccount) {
return;
}
setCurrentAccount(parent);
}
} catch (final Exception e) {
Logger.getLogger(IncomeExpensePieChart.class.getName()).log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
}
@Override
public void chartMouseMoved(ChartMouseEvent event) {
setChartCursor(chartPanel, event.getEntity(), event.getTrigger().getPoint());
}
};
chartPanel.addChartMouseListener(mouseListener);
return panel;
}
Aggregations