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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations