From 58bb1611c89527c70c5d0201a6815137b9ce6772 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 10 Jul 2016 07:33:35 -0700 Subject: [PATCH] ellipse works via mouse + menu, but dimensions are probably wrong --- .idea/workspace.xml | 206 +++++++++++++++++++++++------------------ src/Ellipse.java | 2 +- src/EuglenaApplet.java | 18 ++-- src/Menu.java | 22 +++-- 4 files changed, 139 insertions(+), 109 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e7fc455..0ec3ffe 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,12 +2,10 @@ - - - + @@ -31,8 +29,8 @@ - - + + @@ -55,11 +53,14 @@ - - + + - - + + + + + @@ -68,7 +69,7 @@ - + @@ -82,8 +83,8 @@ - - + + @@ -94,7 +95,7 @@ - + @@ -106,8 +107,8 @@ - - + + @@ -143,7 +144,6 @@ @@ -522,8 +523,11 @@ - - + + + + + @@ -598,8 +602,11 @@ - - + + + + + @@ -635,8 +642,11 @@ - - + + + + + @@ -646,8 +656,11 @@ - - + + + + + @@ -657,8 +670,11 @@ - - + + + + + @@ -668,8 +684,11 @@ - - + + + + + @@ -679,8 +698,11 @@ - - + + + + + @@ -690,8 +712,11 @@ - - + + + + + @@ -762,16 +787,6 @@ - - - - - - - - - - @@ -799,39 +814,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -840,16 +822,6 @@ - - - - - - - - - - @@ -858,13 +830,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + + + + diff --git a/src/Ellipse.java b/src/Ellipse.java index 7dad69d..b9ae67d 100644 --- a/src/Ellipse.java +++ b/src/Ellipse.java @@ -54,7 +54,7 @@ class Ellipse { }; } - ClickGetter clickGetter(ProjectorApplet p) { + ClickGetter makeClickGetter(ProjectorApplet p) { return (int x, int y) -> { if (!centerPointComplete){ centerX = x; diff --git a/src/EuglenaApplet.java b/src/EuglenaApplet.java index 05d26c6..e85a46c 100644 --- a/src/EuglenaApplet.java +++ b/src/EuglenaApplet.java @@ -1,3 +1,4 @@ +import controlP5.ControlEvent; import processing.core.*; public class EuglenaApplet extends PApplet { @@ -14,7 +15,10 @@ public class EuglenaApplet extends PApplet { Calibrator calibrator; ClickGetter clickGetter; - boolean tester; + //Pen + int penColor = color(200); + int penWidth = 15; + public static void main(String args[]) { PApplet.main("EuglenaApplet"); @@ -40,7 +44,6 @@ public class EuglenaApplet extends PApplet { projectorApplet = new ProjectorApplet(this); String[] args = {"Euglena projector"}; PApplet.runSketch(args, projectorApplet); - tester = false; } @Override @@ -52,13 +55,6 @@ public class EuglenaApplet extends PApplet { imageMode(PApplet.CORNER); image(camera.getImage(), 0, 0, width - menu.width, height); - if (!tester) { -// this.projectorApplet.commandQueue.add(new Ellipse(0f, 0f, 1000f, 1000f, color(250, 250, 250), 8).drawCommand()); - - this.clickGetter = new Ellipse(color(255), 10).clickGetter(projectorApplet); - tester = true; - } - } @@ -71,6 +67,10 @@ public class EuglenaApplet extends PApplet { } } + public void controlEvent(ControlEvent theEvent) { + menu.controlEvent(theEvent); + } + void drawArrow(int cx, int cy, int len, float angle){ pushMatrix(); translate(cx, cy); diff --git a/src/Menu.java b/src/Menu.java index ddb0ad5..e6e515f 100644 --- a/src/Menu.java +++ b/src/Menu.java @@ -1,9 +1,12 @@ import processing.core.*; +import static processing.core.PApplet.*; import controlP5.*; class Menu { final int width = 200; // Width of toolbar on left side of display + EuglenaApplet parent; + private Button resetButton, calibrateButton, commitButton, lineButton, freehandButton, eraserButton, goButton; private Textfield redField, greenField, blueField, backgroundField, penwidthField, lagField, totaltimeField, speedField; @@ -13,7 +16,8 @@ class Menu { private Group g1, g2, g3; - Menu(PApplet applet){ + Menu(EuglenaApplet applet){ + parent = applet; cp5 = new ControlP5(applet).setPosition(applet.width - width, 0); @@ -183,25 +187,23 @@ class Menu { a.fill(0); a.rect(a.width - width, 0, width, a.height); } -/* + void controlEvent(ControlEvent theEvent) { if (theEvent.isFrom(shapesList)) { switch((int) shapesList.getValue()) { case 0: - ellipseDrawer.reset(); - drawtype = 'e'; + parent.clickGetter = new Ellipse(parent.penColor, parent.penWidth) + .makeClickGetter(parent.projectorApplet); break; case 1: - rectangleDrawer.reset(); - drawtype = 'r'; + //rectangleDrawer.reset(); break; case 2: - triangleDrawer.reset(); - drawtype = 't'; + //triangleDrawer.reset(); break; } } - +/* if (theEvent.isFrom(animateList)){ switch((int) animateList.getValue()) { case 0: @@ -226,8 +228,8 @@ class Menu { if (theEvent.isFrom(presetsList)){ preset = (int) presetsList.getValue(); } + */ } -*/ } /*