Your SlideShare is downloading. ×
0
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Svcc Java2D And Groovy
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Svcc Java2D And Groovy

1,362

Published on

Java2D and Groovy, a Perfect Match

Java2D and Groovy, a Perfect Match

Published in: Technology, Art & Photos
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,362
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
14
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Java2D and G r oo v y , a Perfect Match Andres Almiray
  • 2. Agenda <ul><li>What is G r oo v y? </li></ul><ul><li>SwingBuilder </li></ul><ul><li>GraphicsBuilder </li></ul><ul><li>Putting it all together </li></ul><ul><li>What’s next? </li></ul>
  • 3. W hat is G r oo v y ?
  • 4. SwingBuilder
  • 5. Builder Basics <ul><li>Builders are a form of a DSL </li></ul><ul><li>Focused on Hierarchical Structures </li></ul><ul><li>SwingBuilder is not the only Builder in G r oo v y </li></ul><ul><ul><li>XMLBuilder </li></ul></ul><ul><ul><li>AntBuilder </li></ul></ul><ul><ul><li>ObjectGraphBuilder </li></ul></ul><ul><ul><li>Still Others… </li></ul></ul><ul><li>Swing applications follow a hierarchical model: </li></ul><ul><ul><li>Window </li></ul></ul><ul><ul><li>Panel </li></ul></ul><ul><ul><li>Button </li></ul></ul><ul><li>Builders are a perfect fit for making Swing UIs </li></ul>
  • 6. A Quick HelloWorld Example <ul><li>groovy.swing.SwingBuilder.build { </li></ul><ul><li>frame( id: 'root', title:'Hello World', </li></ul><ul><li>show:true, pack:true) { </li></ul><ul><li>flowLayout()‏ </li></ul><ul><li>label('Enter a message:')‏ </li></ul><ul><li>textField(id:'name', columns:20)‏ </li></ul><ul><li>button('Click', </li></ul><ul><li>actionPerformed: { ActionEvent e -> </li></ul><ul><li>if (name.text)‏ </li></ul><ul><li>optionPane().showMessageDialog( </li></ul><ul><li>root, name.text)‏ </li></ul><ul><li>})‏ </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  • 7. What's going on? <ul><li>Each node is syntactically a method call </li></ul><ul><li>All of these method calls are dynamically dispatched </li></ul><ul><ul><li>Most don’t actually exist in bytecode </li></ul></ul><ul><li>Child closures create hierarchical relations </li></ul><ul><ul><li>Child widgets are added to parent containers </li></ul></ul><ul><li>SwingBuilder node names are derived from Swing classes </li></ul><ul><ul><li>Remove the leading ‘J’ from a Swing class when present </li></ul></ul><ul><li>SwingBuilder also supports some AWT classes like layouts </li></ul>
  • 8. GraphicsBuilder
  • 9. GraphicsBuilder - Basics <ul><li>GraphicsBuilder is to Java2D what SwingBuilder is to Swing </li></ul><ul><li>It produces a hierarchy of GraphicsOperations (or nodes)‏ </li></ul><ul><li>A specialized component is required to render graphicsOperations and handle input events: GraphicsPanel </li></ul>
  • 10. GraphicsBuilder - Features <ul><li>shapes - shape, outline, areas </li></ul><ul><ul><li>regular Java2D shapes from java.wt.geom </li></ul></ul><ul><ul><li>additional shapes from jSilhouette </li></ul></ul><ul><li>paints - solid, gradients, composite </li></ul><ul><li>strokes - from jhlabs </li></ul><ul><li>filters - from swingx, jhlabs </li></ul><ul><li>grouping, transfortmations , images </li></ul><ul><li>svg - import/export via Batik </li></ul><ul><li>swf - partial export (still experimental)‏ </li></ul>
  • 11. GraphicsPad
  • 12. Putting it all together
  • 13. Mixing Swing & Graphics <ul><li>Use SwingBuilder to build the UI </li></ul><ul><li>Use GraphicsBuilder to draw anywhere you need </li></ul><ul><ul><li>in a GraphicsPanel </li></ul></ul><ul><ul><li>in JLayeredPane </li></ul></ul><ul><ul><li>in SwingX layered components </li></ul></ul><ul><ul><li>in Jide’s overlay support </li></ul></ul>
  • 14. Tips & Hints <ul><li>Use SwingBuilder.build()‏ </li></ul><ul><li>Use Expando for quick prototyping of beans </li></ul><ul><li>Use ObservableMap for quick binding tests </li></ul><ul><li>Reuse shapes as must as you can </li></ul><ul><li>Group operations that may have the same settings applied (color, borderWidth, fill, transformations)‏ </li></ul>
  • 15. What’s next?
  • 16. Tips & Hints <ul><li>Custom nodes </li></ul><ul><li>Custom painting of Swing components </li></ul><ul><li>Animation support </li></ul>
  • 17. Resources <ul><li>h tt p : // groovy.codehaus.org </li></ul><ul><li>h tt p : // groovy.codehaus.org/Swing+Builder </li></ul><ul><li>h tt p : // groovy.codehaus.org/SwingXBuilder </li></ul><ul><li>h tt p : // groovy.codehaus.org/JideBuilder </li></ul><ul><li>h tt p : // groovy.codehaus.org/GraphicsBuilder </li></ul><ul><li>h tt p : // code.google.com/p/jsilhouette </li></ul><ul><li>h tt p : // jroller.com/aalmiray </li></ul><ul><li>h tt p : // twitter.com/aalmiray </li></ul>
  • 18. Q & A
  • 19. Thank you!

×