import processing.core.*; 
import processing.xml.*; 

import controlP5.*; 

import controlP5.*; 

import java.applet.*; 
import java.awt.Dimension; 
import java.awt.Frame; 
import java.awt.event.MouseEvent; 
import java.awt.event.KeyEvent; 
import java.awt.event.FocusEvent; 
import java.awt.Image; 
import java.io.*; 
import java.net.*; 
import java.text.*; 
import java.util.*; 
import java.util.zip.*; 
import java.util.regex.*; 

public class CNCHotwire extends PApplet {

// CNC Tragf\u00e4chen Schneideger\u00e4t
// Interface f\u00fcr den PC/Linux
// Gekoppelt \u00fcber Serielle Schnittstelle mit Arduino



ControlP5 controlP5;

Textfield ProfLinks;
Textfield ProfRechts;
Textfield TLinks;
Textfield TRechts;
Textfield AWLinks;
Textfield AWRechts;
Textfield Pfeilung;
Textfield SegBreite;

public void setup() {
  size(400,380);
  frameRate(25);
  controlP5 = new ControlP5(this);
  ProfLinks = controlP5.addTextfield("Profil Links",30,30,100,20);
  ProfRechts = controlP5.addTextfield("Profil Rechts",250,30,100,20);
  TLinks = controlP5.addTextfield("Tiefe Links",30,90,100,20);
  TRechts = controlP5.addTextfield("Tiefe Rechts",250,90,100,20);
  AWLinks = controlP5.addTextfield("Anstellwinkel Links",30,130,100,20);
  AWRechts = controlP5.addTextfield("Anstellwinkel Rechts",250,130,100,20);
  
  Pfeilung = controlP5.addTextfield("Pfeilungswinkel",140,220,100,20);
  SegBreite = controlP5.addTextfield("Segmentbreite",140,270,100,20);
  
  controlP5.addButton("Start",0,30,340,80,19).setId(9);
  controlP5.addButton("Cancel",255,150,340,80,19).setId(10);
  controlP5.addButton("Home",128,270,340,80,19).setId(11);
  
  
}

public void draw() {
  background(100);
  fill(100);
  stroke(60);
  rect(10,10,160,180);
  rect(220,10,160,180);  
  rect(10,210,370,100);
}

public void controlEvent(ControlEvent theEvent) {
  println("got a control event from controller with id "+theEvent.controller().id());
  switch(theEvent.controller().id()) {
    case(9): // Start
    println("Start");
    println(ProfLinks.getText());
    break;
    case(10): // Cancel
    println("Cancel");
    println(Pfeilung.getText());
    break;
    case(11): // Home
    println("Home");
    println(SegBreite.getText());
    break;
  }
}
  static public void main(String args[]) {
    PApplet.main(new String[] { "--bgcolor=#DFDFDF", "CNCHotwire" });
  }
}
