[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wekalist
Subject:    [Wekalist] Plot2D class in SWT application
From:       yazan <qetoom () gmail ! com>
Date:       2006-10-31 13:37:32
Message-ID: 200610311537.32234.qetoom () gmail ! com
[Download RAW message or body]

I'm trying to embed Plot2D class in SWT application, but nothing shows up on 
the application window. although I used the same instruction to embed a 
JPanel (witch Plot2D descends from) and it works. 
http://eclipsezone.com/eclipse/forums/t45697.html

here is the code listing:

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.awt.SWT_AWT;
import weka.core.Instances;
import weka.gui.visualize.*;

public class SwtVisulizer {
	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setText("Plot2d in SWT app");
		Composite compos = new Composite(shell, SWT.EMBEDDED);
		java.awt.Frame frame = SWT_AWT.new_Frame(compos);
		Plot2D p2 = new Plot2D();
		frame.add(p2);
		try
		{
			java.io.Reader r = new java.io.BufferedReader(
					new java.io.FileReader(args[0]));
			Instances i = new Instances(r);
			i.setClassIndex(i.numAttributes()-1);
			PlotData2D pd1 = new PlotData2D(i);
	  
			pd1.setPlotName("Master plot");
			p2.setMasterPlot(pd1);
			p2.setXindex(2);
			p2.setYindex(3);
			p2.setCindex(i.classIndex());
		}catch (Exception e) {
				System.out.println("error\n");
		}
		shell.open();
		while(!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	}
}



_______________________________________________
Wekalist mailing list
Wekalist@list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic