Package Gui
Package Gui
Package Gui
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import java.util.Timer;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.plaf.basic.BasicArrowButton;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public GUI_DrawThreshold() {
series = new XYSeries("Random Data");
XYDataset dataset = new XYSeriesCollection(series);
JFreeChart chart = createChart(dataset);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(700, 500));
chart.setBackgroundPaint(Color.white);
//AXE DES Y
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setAutoRange(false);
rangeAxis.setRange(-10, 10);
rangeAxis.setFixedDimension(15.0);//décalage vers la droite
if (rangeAxis instanceof NumberAxis) {
NumberAxis axisY = (NumberAxis) rangeAxis;
axisY.setAutoRangeIncludesZero(true);
axisY.setTickUnit(new NumberTickUnit(1, new DecimalFormat("0")));
}
// Channel A
Box channel_A = Box.createVerticalBox();
channel_A.setBorder(BorderFactory.createTitledBorder("Channel A"));
Box trigger = Box.createVerticalBox();
BasicArrowButton up = new BasicArrowButton(BasicArrowButton.NORTH);
up.setActionCommand("UP");
up.addActionListener(this);
trigger.add(up);
trigger.add(down);
trigger.add(button);
channel_A.add(vPositionA);
channel_A.add(vRangeA);
// Creating Channel B
Box channel_B = Box.createVerticalBox();
channel_B.setBorder(BorderFactory.createTitledBorder("Channel B"));
channel_B.add(Box.createVerticalStrut(30));
channel_B.add(new JCheckBox("Show real-time trace"));
channel_B.add(Box.createVerticalStrut(30));
channel_B.add(vPositionB);
channel_B.add(vRangeB);
content.add(top, BorderLayout.CENTER);
aWindow.pack();
aWindow.setVisible(true);
aWindow.pack();
aWindow.setVisible(true);
thre_UP_DOWN++;
for (int i = 0; i < 512; i++) {
y_of_x[i] = thre_UP_DOWN;
series.add((double) i, y_of_x[i]);
}
}
if (event.getActionCommand().equals("DOWN")) {
thre_UP_DOWN--;
for (int i = 0; i < 512; i++) {
y_of_x[i] = thre_UP_DOWN;
series.add((double) i, y_of_x[i]);
}
}
new GUI_DrawThreshold();
}
}