I have successfully built the JFreeChart 1.0.8a source along with its experimental SWT support. I have also read all of this forum's posts with "SWT" in the post, but it is still not clear to me if there is or is not a way to embed a JFreeChart object in an SWT group (possibly deeply embedded in other group objects).
I have a standalone SWT app with a complex SWT frame, some of it developed by myself, some of it by a closed source package that my work extends. I have a specific scrolled composite embedded a couple of levels down in a group that I would like to display my chart in. Is there a way to do this presently?
If not, can anyone outline the proper extensions/additions that would required if I were to attempt to customize the SWT support to add this capability?
I reviewed the discussion of a possible ChartCanvas class development and understand most of it, but I guess that what I really want to do is treat a JFreeChart object the same as any other SWT widget so that it can be embedded easily anywhere any other SWT widget can be embedded.
My background level is 30 years of real-time hard core C programming, embedded device design and software design, C and C like compiler development, real time OS design and construction, etc, but only about 6 weeks of Java programming and no prior GUI programming experience. I am presently using Eclipse 3.3 and the very nice Instantiation's WindowsBuilder GUI editor as my programming environment.
I don't know if it will help, but here is a toString() version of the layout that I am trying to insert the chart into:
FFTS.getLayout().toString() = [
HORIZONTAL
org.eclipse.swt.layout.grouplayout.GroupLayout$SequentialGroup 1e04cbf , size=0, alignment=0 prefs=[684 684 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$ParallelGroup cec0c5 , size=0, alignment=0 prefs=[684 684 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$SequentialGroup 1d2068d , size=0, alignment=0 prefs=[684 684 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$ContainerAutopaddingSpring 1ac2f9c , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=--]
org.eclipse.swt.layout.grouplayout.GroupLayout$ParallelGroup 169ca65 , size=0, alignment=0 prefs=[521 521 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$SequentialGroup 66e815 , size=0, alignment=0 prefs=[506 506 506]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring ece65 name=Group {Trigger}, , size=0, alignment=0 prefs=[102 102 102]
org.eclipse.swt.layout.grouplayout.GroupLayout$AutopaddingSpring 106082 , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring 1301ed8 name=Group {Time Base}, , size=0, alignment=0 prefs=[167 167 167]
org.eclipse.swt.layout.grouplayout.GroupLayout$AutopaddingSpring 3901c6 , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring a37368 name=Group {FFT Display}, , size=0, alignment=0 prefs=[107 107 107]
org.eclipse.swt.layout.grouplayout.GroupLayout$AutopaddingSpring edc3a2 , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring 1c6f579 name=Group {FFT Display}, , size=0, alignment=0 prefs=[130 130 130]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring 11ddcde name=ScrolledComposite {}, , size=0, alignment=0 prefs=[521 521 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$AutopaddingSpring 18fb1f7 , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring ed0338 name=Label {}, , size=0, alignment=0 prefs=[4 4 4]
org.eclipse.swt.layout.grouplayout.GroupLayout$GapSpring 6e70c7 , size=0, alignment=0 prefs=[159 159 159]
VERTICAL
org.eclipse.swt.layout.grouplayout.GroupLayout$SequentialGroup ae506e , size=0, alignment=0 prefs=[306 306 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$ParallelGroup 228a02 , size=0, alignment=0 prefs=[306 306 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$SequentialGroup 192b996 , size=0, alignment=0 prefs=[306 306 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$ContainerAutopaddingSpring 1d63e39 , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=--]
org.eclipse.swt.layout.grouplayout.GroupLayout$ParallelGroup 8f4fb3 , size=0, alignment=0 prefs=[306 306 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$SequentialGroup b988a6 , size=0, alignment=0 prefs=[306 306 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring ba6c83 name=ScrolledComposite {}, , size=0, alignment=0 prefs=[205 205 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$AutopaddingSpring 12a1e44 , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=]
org.eclipse.swt.layout.grouplayout.GroupLayout$ParallelGroup 29428e , size=0, alignment=0 prefs=[95 95 95]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring d0a5d9 name=Group {FFT Display}, , size=0, alignment=0 prefs=[95 95 95]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring 388993 name=Group {FFT Display}, , size=0, alignment=0 prefs=[95 95 95]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring 1d04653 name=Group {Time Base}, , size=0, alignment=0 prefs=[95 95 95]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring b8f82d name=Group {Trigger}, , size=0, alignment=0 prefs=[95 95 95]
org.eclipse.swt.layout.grouplayout.GroupLayout$GapSpring 1ad77a7 , size=0, alignment=0 prefs=[6 6 6]
org.eclipse.swt.layout.grouplayout.GroupLayout$SequentialGroup 18aaa1e , size=0, alignment=2 prefs=[302 302 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$ComponentSpring a6aeed name=Label {}, , size=0, alignment=0 prefs=[302 302 32767]
org.eclipse.swt.layout.grouplayout.GroupLayout$ContainerAutopaddingSpring 126804e , size=0, alignment=0 prefs=[0 0 0, userCreated=true, matches=--]
]
Best regards,
Don Lucas
Embedding a JFreeChart object in an SWT group
Embedding a JFreeChart object in an SWT group
Best regards,
Don
Don
Hi Don,
Let's get strainght to your question: yes you can. The thing is I'm not sure to understand your question... You can embed a Chart in any SWT composite object. Did you run the faw demos shipped in the swt/experimental package. You can see that a ChartComposite is embeded into the shell but you can replace the shell by any composite instance. That's it !
now I'll explain one point you might be misunderstanding (I reckon it is confusing). To use jfreechart in an application built with swt you have two options:
Henry
Let's get strainght to your question: yes you can. The thing is I'm not sure to understand your question... You can embed a Chart in any SWT composite object. Did you run the faw demos shipped in the swt/experimental package. You can see that a ChartComposite is embeded into the shell but you can replace the shell by any composite instance. That's it !
now I'll explain one point you might be misunderstanding (I reckon it is confusing). To use jfreechart in an application built with swt you have two options:
- 1) Use a ChartPanel instance and embed it in a SWT_AWT panel which you can embed itself into an swt composite (seach for swt_awt in the forum to get some examples).
- 2) Use a ChartComposite instance (easier but experimental). This has proved to work well but you may bump into undiscovered issues, if so please report them
Henry
Hi Henry -
Thanks for your reply. I am using method #2 that you outlined. I understand method #1, but haven't played with this and prefer to get method #2 to work. I have studied and run several of the demos and modified the demos to get the kind of chart that I want with no problems.
I think that the area that I had difficulty with is probably due to my lack of Java experience. I thought that a ChartComposite instance could only be embedded in a shell and not just any type of composite instance. All of the demos that I found only embed in a standalone shell, never (at least not that I could find and easily understand) deep down in some more complex composite.
I will give this a try and see if I can get it to work. I will certainly report any bugs that I find and thanks very much for your key contributions to the SWT support!
Thanks for your reply. I am using method #2 that you outlined. I understand method #1, but haven't played with this and prefer to get method #2 to work. I have studied and run several of the demos and modified the demos to get the kind of chart that I want with no problems.
I think that the area that I had difficulty with is probably due to my lack of Java experience. I thought that a ChartComposite instance could only be embedded in a shell and not just any type of composite instance. All of the demos that I found only embed in a standalone shell, never (at least not that I could find and easily understand) deep down in some more complex composite.
I will give this a try and see if I can get it to work. I will certainly report any bugs that I find and thanks very much for your key contributions to the SWT support!
Best regards,
Don
Don
Hi Henry -
I have now successfully embedded two ChartComposites into a very complex nested group composite now.
The one thing that I misunderstood was that ChartComposite takes a shell as one of the arguments in most of the demos and due to my lack of experience with Java and SWT, I failed to realize that a shell is a type of composite so that anywhere that a shell is used in the example code, any other composite could also be used instead.
I am learning Java, SWT, JFreeChart, and the NIST FFT package along with Eclipse and WindowsBuilder Pro all at the same time
and I am only about 6 weeks into the process so you can imagine some of the confusion that I am slowly working my way through.
Thanks for your help on the composite issue and keep up the great work!
I have now successfully embedded two ChartComposites into a very complex nested group composite now.
The one thing that I misunderstood was that ChartComposite takes a shell as one of the arguments in most of the demos and due to my lack of experience with Java and SWT, I failed to realize that a shell is a type of composite so that anywhere that a shell is used in the example code, any other composite could also be used instead.
I am learning Java, SWT, JFreeChart, and the NIST FFT package along with Eclipse and WindowsBuilder Pro all at the same time

Thanks for your help on the composite issue and keep up the great work!
Best regards,
Don
Don