Code covered by the BSD License  

Highlights from
Making MATLAB Swing

4.81818

4.8 | 11 ratings Rate this file 41 Downloads (last 30 days) File Size: 1.05 MB File ID: #32697
image thumbnail

Making MATLAB Swing

by Malcolm Lidierth

 

26 Aug 2011 (Updated 30 Sep 2011)

TabbedPanes, SplitPanes, SideBars, ScrollPanes etc for MATLAB

| Watch this File

File Information
Description

A short summary of the features available in the Project Waterloo Swing Library.

This collection of MATLAB classes provide support for TabbedPanes, SplitPanes, ScrollPanes, SideBars, Accordions etc within MATLAB.

Both MATLAB and Java Swing graphics can be added to the containers

This library includes several files that were previously available separately on the FEX:

JCONTROL CLASS
For adding Java Swing components to MATLAB figures

MOUSEMOTIONHANDLER
For extending mouse motion callbacks to all MATLAB components

GCOLOR
Static class for RGB/HSL/Java/MATLAB color conversions + manipulation. Color series.

MUTILITIES
AWT/Swing/MATLAB graphics utilities. Figure transparency etc

Project Waterloo is free and open-source and is available from:

http://sigtool.sourceforge.net/

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Code has been tested on Windows XP/7, Mac Snow Leopard and Ubuntu 11.04
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (32)
26 Aug 2011 Yair Altman

Exceptional work!

A very useful set of tools for anyone who wishes to develop professional-looking GUI in Matlab.

26 Aug 2011 Etienne Coetzee

Very impressive!

27 Aug 2011 Bruno Luong

Quite promising.

The Java crash on Window when using GElasticPane is a minor issue.

I notice during the Demo the NEXT button is blinking. What is the reason?

Excellent work.

27 Aug 2011 Malcolm Lidierth

@Bruno
The GElasticPane null pointer issue has now been fixed and I'll post an update. The flashing button is not something I have seen - what OS/ML version did you see that with. It may well be caused by the fixed GElasticPane issue - probably a mismatch between MATLAB stack and Java ZOrder.

30 Aug 2011 David

Great work! Things individually seems to work very nicely. However, when running the demo and clicking through the various tabs, there seem to be a performance issue. Sometimes the screen will hang after clicking a tab and sometimes the "Next" button will not be functional until everything is fully loaded (takes several seconds between tabs). I am running the demo on Windows XP on a Core i7 computer with 4 GB of ram so I don't think my computer specs is the issue. I also got the same problem when building my own GUI with a few simple plots using GTabbedPane. Do you know what might be causing this issue?

Also how do you turn off the animation between tabs? I've looked through the GTabbedPane comments and it only says you can turn it off but not how. Maybe this is contributing to the performance issue?

Awesome work though!

30 Aug 2011 Malcolm Lidierth

@David
It's a bug. myTabbedPane.setAnimated(false);
is not doing anything useful. I'll fix that, but for the present

myTabbedPane.getComponent(1).setAnimated(false);

should do the trick (Component 1 is the GCardPane).

I will be looking to improve performance through profiling. For the demo, compilation time seems to be an issue as it runs much faster on a 2nd run through especially on WIndows XP: e.g. the split pane dividers can be sluggish until they have been moved a few times. If you have a simple example that performs particularly badly I'd appreciate a copy [sigtool(at) kcl(dot) ac(dot )uk].

31 Aug 2011 David

Thanks Malcolm. Turning the animation off between tabs provided a huge performance increase. Now I can quickly switch between several tabs with no issues. I also reran the demo and everything works great! Everything loads almost instantly!

31 Aug 2011 Corey

Outstanding!

31 Aug 2011 Malcolm Lidierth

@David
All the code is now much tidier (I hope). The problems were related to too many drawnow() calls in individual object methods which showed up particularly in the animations. Removing them may mean that you need the odd drawnow() in your own code to use these.
The animations are also now much tidier if you turn them on. You can do that from the command line:
GTool.getDefaults().put('GCardPane.Animated', true);
[NB Only affects objects created subsequently].
The speed can be adjusted using
GTool.getDefaults().put('Timer.Interval', T);
where T is an interval in seconds (default 0.05).

I'll document all of this properly once the code is stable.

Also TODO is a drop-in GTabbedPane alternative that better suits MATLAB - using the JTabbedPane gives the right OS Look and Feel but the JTabbedPane is not Swing's best designed or most easily customised component.

01 Sep 2011 Brett Baker  
15 Sep 2011 Sven Körner

This is a very good peace of work! Excellent!

15 Sep 2011 Aurelien Queffurust

Just a remark : I think the if-test of nargin in line 80 of GWait.m is wrong. It should be 4 instead of 3 .

15 Sep 2011 Malcolm Lidierth

@ Aurelien. Many thanks - I'll fix that.

19 Sep 2011 Aurelien Queffurust

Thanks Malcom. Another remark (not important)
 In GProgressBar.m line 205 , I would change the word "remaining" by a smaller word like "left" when computation is greater than 1 mn. It allows to have the text centered and see correctly the text in progress bar.

19 Sep 2011 Malcolm Lidierth

@ Aurelien. There is a FEX post in the pipeline (on SourceForge already) that probably fixes this problem - text set/get off the EDT - but I will shorten as suggested.

19 Sep 2011 Aurelien Queffurust

super merci

26 Sep 2011 Malcolm Lidierth

@Aurelien
Aha. I have seen the problem. Fixed properly in version 1.06, see http://sigtool.sourceforge.net/.
The progress bar and text are now the same width.
The new version includes several other updates: e.g. addition of scroll panes and a short PDF describing the library.

