bluemarine or why you should really ship swing applications

65
blueMarine Or Why You Should Really Ship Swing Applications Fabrizio Giudici, Senior Java Architect, Tidalwave s.a.s. TS-5483

Upload: fabrizio-giudici

Post on 14-Jan-2015

1.620 views

Category:

Technology


4 download

DESCRIPTION

 

TRANSCRIPT

Page 1: blueMarine  Or Why You Should Really Ship Swing  Applications

blueMarineOr Why You Should Really Ship Swing Applications

Fabrizio Giudici, Senior Java Architect, Tidalwave s.a.s.

TS-5483

Page 2: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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.”

Page 3: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 3

Agenda

Introduction

NetBeans™ Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

Page 4: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 4

blueMarine introductory video

Page 5: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 6: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 6

Java Platform on the Desktop: Readiness Phases

Phase -1: prior 2005• Slow, poorly integrated, ugly L&F

Phase 0: 2005• JDK™ release 5 spreads, “Extreme GUI Makeover” starts

Phase +1: 2006-2007• JDK™ release 6, Aerith, SwingLabs matures

• TimingFramework, Nimbus, Filthy Rich Clients

Phase +2: 2008• Add NetBeans Software RCP: Filthy Rich Platform Clients

• Ready for complex applications - anyone?

Page 7: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 7

Java Platform on the Desktop: Readiness Phases

Phase -1: prior 2005• Slow, poorly integrated, ugly L&F

Phase 0: 2005• JDK™ release 5 spreads, “Extreme GUI Makeover” starts

Phase +1: 2006-2007• JDK™ release 6, Aerith, SwingLabs matures

• TimingFramework, Nimbus, Filthy Rich Clients

Phase +2: 2008• Add NetBeans Software RCP: Filthy Rich Platform Clients

• Ready for complex applications - anyone?

blueMarine 0.8died here

Page 8: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 8

Java Platform on the Desktop: Readiness Phases

Phase -1: prior 2005• Slow, poorly integrated, ugly L&F

Phase 0: 2005• JDK™ release 5 spreads, “Extreme GUI Makeover” starts

Phase +1: 2006-2007• JDK™ release 6, Aerith, SwingLabs matures

• TimingFramework, Nimbus, Filthy Rich Clients

Phase +2: 2008• Add NetBeans Software RCP: Filthy Rich Platform Clients

• Ready for complex applications - anyone?

blueMarine 0.8died here

blueMarine 0.9reborn here

Page 9: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 9

Problems

Page 10: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 10

Solutions

Page 11: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 11

If you can just remember four points

NetBeans Software RCP

NetBeans Visual Library

SwingLabs

NASA World Wind for Java Platform

Page 12: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 12

OpenBlueSky

Where generic stuff spins off blueMarine

Can be used for other applications

Consolidated stuff going to PlatformX

Page 13: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 13

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

Page 14: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 14

Question

What do you expect from a (desktop) framework?

Page 15: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 16: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 17: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 17

What is NetBeans Software RCP?

NetBeansNetBeans IDE

