1. blueMarine
Or Why You Should Really Ship Swing
Applications
Fabrizio Giudici, Senior Java Architect, Tidalwave s.a.s.
TS-5483
2. Talk about issues with Java™ platform's Rich
Client Applications; enumerate and introduce
solutions from the perspective of a real project.
“Java is mature for Rich Desktop Applications.
Just look beyond Swing.”
2008 JavaOneSM Conference | java.sun.com/javaone | 2
5. Speaker’s Qualifications
Senior Java Architect with 12 years of Java platform
experience
Project leading, mentoring, teaching
Member of JUG Milano, NetBeans Software Dream Team
Speaker at JavaPolis, Jazoon, JavaOneSM Event, JiniSM
Meeting
Writer for NetBeans Software Magazine, Mokabyte
Blogger at Java.Net
2008 JavaOneSM Conference | java.sun.com/javaone | 5
11. If you can just remember four points
NetBeans Software RCP
NetBeans Visual Library
SwingLabs
NASA World Wind for Java Platform
2008 JavaOneSM Conference | java.sun.com/javaone | 11
12. OpenBlueSky
Where generic stuff spins off blueMarine
Can be used for other applications
Consolidated stuff going to PlatformX
2008 JavaOneSM Conference | java.sun.com/javaone | 12
14. Question
What do you expect from a (desktop) framework?
2008 JavaOneSM Conference | java.sun.com/javaone | 14
15. Desktop Frameworks
Solid foundation to base your application on
APIs working together, well tested
Service discovery and provider
Plugin support
Messaging infrastructure (via events)
Integrated help system
And more
2008 JavaOneSM Conference | java.sun.com/javaone | 15
16. Swing is not a framework
Missing sophisticated components
• e.g.: date picker, tree+table, etc...
Neither service discovery nor providers
No plugins
No messaging (only simple listeners)
Threading issues
JSR-296 (Java Specification Request Swing Application
Framework) not good for large applications
2008 JavaOneSM Conference | java.sun.com/javaone | 16
17. What is NetBeans Software RCP?
NetBeans { NetBeans IDE
NetBeans RCP
2008 JavaOneSM Conference | java.sun.com/javaone | 17
18. What is NetBeans Software RCP?
NetBeans { NetBeans IDE
NetBeans RCP
2008 JavaOneSM Conference | java.sun.com/javaone | 18
19. What is NetBeans Software RCP?
NetBeans { NetBeans IDE
NetBeans RCP
Your Desktop Application
2008 JavaOneSM Conference | java.sun.com/javaone | 19
20. NetBeans Software RCP
You start with a skeleton application
You populate it
• panels, views
• actions, menus, toolbars
• etc..
Often declaratively
Based on Swing
• You can integrate third parties' components
• You can control the Look&Feel
2008 JavaOneSM Conference | java.sun.com/javaone | 20
21. Most important NetBeans RCP APIs
Actions Modules
DataObjects Nodes
Dialogs Options
Explorer Progress
FileSystem Visual Library
Lookup Windowing/docking
2008 JavaOneSM Conference | java.sun.com/javaone | 21
23. Lookup API
Plays a fundamental role in many APIs
Repository for a bag of objects
Locator for services
Fires events
“Global” lookup can be used as a simple “event bus”
Service service =
Lookup.getDefault().lookup(Service.class);
2008 JavaOneSM Conference | java.sun.com/javaone | 23
37. Example of context-sensitive Action
public class ShowPhotoAction extends CookieAction {
protected void performAction(Node[] nodes) {
PhotoDataObject dataObject = nodes[0].getLookup().
lookup(PhotoDataObject.class);
// use dataObject
}
protected int mode() {
return CookieAction.MODE_EXACTLY_ONE;
}
public String getName() {
return "Show Photo";
}
protected Class[] cookieClasses() {
return new Class[] { PhotoDataObject.class };
}
protected String iconResource() {
return ".../show_photo.png";
}
...
}
2008 JavaOneSM Conference | java.sun.com/javaone | 37
38. Some points
You don't need to always use everything
• E.g. just Nodes, no DataObjects
• Can use them “incrementally”
NetBeans Software RCP keeps objects in sync
• E.g. updating a DataObject → bound Nodes
• E.g. Nodes bound to the same DataObject
• By means of PropertyChangeListener
2008 JavaOneSM Conference | java.sun.com/javaone | 38
39. NetBeans Software RCP stuff can be
extended
What about a “cover flow” view?
Use JOGL (Java Bindings for OpenGL) for fast 3D API
Just extend and create a new View
TimingFramework for animating stuff
2008 JavaOneSM Conference | java.sun.com/javaone | 39
41. Update Centers
NetBeans software components (.nbm)
• can be added / removed on the fly
• can declare dependencies
• can be versioned
• can add actions, menus, toolbars
Pretty good for plugins
2008 JavaOneSM Conference | java.sun.com/javaone | 41
44. Visual Library
Support for graph-oriented modeling
• Nodes
• Arcs
• Routing
• Interaction
Can be creatively used
• Whiteboard paradigm
• Use interactivity: touch, drag, change objects
PS Can be used with plain Swing apps
2008 JavaOneSM Conference | java.sun.com/javaone | 44
47. JXMapViewer
A generic 2D, tile-based map renderer
• See Joshua Marinacci's blog
• Retrieves tiles from the web
(or locally)
• Part of Swing-WS (SwingLabs)
• Can stick objects to the map
Hint: integrate it with the Visual Library
2008 JavaOneSM Conference | java.sun.com/javaone | 47
49. NASA World Wind for Java Platform
Java platform version of NASA World Wind
• 3D software that renders the Earth
• NASA terrain imagery
• Other data sets can be plugged in
• if legal stuff is ok...
Based on JOGL
2008 JavaOneSM Conference | java.sun.com/javaone | 49
50. GeoViewer 3D
2008 JavaOneSM Conference | java.sun.com/javaone | 50
52. Java Platform Imaging APIs
Many options (and dispersive?)
• Java 2D™ API, JAI, ImageJ, JMagick, JHLabs, ...
Some too difficult
Wild behaviour and performance differences
Parallel Computing is a must
• Multi Core
• Small, local mini-grids
• Massive Grid Computing
There's not a global community
2008 JavaOneSM Conference | java.sun.com/javaone | 52
53. Mistral: fix 'em up
Imaging meta-framework
Multiple APIs can
be used together
Simplifies APIs
Supports multicore,
Jini services, Sun™ Grid
2008 JavaOneSM Conference | java.sun.com/javaone | 53
54. Some Mistral examples
File file = new File(...);
EditableImage image = EditableImage.create(new ReadOp(file, 0));
image.execute(new ResizeOp(600, 400));
EXIF exif = image.getMetadata(EXIF.class);
public class MyTask extends ImagingTask {
private File file;
public MyImagingTask (File file) { this.file = file; }
public void run() {
EditableImage image = read(file, 0);
execute(image, new CropOp(10, 10, 600, 400), "crop");
Histogram histogram = execute(image,
new HistogramOp(), "histogram").getHistogram();
// etc...
}
}
for (int i = 0; i < n; i++) {
ImagingTaskProcessor.getInstance().post(new MyTask(file[i]));
}
2008 JavaOneSM Conference | java.sun.com/javaone | 54
56. Open Problems for blueMarine
Java platform still misses something on the desktop
• e.g. video streaming, USB support
• Can be worked around with JNI/JNA
• Java platform 7 is not too far
Some NB RCP stuff not fully customizable
Better integration NB RCP SwingLabs
Compliance to Apple HIG
Linux + JOGL issues
No JAI native support for Mac OS X
2008 JavaOneSM Conference | java.sun.com/javaone | 56
57. Be efficient with innovation
“Cool stuff„ often means complexity
• Go quickly from idea to prototype
• Integrate easily others' stuff
• NIH isn't a killer-idea, but an idea-killer
Build cool demonstrators
• ...and cool applications soon after
(stay tuned for some new cool stuff)
2008 JavaOneSM Conference | java.sun.com/javaone | 57
58. Summary
Most Swing showstoppers are history now
2008 JavaOneSM Conference | java.sun.com/javaone | 58
59. Summary
Most Swing showstoppers are history now
You CAN ship desktop apps
2008 JavaOneSM Conference | java.sun.com/javaone | 59
60. Summary
Most Swing showstoppers are history now
You CAN ship desktop apps
There's a world beyond Swing
• SwingLabs, NetBeans Software RCP, etc...
2008 JavaOneSM Conference | java.sun.com/javaone | 60
61. Summary
Most Swing showstoppers are history now
You CAN ship desktop apps
There's a world beyond Swing
• SwingLabs, NetBeans Software RCP, etc...
Be creative. Mix 'em up.
NetBeans: the only IDE I need...
2008 JavaOneSM Conference | java.sun.com/javaone | 61
62. Summary
Most Swing showstoppers are history now
You CAN ship desktop apps
There's a world beyond Swing
• SwingLabs, NetBeans Software RCP, etc...
Be creative. Mix 'em up.
NetBeans: the only IDE I need...
... but for some tasks related to digital photo management
Eclipse is just the best tool
2008 JavaOneSM Conference | java.sun.com/javaone | 62