Most control frames now working.

This commit is contained in:
Sandy Noble 2015-09-05 16:00:22 +01:00
parent f9ab305fad
commit d005b1bb0c
7 changed files with 496 additions and 366 deletions

View File

@ -17,15 +17,15 @@ public class ControlFrame extends PApplet {
}
public ControlP5 cp5() {
if (this.cp5 == null) {
this.cp5 = this.setupControlP5();
}
return this.cp5;
if (this.cp5 == null) {
this.cp5 = this.setupControlP5();
}
return this.cp5;
}
public PApplet getParent() {
return this.parent;
}
public PApplet getParent() {
return this.parent;
}
public void setup() {
size(w, h);
@ -33,18 +33,20 @@ public class ControlFrame extends PApplet {
}
public ControlP5 setupControlP5() {
println("About to create new ControlP5");
println("About to create new ControlP5");
ControlP5 cp5 = new ControlP5(this);
println("Created: " + cp5);
while (cp5 == null) {
println("Created: " + cp5);
while (cp5 == null) {
println("Was null: " + cp5);
}
println("Finally created: " + cp5);
return cp5;
}
println("Finally created: " + cp5);
return cp5;
}
public void draw() {
background(abc);
background(abc);
}
}

View File

@ -6,6 +6,105 @@ public Integer renderStartDirection = DRAW_DIR_SE; // default start drawing in S
public Integer renderStartPosition = DRAW_DIR_NE; // default top right hand corner for start
public Integer renderStyle = PIXEL_STYLE_SQ_FREQ; // default pixel style square wave
ControlFrameSimple addDrawPixelsControlFrame(String theName, int theWidth, int theHeight, int theX, int theY, int theColor ) {
final Frame f = new Frame( theName );
final ControlFrameSimple p = new ControlFrameSimple( this, theWidth, theHeight, theColor );
f.add( p );
p.init();
f.setTitle(theName);
f.setSize( p.w, p.h );
f.setLocation( theX, theY );
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
p.dispose();
f.dispose();
}
}
);
f.setResizable( true );
f.setVisible( true );
// sleep a little bit to allow p to call setup.
// otherwise a nullpointerexception might be caused.
try {
Thread.sleep( 100 );
}
catch(Exception e) {
}
// set up controls
RadioButton rPos = p.cp5().addRadioButton("radio_startPosition",10,10)
.add("Top-right", DRAW_DIR_NE)
.add("Bottom-right", DRAW_DIR_SE)
.add("Bottom-left", DRAW_DIR_SW)
.add("Top-left", DRAW_DIR_NW)
.plugTo(this, "radio_startPosition");
RadioButton rSkip = p.cp5().addRadioButton("radio_pixelSkipStyle",10,100)
.add("Lift pen over masked pixels", 1)
.add("Draw masked pixels as blanks", 2)
.plugTo(this, "radio_pixelSkipStyle");
RadioButton rStyle = p.cp5().addRadioButton("radio_pixelStyle",100,10);
rStyle.add("Variable frequency square wave", PIXEL_STYLE_SQ_FREQ);
rStyle.add("Variable size square wave", PIXEL_STYLE_SQ_SIZE);
rStyle.add("Solid square wave", PIXEL_STYLE_SQ_SOLID);
rStyle.add("Scribble", PIXEL_STYLE_SCRIBBLE);
if (currentHardware >= HARDWARE_VER_MEGA) {
rStyle.add("Spiral", PIXEL_STYLE_CIRCLE);
rStyle.add("Sawtooth", PIXEL_STYLE_SAW);
}
rStyle.plugTo(this, "radio_pixelStyle");
Button submitButton = p.cp5().addButton("submitDrawWindow",0,280,10,120,20)
.setLabel("Generate commands")
.plugTo(this, "submitDrawWindow");
return p;
}
void radio_startPosition(int pos) {
renderStartPosition = pos;
radio_rowStartDirection(1);
}
void radio_rowStartDirection(int dir) {
if (renderStartPosition == DRAW_DIR_NE || renderStartPosition == DRAW_DIR_SW)
renderStartDirection = (dir == 0) ? DRAW_DIR_NW : DRAW_DIR_SE;
else if (renderStartPosition == DRAW_DIR_SE || renderStartPosition == DRAW_DIR_NW)
renderStartDirection = (dir == 0) ? DRAW_DIR_NE : DRAW_DIR_SW;
}
void radio_pixelStyle(int style) {
renderStyle = style;
}
void radio_pixelSkipStyle(int style) {
if (style == 1)
liftPenOnMaskedPixels = true;
else if (style == 2)
liftPenOnMaskedPixels = false;
}
void submitDrawWindow(int theValue) {
println("draw.");
println("Style: " + renderStyle);
println("Start pos: " + renderStartPosition);
println("Start dir: " + renderStartDirection);
switch (renderStyle) {
case PIXEL_STYLE_SQ_FREQ: button_mode_renderSquarePixel(); break;
case PIXEL_STYLE_SQ_SIZE: button_mode_renderScaledSquarePixels(); break;
case PIXEL_STYLE_SQ_SOLID: button_mode_renderSolidSquarePixels(); break;
case PIXEL_STYLE_SCRIBBLE: button_mode_renderScribblePixels(); break;
case PIXEL_STYLE_CIRCLE: button_mode_renderCirclePixel(); break;
case PIXEL_STYLE_SAW: button_mode_renderSawPixel(); break;
}
}
class DrawPixelsWindow extends ControlFrame {
@ -32,71 +131,8 @@ class DrawPixelsWindow extends ControlFrame {
}
});
RadioButton rPos = cp5().addRadioButton("radio_startPosition",10,10)
.add("Top-right", DRAW_DIR_NE)
.add("Bottom-right", DRAW_DIR_SE)
.add("Bottom-left", DRAW_DIR_SW)
.add("Top-left", DRAW_DIR_NW)
.plugTo("radio_startPosition");
RadioButton rSkip = cp5().addRadioButton("radio_pixelSkipStyle",10,100)
.add("Lift pen over masked pixels", 1)
.add("Draw masked pixels as blanks", 2)
.plugTo("radio_pixelSkipStyle");
RadioButton rStyle = cp5().addRadioButton("radio_pixelStyle",100,10);
rStyle.add("Variable frequency square wave", PIXEL_STYLE_SQ_FREQ);
rStyle.add("Variable size square wave", PIXEL_STYLE_SQ_SIZE);
rStyle.add("Solid square wave", PIXEL_STYLE_SQ_SOLID);
rStyle.add("Scribble", PIXEL_STYLE_SCRIBBLE);
if (currentHardware >= HARDWARE_VER_MEGA) {
rStyle.add("Spiral", PIXEL_STYLE_CIRCLE);
rStyle.add("Sawtooth", PIXEL_STYLE_SAW);
}
rStyle.plugTo("radio_pixelStyle");
Button submitButton = cp5().addButton("submitDrawWindow",0,280,10,120,20)
.setLabel("Generate commands")
.plugTo("submitDrawWindow");
}
void radio_startPosition(int pos) {
renderStartPosition = pos;
radio_rowStartDirection(1);
}
void radio_rowStartDirection(int dir) {
if (renderStartPosition == DRAW_DIR_NE || renderStartPosition == DRAW_DIR_SW)
renderStartDirection = (dir == 0) ? DRAW_DIR_NW : DRAW_DIR_SE;
else if (renderStartPosition == DRAW_DIR_SE || renderStartPosition == DRAW_DIR_NW)
renderStartDirection = (dir == 0) ? DRAW_DIR_NE : DRAW_DIR_SW;
}
void radio_pixelStyle(int style) {
renderStyle = style;
}
void radio_pixelSkipStyle(int style) {
if (style == 1)
liftPenOnMaskedPixels = true;
else if (style == 2)
liftPenOnMaskedPixels = false;
}
void submitDrawWindow(int theValue) {
println("draw.");
println("Style: " + renderStyle);
println("Start pos: " + renderStartPosition);
println("Start dir: " + renderStartDirection);
switch (renderStyle) {
case PIXEL_STYLE_SQ_FREQ: button_mode_renderSquarePixel(); break;
case PIXEL_STYLE_SQ_SIZE: button_mode_renderScaledSquarePixels(); break;
case PIXEL_STYLE_SQ_SOLID: button_mode_renderSolidSquarePixels(); break;
case PIXEL_STYLE_SCRIBBLE: button_mode_renderScribblePixels(); break;
case PIXEL_STYLE_CIRCLE: button_mode_renderCirclePixel(); break;
case PIXEL_STYLE_SAW: button_mode_renderSawPixel(); break;
}
}
}

View File

@ -1,48 +1,64 @@
class MachineExecWindow extends ControlFrame {
ControlFrameSimple addMachineExecControlFrame(String theName, int theWidth, int theHeight, int theX, int theY, int theColor ) {
final Frame f = new Frame( theName );
final ControlFrameSimple p = new ControlFrameSimple( this, theWidth, theHeight, theColor );
void execFilename(String filename) {
println("Filename event: "+ filename);
if (filename != null && filename.length() <= 12) {
setStoreFilename(filename);
sendMachineExecMode();
}
}
f.add( p );
p.init();
f.setTitle(theName);
f.setSize( p.w, p.h );
f.setLocation( theX, theY );
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
p.dispose();
f.dispose();
}
}
);
f.setResizable( true );
f.setVisible( true );
// sleep a little bit to allow p to call setup.
// otherwise a nullpointerexception might be caused.
try {
Thread.sleep( 100 );
}
catch(Exception e) {
}
void submitExecFilenameWindow(int theValue) {
cp5().get(Textfield.class, "execFilename").submit();
}
// set up controls
Textfield filenameField = p.cp5().addTextfield("machineExec_execFilename",20,20,150,20)
.setText(getStoreFilename())
.setLabel("Filename to execute from")
.addListener( new ControlListener() {
public void controlEvent( ControlEvent ev ) {
machineExec_execFilename(ev.getController().getStringValue());
Textfield tf = p.cp5().get(Textfield.class, "machineExec_execFilename");
}
});
public MachineExecWindow() {
super(parentPapplet, 450, 150);
int xPos = 100;
int yPos = 100;
String name = MACHINE_EXEC_WINDOW_NAME;
final Frame f = new Frame(name);
f.add(this);
this.init();
f.setTitle(name);
f.setSize(super.w, super.h);
f.setLocation(xPos, yPos);
f.setResizable(false);
f.setVisible(true);
Button submitButton = p.cp5().addButton("machineExec_submitExecFilenameWindow",0,180,20,60,20)
.setLabel("Submit")
.addListener( new ControlListener() {
public void controlEvent( ControlEvent ev ) {
p.cp5().get(Textfield.class, "machineExec_execFilename").submit();
p.cp5().get(Textfield.class, "machineExec_execFilename").setText(getStoreFilename());
}
});
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
filenameField.setFocus(true);
Textfield filenameField = cp5().addTextfield("execFilename",20,20,150,20)
.setText(getStoreFilename())
.setLabel("Filename to execute from")
.plugTo("execFilename");
Button submitButton = cp5().addButton("submitExecFilenameWindow",0,180,20,60,20)
.setLabel("Submit")
.plugTo("submitExecFilenameWindow");
filenameField.setFocus(true);
}
return p;
}
void machineExec_execFilename(String filename) {
println("Filename event: "+ filename);
if (filename != null
&& filename.length() <= 12
&& !"".equals(filename.trim())) {
filename = filename.trim();
setStoreFilename(filename);
sendMachineExecMode();
}
}

View File

@ -11,9 +11,7 @@ class MachineStoreWindow extends ControlFrame {
}
}
void toggleAppendToFile(boolean theFlag) {
setOverwriteExistingStoreFile(theFlag);
}
void submitStoreFilenameWindow(int theValue) {
cp5().get(Textfield.class, "storeFilename").submit();
@ -57,3 +55,78 @@ class MachineStoreWindow extends ControlFrame {
filenameField.setFocus(true);
}
}
ControlFrameSimple addMachineStoreControlFrame(String theName, int theWidth, int theHeight, int theX, int theY, int theColor ) {
final Frame f = new Frame( theName );
final ControlFrameSimple p = new ControlFrameSimple( this, theWidth, theHeight, theColor );
f.add( p );
p.init();
f.setTitle(theName);
f.setSize( p.w, p.h );
f.setLocation( theX, theY );
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
p.dispose();
f.dispose();
}
}
);
f.setResizable( true );
f.setVisible( true );
// sleep a little bit to allow p to call setup.
// otherwise a nullpointerexception might be caused.
try {
Thread.sleep( 100 );
}
catch(Exception e) {
}
// set up controls
Textfield filenameField = p.cp5().addTextfield("machineStore_storeFilename",20,20,150,20)
.setText(getStoreFilename())
.setLabel("Filename to store to")
.addListener( new ControlListener() {
public void controlEvent( ControlEvent ev ) {
machineStore_storeFilename(ev.getController().getStringValue());
Textfield tf = p.cp5().get(Textfield.class, "machineExec_execFilename");
}
});
Button submitButton = p.cp5().addButton("machineStore_submitStoreFilenameWindow",0,180,20,60,20)
.setLabel("Submit")
.addListener( new ControlListener() {
public void controlEvent( ControlEvent ev ) {
p.cp5().get(Textfield.class, "machineStore_storeFilename").submit();
p.cp5().get(Textfield.class, "machineStore_storeFilename").setText(getStoreFilename());
}
});
Toggle overwriteToggle = p.cp5().addToggle("machineStore_toggleAppendToFile",true,180,50,20,20)
.setCaptionLabel("Overwrite existing file")
.plugTo(this, "machineStore_toggleAppendToFile");
filenameField.setFocus(true);
return p;
}
void machineStore_toggleAppendToFile(boolean theFlag) {
setOverwriteExistingStoreFile(theFlag);
}
void machineStore_storeFilename(String filename) {
println("Filename event: "+ filename);
if (filename != null
&& filename.length() <= 12
&& !"".equals(filename.trim())) {
filename = filename.trim();
setStoreFilename(filename);
sendMachineStoreMode();
}
}

