Search in sources :

Example 1 with ChartPanel

use of org.jfree.chart.ChartPanel 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);
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) Dimension(java.awt.Dimension) JFreeChart(org.jfree.chart.JFreeChart)

Example 2 with ChartPanel

use of org.jfree.chart.ChartPanel 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();
    }
}
Also used : MResource(org.compiere.model.MResource) MUOM(org.compiere.model.MUOM) ChartPanel(org.jfree.chart.ChartPanel) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) Timestamp(java.sql.Timestamp) JFreeChart(org.jfree.chart.JFreeChart)

Example 3 with ChartPanel

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);
}
Also used : MResource(org.compiere.model.MResource) JScrollPane(javax.swing.JScrollPane) JTree(javax.swing.JTree) ChartPanel(org.jfree.chart.ChartPanel) Timestamp(java.sql.Timestamp) JFreeChart(org.jfree.chart.JFreeChart)

Example 4 with ChartPanel

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);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) MLookupInfo(org.compiere.model.MLookupInfo) PropertyChangeEvent(java.beans.PropertyChangeEvent) ChartPanel(org.jfree.chart.ChartPanel) MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) VetoableChangeListener(java.beans.VetoableChangeListener) JFreeChart(org.jfree.chart.JFreeChart) Point(java.awt.Point)

Example 5 with ChartPanel

use of org.jfree.chart.ChartPanel in project BachelorPraktikum by lucasbuschlinger.

the class Plotter method viewPlot.

/**
 * Views the plot with the plotted data.
 */
public void viewPlot() {
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
    setContentPane(chartPanel);
    this.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}
Also used : ChartPanel(org.jfree.chart.ChartPanel)

Aggregations

ChartPanel (org.jfree.chart.ChartPanel)66 JFreeChart (org.jfree.chart.JFreeChart)42 XYPlot (org.jfree.chart.plot.XYPlot)19 Color (java.awt.Color)16 Dimension (java.awt.Dimension)16 NumberAxis (org.jfree.chart.axis.NumberAxis)16 JPanel (javax.swing.JPanel)15 XYSeries (org.jfree.data.xy.XYSeries)14 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)14 XYDataset (org.jfree.data.xy.XYDataset)12 BasicStroke (java.awt.BasicStroke)11 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)11 DecimalFormat (java.text.DecimalFormat)7 JButton (javax.swing.JButton)7 JLabel (javax.swing.JLabel)7 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)7 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)6 FormLayout (com.jgoodies.forms.layout.FormLayout)6 Font (java.awt.Font)6 GridBagLayout (java.awt.GridBagLayout)6