Created
April 30, 2013 12:47
-
-
Save y-sumida/5488481 to your computer and use it in GitHub Desktop.
Yokohama.groovy #14の成果
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gbf | |
class GbfController { | |
def model | |
def view | |
def bf | |
def execute = {evt = null -> | |
bf = new GBrainFuck(model.program) | |
while(!bf.isFinished()) { | |
GBrainFuckResult result = bf.convert() | |
model.output = result.output | |
model.buffer = result.buffer | |
sleep(200) | |
} | |
} | |
def stop = {evt = null -> | |
bf.stop() | |
} | |
def clear = {evt = null -> | |
model.program = '' | |
model.buffer = '' | |
model.output = '' | |
bf.clear() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gbf | |
import groovy.beans.Bindable | |
class GbfModel { | |
@Bindable String program = "" | |
@Bindable String buffer = "" | |
@Bindable String output = "" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gbf | |
import static java.awt.BorderLayout.* | |
application(title: 'Gbf', | |
preferredSize: [400, 250], | |
pack: true, | |
//location: [50,50], | |
locationByPlatform:true, | |
iconImage: imageIcon('/griffon-icon-48x48.png').image, | |
iconImages: [imageIcon('/griffon-icon-48x48.png').image, | |
imageIcon('/griffon-icon-32x32.png').image, | |
imageIcon('/griffon-icon-16x16.png').image]) { | |
scrollPane(constraints:NORTH) { | |
hbox { | |
textArea editable:true, columns:20, rows:8, text:bind(target:model, 'program', mutual:true) | |
//textField columns:20, text: bind(target:model, 'program', mutual:true) | |
} | |
} | |
panel(constraints:CENTER) { | |
hbox { | |
label 'buffer ' | |
textArea editable:false, columns:25, rows:1 , text:bind{model.buffer} | |
} | |
hbox { | |
label 'result ' | |
textArea editable:false, columns:25, rows:1, text:bind{model.output} | |
} | |
} | |
panel(constraints:SOUTH) { | |
hbox { | |
button 'run', actionPerformed: controller.&execute | |
button 'stop', actionPerformed: controller.&stop | |
button 'clear', actionPerformed: controller.&clear | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gbf | |
class GBrainFuckResult { | |
final String output | |
final String buffer | |
GBrainFuckResult(String output, String buffer) { | |
this.output = output | |
this.buffer = buffer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment