Skip to content

Instantly share code, notes, and snippets.

@kgbu
Created November 1, 2011 06:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgbu/1330027 to your computer and use it in GitHub Desktop.
Save kgbu/1330027 to your computer and use it in GitHub Desktop.
just a test for GraphicBuilder
import groovy.swing.SwingBuilder
import groovy.swing.j2d.GraphicsBuilder
import groovy.swing.j2d.GraphicsPanel
import java.awt.BorderLayout as BL
def gb = new GraphicsBuilder()
def shapes = [
'Arrow': gb.group {
arrow( x: 20, y: 20, width: 100, height: 60, /*rise: 0.5, depth: 0.5*/
fill: 'red', borderColor: 'black' )
},
'Arrow2': gb.group {
arrow( x: 120, y: 220, width: 100, height: 60, /*rise: 0.5, depth: 0.5*/
fill: 'blue', borderColor: 'black' )
},
'Arrow3': gb.group {
arrow( x: 220, y:320, width: 100, height: 60, /*rise: 0.5, depth: 0.5*/
fill: 'yellow', borderColor: 'black' )
},
'Arrow4': gb.group {
arrow( x: 320, y:20, width: 100, height: 60, /*rise: 0.5, depth: 0.5*/
fill: 'green', borderColor: 'black' )
},
]
SwingBuilder.build {
frame( title: 'jSilhouette Shapes (Groovy)',
size: [500,500],
show: true ) {
borderLayout()
panel( new GraphicsPanel(), id: 'canvas', constraints: BL.CENTER )
panel( constraints: BL.WEST) {
gridLayout( columns: 2, rows: shapes.size()/2 )
shapes.each { shape, graphicsOperation ->
button( shape, actionPerformed: { evt ->
canvas.graphicsOperation = graphicsOperation
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment