package GExamples;
import processing.core.PApplet;
import GShape.Core.GCore;
import GShape.Core.Expression.GExpression;
public class TestExpression001 extends PApplet {
public void setup () {
GCore core = new GCore (this, "", null);
GExpression exp1 = new GExpression (core, "4000cm:Wiese ; Xm:tmpPerimeter ; 20000mm:Wiese");
try {
float length = 300; // 300m length
if (exp1.Items.size() != 3) { System.out.println ("Expression 1: not enough items!"); }
if (exp1.Items.get(0).isNumber == false) { System.out.println ("Expression 1, Item 1: isNumber:" + exp1.Items.get(0).isNumber); }
if (exp1.Items.get(0).getNumber(0, 0) != 40) { System.out.println ("Expression 1, Item 1: Value:" + exp1.Items.get(0).getNumber(0, 0)); }
if (exp1.Items.get(1).isNumber == false) { System.out.println ("Expression 1, Item 2: isNumber:" + exp1.Items.get(1).isNumber); }
if (exp1.Items.get(1).isX == false) { System.out.println ("Expression 1, Item 2: X:" + exp1.Items.get(1).isX); System.out.println ("Expression 1, Item 2: Value:" + exp1.Items.get(1).getNumber(0, 0)); }
if (exp1.Items.get(1).getNumber(length, 0) != 240) { System.out.println ("Expression 1, Item 1: Value:" + exp1.Items.get(1).getNumber(length, 0)); }
if (exp1.Items.get(2).isNumber == false) { System.out.println ("Expression 1, Item 3: isNumber:" + exp1.Items.get(2).isNumber); }
if (exp1.Items.get(2).getNumber(0, 0) != 20) { System.out.println ("Expression 1, Item 3: Value:" + exp1.Items.get(2).getNumber(0, 0)); }
} catch (Exception ex) {}
// Expression 2
GExpression exp2 = new GExpression (core, "15m:EG ; ~7.7m:OG ; 15m:OG");
try {
float length = 300; // 300m length
if (exp2.Items.size() < 3) { System.out.println ("Expression 2: not enough items!"); }
if (exp2.Items.get(0).isNumber == false) { System.out.println ("Expression 2: Item 1: isNumber:" + exp2.Items.get(0).isNumber); }
if (exp2.Items.get(0).getNumber(0, 0) != 15) { System.out.println ("Expression 2: Item 1: Value:" + exp2.Items.get(0).getNumber(0, 0)); }
if (exp2.Items.get(1).isNumber == false) { System.out.println ("Expression 2: Item 2: isNumber:" + exp2.Items.get(1).isNumber); System.out.println ("Expression 2: Item 1: Value:" + exp2.Items.get(1).getNumber(0, 0)); }
if ((int) (exp2.Items.get(1).getNumber(length, 0) * 100) != 771) { System.out.println ("Expression 2, Item 2: Value:" + exp2.Items.get(1).getNumber(length, 0) + " TildeCount: " + exp2.Items.get(1).getCount(length));}
if (exp2.Items.get(2).isNumber == false) { System.out.println ("Expression 2: Item 3: isNumber:" + exp2.Items.get(2).isNumber); }
if (exp2.Items.get(2).getNumber(0, 0) != 15) { System.out.println ("Expression 2: Item 3: Value:" + exp2.Items.get(2).getNumber(0, 0)); }
} catch (Exception ex) {System.out.println ("Expression 1: ERROR " + ex.getMessage());}
// Expression 2_2
GExpression exp2_2 = new GExpression (core, "15m:EG ; ~5m:OG ; 3m:OG ; ~7m:OG ; 15m:OG");
try {
float length = 300; // 300m length
if (exp2_2.Items.size() < 5) { System.out.println ("Expression 2_2: not enough items!"); }
if (exp2_2.Items.get(0).isNumber == false) { System.out.println ("Expression 2_2: Item 1: isNumber:" + exp2_2.Items.get(0).isNumber); }
if (exp2_2.Items.get(0).getNumber(0, 0) != 15) { System.out.println ("Expression 2_2: Item 1: Value:" + exp2_2.Items.get(0).getNumber(0, 0)); }
if (exp2_2.Items.get(1).isNumber == false) { System.out.println ("Expression 2_2: Item 2: isNumber:" + exp2_2.Items.get(1).isNumber); System.out.println ("Expression 2: Item 1: Value:" + exp2.Items.get(1).getNumber(0, 0)); }
if ((int) (exp2_2.Items.get(1).getNumber(length, 0) * 100) != 505) { System.out.println ("Expression 2_2, Item 2: Value:" + exp2_2.Items.get(1).getNumber(length, 0) + " TildeCount: " + exp2_2.Items.get(1).getCount(length));}
if (exp2_2.Items.get(2).isNumber == false) { System.out.println ("Expression 2_2: Item 3: isNumber:" + exp2_2.Items.get(2).isNumber); }
if (exp2_2.Items.get(2).getNumber(0, 0) != 3) { System.out.println ("Expression 2_2: Item 3: Value:" + exp2_2.Items.get(2).getNumber(0, 0)); }
if (exp2_2.Items.get(3).isNumber == false) { System.out.println ("Expression 2_2: Item 4: isNumber:" + exp2_2.Items.get(3).isNumber); }
if ((int) (exp2_2.Items.get(3).getNumber(length, 0) * 100) != 707) { System.out.println ("Expression 2_2, Item 4: Value:" + exp2_2.Items.get(3).getNumber(length, 0) + " TildeCount: " + exp2_2.Items.get(3).getCount(length));}
if (exp2_2.Items.get(4).isNumber == false) { System.out.println ("Expression 2_2: Item 5: isNumber:" + exp2_2.Items.get(4).isNumber); }
if (exp2_2.Items.get(4).getNumber(0, 0) != 15) { System.out.println ("Expression 2_2: Item 5: Value:" + exp2_2.Items.get(4).getNumber(0, 0)); }
} catch (Exception ex) {System.out.println ("Expression 2: ERROR " + ex.getMessage());}
// Expression 3
GExpression exp3 = new GExpression (core, "10m ; 20% ; 60% ; 15m");
try {
float length = 300; // 300m length
if (exp3.Items.size() != 4) { System.out.println ("Expression 3: not enough items!"); }
if (exp3.Items.get(0).isNumber == false) { System.out.println ("Expression 3: Item 1: isNumber:" + exp3.Items.get(0).isNumber); }
if (exp3.Items.get(0).getNumber(0, 0) != 10) { System.out.println ("Expression 3: Item 1: Value:" + exp3.Items.get(0).getNumber(0, 0)); }
if (exp3.Items.get(1).isNumber == false) { System.out.println ("Expression 3: Item 2: isNumber:" + exp3.Items.get(1).isNumber); System.out.println ("Expression 3: Item 2: Value:" + exp3.Items.get(1).getNumber(0, 0)); }
if ((int) (exp3.Items.get(1).getNumber(length, 0) * 100) != 6875) { System.out.println ("Expression 3: Item 2: Value:" + exp3.Items.get(1).getNumber(length, 0)); }
if (exp3.Items.get(2).isNumber == false) { System.out.println ("Expression 3: Item 3: isNumber:" + exp3.Items.get(2).isNumber); System.out.println ("Expression 3: Item 3: Value:" + exp3.Items.get(2).getNumber(0, 0)); }
if ((int) (exp3.Items.get(2).getNumber(length, 0) * 100) != 20625) { System.out.println ("Expression 3: Item 3: Value:" + exp3.Items.get(2).getNumber(length, 0)); }
if (exp3.Items.get(3).isNumber == false) { System.out.println ("Expression 3: Item 4: isNumber:" + exp3.Items.get(3).isNumber); }
if (exp3.Items.get(3).getNumber(0, 0) != 15) { System.out.println ("Expression 3: Item 4: Value:" + exp3.Items.get(3).getNumber(0, 0)); }
} catch (Exception ex) {System.out.println ("Expression 3: ERROR " + ex.getMessage());}
// Expression 4
GExpression exp4 = new GExpression (core, "400m2:Lots:20m:40m");
try {
if (exp4.Items.get(0).isNumber == false) { System.out.println ("Expression 4: Item 1: isNumber:" + exp4.Items.get(0).isNumber); }
if (exp4.Items.get(0).getNumber(0, 0) != 400) { System.out.println ("Expression 4: Item 1: Value:" + exp4.Items.get(0).getNumber(0, 0)); }
if (exp4.Items.get(0).Parts.get(2).getNumber(0, 0) != 20) { System.out.println ("Expression 4: Item 1: Value2:" + exp4.Items.get(0).Parts.get(2).getNumber(0, 0)); }
if (exp4.Items.get(0).Parts.get(3).getNumber(0, 0) != 40) { System.out.println ("Expression 4: Item 1: Value3:" + exp4.Items.get(0).Parts.get(3).getNumber(0, 0)); }
} catch (Exception ex) {System.out.println ("Expression 4: ERROR " + ex.getMessage());}
// Expression 5
GExpression exp5 = new GExpression (core, "100m:70m:Lots:30%");
try {
if (exp5.Items.get(0).isNumber == false) { System.out.println ("Expression 5: Item 1: isNumber:" + exp5.Items.get(0).isNumber); }
if (exp5.Items.get(0).getNumber(0, 0) != 100) { System.out.println ("Expression 5: Item 1: Value:" + exp5.Items.get(0).getNumber(0, 0)); }
if (exp5.Items.get(0).Parts.get(1).getNumber(0, 0) != 70) { System.out.println ("Expression 5: Item 1: Value2:" + exp5.Items.get(0).Parts.get(1).getNumber(0, 0)); }
if (exp5.Items.get(0).Parts.get(3).Number != 30) { System.out.println ("Expression 5: Item 1: Value2:" + exp5.Items.get(0).Parts.get(3).Number); }
} catch (Exception ex) {System.out.println ("Expression 5: ERROR " + ex.getMessage());}
}
}