SWT -- Tooltips and plot Orientation

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
marc0
Posts: 1
Joined: Wed Oct 27, 2010 4:19 pm
antibot: No, of course not.

SWT -- Tooltips and plot Orientation

Post by marc0 » Wed Oct 27, 2010 4:44 pm

Hello everyone,

I currently am using JFreeChart 1.0.13 to develop an Eclipse plug-in that will generate plots, using the ChartComposite class within a JFace Structured Viewer.

I have found out that whenever I set the plot orientation to horizontal during runtime, tooltips will not show up at all, unless I set the plot back to vertial. This is happening whether I use an XY chart, bar chart, etc..

I wouldn't want to say that this is a possible bug yet, but is there a known workaround, or am i doing it wrong?

Here is an example code I used (and modified a bit), I do not remember the source (it may probably be this forum!). It is not a JFace application but if you set the plot orientation to vertical during runtime, this 'bug' will show up.

Code: Select all


import java.awt.Frame;
import java.awt.GridLayout;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 * Simple SWT demonstration.
 * 
 * @author Robert Gash (gashalot [at] gashalot.com)
 */
public class App2 {
	/**
	 * Simple driving main, a quick and dirty intro to SWT_AWT using JFreeChart.
	 * 
	 * @param args command line arguments (ignored)
	 */
	public static void main(String[] args) {
		// create the SWT display and the new window (Shell)
		Display display = new Display();
		Shell shell = new Shell(display,SWT.EMBEDDED);
		
		// Set the layout to a simple FillLayout
		FillLayout layout = new FillLayout();
		layout.type = SWT.VERTICAL;
		
		XYSeries series = new XYSeries("XYGraph",false);
    
	       for(int i = 0; i < 100;++i)
			{
	        	series.add(i,Math.random() * 100);
		
			}
	        //         Add the series to your data set
	        XYSeriesCollection dataset = new XYSeriesCollection();
	        dataset.addSeries(series);
	        //         Generate the graph
	      
	        JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", // Title
	                "x-axis", // x-axis Label
	                "y-axis", // y-axis Label
	                dataset, // Dataset
	                PlotOrientation.VERTICAL, // Plot Orientation
	                true, // Show Legend
	                true, // Use tooltips
	                false // Configure chart to generate URLs?
	           );
	        
		
		
		// grab a new AWT frame from our shell
		Frame chartFrame = SWT_AWT.new_Frame(shell);
		
		// set the layout of our frame to a GridLayout so the chart will
		// automatically fill the entire area
		chartFrame.setLayout(new GridLayout());
		ChartPanel cp = new ChartPanel(chart);
		chartFrame.add(cp);
		
		// pack the shell, set the size to a reasonable default, and show it
		shell.pack();
		shell.setSize(400,400);
		shell.open();
		
		// standard SWT dispose loop
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();		
	}
}

Locked