diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e035d51..b90d99e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,12 +2,12 @@ - + - - + + @@ -29,11 +29,23 @@ + + + + + + + + + + + + - - + + @@ -45,21 +57,11 @@ - + - - - - - - - - - - - - + + @@ -70,8 +72,8 @@ - - + + @@ -79,21 +81,21 @@ - - + + - - + + - - + + - - + + @@ -102,18 +104,20 @@ - + - + + + - - + + - - + + @@ -122,8 +126,8 @@ - - + + @@ -170,9 +174,7 @@ - @@ -474,11 +479,11 @@ - + - + @@ -606,10 +611,6 @@ - - - - @@ -684,10 +685,6 @@ - - - - @@ -721,10 +718,6 @@ - - - - @@ -735,10 +728,6 @@ - - - - @@ -749,10 +738,6 @@ - - - - @@ -763,10 +748,6 @@ - - - - @@ -777,10 +758,6 @@ - - - - @@ -791,10 +768,6 @@ - - - - @@ -879,47 +852,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -944,60 +876,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -1012,14 +894,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ClickGetter.java b/src/ClickGetter.java index 57871d2..758a92c 100644 --- a/src/ClickGetter.java +++ b/src/ClickGetter.java @@ -1,3 +1,7 @@ +/* + Interface for handling mouse clicks + */ + public interface ClickGetter { boolean click(int mouseX, int mouseY); } diff --git a/src/EuglenaApplet.java b/src/EuglenaApplet.java index 99333f0..147fecd 100644 --- a/src/EuglenaApplet.java +++ b/src/EuglenaApplet.java @@ -4,9 +4,10 @@ import processing.core.*; public class EuglenaApplet extends PApplet { /* This is the main Processing applet. + This applet draws the main window and menu */ - final int cameraMode = 9; + final int cameraMode = 8; final int whichArduino = 0; // Hardware diff --git a/src/LEDControl.java b/src/LEDControl.java index 2999eb3..a035618 100644 --- a/src/LEDControl.java +++ b/src/LEDControl.java @@ -3,6 +3,10 @@ import static processing.core.PApplet.*; import cc.arduino.*; class LEDControl { + /* + LED controller + */ + final int comRate = 57600; Arduino arduino; diff --git a/src/Line.java b/src/Line.java index ba8496a..e79f16b 100644 --- a/src/Line.java +++ b/src/Line.java @@ -3,6 +3,10 @@ import static processing.core.PApplet.*; class Line { + /* + Class representing a line + */ + float x1, y1, x2, y2; int color, brushSize; boolean visible; @@ -31,6 +35,14 @@ class Line { ProjectorCommand makeProjectorCommand() { + /* + Create a ProjectorCommand which draws ourselves! + + The ```(arg) -> {my(); commands(); here(); return v}``` syntax creates a + "closure", which is just a function that we write on-the-fly and + store for later use. + */ + return (ProjectorApplet p) -> { if (!visible) { //done drawing already @@ -54,6 +66,11 @@ class Line { } ClickGetter makeClickGetter(ProjectorApplet p) { + /* + Create a ClickGetter which can accept incoming mouse clicks + and use them to update ourselves. + */ + return (int x, int y) -> { if (!point1complete){ x1 = x; diff --git a/src/Menu.java b/src/Menu.java index 8df3a49..9eac439 100644 --- a/src/Menu.java +++ b/src/Menu.java @@ -3,6 +3,10 @@ import static processing.core.PApplet.*; import controlP5.*; class Menu { + /* + Right-side menu + */ + final int width = 200; // Width of toolbar on left side of display EuglenaApplet parent; @@ -189,6 +193,11 @@ class Menu { } void controlEvent(ControlEvent theEvent) { + /* + Handle a controlEvent -- controlP5 generates these events anytime + a menu item is clicked. + */ + //println(theEvent); if (theEvent.isFrom(shapesList)) { switch((int) shapesList.getValue()) { diff --git a/src/ProjectorCommand.java b/src/ProjectorCommand.java index 9a77015..410b7ac 100644 --- a/src/ProjectorCommand.java +++ b/src/ProjectorCommand.java @@ -1,3 +1,21 @@ +/* + This file defines the ProjectorCommand interface. + + It says, "if you want a class you wrote to also be a ProjectorCommand, + it must have a method ```run``` which takes a ProjectorApplet and + returns a boolean". + + You can quickly make a ProjectorCommand by using the syntax + + yourLocalVariable = 5; + ProjectorCommand yourCommand = (ProjectorApplet p) -> { + your(yourLocalVariable); + code(); + here(); + } + return yourCommand; + */ + public interface ProjectorCommand { boolean run(ProjectorApplet p) throws ProjectorCommandException; }