27 Sep 2011 Aurelien Queffurust

Super! Good job for the PDF and the new question "Do you really want to sop procesing?" for the GProgressbar! Thanks a lot

10 Oct 2011 NK University

It is very usfull for me! Thank your for your kindly works!!!

11 Oct 2011 NK University

Can works based on waterfoo be mcc to exes?

12 Oct 2011 Malcolm Lidierth

@NK University
I do not use mcc but having looked at the spec I see no reason not to use it with this code.
Maybe you could try and let me know how you get on.

11 Nov 2011 Jveer

This is great but doesn't not work with mcc:

"MCC does not permit the ADDPATH function"

Could you please update waterloo.m so that it can be deployed?

12 Nov 2011 Malcolm Lidierth

@Jveer.

As waterloo.m dynamically sets up the MATLAB path in a MATLAB session, it is inherently non-deployable. Does calling it before mcc not do the trick? The main library may or may not be deployable - I have not tried and do not have mcc.

As mcc is often used to protect proprietary rights over code, I did not imagine this library would see much use there. The code is distributed under GNU GPL v3 (which is why only a PDF is on the FEX) and propagation of the code, mcc'd or otherwise, would need to comply with the terms of that license.

02 Dec 2011 Romesh

Fantastic work. I'm also interested in the MCC, and successfully compiled the demo on Mac OS R2011a with only one issue:

Depfun error: 'Method 'getBackground' in class 'GSideBar' uses different access permissions than its super-class 'GTool'.'

The compiled code seems to run fine after I deleted this file. I ran waterloo.m before mcc. I guess I'll need to send some emails to work out exactly what constitutes a derivative work/whether including the source code for just the waterloo part of the project is sufficient (my current impression is that this would be acceptable...?)

03 Dec 2011 Malcolm Lidierth

@Romesh
Glad it worked. I'll look at the permissions issue.
The reason for GNU GPL is that Waterloo will eventually include third-party code distributed under GPL.
The next component, GImport, will be released shortly and provides a way to avoid GUIDE. GImport lets you import Java Swing GUIs designed with the tools in Netbeans, Eclipse, IntelliJ etc. GImport manages the layouts to give MATLAB-like resize behaviour and provides mechanisms for modifying/querying/managing the GUIs easily from within MATLAB.

03 Dec 2011 Corey

Malcolm,
Your next submission sounds substantial....looking forward to it!

13 Dec 2011 Jorge Durán

Great Work! Congratulations. I have two questions about the MATLAB/JAVA integration with this library.

1- Is it possible to use the library to include a figure obtained with matlab into a pure JaVa-Swing interface?

2- Is it possible to load a Simulink Model into figure created with your library?

I have just read your last comment so i think that my first cuestion is answered.

Thanks for the work. I looking forward for the next version and the new issues. Which is the release date?

13 Dec 2011 Malcolm Lidierth

@Jorge
1. Swing components can be added to MATLAB containers using the existing jcontrol class that is in the present distribution. GImport provides a convenient wrapper that also takes over some isses like layout management to get MATLAB-like behaviour.
If you want things the other way round, i.e. to put a MATLAB figure into Swing panel, I am not sure that can be done easily/to ggod effect.

2. I do not use SimuLink and do not know the answer.

Regards
ML

16 Dec 2011 Malcolm Lidierth

An update (1.07) is now on SourceForge.
This includes a new GImport class for installing GUIs designed in Eclipse/NetBeans/IntelliJ GUI designers. GImport is also posted to the FEX under the BSD licence.

The full project now includes the correct (non-dev) jar file - so GradientPaints etc will be available.

22 Dec 2011 Malcolm Lidierth

Link for GImport on the FEX
http://www.mathworks.com/matlabcentral/fileexchange/34235-making-matlab-swing-more

31 May 2012 Nilimb

while using GScroller(panel,'left',4), if i add 10 images and assign a callback to each. when i click on a image which is visible, the callback gets executed. but if i scroll down to image no 5 onwards, their callbacks do not get executed...any workaround. excellent submission though!!

31 May 2012 Malcolm Lidierth

@ Nilimb
Could you post some example code?

Please login to add a comment or rating.
Updates
29 Aug 2011

Fix Windows null pointer problems. Numerous improvements/additions from feedback (thanks Yair!).

31 Aug 2011

Now much faster. Animations improved and set off by default.

14 Sep 2011

Improvied performance. GTabContainer added. GWait/GProgressBar improved. Added support for themes.

26 Sep 2011

Change submission to PDF with link in description

30 Sep 2011

Update description re: removed old files

Tag Activity for this File
Tag Applied By Date/Time
gui Malcolm Lidierth 26 Aug 2011 09:46:14
java Malcolm Lidierth 26 Aug 2011 09:46:14
swing Malcolm Lidierth 26 Aug 2011 09:46:14
graphics Malcolm Lidierth 26 Aug 2011 09:46:14
swing Thomas Pieper 29 Aug 2011 08:25:33
jcontrol Malcolm Lidierth 28 Sep 2011 05:59:54
mutilities Malcolm Lidierth 28 Sep 2011 06:00:13
mousemotionhandler Malcolm Lidierth 28 Sep 2011 06:01:00
splitpane Malcolm Lidierth 30 Sep 2011 11:27:20
scrollpane Malcolm Lidierth 30 Sep 2011 11:27:20
tabbedpane Malcolm Lidierth 30 Sep 2011 11:27:20
accordion Malcolm Lidierth 30 Sep 2011 11:27:20

Contact us at files@mathworks.com