Popup Menu not showing up

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ankit5321
Posts: 5
Joined: Tue Aug 07, 2007 1:43 pm
Location: Pune
Contact:

Popup Menu not showing up

Post by ankit5321 » Tue Aug 07, 2007 1:51 pm

Hi all,

I have created a line chart using JfreeChart but on right clicking on the panel the popup menu is not generated.

I am developing an Eclipse RCP application with multiple views, one of the view is having a TableTreeViewer, on selecting a node of this viewer a line chart is drawn in another view with different no of series depending on the selection. Everything is fine except for the Pop-up menu

Please help me out.. :(
Thanks in advance

ankit5321
Posts: 5
Joined: Tue Aug 07, 2007 1:43 pm
Location: Pune
Contact:

Post by ankit5321 » Tue Aug 07, 2007 2:30 pm

Hi all I was working on the problem, and was jus trying to check weather the popup menu will be generated in a simple view.

I m posting a simple View class which is having a chart as its content. Here also the popup menu is not coming..

Any ideas??
here is my code

package com.example.rcpapp1;

import java.awt.Frame;
import java.text.SimpleDateFormat;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public class Test extends ViewPart{
public static final String ID = "com.example.rcpapp1.Treeview";
static ChartPanel chartPanel = null;
CategoryDataset dataset = null;
XYDataset xyDataset = null;
DefaultPieDataset piedataset = null;
static Frame frame = null;
JFreeChart chart = null;
static Composite SWT_AWT_Composite = null;

public void createPartControl(Composite parent) {
SWT_AWT_Composite = new Composite(parent, SWT.EMBEDDED);
frame = SWT_AWT.new_Frame(SWT_AWT_Composite);
XYDataset xyDataset = createDataset();
chart = createLineChart(xyDataset);
chartPanel = new ChartPanel(chart);
//chartPanel.setDismissDelay(999999999);
System.out.println("hi ankit"+chartPanel.getPopupMenu());
frame.add(chartPanel);
}

public static JFreeChart createLineChart(XYDataset xyDataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart("", // chart title
"Date", // domain axis label
"Net Asset Value", // range axis label
xyDataset, // data
true, // include legend
true, // tooltips?
false // URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("d-M-yy"));
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer)plot.getRenderer();
renderer.setShapesVisible(true);
renderer.setShapesFilled(true);
renderer.setUseFillPaint(true);
renderer.setUseOutlinePaint(false);

return chart;
};

private XYSeriesCollection createDataset(){
XYSeries series1 = new XYSeries("First");
series1.add(1.0, 1.0);
series1.add(2.0, 4.0);
series1.add(3.0, 3.0);
series1.add(4.0, 5.0);
series1.add(5.0, 5.0);
series1.add(6.0, 7.0);
series1.add(7.0, 7.0);
series1.add(8.0, 8.0);

XYSeries series2 = new XYSeries("Second");
series2.add(1.0, 5.0);
series2.add(2.0, 7.0);
series2.add(3.0, 6.0);
series2.add(4.0, 8.0);
series2.add(5.0, 4.0);
series2.add(6.0, 4.0);
series2.add(7.0, 2.0);
series2.add(8.0, 1.0);

XYSeries series3 = new XYSeries("Third");
series3.add(3.0, 4.0);
series3.add(4.0, 3.0);
series3.add(5.0, 2.0);
series3.add(6.0, 3.0);
series3.add(7.0, 6.0);
series3.add(8.0, 3.0);
series3.add(9.0, 4.0);
series3.add(10.0, 3.0);

XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series1);
dataset.addSeries(series2);
dataset.addSeries(series3);

return dataset;
}

public void setFocus() {
SWT_AWT_Composite.setFocus(); // Required for F1 help support
}
}

ankit5321
Posts: 5
Joined: Tue Aug 07, 2007 1:43 pm
Location: Pune
Contact:

Post by ankit5321 » Wed Aug 08, 2007 1:05 pm

HI all plz anyone help me out.... :( :cry:

ankit5321
Posts: 5
Joined: Tue Aug 07, 2007 1:43 pm
Location: Pune
Contact:

Post by ankit5321 » Fri Aug 10, 2007 10:04 am

Thanks for not replying to my post, atleast it make me to look a lot more deeper into the eclipse RCP. 8)

Actually i found my answer, there was some problem with my jre settings.
previously i was using jre 1.6. When i changed it to 1.5, the popup menu was there..... :D

consutes
Posts: 9
Joined: Fri Sep 14, 2007 6:06 pm

Post by consutes » Mon Oct 15, 2007 3:30 pm

hi,

I have the same problem like you, I have changed to version 1.6 of jdk and
my popup menu don't come, but I need to use this version of jdk, is there a
solution?

Very Thanks!!!!

consutes
Posts: 9
Joined: Fri Sep 14, 2007 6:06 pm

Post by consutes » Tue Oct 16, 2007 4:48 pm

no answer for my post?

Thanks.

ankit5321
Posts: 5
Joined: Tue Aug 07, 2007 1:43 pm
Location: Pune
Contact:

Post by ankit5321 » Wed Oct 17, 2007 4:23 pm

well i don't know anythin else.

the solution i have posted worked for me so i didn't move into any more details...

may be any body else can have a solution...

heprom
Posts: 91
Joined: Sat May 27, 2006 4:25 am
Location: Paris

Post by heprom » Wed Oct 17, 2007 7:50 pm

did you try the native SWT version of JFreechart?, the menu is working fine here with linux. Try following the tutorial written by vogella:
http://www.vogella.de/articles/EclipseJ ... ticle.html

Regards,
/heprom

khanhlv
Posts: 21
Joined: Thu May 22, 2008 10:27 am

Post by khanhlv » Fri May 23, 2008 4:18 am

Hura!

I also have the same problem when i create a View eclipse plugin extends.
Popup menu does not work with jre 1.6 but jre1.5. But with jre 1.5 there are still some conflicts of mouse event :(!

Any solution!?

Thanks!

heprom
Posts: 91
Joined: Sat May 27, 2006 4:25 am
Location: Paris

Post by heprom » Sat May 24, 2008 8:04 pm

seems to be a problem with java 6 on windows. No problem for me on Linux both with 1.5 and 1.6 so I cannot help much here...

Locked