bluemarine or why you should really ship swing applications

Post on 14-Jan-2015

1.618 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

blueMarineOr Why You Should Really Ship Swing Applications

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

TS-5483

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.”

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

Agenda

Introduction

NetBeans™ Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

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

blueMarine introductory video

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

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?

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

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

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

Problems

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

Solutions

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

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

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

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

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

Question

What do you expect from a (desktop) framework?

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

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

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

What is NetBeans Software RCP?

NetBeansNetBeans IDE

NetBeans RCP{

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

What is NetBeans Software RCP?

NetBeansNetBeans IDE

NetBeans RCP{

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

What is NetBeans Software RCP?

NetBeansNetBeans IDE

NetBeans RCP{Your Desktop Application

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

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

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

Explorers, Viewers, Actions

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);

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

DataObject represents a file-based entity

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

You can extend DataObject

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>

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); }

//... }

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

Lookup holds “capabilities”

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

Node “represents” DataObject

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

Node has “capabilities” too

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);

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

Representing sets of Nodes

\

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

View renders Nodes

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

Actions can be automatically enabled

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>

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>

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"; } ...}

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

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

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

CoverFlowView

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

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

Update Centers

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

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

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

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

LightTable

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

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

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

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

GeoViewer

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

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

GeoViewer 3D

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

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

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

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

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

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

Agenda

Introduction

NetBeans Software RCP

Visual Library

GeoSpatial Components

Java Platform Imaging APIs

Conclusion

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

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)

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

Summary

Most Swing showstoppers are history now

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

Summary

Most Swing showstoppers are history now

You CAN ship desktop apps

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...

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...

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

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

Eclipse Optic Cleaning System

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

blueMarineOr Why You Should Really Ship Swing ApplicationsFabrizio Giudici

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

top related