use of org.jfree.chart.JFreeChart in project libresonic by Libresonic.
the class UserChartController method createChart.
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) {
JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
CategoryPlot plot = chart.getCategoryPlot();
Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white);
plot.setBackgroundPaint(background);
plot.setDomainGridlinePaint(Color.white);
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.white);
plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
LogarithmicAxis rangeAxis = new LogarithmicAxis(null);
rangeAxis.setStrictValuesFlag(false);
rangeAxis.setAllowNegativesFlag(true);
plot.setRangeAxis(rangeAxis);
// Disable bar outlines.
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
// Set up gradient paint for series.
GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
renderer.setSeriesPaint(0, gp0);
// Rotate labels.
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
// Set theme-specific colors.
Color bgColor = getBackground(request);
Color fgColor = getForeground(request);
chart.setBackgroundPaint(bgColor);
domainAxis.setTickLabelPaint(fgColor);
domainAxis.setTickMarkPaint(fgColor);
domainAxis.setAxisLinePaint(fgColor);
rangeAxis.setTickLabelPaint(fgColor);
rangeAxis.setTickMarkPaint(fgColor);
rangeAxis.setAxisLinePaint(fgColor);
return chart;
}
use of org.jfree.chart.JFreeChart in project adempiere by adempiere.
the class VChart method createChart.
public void createChart() {
JFreeChart chart = chartModel.createChart();
if (chartPanel != null)
remove(chartPanel);
chartPanel = new ChartPanel(chart);
Dimension size = getSize();
size.height = chartModel.getWinHeight();
chartPanel.setPreferredSize(size);
chartPanel.addChartMouseListener(this);
add(chartPanel, BorderLayout.CENTER);
this.setMinimumSize(size);
}
use of org.jfree.chart.JFreeChart in project adempiere by adempiere.
the class VCRP method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(ConfirmPanel.A_OK)) {
Timestamp date = null;
if (dateFrom.getValue() != null)
date = (Timestamp) dateFrom.getValue();
int S_Resource_ID = 0;
if (resource.getValue() != null)
S_Resource_ID = ((Integer) resource.getValue()).intValue();
if (date != null && S_Resource_ID != 0) {
MResource r = MResource.get(Env.getCtx(), S_Resource_ID);
int uom_id = r.getResourceType().getC_UOM_ID();
MUOM uom = MUOM.get(Env.getCtx(), uom_id);
CategoryDataset dataset = null;
if (uom.isHour()) {
dataset = createDataset(date, r);
} else {
dataset = createWeightDataset(date, r);
}
String title = r.getName() != null ? r.getName() : "";
title = title + " " + r.getDescription() != null ? r.getDescription() : "";
JFreeChart jfreechart = createChart(dataset, title, uom);
centerPanel.removeAll();
chartPanel = new ChartPanel(jfreechart, false);
centerPanel.add(chartPanel, BorderLayout.CENTER);
centerPanel.setVisible(true);
m_frame.pack();
}
}
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
dispose();
}
}
use of org.jfree.chart.JFreeChart 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.JFreeChart 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);
}
Aggregations