use of org.jfree.chart.ChartPanel in project FRC2018 by first95.
the class AdjustedTalonTester method runVoltageTest.
public void runVoltageTest() {
// Create dataset
XYDataset dataset = new XYSeriesCollection();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
int seriesNum = 0;
for (double throttle = -1.0; throttle <= 1.0; throttle += 0.25) {
// Prime the UUT with normal voltages for a while
double voltage = 13;
for (int i = 0; i < AdjustedTalon.NUM_RECENT_SAMPLES; ++i) {
pdp.setVoltage(13);
uut.set(ControlMode.PercentOutput, 0.0);
}
XYSeries series = new XYSeries("Throttle at " + throttle, false);
for (; voltage >= 5.0; voltage -= 0.01) {
pdp.setVoltage(voltage);
uut.set(ControlMode.PercentOutput, throttle);
series.add(voltage, lastCommandedThrottle);
}
((XYSeriesCollection) dataset).addSeries(series);
renderer.setSeriesLinesVisible(seriesNum, true);
renderer.setSeriesShapesVisible(seriesNum, false);
seriesNum++;
}
// Create chart
JFreeChart chart = ChartFactory.createScatterPlot("Adjusted throttle vs battery voltage", "voltage", "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 ta4j by ta4j.
the class IndicatorsToChart method displayChart.
/**
* Displays a chart in a frame.
* @param chart the chart to be displayed
*/
private static void displayChart(JFreeChart chart) {
// Chart panel
ChartPanel panel = new ChartPanel(chart);
panel.setFillZoomRectangle(true);
panel.setMouseWheelEnabled(true);
panel.setPreferredSize(new java.awt.Dimension(500, 270));
// Application frame
ApplicationFrame frame = new ApplicationFrame("Ta4j example - Indicators to chart");
frame.setContentPane(panel);
frame.pack();
RefineryUtilities.centerFrameOnScreen(frame);
frame.setVisible(true);
}
use of org.jfree.chart.ChartPanel in project ta4j by ta4j.
the class BuyAndSellSignalsToChart method displayChart.
/**
* Displays a chart in a frame.
* @param chart the chart to be displayed
*/
private static void displayChart(JFreeChart chart) {
// Chart panel
ChartPanel panel = new ChartPanel(chart);
panel.setFillZoomRectangle(true);
panel.setMouseWheelEnabled(true);
panel.setPreferredSize(new Dimension(1024, 400));
// Application frame
ApplicationFrame frame = new ApplicationFrame("Ta4j example - Buy and sell signals to chart");
frame.setContentPane(panel);
frame.pack();
RefineryUtilities.centerFrameOnScreen(frame);
frame.setVisible(true);
}
use of org.jfree.chart.ChartPanel in project Energieverbrauchssimulator by duschdas2.
the class Diagramm method erzeuge2.
public static void erzeuge2(String s) throws IOException {
JFreeChart xylineChart = ChartFactory.createXYLineChart("Simulierter Haushalt", "Zeit in Minuten", "Verbrauch in Watt", erstelleDataset(s), PlotOrientation.VERTICAL, true, true, false);
XYPlot plot = xylineChart.getXYPlot();
plot.setBackgroundPaint(Color.black);
plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
ChartPanel chartPanel = new ChartPanel(xylineChart);
chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
// Erstellt das Frame zum abbilden des Graphen
ChartFrame frame = new ChartFrame("Diagramm", xylineChart);
frame.pack();
frame.setVisible(true);
}
use of org.jfree.chart.ChartPanel in project Stock-Ticker-Project by IsaiahL12.
the class DynamicDataDemo method graph2.
/**
* Constructs a new demonstration application.
*
* @param title the frame title.
*/
public JPanel graph2(String title, Vector<Double> avgV, Vector<String> time) {
final TimeSeries high = new TimeSeries("High");
final TimeSeries average = new TimeSeries("Price");
final TimeSeries low = new TimeSeries("Low");
double hold = 0;
double hold1 = -1;
double hold2 = 100000000;
int spacing = 20;
for (int i = 0; i < avgV.size(); i++) {
if (avgV.get(i) != -1 && avgV.get(i) != 0) {
if (hold1 < avgV.get(i)) {
hold1 = avgV.get(i);
}
if (hold2 > avgV.get(i)) {
hold2 = avgV.get(i);
// System.out.println(hold2);
}
// Date day = new SimpleDateFormat("HH:MM").parse("9:30");
try {
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(time.get(i));
hold = avgV.get(i);
average.addOrUpdate(new Day(date), round(hold, 2));
// average.add( null, round(hold,2));
high.addOrUpdate(new Day(date), round(hold1, 2));
low.addOrUpdate(new Day(date), round(hold2, 2));
// high.add(spacing*i, round(hold1,2));
// low.add(spacing*i, round(hold2,2));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
TimeSeriesCollection dataset = new TimeSeriesCollection(high);
dataset.addSeries(low);
dataset.addSeries(average);
JFreeChart chart;
chart = createChart2(dataset, title);
chart.getPlot().setBackgroundPaint(Color.BLACK);
ChartPanel chartPanel = new ChartPanel(chart);
// chartPanel.overlayChanged(event);
JPanel content = new JPanel(new BorderLayout());
content.add(chartPanel);
// content.add(button, BorderLayout.SOUTH);
chartPanel.setPreferredSize(new java.awt.Dimension(375, 320));
// this.add(content);
return content;
/*
final XYSeries high = new XYSeries("High");
final XYSeries average = new XYSeries("Price");
final XYSeries low = new XYSeries("Low");
double hold = 0;
double hold1 = -1;
double hold2 = 100000000;
int spacing = 20;
for (int i =0; i< avgV.size(); i++) {
if (avgV.get(i) != -1 && avgV.get(i) != 0) {
if (hold1 < avgV.get(i)) {
hold1 = avgV.get(i);
}
if (hold2 > avgV.get(i)) {
hold2 = avgV.get(i);
//System.out.println(hold2);
}
// Date day = new SimpleDateFormat("HH:MM").parse("9:30");
hold = avgV.get(i);
average.add(spacing*i, round(hold,2));
high.add(spacing*i, round(hold1,2));
low.add(spacing*i, round(hold2,2));
}
}
XYSeriesCollection dataset = new XYSeriesCollection(high);
dataset.addSeries(low);
dataset.addSeries(average);
JFreeChart chart;
chart = createChart2(dataset, title);
chart.getPlot().setBackgroundPaint( Color.BLACK );
ChartPanel chartPanel = new ChartPanel(chart);
// chartPanel.overlayChanged(event);
JPanel content = new JPanel(new BorderLayout());
content.add(chartPanel);
//content.add(button, BorderLayout.SOUTH);
chartPanel.setPreferredSize(new java.awt.Dimension(375, 320));
//setContentPane(content)
//this.add(content);
return content;
*/
}
Aggregations