Gerald Bauer (Chairmain, CEO, CFO and CTO of Me, Myself & I, Inc.)
Java User Group (JUG) Austria Talk, November 2002
make building cross-platform user interfaces as easy as building web pages
use XML tags and CSS style sheets to create UIs for rich desktop apps
Break UI into Four Parts
Beyond Hairballs and Spaghetti Code.
Prefer the single-purpose languages below to general-purpose languages such as Java, C# or Shark.
Shape Tags:
<line>
,
<rect>
,
<circle>
,
<ellipse>
,
<polyline>
,
<polygon>
,
<path>
Paint Tags:
<linearGradient>
,
<radialGradient>
,
<pattern>
,
<mask>
Text Tags:
<text>
,
<tspan>
,
<textPath>
,
<font>
,
<font-face>
,
<glyph>
Filter Tags:
<filter>
,
<feBlend>
,
<feFlood>
,
<feColorMatrix>
,
<feGaussianBlur>
<feMorphology>
<feSpotLight>
Animation Tags:
<animate>
,
<animateMotion>
,
<animateTransform>
,
<animateColor>
,
<set>
Misc Tags:
<image>
,
<symbol>
,
<g>
,
<defs>
,
<use>
And Much More
|
|
|
Examples for Raster/Pixel/Bitmapped Graphic Formats: GIF, JPEG, PNG, etc.
Examples for Vector/Line Graphic Formats: SVG, SWF (Flash), EPS (Encapsulated Postscript), CGM (Computer Graphics Metafile), Visio, etc.
Shape | Description |
---|---|
<line x1="start-x" y1="start-y"
x2="end-x" y2="end-y" />
|
Draws a line from the starting point (start-x/start-y) to the end point (end-x/end-y). |
<rect x="left-x" y="top-y"
width="width" height="height" />
|
Draws a rectangle with a upper left corner at (left-x/top-y) and the given width and height |
<circle cx="center-x" cy="center-y" r="radius" />
|
Draws a circle with the given radius centered at (center-x/center-y) |
<ellipse cx="center-x" cy="center-y" rx="x-radius"
ry="y-radius" />
|
Draws an ellipse with the given x-radius and y-radius centered at (center-x/center-y) |
<polygon points="points" />
|
Draws an arbitrary closed polygon outlined by x/y point pairs in points |
<polyline points="points" />
|
Draws a series of connected lines described by x/y point pairs in points |
|
Style | Description |
---|---|
stroke
|
Line color |
stroke-width
|
Line width |
stroke-opacity
|
Number between 0.0 and 1.0; 0.0 for entirely transparent; 1.0 for entirely opaque (that is, non-transparent) |
stroke-dasharray
|
Series of number to define the length of dashes and gaps for lines |
stroke-linecap
|
Shape of the ends of a line; use butt , round , or square
|
stroke-linejoin
|
Shape of the corners of a polygon or polyline;
use miter (that is, pointed), round , or bevel (that is, flat)
|
stroke-miterlimit
|
Don't ask |
|
|
|
Command | Description |
---|---|
M | m
|
Move To |
L | l
|
Draw a line |
H | h
|
Draw a horizontal line |
V | v
|
Draw a vertical line |
A | a
|
Draw an elliptical arc |
Q | q
|
Draw a quadratic Bezier curve |
T | t
|
Draw a smooth quadratic Bezier curve; use control point from previous Bezier curve |
C | c
|
Draw a cubic Bezier curve |
S | s
|
Draw a smooth cubic Bezier curve; use control point from previous Bezier curve |
Z | z
|
Close path, that is, draw line from last point to first point |
|
|
|
|
|
|
Effect | Description |
---|---|
Blend And Merge Effects | |
feBlend
|
merges content with content below |
feComposite
|
blends content with another content |
feMerge
|
duplicates content using different effects |
Color Effects | |
feColorMatrix
|
changes content's colors and alpha channels using matrix mathematics (similar to Photoshop's Hue/Saturation/Balance tool) |
feComponentTransfer
|
changes content's colors and alpha channels using matrix mathematics (similar to Photoshop's Contrast/Brightness tool) |
feFlood
|
fills content with color |
More Effects | |
feConvolveMatrix
|
changes content's edges using matrix mathematics for creating bevels, embossing, blurring and so on |
feDisplacementMap
|
moves content using matrix mathematics for RGB color values |
feTurbulence
|
fills content with randomized patterns of dots or color (similar to Photoshop noise filters) |
feGaussianBlur
|
blurs content |
feOffset
|
shifts content's position |
feImage
|
adds external raster or vector image |
feMorphology
|
changes content by adding or subracting weight from the edges (thus, fattening or slimming the content's shape) |
feTile
|
fills content with tiled objects, similar to pattern fill |
Lighting Effects | |
feDiffuseLighting
|
lits content using alpha channel values |
feSpectularLighting
|
lits content from above (that is, uses light source from above) |
Light Sources | |
fePointLight
|
uses light source defined by a source point |
feDistantLight
|
uses light source defined by angles |
feSpotLight
|
uses light source defined by a source point and a target point |
Easy Editing - plain vanilla-text using easy-to-read XML and CSS format
Searchable Content - deep search or google through your graphic's contents
Localization - easily translate your graphic's text to different languages
Stylesheets - use a single CSS style sheet for an entire suite of graphics
Open Standard - no royality; no-vendor lock-in; choice of SVG plug-in; choice of SVG designer
Bitmap Effects On Vector Graphics - apply real-time Photoshop-like effects (e.g. drop shadow, spotlight, embossing, blurs, etc.) to your artwork
Data Handling - create graphics on-the-fly using scripts
Rich Typography - embed entire typefaces or just selected character outlines
Pixel-Precise Layout - true "What You See Is What You Get" through embed typefaces or pixel precise layout
Error Handling - uses "zero-tolerance" XML; can pinpoint line and column number for SVG errors
Adobe SVG Viewer
http://www.adobe.com/svg/
most popular SVG browser plug-in; available for Windows (98, 2000, Me, XP),
Mac OS 8.5 to X, Linux, Solaris
runs in Internet Exploder, Netscape, Mozilla, Opera, and many other browsers
Corel SVG Viewer
http://www.corel.com/svgviewer/
upcoming SVG browser plug-in; currenlty Beta
Apache Batik
http://xml.apache.org/batik
open-source SVG toolkit in 100 % Java;
includes SVG browser (Squiggle), SVG motor, font converter (True Type fonts to SVG),
rasterizer (SVG to JPEG/PNG) and much more; headed by Vincent Hardy (Sun)
Mozilla SVG
http://www.mozilla.org/projects/svg/
official Mozilla SVG project site; for built-in (aka native) SVG support in Mozilla
Croczilla
http://www.croczilla.com/svg
ready-to-run Mozilla builds/executables with built-in SVG support
W3C Amaya
http://www.w3.org/Amaya/
W3C's experimental proof-of-concept, open-source browser with built-in SVG viewer and editor
(available for Unix, Windows, and Mac OS X)
X-Smiles
http://www.x-smiles.org
experimental, open-source XML browser in Java includes
support for SVG, XForms, XSL-FO, XHTML and more;
developed by Helsinki University of Technology.
CSIRO SVG Toolkit (Australia's Commonwealth Scientific Industrial Research Organization)
http://sis.cmis.csiro.au/svg/
open-source SVG toolkit in Java; Apache-style License;
no longer developed (apart from minor bug fixes); use Apache Batik instead;
last minor update on March 2002
IBM alphaWorks SVGView
http://www.alphaworks.ibm.com/tech/svgview
SVG viewer prototype using Java2D;
no longer developed; use Apache Batik instead;
last update on April 2000
SVG on mobile devices (e.g. Palm, PocketPC, cell phones, RIM Blackberry)
BitFlash Mobile SVG Player
http://www.bitflash.com/products/vis.asp
Mobile SVG player for PocketPC (Windows CE) or Symbian
CSIRO Pocket SVG Viewer
http://www.pocketsvg.com
Low memory footprint (390k) C++ Active-X control for Pocket PC (Windows CE)
TinyLine SVG Toolkit
http://www.tinyline.com
SVG Tiny toolkit for Personal Java ME, IPAQ, and Zaurus
Adobe Illustrator
http://www.adobe.com/products/illustrator/
vector graphics design studio for MacOS (9.1/9.2/10.1) and Windows (98/Me/2000/XP);
SVG import and export; includes data-driven SVG graphics support
Corel Draw!
vector graphics design studio for Windows (95/98/Me/2000/XP/Tablet);
SVG import and export
Jasc WebDraw
http://www.jasc.com/products/webdraw/
a native 100% SVG design studio
allowing both import and export of SVG;
lets you view and change the SVG source at any time;
includes WYSIWYG visual editing of filter effects, and timeline editing of animations,
and much more; runs on Windows (98/NT/2000/Me/XP)
Mayura Draw
http://www.mayura.com
Shareware (US$25); vector graphics design studio with SVG export;
runs on Windows (95/98/Me/NT/2000/XP)
Sodipodi
http://sodipodi.sourceforge.net
open-source 100 % SVG design studio for Linux; developed in C using Gtk+;
GNU General Public License (GPL)
For more tools for authoring/exporting SVG check out the W3C SVG tools catalog
SVGZ - use GZIP compression for reduced-size SVG documents
Mime Type - image/svg+xml
100 % Java; Open-Source; Apache Licensed; Headed By Vincent Hardy (Sun)
Standalone Tools and Apps
Building Blocks
SVG Browser (Squiggle)
SVG Rasterizer (SVG to JPEG/PNG/TIFF) - converts vector graphics to raster/pixel graphics
SVG Font Converter (True Type Fonts to SVG) - converts True Type Fonts to SVG for embedding in SVG documents; Example:
java -jar batik-ttf2svg.jar matisse.ttf -l 48 -h 57 -id matisse -o matisse.svg -testcard |
converts characters 48 to 57, that is,
'0' to '9', from matisse.ttf
in True Type format to
matisse.svg
in SVG format
plus adds a test card so that
you can check the font in a SVG browser
<font id="matisse" horiz-adv-x="836" > <font-face font-family="Matisse ITC" units-per-em="2048" panose-1="4 4 4 3 3 13 2 2 7 4" ascent="2062" descent="-473" alphabetic="0" /> <missing-glyph horiz-adv-x="1229" d="M102 -362 V1444 H1126 V-362 ..." /> <glyph unicode="0" glyph-name="zero" horiz-adv-x="950" d="M506 -96 Q645 30 728 245 T811 694 ..." /> <glyph unicode="1" glyph-name="one" horiz-adv-x="641" d="M311 1622 Q411 1482 459 1289 T508 836 ..." /> <glyph unicode="2" glyph-name="two" horiz-adv-x="862" d="M147 1661 Q469 1630 622 1494 T776 1102 ..." /> ... |
SVGGraphics2D (SVG Generator) - lets you use the Java2D API to generate SVG XML markup; Example:
SVGGraphics2D g = new SVGGraphics2D(doc); Shape circle = new Ellipse2D.Double(0,0,50,50); g.setPaint(Color.red); g.fill(circle); g.translate(60,0); g.setPaint(Color.green); g.fill(circle); g.translate(60,0); g.setPaint(Color.blue); g.fill(circle); g.setSVGCanvasSize(new Dimension(180,50)); |
JSVGCanvas - Swing component to display SVG documents; includes rotating, zooming, panning, selecting text, or activating hyperlinks. Example:
JSVGCanvas canvas = new JSVGCanvas(); canvas.setURI( uri ); |
Hello SVG Example:
import java.io.*; import javax.swing.*; import org.apache.batik.swing.JSVGCanvas; public class HelloSVG { public static void main(String argv[]) throws IOException { JFrame f = new JFrame( "Hello SVG" ); JSVGCanvas canvas = new JSVGCanvas(); canvas.setURI( new File( argv[0] ).toURL().toString() ); f.getContentPane().add( canvas ); f.setSize( 600, 300 ); f.setVisible( true ); } } |
SVG DOM API - W3C compliant DOM API for SVG documents; let's you create SVG documents in memory, for example, that you can pass on to the JSVGCanvas for display or to the transcoder API for creating raster/bitmap graphics
Transcoder API - Lets you convert (=transcode) SVG documents (vector graphics) to pixel graphics such as JPEG, PNG or TIFF on the fly; useful in servlets, for example. Code Snippet Example:
public static void main(String [] args) throws Exception { // create a JPEG transcoder JPEGTranscoder t = new JPEGTranscoder(); // set the transcoding hints t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8)); // create the transcoder input String svgURI = new File( args[0] ).toURL().toString(); TranscoderInput input = new TranscoderInput(svgURI); // create the transcoder output OutputStream ostream = new FileOutputStream("out.jpg"); TranscoderOutput output = new TranscoderOutput(ostream); // save the image t.transcode(input, output); // flush and close the stream then exit ostream.flush(); ostream.close(); } |
Feature | SVG | Flash | GIF | PNG | |
---|---|---|---|---|---|
Vector artwork | Yes | Yes | - | - | Yes |
Alpha Channel Transparency | Yes | Yes | - | Yes | Yes |
Pixel-Precise Layout | Yes | Yes | Yes | Yes | Yes |
Typeface Selection | Yes | Yes | - | - | Yes |
Typeface Embedding | Yes | Yes | - | - | Yes |
Gradients | Yes | Yes | Yes | Yes | Yes |
Masking | Yes | Yes | - | - | Yes |
Shared Resources (fonts, symbols, text) across multiple files | Yes | - | - | - | |
Open Standard | Yes | - | - | Yes | - |
Live Filter Effects | Yes | - | - | - | - |
Pinpoint Invalid Code | Yes | - | - | - | - |
Extensible | Yes | - | - | - | - |
Animation | Yes | Yes | Yes | - | - |
Interaction | Yes | Yes | - | - | Yes |
Filesize compression | Yes | Yes | Yes | Yes | Yes |
Editable executable | Yes | - | Yes | Yes | Yes |
Summary: + Flash: well suited for animation; large plug-in install base on Windows (> 90%); ActiceX browser-plug-in is a small download (< 400 k); popular animation authoring tool for designers
O'Reilly Network Article Series
Web Architecture - The Big Picture
XML Syntax - mixes easily with established and emerging XML standards such as: XHTML, XUL, MathML, XForms; XML is the lingua franca because it's simple, extensible, royality-free; operating system or programming language independent and much more
Web Services - mixes easily with Web Services; send SVG diagrams or animations via SOAP messages or create rich graphical user interfaces for Web Services
Styling with CSS - use a single style language for XHTML, XUL and SVG
Animation with SMIL - use SVG docs in multimedia SMIL presentations to mix vector graphics with audio and video
DOM and Scripting - use Javascript to access the SVG document tree at-run-time
Modul-Mania - use SVG Tiny or SVG Basic on mobile-devices (cell phones, palms, etc.)
SVG 1.0
http://www.w3.org/TR/SVG/
W3C Recommendation (=Official Web Standard); 4 September 2001; 600+ pages
SVG 1.1
http://www.w3.org/TR/SVG11/
W3C Proposed Recommendation (=Upcoming Web Standard); 15 November 2002;
modular SVG plus errata (=bug fixes)
SVG Mobile Profiles: SVG Basic and SVG Tiny
http://www.w3.org/TR/SVGMobile/
W3C Proposed Recommendation (=Upcoming Web Standard); 15 November 2002;
SVG Tiny is a stripped down version of SVG for cell phones;
SVG Basic is slightly larger version of SVG for PDAs (=Palms, Pocket PCs, etc.)
SVG 1.2
http://www.w3.org/TR/SVG12/
W3C Working Draft; 15 November 2002;
possible new features include
flowText
tag for wrapping text inside shapessolidColor
tag is a paint server that provides a single color with opacity
and can be referenced like gradients and patterns.
SVGWindow
interface
SVG 1.1/1.2/2.0 Requirements
http://www.w3.org/TR/SVG2Reqs/
Want more? Roadmap outlines upcoming features; too many to list; 22 April 2002
Upcoming SVG Printing Profile; SVG 2.0
SVG Programming: The Graphical Web by Kurt Cagle, 624 pages, APress; ISBN: 1590590198; (July 2002) | |
SVG Essentials by J. David Eisenberg, 364 pages, O'Reilly; ISBN: 0596002238; (February 2002) | |
Teach Yourself SVG in 24 Hours by Micah Laaker, 456 pages; Sams; ISBN: 0672322900; (February 2002) | |
SVG Unleashed by Chris Lilley, Daniel J. Ayers, Randy George, ch Wenz, Andrew H. Watt; 1152 pages; Sams; ISBN: 0672324296; September 2002 |
W3C SVG Portal
http://www.w3.org/Graphics/SVG/
News, Specs, Links and More
Adobe SVG Zone
http://www.adobe.com/svg/
Download SVG Browser Plug-In, SVG Examples and more
SVG Developer Mailinglist/Discussion Forum
http://groups.yahoo.com/group/svg-developers
high traffic; +3000 members; +1000 messages/month