View File

@ -1,113 +1,112 @@
/*------------------------------------------------------------------------
Class and controllers on the "serial port" subwindow
------------------------------------------------------------------------*/
Class and controllers on the "serial port" subwindow
------------------------------------------------------------------------*/
class SerialPortWindow extends ControlFrame {
public SerialPortWindow() {
super(parentPapplet, 150, 350);
ControlFrameSimple addSerialPortControlFrame(String theName, int theWidth, int theHeight, int theX, int theY, int theColor ) {
final Frame f = new Frame( theName );
final ControlFrameSimple p = new ControlFrameSimple( this, theWidth, theHeight, theColor );
int xPos = 100;
int yPos = 100;
f.add( p );
p.init();
f.setTitle(theName);
f.setSize( p.w, p.h );
f.setLocation( theX, theY );
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
p.dispose();
f.dispose();
}
}
);
f.setResizable( true );
f.setVisible( true );
// sleep a little bit to allow p to call setup.
// otherwise a nullpointerexception might be caused.
try {
Thread.sleep( 100 );
}
catch(Exception e) {
}
final Frame f = new Frame(CHANGE_SERIAL_PORT_WINDOW_NAME);
f.add(this);
this.init();
f.setTitle(CHANGE_SERIAL_PORT_WINDOW_NAME);
f.setSize(super.w, super.h);
f.setLocation(xPos, yPos);
f.setResizable(true);
f.setVisible(true);
// set up controls
RadioButton r = p.cp5().addRadioButton("radio_serialPort")
.setPosition(10, 10)
.setSize(15, 15)
.setSpacingRow(5)
.plugTo(this, "radio_serialPort");
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
r.addItem("No serial connection", -1);
RadioButton r = cp5().addRadioButton("radio_serialPort")
.setPosition(10, 10)
.setSize(15,15)
.setSpacingRow(5)
.plugTo(parentPapplet, "radio_serialPort");
String[] ports = Serial.list();
r.addItem("No serial connection", -1);
for (int i = 0; i < ports.length; i++) {
println("Adding " + ports[i]);
r.addItem(ports[i], i);
}
String[] ports = Serial.list();
int portNo = getSerialPortNumber();
if (portNo >= 0 && portNo < ports.length)
r.activate(ports[portNo]);
else
r.activate("No serial connection");
for (int i = 0; i < ports.length; i++) {
println("Adding " + ports[i]);
r.addItem(ports[i], i);
}
int portNo = getSerialPortNumber();
if (portNo >= 0 && portNo < ports.length)
r.activate(ports[portNo]);
else
r.activate("No serial connection");
}
return p;
}
void radio_serialPort(int newSerialPort)
{
println("In radio_serialPort");
if (newSerialPort == -2)
{
}
else if (newSerialPort == -1)
{
println("Disconnecting serial port.");
useSerialPortConnection = false;
if (myPort != null)
{
myPort.stop();
myPort = null;
}
drawbotReady = false;
drawbotConnected = false;
serialPortNumber = newSerialPort;
else if (newSerialPort == -1) {
println("Disconnecting serial port.");
useSerialPortConnection = false;
if (myPort != null)
{
myPort.stop();
myPort = null;
}
drawbotReady = false;
drawbotConnected = false;
serialPortNumber = newSerialPort;
}
else if (newSerialPort != getSerialPortNumber())
{
println("About to connect to serial port in slot " + newSerialPort);
// Print a list of the serial ports, for debugging purposes:
if (newSerialPort < Serial.list().length)
{
try
{
drawbotReady = false;
drawbotConnected = false;
if (myPort != null)
{
myPort.stop();
myPort = null;
}
if (getSerialPortNumber() >= 0)
println("closing " + Serial.list()[getSerialPortNumber()]);
else if (newSerialPort != getSerialPortNumber()) {
println("About to connect to serial port in slot " + newSerialPort);
// Print a list of the serial ports, for debugging purposes:
if (newSerialPort < Serial.list().length) {
try {
drawbotReady = false;
drawbotConnected = false;
if (myPort != null) {
myPort.stop();
myPort = null;
}
serialPortNumber = newSerialPort;
String portName = Serial.list()[serialPortNumber];
if (getSerialPortNumber() >= 0)
println("closing " + Serial.list()[getSerialPortNumber()]);
myPort = new Serial(this, portName, getBaudRate());
//read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil('\n');
useSerialPortConnection = true;
println("Successfully connected to port " + portName);
}
catch (Exception e)
{
println("Attempting to connect to serial port in slot " + getSerialPortNumber()
+ " caused an exception: " + e.getMessage());
}
}
else
{
println("No serial ports found.");
useSerialPortConnection = false;
}
}
else
{
println("no serial port change.");
serialPortNumber = newSerialPort;
String portName = Serial.list()[serialPortNumber];
myPort = new Serial(this, portName, getBaudRate());
//read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil('\n');
useSerialPortConnection = true;
println("Successfully connected to port " + portName);
}
catch (Exception e) {
println("Attempting to connect to serial port in slot " + getSerialPortNumber()
+ " caused an exception: " + e.getMessage());
}
} else {
println("No serial ports found.");
useSerialPortConnection = false;
}
} else {
println("no serial port change.");
}
}

View File

@ -1,34 +1,34 @@
/**
Polargraph controller
Copyright Sandy Noble 2015.
Polargraph controller
Copyright Sandy Noble 2015.
This file is part of Polargraph Controller.
This file is part of Polargraph Controller.
Polargraph Controller is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Polargraph Controller is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Polargraph Controller is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Polargraph Controller is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Polargraph Controller. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with Polargraph Controller. If not, see <http://www.gnu.org/licenses/>.
Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
Requires the excellent ControlP5 GUI library available from http://www.sojamo.de/libraries/controlP5/.
Requires the excellent Geomerative library available from http://www.ricardmarxer.com/geomerative/.
This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
This is an application for controlling a polargraph machine, communicating using ASCII command language over a serial link.
sandy.noble@gmail.com
http://www.polargraph.co.uk/
https://github.com/euphy/polargraphcontroller
*/
sandy.noble@gmail.com
http://www.polargraph.co.uk/
https://github.com/euphy/polargraphcontroller
*/
void button_mode_sendMachineLiveMode() {
sendMachineLiveMode();
sendMachineLiveMode();
}
String CHANGE_SERIAL_PORT_WINDOW_NAME = "changeSerialPortWindow";
@ -38,23 +38,26 @@ String DRAW_PIXELS_WINDOW_NAME = "drawPixelsWindow";
String DRAW_WRITING_WINDOW_NAME = "drawWritingWindow";
void button_mode_serialPortDialog() {
final SerialPortWindow serialPortWindow = new SerialPortWindow();
ControlFrameSimple cf = addSerialPortControlFrame("Serial Port", 200, 200, 20, 240, color( 100 ) );
}
void button_mode_machineStoreDialog() {
final MachineStoreWindow machineStoreWindow = new MachineStoreWindow();
ControlFrameSimple cf = addMachineStoreControlFrame("Machine Store", 450, 250, 20, 240, color( 100 ) );
// final MachineStoreWindow machineStoreWindow = new MachineStoreWindow();
}
void button_mode_machineExecDialog() {
final MachineExecWindow machineExecWindow = new MachineExecWindow();
ControlFrameSimple cf = addMachineExecControlFrame("Machine Execute", 450, 250, 20, 240, color( 100 ) );
// final MachineExecWindow machineExecWindow = new MachineExecWindow();
}
void button_mode_drawPixelsDialog() {
final DrawPixelsWindow drawPixelsWindow = new DrawPixelsWindow();
ControlFrameSimple cf = addDrawPixelsControlFrame("Render pixels", 450, 250, 20, 240, color( 100 ) );
// final DrawPixelsWindow drawPixelsWindow = new DrawPixelsWindow();
}
void button_mode_drawWritingDialog() {
final DrawWritingWindow drawWritingWindow = new DrawWritingWindow();
final DrawWritingWindow drawWritingWindow = new DrawWritingWindow();
}
///*------------------------------------------------------------------------
@ -64,117 +67,118 @@ String textToWrite = "";
String spriteFilePrefix = "sprite/let";
String spriteFileSuffix = ".txt";
public class DrawWritingWindow extends ControlFrame {
public DrawWritingWindow() {
super(parentPapplet, 450, 250);
int xPos = 100;
int yPos = 100;
String name = DRAW_WRITING_WINDOW_NAME;
public DrawWritingWindow() {
super(parentPapplet, 450, 250);
int xPos = 100;
int yPos = 100;
String name = DRAW_WRITING_WINDOW_NAME;
final Frame f = new Frame(name);
f.add(this);
this.init();
f.setTitle(name);
f.setSize(super.w, super.h);
f.setLocation(xPos, yPos);
f.setResizable(false);
f.setVisible(true);
final Frame f = new Frame(name);
f.add(this);
this.init();
f.setTitle(name);
f.setSize(super.w, super.h);
f.setLocation(xPos, yPos);
f.setResizable(false);
f.setVisible(true);
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
Textfield spriteFileField = cp5().addTextfield("spriteFilePrefixField",20,20,150,20)
.setText(getSpriteFilePrefix())
.setLabel("File prefix")
.plugTo("spriteFilePrefixField");
f.addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent we) {
f.dispose();
}
}
);
Textfield spriteFileField = cp5().addTextfield("spriteFilePrefixField", 20, 20, 150, 20)
.setText(getSpriteFilePrefix())
.setLabel("File prefix")
.plugTo("spriteFilePrefixField");
Textfield writingField = cp5().addTextfield("textToWriteField",20,60,400,20)
.setText(getTextToWrite())
.setLabel("Text to write")
.plugTo("textToWriteField");
Textfield writingField = cp5().addTextfield("textToWriteField", 20, 60, 400, 20)
.setText(getTextToWrite())
.setLabel("Text to write")
.plugTo("textToWriteField");
Button importTextButton = cp5().addButton("importTextButton",0,20,100,120,20)
.setLabel("Load text from file")
.plugTo("importTextButton");
Button importTextButton = cp5().addButton("importTextButton", 0, 20, 100, 120, 20)
.setLabel("Load text from file")
.plugTo("importTextButton");
RadioButton rPos = cp5().addRadioButton("radio_drawWritingDirection",20,140);
// rPos.add("North-east", DRAW_DIR_NE);
rPos.add("South-east", DRAW_DIR_SE);
// rPos.add("South-west", DRAW_DIR_SW);
// rPos.add("North-west", DRAW_DIR_NW);
rPos.plugTo("radio_drawWritingDirection");
RadioButton rPos = cp5().addRadioButton("radio_drawWritingDirection", 20, 140);
// rPos.add("North-east", DRAW_DIR_NE);
rPos.add("South-east", DRAW_DIR_SE);
// rPos.add("South-west", DRAW_DIR_SW);
// rPos.add("North-west", DRAW_DIR_NW);
rPos.plugTo("radio_drawWritingDirection");
Button submitButton = cp5.addButton("submitWritingWindow",0,300,100,120,20)
.setLabel("Generate commands")
.plugTo("submitWritingWindow");
}
Button submitButton = cp5.addButton("submitWritingWindow", 0, 300, 100, 120, 20)
.setLabel("Generate commands")
.plugTo("submitWritingWindow");
}
void spriteFilePrefixField(String value) {
spriteFilePrefix = value;
}
void textToWriteField(String value) {
textToWrite = value;
}
void spriteFilePrefixField(String value) {
spriteFilePrefix = value;
}
void textToWriteField(String value) {
textToWrite = value;
}
String getTextToWrite() {
return textToWrite;
}
String getSpriteFilePrefix() {
return spriteFilePrefix;
}
String getSpriteFileSuffix() {
return spriteFileSuffix;
}
String getTextToWrite() {
return textToWrite;
}
String getSpriteFilePrefix() {
return spriteFilePrefix;
}
String getSpriteFileSuffix() {
return spriteFileSuffix;
}
void importTextButton() {
println("Text!");
selectInput("Select the text file to load the text from:", "importTextToWriteFromFile", null, this);
}
void importTextButton() {
println("Text!");
selectInput("Select the text file to load the text from:", "importTextToWriteFromFile", null, this);
}
public void importTextToWriteFromFile(File selection) {
if (selection != null) {
String fp = selection.getAbsolutePath();
println("Input file: " + fp);
List<String> rows = java.util.Arrays.asList(loadStrings(fp));
StringBuilder sb = new StringBuilder(200);
for (String row : rows) {
sb.append(row);
}
textToWriteField(sb.toString());
println("Completed text import, " + getTextToWrite().length() + " characters found.");
public void importTextToWriteFromFile(File selection) {
if (selection != null) {
String fp = selection.getAbsolutePath();
println("Input file: " + fp);
List<String> rows = java.util.Arrays.asList(loadStrings(fp));
StringBuilder sb = new StringBuilder(200);
for (String row : rows) {
sb.append(row);
}
textToWriteField(sb.toString());
println("Completed text import, " + getTextToWrite().length() + " characters found.");
println("Text: " + getTextToWrite());
println("Text: " + getTextToWrite());
Textfield tf = cp5().get(Textfield.class, "textToWriteField");
tf.setText(getTextToWrite());
tf.submit();
}
}
Textfield tf = cp5().get(Textfield.class, "textToWriteField");
tf.setText(getTextToWrite());
tf.submit();
}
}
void submitWritingWindow(int theValue)
{
println("Write.");
void submitWritingWindow(int theValue)
{
println("Write.");
Textfield tf = cp5().get(Textfield.class, "spriteFilePrefixField");
tf.submit();
tf.setText(getSpriteFilePrefix());
Textfield tf = cp5().get(Textfield.class, "spriteFilePrefixField");
tf.submit();
tf.setText(getSpriteFilePrefix());
Textfield wf = cp5.get(Textfield.class, "textToWriteField");
wf.submit();
wf.setText(getTextToWrite());
Textfield wf = cp5.get(Textfield.class, "textToWriteField");
wf.submit();
wf.setText(getTextToWrite());
println("Start dir: " + renderStartDirection);
println("Sprite file prefix: " + spriteFilePrefix);
println("Text: " + textToWrite);
println("Start dir: " + renderStartDirection);
println("Sprite file prefix: " + spriteFilePrefix);
println("Text: " + textToWrite);
for (int i=0; i<getTextToWrite().length(); i++) {
String filename = getSpriteFilePrefix() + (int) getTextToWrite().charAt(i) + getSpriteFileSuffix();
addToCommandQueue(CMD_DRAW_SPRITE + int(gridSize * pixelScalingOverGridSize) + "," + filename+",END");
println(filename);
}
}
for (int i=0; i<getTextToWrite ().length(); i++) {
String filename = getSpriteFilePrefix() + (int) getTextToWrite().charAt(i) + getSpriteFileSuffix();
addToCommandQueue(CMD_DRAW_SPRITE + int(gridSize * pixelScalingOverGridSize) + "," + filename+",END");
println(filename);
}
}
}
//
//void button_mode_drawWritingDialog()

View File

@ -944,7 +944,7 @@ void sendMachineStoreMode()
}
void sendMachineLiveMode()
{
addToRealtimeCommandQueue(CMD_MACHINE_MODE_LIVE+"END");
addToCommandQueue(CMD_MACHINE_MODE_LIVE+"END");
}
void sendMachineExecMode()
{