NetBeans RCP{

Page 18: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 18

What is NetBeans Software RCP?

NetBeansNetBeans IDE

NetBeans RCP{

Page 19: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 19

What is NetBeans Software RCP?

NetBeansNetBeans IDE

NetBeans RCP{Your Desktop Application

Page 20: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 21: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 21

Most important NetBeans RCP APIs

ActionsDataObjects

Dialogs

Explorer

FileSystem

Lookup

ModulesNodes

Options

Progress

Visual Library

Windowing/docking

Page 22: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 22

Explorers, Viewers, Actions

Page 23: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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);

Page 24: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 24

DataObject represents a file-based entity

Page 25: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 25

You can extend DataObject

Page 26: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 26

Creating a new DataObjectlayer.xml:<filesystem> <folder name="Services"> <folder name="MIMEResolver"> <file name="PhotoResolver.xml" url="PhotoResolver.xml"> </file> </folder> </folder></filesystem>

PhotoResolver.xml:<MIME-resolver> <file> <ext name="TIF"/> <ext name="TIFF"/> <resolver mime="image/tiff"/> </file> <!-- others ext/mime mappings --></MIME-resolver>

Page 27: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 27

Creating a new DataObjectpublic class PhotoDataObject extends MultiDataObject { ... }

public class PhotoDataLoader extends UniFileLoader { public PhotoDataLoader() { // contains “image/jpg”, “image/tiff”, etc... String[] mimeTypes = ImageIO.getReaderMIMETypes(); for (final String mimeType : mimeTypes) { getExtensions().addMimeType(mimeType); } }

protected MultiDataObject createMultiObject(FileObject file) { return new PhotoDataObject(file, this); }

//... }

Page 28: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 28

Lookup holds “capabilities”

Page 29: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 29

Node “represents” DataObject

Page 30: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 30

Node has “capabilities” too

Page 31: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 31

Managing basic objects

File file = new File("photo.jpg");FileObject fileObject = FileUtil.toFileObject(file);DataObject dataObject = DataObject.find(fileObject);// Note: static type is DataObject,// not PhotoDataObject Node node = dataObject.getNodeDelegate();

// Retrieve capabilities// They have been set by PhotoDataObject constructor

Metadata metadata = dataObject.getLookup(). lookup(Metadata.class);// orMetadata metadata = node.getLookup(). lookup(Metadata.class);

Page 32: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 32

Representing sets of Nodes

\

Page 33: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 33

View renders Nodes

Page 34: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 34

Actions can be automatically enabled

Page 35: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 35

Declaring Actions<filesystem> <folder name="Actions"> <folder name="Window"> <file name="mypkg-CalendarExplorerAction.instance"/> </folder> </folder> <!-- Adds the action to the Menu/Window main menu. --> <folder name="Menu"> <folder name="Window"> <file name="CalendarExplorerAction.shadow"> <attr name="originalFile" stringvalue="Actions/Window/mypkg-CalendarExplorerAction.instance"/> <attr name="position" intvalue="120"/> </file> </folder> </folder>

Page 36: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 36

Declaring Actions <!-- Adds the actions to the Component toolbar. --> <folder name="Toolbars"> <folder name="Explorer"> <file name="mypkg-CalendarExplorerAction.shadow"> <attr name="originalFile" stringvalue="Actions/Window/mypkg-CalendarExplorerAction.instance"/> <attr name="position" intvalue="120"/> </file> </folder> </folder> <!-- Creates keystroke shortcuts. --> <folder name="Shortcuts"> <file name="A-D-L.shadow"> <attr name="originalFile" stringvalue="Actions/Window/mypkg-CalendarExplorerAction.instance"/> </file> </folder>

</filesystem>

Page 37: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 37

Example of context-sensitive Actionpublic 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"; } ...}

Page 38: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 39: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 40: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 40

CoverFlowView

Page 41: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 42: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 42

Update Centers

Page 43: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 43

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

Page 44: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 45: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 45

LightTable

Page 46: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 46

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

Page 47: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 48: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 48

GeoViewer

Page 49: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 50: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 50

GeoViewer 3D

Page 51: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 51

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

Page 52: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 53: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 53

Mistral: fix 'em up

Imaging meta-framework

Multiple APIs can be used together

Simplifies APIs

Supports multicore,Jini services, Sun™ Grid

Page 54: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 54

Some Mistral examplesFile 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])); }

Page 55: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 55

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

Page 56: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 57: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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)

Page 58: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 58

Summary

Most Swing showstoppers are history now

Page 59: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 59

Summary

Most Swing showstoppers are history now

You CAN ship desktop apps

Page 60: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 60

Summary

Most Swing showstoppers are history now

You CAN ship desktop apps

There's a world beyond Swing• SwingLabs, NetBeans Software RCP, etc...

Page 61: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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...

Page 62: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 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

Page 63: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 63

Eclipse Optic Cleaning System

Page 64: blueMarine  Or Why You Should Really Ship Swing  Applications

2008 JavaOneSM Conference | java.sun.com/javaone | 64

For More Information

Links to projects, blogs and documentation• weblogs.java.net/blog/fabriziogiudici

• bluemarine.tidalwave.it

• openbluesky.dev.java.net

• mistral.tidalwave.it

• forceten.tidalwave.it

• www.netbeans.org/features/platform

• graph.netbeans.org

• platformx.netbeans.org

• www.swinglabs.org

• worldwind.arc.nasa.gov/java

• quaqua.dev.java.net

Page 65: blueMarine  Or Why You Should Really Ship Swing  Applications

blueMarineOr Why You Should Really Ship Swing ApplicationsFabrizio Giudici

TS-5483. Speaker’s logo here (optional)