Search in sources :

Example 21 with ChartPanel

use of org.jfree.chart.ChartPanel in project FRC2018 by first95.

the class AdjustedTalonTester method runThrottleTest.

public void runThrottleTest() {
    // Create dataset
    XYDataset dataset = new XYSeriesCollection();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    int seriesNum = 0;
    for (double voltage = 10; voltage >= 5.0; voltage -= 0.5) {
        pdp.setVoltage(voltage);
        XYSeries series = new XYSeries("Battery at " + pdp.getVoltage() + "V", false);
        for (double throttle = -1.0; throttle <= 1.0; throttle += 0.01) {
            uut.set(ControlMode.PercentOutput, throttle);
            series.add(throttle, lastCommandedThrottle);
        }
        ((XYSeriesCollection) dataset).addSeries(series);
        renderer.setSeriesLinesVisible(seriesNum, true);
        renderer.setSeriesShapesVisible(seriesNum, false);
        seriesNum++;
    }
    // Create chart
    JFreeChart chart = ChartFactory.createScatterPlot("Adjusted throttle vs input", "Input throttle", "Adjusted throttle", dataset);
    // Changes background color
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(200, 200, 200));
    plot.setRenderer(renderer);
    // Create Panel
    ChartPanel panel = new ChartPanel(chart);
    setContentPane(panel);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) ChartPanel(org.jfree.chart.ChartPanel) XYPlot(org.jfree.chart.plot.XYPlot) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) XYDataset(org.jfree.data.xy.XYDataset) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart)

Example 22 with ChartPanel

use of org.jfree.chart.ChartPanel in project FRC2018 by first95.

the class DrivePodTester method runDrivePodTest.

public void runDrivePodTest() {
    // Create dataset
    XYDataset dataset = new XYSeriesCollection();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    XYSeries throttleSeries = new XYSeries("Throttle (input)");
    XYSeries currentSeries = new XYSeries("Motor current (simulated)");
    XYSeries gearSeries = new XYSeries("Transmission gear (output)");
    for (double t = 0; t <= 15; t += 0.01) {
        // Generate stimulus
        double throttle = Math.sin(t * t / (Math.PI));
        // until we replace this with a better approximation
        double current = 2.0 * throttle;
        // Feed stimulus to unit under test.
        // Set the current first so that the drive pod can respond to it.
        leader.setOutputCurrent(current);
        uut.setThrottle(throttle);
        // Add inputs and outputs to plot
        throttleSeries.add(t, throttle);
        currentSeries.add(t, current);
        gearSeries.add(t, lastShifterGear ? 1 : 0);
    }
    ((XYSeriesCollection) dataset).addSeries(throttleSeries);
    ((XYSeriesCollection) dataset).addSeries(currentSeries);
    ((XYSeriesCollection) dataset).addSeries(gearSeries);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesShape(2, ShapeUtilities.createDiamond(2.0f));
    // Create chart
    JFreeChart chart = ChartFactory.createScatterPlot("Gearshift behavior over time", "Time", "Amps, Volts, high/low", dataset);
    // Changes background color
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(200, 200, 200));
    plot.setRenderer(renderer);
    // Create Panel
    ChartPanel panel = new ChartPanel(chart);
    setContentPane(panel);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) ChartPanel(org.jfree.chart.ChartPanel) XYPlot(org.jfree.chart.plot.XYPlot) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) XYDataset(org.jfree.data.xy.XYDataset) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) JFreeChart(org.jfree.chart.JFreeChart)

Example 23 with ChartPanel

use of org.jfree.chart.ChartPanel in project lotro-tools by dmorcellet.

the class ScalableStatChartController method buildChartPanel.

private JPanel buildChartPanel() {
    ChartPanel chartPanel = new ChartPanel(_chart);
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(true);
    chartPanel.setHorizontalAxisTrace(false);
    chartPanel.setVerticalAxisTrace(false);
    chartPanel.setPreferredSize(new Dimension(500, 300));
    chartPanel.setOpaque(false);
    return chartPanel;
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) Dimension(java.awt.Dimension)

Example 24 with ChartPanel

use of org.jfree.chart.ChartPanel in project openblocks by mikaelhg.

the class CBarGraph method getOutputPanel.

public ChartPanel getOutputPanel() {
    // we return a copy of the chart because we only want to show the
    // legend in the larger view of the graph
    // not the small runtime graph block view
    JFreeChart newChart = new JFreeChart(chart.getPlot());
    newChart.getLegend().setPosition(RectangleEdge.TOP);
    newChart.getLegend().setPadding(5, 5, 5, 5);
    newChart.setBackgroundPaint(background);
    output = new ChartPanel(newChart);
    return output;
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) JFreeChart(org.jfree.chart.JFreeChart)

Example 25 with ChartPanel

use of org.jfree.chart.ChartPanel in project openblocks by mikaelhg.

the class CLineGraph method getOutputPanel.

public ChartPanel getOutputPanel() {
    // we return a copy of the chart because we only want to show the
    // legend in the larger view of the graph
    // not the small runtime graph block view
    JFreeChart newChart = new JFreeChart(chart.getPlot());
    newChart.getLegend().setPosition(RectangleEdge.TOP);
    newChart.getLegend().setPadding(5, 5, 5, 5);
    newChart.setBackgroundPaint(background);
    output = new ChartPanel(newChart);
    return output;
}
Also used : ChartPanel(org.jfree.chart.ChartPanel) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

ChartPanel (org.jfree.chart.ChartPanel)84 JFreeChart (org.jfree.chart.JFreeChart)50 XYPlot (org.jfree.chart.plot.XYPlot)20 Dimension (java.awt.Dimension)18 JPanel (javax.swing.JPanel)17 Color (java.awt.Color)16 NumberAxis (org.jfree.chart.axis.NumberAxis)16 ChartEntity (org.jfree.chart.entity.ChartEntity)15 XYSeries (org.jfree.data.xy.XYSeries)15 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)15 XYDataset (org.jfree.data.xy.XYDataset)12 BasicStroke (java.awt.BasicStroke)11 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)11 ChartGesture (net.sf.mzmine.chartbasics.gestures.ChartGesture)8 Button (net.sf.mzmine.chartbasics.gestures.ChartGesture.Button)8 Entity (net.sf.mzmine.chartbasics.gestures.ChartGesture.Entity)8 ChartGestureEvent (net.sf.mzmine.chartbasics.gestures.ChartGestureEvent)8 DecimalFormat (java.text.DecimalFormat)7 JButton (javax.swing.JButton)7 JLabel (javax.swing.JLabel)7