本文整理汇总了Java中info.monitorenter.gui.chart.Chart2D.addTrace方法的典型用法代码示例。如果您正苦于以下问题:Java Chart2D.addTrace方法的具体用法?Java Chart2D.addTrace怎么用?Java Chart2D.addTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类info.monitorenter.gui.chart.Chart2D
的用法示例。
在下文中一共展示了Chart2D.addTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLabelSpacing
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Creates a a chart with three traces and different labels and displays it.
* <p>
*
* @throws InterruptedException
*/
public void testLabelSpacing() throws InterruptedException {
JFrame frame = new JFrame(this.getName());
Chart2D chart = new Chart2D();
ITrace2D trace1 = new Trace2DLtd();
trace1.setName("lottolotto");
trace1.setColor(Color.RED);
chart.addTrace(trace1);
ITrace2D trace2 = new Trace2DLtd();
trace2.setName("bbb");
trace2.setColor(Color.BLUE);
chart.addTrace(trace2);
ITrace2D trace3 = new Trace2DLtd();
trace3.setColor(Color.BLACK);
trace3.setName("ffollejolle");
chart.addTrace(trace3);
frame.getContentPane().add(chart);
frame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
frame.setSize(new Dimension(400, 300));
frame.setVisible(true);
while (frame.isVisible()) {
Thread.sleep(1000);
}
}
示例2: testAddRemoveTrace
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Creates an empty chart adds a trace, removes it again and displays it.
* <p>
*
* @throws InterruptedException
* if sleeping is interrupted.
*/
public void testAddRemoveTrace() throws InterruptedException {
JFrame frame = new JFrame(this.getClass().getName());
Dimension size = new Dimension(400,400);
Chart2D chart = new Chart2D();
chart.setPreferredSize(size);
ITrace2D trace = new Trace2DLtd();
chart.addTrace(trace);
chart.removeTrace(trace);
frame.getContentPane().add(chart);
frame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
while (frame.isVisible()) {
Thread.sleep(1000);
}
}
示例3: plot
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
public static void plot (String title, String xlabel, String ylabel, double[] data) {
//////////////////////////////////
// Create a chart:
//////////////////////////////////
Chart2D chart = new Chart2D();
// Create an ITrace:
ITrace2D trace = new Trace2DSimple();
// Add the trace to the chart. This has to be done before adding points
chart.addTrace(trace);
// Add all points, as it is static:
for (int i = 0; i < data.length; i++) {
trace.addPoint(i, data[i]);
}
chart.getAxisX().setAxisTitle(new AxisTitle(xlabel));
chart.getAxisY().setAxisTitle(new AxisTitle(ylabel));
// Make it visible:
// Create a frame.
JFrame frame = new JFrame(title);
// add the chart to the frame:
frame.getContentPane().add(chart);
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize().width, 400);
// Enable the termination button [cross on the upper right edge]:
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
}
示例4: ChartPanel
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
public ChartPanel(String... params) {
super(new BorderLayout());
int historySize = 200;
chart = new Chart2D();
chart.setBorder(new EmptyBorder(0,0,0,0));
//chart.setSize(200,200);
chart.setUseAntialiasing(true);
chart.setBackground(Color.BLACK);
chart.setForeground(Color.WHITE);
chart.setGridColor(Color.darkGray);
for (IAxis left : chart.getAxesYLeft()) {
left.setAxisTitle(new AxisTitle(""));
left.setPaintGrid(true);
}
for (IAxis bottom : chart.getAxesXBottom()) {
bottom.setVisible(false);
}
for (String p : params) {
Trace2DLtd t = new Trace2DLtd(historySize, p);
t.setColor(Color.getHSBColor( ((float)(p.hashCode()%1024))/1024.0f, 0.5f, 1.0f));
chart.addTrace(t);
this.params.put(p, t);
}
add(chart, BorderLayout.CENTER);
}
示例5: main
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Main entry.
* <p>
*
* @param args
* ignored
*/
public static void main(final String[] args) {
// Create a chart:
Chart2D chart = new Chart2D();
// Create an ITrace:
// Note that dynamic charts need limited amount of values!!!
ITrace2D trace = new Trace2DLtd(100);
trace.setColor(Color.RED);
// Add the trace to the chart:
chart.addTrace(trace);
IAxis<?> axisX = chart.getAxisX();
axisX.setStartMajorTick(false);
axisX.setMajorTickSpacing(10);
// Make it visible:
// Create a frame.
JFrame frame = new JFrame("MinimalDynamicChart");
// add the chart to the frame:
frame.getContentPane().add(chart);
frame.setSize(400, 300);
// Enable the termination button [cross on the upper right edge]:
frame.addWindowListener(new WindowAdapter() {
/**
* @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
*/
@Override
public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
// Every 20 milliseconds a new value is collected.
ADataCollector collector = new RandomDataCollectorOffset(trace, 100);
collector.start();
}
示例6: MinimalStaticChartWithNanValues
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Defcon.
*/
private MinimalStaticChartWithNanValues() {
this.setLayout(new BorderLayout());
Chart2D chart = new Chart2D();
// Create an ITrace:
// Note that dynamic charts need limited amount of values!!!
// ITrace2D trace = new Trace2DLtd(200);
ITrace2D trace = new Trace2DSimple();
trace.setColor(Color.RED);
// Add the trace to the chart:
chart.addTrace(trace);
// Add all points, as it is static:
trace.addPoint(0, 0);
trace.addPoint(1, 10);
trace.addPoint(2, Double.NaN);
trace.addPoint(3, 10);
trace.addPoint(4, 15);
trace.addPoint(5, Double.NaN);
trace.addPoint(6, 16);
trace.addPoint(7, 14);
trace.addPoint(8, 13);
chart.setToolTipType(Chart2D.ToolTipType.VALUE_SNAP_TO_TRACEPOINTS);
// Make it visible:
this.add(chart, BorderLayout.CENTER);
}
示例7: main
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Demo application startup method.
* <p>
*
* @param args
* ignored.
* @throws IOException
* if loading data for the demo chart fails.
*/
public static void main(final String[] args) throws IOException {
Chart2D chart = new Chart2D();
chart.enablePointHighlighting(true);
chart.setToolTipType(Chart2D.ToolTipType.VALUE_SNAP_TO_TRACEPOINTS);
ITrace2D trace = new Trace2DLtd(400);
AStaticDataCollector collector = new PropertyFileStaticDataCollector(trace,
CoordinateViewChart.class.getResourceAsStream("data.properties"));
chart.addTrace(trace);
trace.setPointHighlighter(new PointPainterDisc(10));
collector.collectData();
new CoordinateViewChart(chart);
}
示例8: main
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Main entry.
* <p>
*
* @param args
* ignored.
*/
public static void main(final String[] args) {
// Create a chart:
Chart2D chart = new Chart2D();
// Create an ITrace:
ITrace2D trace = new Trace2DSimple();
// Add the trace to the chart:
chart.addTrace(trace);
trace.setTracePainter(new TracePainterDisc());
trace.setColor(Color.DARK_GRAY);
// Add all points, as it is static:
double count = 0;
double value;
double place = 0;
for (int i = 120; i >= 0; i--) {
count += 1.0;
place += 1.0;
value = Math.random() * count * 10;
trace.addPoint(place, value);
}
// Make it visible:
// Create a frame.
JFrame frame = new JFrame("StaticChartDiscs");
// add the chart to the frame:
frame.getContentPane().add(new ChartPanel(chart));
frame.setSize(400, 300);
// Enable the termination button [cross on the upper right edge]:
frame.addWindowListener(new WindowAdapter() {
/**
* @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
*/
@Override
public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
}
示例9: testMemoryLeakTrace2DListenersSeverity
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* <p>
* Adds and removes a trace to a chart 100 times and asserts that only zero listeners are
* contained in the chart afterwards.
* </p>
*/
public void testMemoryLeakTrace2DListenersSeverity() {
Chart2D chart = new Chart2D();
ITrace2D trace = new Trace2DSimple();
int listeners = 0;
for (int i = 0; i < 100; i++) {
chart.addTrace(trace);
chart.removeTrace(trace);
}
listeners = trace.getPropertyChangeListeners(ITrace2D.PROPERTY_MAX_X).length;
Assert.assertEquals("All listeners have to be deregistered!", 0, listeners);
}
示例10: testMemoryLeakTrace2DListeners
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Adds and removes a trace to a chart and asserts that only one and afterwards zero listeners are
* contained in the chart.
* <p>
*/
public void testMemoryLeakTrace2DListeners() {
Chart2D chart = new Chart2D();
ITrace2D trace = new Trace2DSimple();
PropertyChangeListener[] listeners;
for (int i = 0; i < 100; i++) {
chart.addTrace(trace);
listeners = trace.getPropertyChangeListeners(ITrace2D.PROPERTY_MAX_X);
Assert.assertEquals("Only one listener should be registered!", 1, listeners.length);
chart.removeTrace(trace);
listeners = trace.getPropertyChangeListeners(ITrace2D.PROPERTY_MAX_X);
Assert.assertEquals("All listeners have to be deregistered!", 0, listeners.length);
}
}
示例11: MinimalStaticChart
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Defcon.
*/
private MinimalStaticChart() {
this.setLayout(new BorderLayout());
Chart2D chart = new Chart2D();
// Create an ITrace:
// Note that dynamic charts need limited amount of values!!!
// ITrace2D trace = new Trace2DLtd(200);
ITrace2D trace = new Trace2DSimple();
trace.setColor(Color.RED);
// Add the trace to the chart:
chart.addTrace(trace);
// Add all points, as it is static:
double time = System.currentTimeMillis();
for (int i = 0; i < 120; i++) {
trace.addPoint(time + 1000 * 60 * i, i);
}
chart.setToolTipType(Chart2D.ToolTipType.VALUE_SNAP_TO_TRACEPOINTS);
chart.getAxisY().setPaintScale(false);
chart.getAxisX().setPaintScale(false);
// Make it visible:
this.add(new ChartPanel(chart), BorderLayout.CENTER);
}
示例12: createChart
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
private Chart2D createChart() {
Chart2D chart = new Chart2D();
chart.setPaintLabels(true);
chart.setUseAntialiasing(true);
chart.setToolTipType(Chart2D.ToolTipType.VALUE_SNAP_TO_TRACEPOINTS);
x_achse = chart.getAxisX();
x_achse.getAxisTitle().setTitle("Minuten");
x_achse.setPaintScale(true);
x_achse.setVisible(true);
x_achse.setPaintGrid(false);
x_achse.setMajorTickSpacing(10);
x_achse.setMinorTickSpacing(1);
IAxis<?> y_achse = chart.getAxisY();
y_achse.getAxisTitle().setTitle("");
y_achse.setPaintScale(true);
y_achse.setVisible(true);
y_achse.setPaintGrid(true);
y_achse.setMajorTickSpacing(5);
y_achse.setMinorTickSpacing(1);
y_achse.setFormatter(new LabelFormatterAutoUnits());
y_achse.setRangePolicy(new RangePolicyForcedPoint());
m_trace.setName("");
m_trace.setColor(Color.RED);
chart.addTrace(m_trace);
return chart;
}
示例13: jButtonGCodeVisualizeActionPerformed
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
private void jButtonGCodeVisualizeActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButtonGCodeVisualizeActionPerformed
{//GEN-HEADEREND:event_jButtonGCodeVisualizeActionPerformed
try
{
/*frmGCodeViewer frm = new frmGCodeViewer();
frm.setVisible(true);*/
final Chart2D chart = new Chart2D();
// Create an ITrace:
ITrace2D trace = new Trace2DSimple();
// Add the trace to the chart. This has to be done before adding points (deadlock prevention):
chart.addTrace(trace);
final Queue<String> gcodeQueue = new ArrayDeque(ConnectionHelper.ACTIVE_CONNECTION_HANDLER.getMyGCodeSender().getGCodeQueue());
double x = 0, y = 0, z = 0, maxX = 0, maxY = 0;
while (gcodeQueue.size() > 0)
{
final GCodeCommand command = new GCodeCommand(gcodeQueue.remove());
x = (command.getCoordinates().getX() != null) ? command.getCoordinates().getX() : x;
y = (command.getCoordinates().getY() != null) ? command.getCoordinates().getY() : y;
z = (command.getCoordinates().getZ() != null) ? command.getCoordinates().getZ() : z;
if (z < 0)
{
maxX = Math.max(x, maxX);
maxY = Math.max(y, maxY);
trace.addPoint(x, y);
}
}
chart.getAxisX().setRangePolicy(new RangePolicyFixedViewport(new Range(0, Math.max(maxY, maxX))));
chart.getAxisY().setRangePolicy(new RangePolicyFixedViewport(new Range(0, Math.max(maxY, maxX))));
// Make it visible:
// Create a frame.
final JFrame frame = new JFrame(ConnectionHelper.ACTIVE_CONNECTION_HANDLER.getMyGCodeSender().getGCodeFile().getName());
// add the chart to the frame:
frame.getContentPane().add(chart);
frame.setSize(600, 600);
frame.setVisible(true);
}
catch (Exception ex)
{
}
}
示例14: main
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Main entry.
* <p>
*
* @param args
* ignored.
*/
public static void main(final String[] args) {
// Create a chart:
Chart2D chart = new Chart2D();
// Create an ITrace:
ITrace2D trace = new Trace2DSimple();
// Add the trace to the chart:
chart.addTrace(trace);
trace.setTracePainter(new TracePainterFill(chart));
trace.setColor(Color.DARK_GRAY);
// Add all points, as it is static:
double count = 0;
double value;
double place = 0;
Random random = new Random();
for (int i = 120; i >= 0; i--) {
count += 1.0;
place += 1.0;
value = random.nextDouble() * 10.0 + i;
trace.addPoint(place, value);
}
// Make it visible:
// Create a frame.
JFrame frame = new JFrame("StaticChartFill");
// add the chart to the frame:
frame.getContentPane().add(new ChartPanel(chart));
frame.setSize(400, 300);
// Enable the termination button [cross on the upper right edge]:
frame.addWindowListener(new WindowAdapter() {
/**
* @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
*/
@Override
public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
}
示例15: main
import info.monitorenter.gui.chart.Chart2D; //导入方法依赖的package包/类
/**
* Main entry.
* <p>
*
* @param args
* ignored.
*/
public static void main(final String[] args) {
// Create a chart:
Chart2D chart = new Chart2D();
chart.setUseAntialiasing(true);
// set a special axis:
AAxis<?> axisy = new AxisLog10<AxisScalePolicyTransformation>();
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(100);
chart.setAxisYLeft(axisy, 0);
axisy.setFormatter(new LabelFormatterAutoUnits(new LabelFormatterNumber(df)));
// Create an ITrace:
ITrace2D trace = new Trace2DSimple();
// Add the trace to the chart:
chart.addTrace(trace);
trace.setTracePainter(new TracePainterDisc(4));
trace.setColor(Color.BLUE);
trace.setStroke(new BasicStroke(1));
// Add the function 1/x + random
for (double i = 1; i < 10; i += 0.1) {
trace.addPoint(i, Math.pow(10, i));
}
// Make it visible:
// Create a frame.
JFrame frame = new JFrame(Log10AxisChart.class.getName());
// add the chart to the frame:
frame.getContentPane().add(new ChartPanel(chart));
frame.setSize(400, 300);
// Enable the termination button [cross on the upper right edge]:
frame.addWindowListener(new WindowAdapter() {
/**
* @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent)
*/
@Override
public void windowClosing(final WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
}