Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to save a xygraph as an png or bmp file (or screenshot) ? the example is known from the homepage(save xygraph swt)
How to save a xygraph as an png or bmp file (or screenshot) ? the example is known from the homepage [message #1747480] Tue, 15 November 2016 10:43
stefan Ohm is currently offline stefan OhmFriend
Messages: 3
Registered: June 2016
Junior Member
package org.eclipse.nebula.visualization.xygraph.examples;

/*******************************************************************************
* Copyright (c) 2010 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************/
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.nebula.visualization.xygraph.dataprovider.CircularBufferDataProvider;
import org.eclipse.nebula.visualization.xygraph.figures.IXYGraph;
import org.eclipse.nebula.visualization.xygraph.figures.Trace;
import org.eclipse.nebula.visualization.xygraph.figures.XYGraph;
import org.eclipse.nebula.visualization.xygraph.figures.Trace.PointStyle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
* A very simple example.
*
* @author Xihui Chen
*
*/
public class SimpleExample {
public static void main(String[] args) {
final Shell shell = new Shell();
shell.setSize(300, 250);
shell.open();

// use LightweightSystem to create the bridge between SWT and draw2D
final LightweightSystem lws = new LightweightSystem(shell);

// create a new XY Graph.
IXYGraph xyGraph = new XYGraph();
xyGraph.setTitle("Simple Example");
// set it as the content of LightwightSystem
lws.setContents(xyGraph);

// create a trace data provider, which will provide the data to the
// trace.
CircularBufferDataProvider traceDataProvider = new CircularBufferDataProvider(false);
traceDataProvider.setBufferSize(100);
traceDataProvider.setCurrentXDataArray(new double[] { 10, 23, 34, 45, 56, 78, 88, 99 });
traceDataProvider.setCurrentYDataArray(new double[] { 11, 44, 55, 45, 88, 98, 52, 23 });

// create the trace
Trace trace = new Trace("Trace1-XY Plot", xyGraph.getPrimaryXAxis(), xyGraph.getPrimaryYAxis(), traceDataProvider);

// set trace property
trace.setPointStyle(PointStyle.XCROSS);

// add the trace to xyGraph
xyGraph.addTrace(trace);

Display display = Display.getDefault();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}

}
}
Previous Topic:Eclipse RAP - current web application vulnerabilities
Next Topic:MXGraph diagramming library for RAP
Goto Forum:
  


Current Time: Thu Apr 25 20:31:48 GMT 2024

Powered by FUDForum. Page generated in 0.03141 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top