Browse Source

shapes! and reset

master
jan 5 years ago
parent
commit
8c41aa417a
  1. 1
      .idea/compiler.xml
  2. 222
      .idea/workspace.xml
  3. 2
      src/Calibrator.java
  4. 1
      src/Ellipse.java
  5. 22
      src/EuglenaApplet.java
  6. 74
      src/Line.java
  7. 79
      src/LineClass.java
  8. 139
      src/Menu.java
  9. 4
      src/Procedure.java
  10. 22
      src/ProjectorApplet.java
  11. 74
      src/Rectangle.java
  12. 88
      src/RectangleClass.java
  13. 86
      src/Triangle.java
  14. 98
      src/TriangleClass.java
  15. 12
      src/clearDisplay.java

1
.idea/compiler.xml

@ -26,7 +26,6 @@
<file url="file://$PROJECT_DIR$/src/TranslateClass.java" />
<file url="file://$PROJECT_DIR$/src/translateCircle.java" />
<file url="file://$PROJECT_DIR$/src/developer.java" />
<file url="file://$PROJECT_DIR$/src/LineClass.java" />
<file url="file://$PROJECT_DIR$/src/shrinkingWindow.java" />
<file url="file://$PROJECT_DIR$/src/ExpandClass.java" />
<file url="file://$PROJECT_DIR$/src/rectangularStim.java" />

222
.idea/workspace.xml

@ -1,10 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="6e752a8c-6cb9-4ef9-9031-0329ce15fcb4" name="Default" comment="">
<list default="true" id="6e752a8c-6cb9-4ef9-9031-0329ce15fcb4" name="Default" comment="Ellipse can be drawn...">
<change type="DELETED" beforePath="$PROJECT_DIR$/src/Procedure.java" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/src/clearDisplay.java" afterPath="" />
<change type="MOVED" beforePath="$PROJECT_DIR$/src/LineClass.java" afterPath="$PROJECT_DIR$/src/Line.java" />
<change type="MOVED" beforePath="$PROJECT_DIR$/src/RectangleClass.java" afterPath="$PROJECT_DIR$/src/Rectangle.java" />
<change type="MOVED" beforePath="$PROJECT_DIR$/src/TriangleClass.java" afterPath="$PROJECT_DIR$/src/Triangle.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/compiler.xml" afterPath="$PROJECT_DIR$/.idea/compiler.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Calibrator.java" afterPath="$PROJECT_DIR$/src/Calibrator.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Ellipse.java" afterPath="$PROJECT_DIR$/src/Ellipse.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/EuglenaApplet.java" afterPath="$PROJECT_DIR$/src/EuglenaApplet.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/LEDControl.java" afterPath="$PROJECT_DIR$/src/LEDControl.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/euglena_basic_stimuli.java" afterPath="$PROJECT_DIR$/src/euglena_basic_stimuli.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Menu.java" afterPath="$PROJECT_DIR$/src/Menu.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/ProjectorApplet.java" afterPath="$PROJECT_DIR$/src/ProjectorApplet.java" />
</list>
<ignored path="processing-intellij.iws" />
<ignored path=".idea/workspace.xml" />
@ -28,8 +37,8 @@
<file leaf-file-name="euglena_basic_stimuli.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/euglena_basic_stimuli.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1787">
<caret line="82" column="0" selection-start-line="82" selection-start-column="0" selection-end-line="82" selection-end-column="0" />
<state relative-caret-position="193">
<caret line="59" column="15" selection-start-line="59" selection-start-column="15" selection-end-line="59" selection-end-column="15" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -48,11 +57,11 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="EuglenaApplet.java" pinned="false" current-in-tab="false">
<file leaf-file-name="EuglenaApplet.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/EuglenaApplet.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="565">
<caret line="101" column="22" selection-start-line="101" selection-start-column="22" selection-end-line="101" selection-end-column="22" />
<state relative-caret-position="889">
<caret line="105" column="11" selection-start-line="105" selection-start-column="11" selection-end-line="105" selection-end-column="11" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#474#475#0" expanded="true" />
@ -67,30 +76,37 @@
<file leaf-file-name="ProjectorApplet.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ProjectorApplet.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1113">
<caret line="44" column="0" selection-start-line="44" selection-start-column="0" selection-end-line="44" selection-end-column="0" />
<state relative-caret-position="648">
<caret line="60" column="33" selection-start-line="60" selection-start-column="33" selection-end-line="60" selection-end-column="33" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#514#515#0" expanded="true" />
<element signature="e#573#574#0" expanded="true" />
<element signature="e#549#550#0" expanded="true" />
<element signature="e#608#609#0" expanded="true" />
<element signature="e#1255#1256#0" expanded="true" />
<element signature="e#1282#1283#0" expanded="true" />
<element signature="e#1333#1334#0" expanded="true" />
<element signature="e#1373#1374#0" expanded="true" />
<element signature="e#1404#1405#0" expanded="true" />
<element signature="e#1434#1435#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Ellipse.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Ellipse.java">
<file leaf-file-name="Calibrator.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Calibrator.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="573">
<caret line="54" column="5" selection-start-line="54" selection-start-column="5" selection-end-line="54" selection-end-column="5" />
<state relative-caret-position="396">
<caret line="101" column="29" selection-start-line="101" selection-start-column="29" selection-end-line="101" selection-end-column="29" />
<folding>
<element signature="e#0#3821#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="LEDControl.java" pinned="false" current-in-tab="true">
<file leaf-file-name="LEDControl.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/LEDControl.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
@ -105,8 +121,8 @@
<file leaf-file-name="Menu.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Menu.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="36">
<caret line="190" column="43" selection-start-line="190" selection-start-column="43" selection-end-line="190" selection-end-column="43" />
<state relative-caret-position="8424">
<caret line="234" column="26" selection-start-line="234" selection-start-column="26" selection-end-line="234" selection-end-column="26" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -141,7 +157,6 @@
<option value="$PROJECT_DIR$/src/heatup.java" />
<option value="$PROJECT_DIR$/src/TriangleClass.java" />
<option value="$PROJECT_DIR$/src/RectangleClass.java" />
<option value="$PROJECT_DIR$/src/Calibrator.java" />
<option value="$PROJECT_DIR$/lib/core.jar!/processing/core/PApplet.class" />
<option value="$PROJECT_DIR$/src/Camera.java" />
<option value="$PROJECT_DIR$/src/EllipseClass.java" />
@ -149,13 +164,18 @@
<option value="$PROJECT_DIR$/src/ProjectorCommand.java" />
<option value="$PROJECT_DIR$/src/MouseGetter.java" />
<option value="$PROJECT_DIR$/src/ClickGetter.java" />
<option value="$PROJECT_DIR$/src/ProjectorApplet.java" />
<option value="$PROJECT_DIR$/src/Procedure.java" />
<option value="$PROJECT_DIR$/src/LEDControl.java" />
<option value="$PROJECT_DIR$/src/euglena_basic_stimuli.java" />
<option value="$PROJECT_DIR$/src/Ellipse.java" />
<option value="$PROJECT_DIR$/src/Rectangle.java" />
<option value="$PROJECT_DIR$/src/Calibrator.java" />
<option value="$PROJECT_DIR$/src/Line.java" />
<option value="$PROJECT_DIR$/src/Triangle.java" />
<option value="$PROJECT_DIR$/src/clearDisplay.java" />
<option value="$PROJECT_DIR$/src/ProjectorApplet.java" />
<option value="$PROJECT_DIR$/src/Menu.java" />
<option value="$PROJECT_DIR$/src/EuglenaApplet.java" />
<option value="$PROJECT_DIR$/src/LEDControl.java" />
<option value="$PROJECT_DIR$/src/euglena_basic_stimuli.java" />
</list>
</option>
</component>
@ -193,7 +213,7 @@
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.IDE.editor.colors.General" />
<property name="settings.editor.selected.configurable" value="reference.projectsettings.compiler.excludes" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="project.structure.last.edited" value="Problems" />
<property name="project.structure.proportion" value="0.15" />
@ -536,8 +556,14 @@
<caret line="33" column="18" selection-start-line="33" selection-start-column="8" selection-end-line="33" selection-end-column="18" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#514#515#0" expanded="true" />
<element signature="e#573#574#0" expanded="true" />
<element signature="e#549#550#0" expanded="true" />
<element signature="e#608#609#0" expanded="true" />
<element signature="e#1255#1256#0" expanded="true" />
<element signature="e#1282#1283#0" expanded="true" />
<element signature="e#1333#1334#0" expanded="true" />
<element signature="e#1373#1374#0" expanded="true" />
<element signature="e#1404#1405#0" expanded="true" />
<element signature="e#1434#1435#0" expanded="true" />
</folding>
</state>
</provider>
@ -578,7 +604,7 @@
<state relative-caret-position="828">
<caret line="47" column="36" selection-start-line="47" selection-start-column="36" selection-end-line="47" selection-end-column="36" />
<folding>
<element signature="e#0#3781#0" expanded="true" />
<element signature="e#0#3821#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
@ -749,22 +775,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/TriangleClass.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="684">
<caret line="40" column="3" selection-start-line="40" selection-start-column="3" selection-end-line="40" selection-end-column="3" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/RectangleClass.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-15">
<caret line="10" column="2" selection-start-line="10" selection-start-column="2" selection-end-line="10" selection-end-column="2" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/snapshot.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="126">
@ -799,85 +809,102 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Calibrator.java">
<entry file="jar://$PROJECT_DIR$/lib/core.jar!/processing/core/PApplet.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="684">
<caret line="97" column="41" selection-start-line="97" selection-start-column="41" selection-end-line="97" selection-end-column="41" />
<folding>
<element signature="e#0#3781#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
<state relative-caret-position="812">
<caret line="887" column="16" selection-start-line="887" selection-start-column="16" selection-end-line="887" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Procedure.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<state relative-caret-position="36">
<caret line="1" column="17" selection-start-line="1" selection-start-column="17" selection-end-line="1" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/core.jar!/processing/core/PApplet.class">
<entry file="file://$PROJECT_DIR$/src/Presets.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="812">
<caret line="887" column="16" selection-start-line="887" selection-start-column="16" selection-end-line="887" selection-end-column="16" />
<state relative-caret-position="72">
<caret line="30" column="6" selection-start-line="30" selection-start-column="6" selection-end-line="30" selection-end-column="6" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Ellipse.java">
<entry file="file://$PROJECT_DIR$/src/euglena_basic_stimuli.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="573">
<caret line="54" column="5" selection-start-line="54" selection-start-column="5" selection-end-line="54" selection-end-column="5" />
<state relative-caret-position="193">
<caret line="59" column="15" selection-start-line="59" selection-start-column="15" selection-end-line="59" selection-end-column="15" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Menu.java">
<entry file="file://$PROJECT_DIR$/src/Line.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="36">
<caret line="190" column="43" selection-start-line="190" selection-start-column="43" selection-end-line="190" selection-end-column="43" />
<state relative-caret-position="961">
<caret line="74" column="0" selection-start-line="74" selection-start-column="0" selection-end-line="74" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ProjectorApplet.java">
<entry file="file://$PROJECT_DIR$/src/Triangle.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1113">
<caret line="44" column="0" selection-start-line="44" selection-start-column="0" selection-end-line="44" selection-end-column="0" />
<state relative-caret-position="849">
<caret line="29" column="27" selection-start-line="29" selection-start-column="27" selection-end-line="29" selection-end-column="27" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#514#515#0" expanded="true" />
<element signature="e#573#574#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/euglena_basic_stimuli.java">
<entry file="file://$PROJECT_DIR$/src/testing.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1787">
<caret line="82" column="0" selection-start-line="82" selection-start-column="0" selection-end-line="82" selection-end-column="0" />
<state relative-caret-position="180">
<caret line="5" column="10" selection-start-line="5" selection-start-column="10" selection-end-line="5" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Ellipse.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="288">
<caret line="8" column="20" selection-start-line="0" selection-start-column="0" selection-end-line="82" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/EuglenaApplet.java">
<entry file="file://$PROJECT_DIR$/src/Rectangle.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="565">
<caret line="101" column="22" selection-start-line="101" selection-start-column="22" selection-end-line="101" selection-end-column="22" />
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/clearDisplay.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="144">
<caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Menu.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="8424">
<caret line="234" column="26" selection-start-line="234" selection-start-column="26" selection-end-line="234" selection-end-column="26" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#474#475#0" expanded="true" />
<element signature="e#519#520#0" expanded="true" />
<element signature="e#2486#2487#0" expanded="true" />
<element signature="e#2529#2530#0" expanded="true" />
</folding>
</state>
</provider>
@ -892,6 +919,49 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Calibrator.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="396">
<caret line="101" column="29" selection-start-line="101" selection-start-column="29" selection-end-line="101" selection-end-column="29" />
<folding>
<element signature="e#0#3821#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ProjectorApplet.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="648">
<caret line="60" column="33" selection-start-line="60" selection-start-column="33" selection-end-line="60" selection-end-column="33" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#549#550#0" expanded="true" />
<element signature="e#608#609#0" expanded="true" />
<element signature="e#1255#1256#0" expanded="true" />
<element signature="e#1282#1283#0" expanded="true" />
<element signature="e#1333#1334#0" expanded="true" />
<element signature="e#1373#1374#0" expanded="true" />
<element signature="e#1404#1405#0" expanded="true" />
<element signature="e#1434#1435#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/EuglenaApplet.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="889">
<caret line="105" column="11" selection-start-line="105" selection-start-column="11" selection-end-line="105" selection-end-column="11" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#474#475#0" expanded="true" />
<element signature="e#519#520#0" expanded="true" />
<element signature="e#2486#2487#0" expanded="true" />
<element signature="e#2529#2530#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>

2
src/Calibrator.java

@ -107,6 +107,8 @@ class Calibrator {
projector.text("world!", x0+20, y0+110);
// Four dots used for calibration (may need to change code so that it better matches the math used to convert other points)
projector.ellipseMode(CORNER);
projector.fill(projector.color(0, 0, 190));
projector.ellipse(x0, y0, 5, 5);

1
src/Ellipse.java

@ -13,6 +13,7 @@ class Ellipse {
Ellipse(int color, int penWidth) {
this.color = color;
this.brushSize = penWidth;
this.visible = false;
this.centerPointComplete = false;
this.widthComplete = false;

22
src/EuglenaApplet.java

@ -116,5 +116,27 @@ public class EuglenaApplet extends PApplet {
line(len, 0, len - 8, 8);
popMatrix();
}
void reset() {
if (projectorApplet.calibrator.active) {
projectorApplet.calibrator.deactivate();
} else {
projectorApplet.calibrator.deactivate();
ledControl.allOff();
projectorApplet.clear();
// lines.clear();
// ellipses.clear();
// rectangles.clear();
// triangles.clear();
// shrinkwindows.clear();
// expandwindows.clear();
// translatewindows.clear();
// rotatewindows.clear();
}
}
}

74
src/Line.java

@ -0,0 +1,74 @@
import processing.core.*;
import static processing.core.PApplet.*;
class Line {
float x1, y1, x2, y2;
int color, brushSize;
boolean visible;
private boolean point1complete;
Line(int color, int penWidth) {
this.color = color;
this.brushSize = penWidth;
this.visible = true;
this.point1complete = false;
}
Line(float x1, float y1, float x2, float y2, int color, int penWidth) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
this.brushSize = penWidth;
this.visible = true;
this.point1complete = true;
}
ProjectorCommand drawCommand() {
return (ProjectorApplet p) -> {
if (!visible) {
//done drawing already
return true;
}
float old_strokeWeight = p.g.strokeWeight;
int old_strokeColor = p.g.strokeColor;
p.strokeWeight(brushSize);
p.stroke(color);
p.noFill();
p.line(p.convertXCoord(x1), p.convertYCoord(y1),
p.convertXCoord(x2), p.convertYCoord(y2));
p.strokeWeight(old_strokeWeight);
p.stroke(old_strokeColor);
return true;
};
}
ClickGetter makeClickGetter(ProjectorApplet p) {
return (int x, int y) -> {
if (!point1complete){
x1 = x;
y1 = y;
point1complete = true;
return false;
} else {
x2 = x;
y2 = y;
visible = true;
p.commandQueue.add(drawCommand());
return true;
}
};
}
}

79
src/LineClass.java

@ -1,79 +0,0 @@
class LineDrawer {
Line lineinprogress;
boolean point1complete;
void reset() {
lineinprogress = new Line(-1,-1,-1,-1);
lineinprogress.visible = false;
point1complete = false;
}
LineDrawer(){
this.reset();
}
void mouseClicked(float x, float y){
if (!point1complete){
lineinprogress.x1 = x;
lineinprogress.y1 = y;
point1complete = true;
} else {
lineinprogress.x2 = x;
lineinprogress.y2 = y;
lineinprogress.visible = true;
lines.add(lineinprogress);
lineinprogress.draw();
this.reset();
}
}
}
class Line {
float x1, y1, x2, y2;
int red, green, blue, brushSize;
boolean visible;
Line(float x1, float y1, float x2, float y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.red = rVal;
this.green = gVal;
this.blue = bVal;
this.brushSize = penWidth;
this.visible = true;
}
void draw() {
if (visible) {
float old_strokeWeight = g.strokeWeight;
int old_strokeColor = g.strokeColor;
strokeWeight(brushSize);
stroke(color(red, green, blue));
line(convertXCoord(x1), convertYCoord(y1), convertXCoord(x2), convertYCoord(y2));
strokeWeight(old_strokeWeight);
stroke(old_strokeColor);
print(rVal);
print(",");
print(gVal);
print(",");
print(bVal);
print("\n");
print(red);
print(",");
print(green);
print(",");
print(blue);
print("\n");
}
}
}

139
src/Menu.java

@ -189,6 +189,9 @@ class Menu {
}
void controlEvent(ControlEvent theEvent) {
println(theEvent);
println(theEvent.getName());
println(theEvent.getLabel());
if (theEvent.isFrom(shapesList)) {
switch((int) shapesList.getValue()) {
case 0:
@ -196,117 +199,67 @@ class Menu {
.makeClickGetter(parent.projectorApplet);
break;
case 1:
//rectangleDrawer.reset();
parent.clickGetter = new Rectangle(parent.penColor, parent.penWidth)
.makeClickGetter(parent.projectorApplet);
break;
case 2:
//triangleDrawer.reset();
parent.clickGetter = new Triangle(parent.penColor, parent.penWidth)
.makeClickGetter(parent.projectorApplet);
break;
}
}
/*
if (theEvent.isFrom(animateList)){
} else if (theEvent.isFrom(animateList)){
switch((int) animateList.getValue()) {
case 0:
shrink.reset();
drawtype = 's';
// shrink.reset();
// drawtype = 's';
break;
case 1:
expand.reset();
drawtype = 'x';
// expand.reset();
// drawtype = 'x';
break;
case 2:
translate.reset();
drawtype = 'm';
// translate.reset();
// drawtype = 'm';
break;
case 3:
rotate.reset();
drawtype = 'c';
// rotate.reset();
// drawtype = 'c';
break;
}
}
if (theEvent.isFrom(presetsList)){
preset = (int) presetsList.getValue();
}
*/
}
}
/*
*/
/* Adds all features to initial display including toolbar and camera display */
/*
void Commit() {
rVal = int(menu.redField.getText());
gVal = int(menu.greenField.getText());
bVal = int(menu.blueField.getText());
penWidth = int(menu.penwidthField.getText());
bgVal = int(menu.backgroundField.getText());
lagTime = float(menu.lagField.getText());
totalTime = int(menu.totaltimeField.getText());
speed = int(menu.speedField.getText());
// print(rVal);
// print(",");
// print(gVal);
// print(",");
// print(bVal);
// print("\n");
// print(speed);
// print("\n");
}
void Reset() {
if (calibrator.active = true){
calibrator.toggle();
} else if (theEvent.isFrom(presetsList)){
// preset = (int) presetsList.getValue();
} else {
calibrator.active = false;
clearDisplay();
switch (theEvent.getLabel()) {
case "Commit":
int rVal = Integer.parseInt(redField.getText());
int gVal = Integer.parseInt(greenField.getText());
int bVal = Integer.parseInt(blueField.getText());
parent.penColor = parent.color(rVal, gVal, bVal);
parent.penWidth = Integer.parseInt(penwidthField.getText());
parent.projectorApplet.setBgColor(Integer.parseInt(backgroundField.getText()));
// parent.lagTime = Integer.parseInt(lagField.getText());
// parent.totalTime = Integer.parseInt(totaltimeField.getText());
// parent.speed = Integer.parseInt(speedField.getText());
break;
lines.clear();
ellipses.clear();
rectangles.clear();
triangles.clear();
case "Reset":
parent.reset();
break;
shrinkwindows.clear();
expandwindows.clear();
translatewindows.clear();
rotatewindows.clear();
case "Calibrate":
parent.projectorApplet.calibrator.toggle();
break;
arduino.digitalWrite(left, Arduino.LOW);
arduino.digitalWrite(right, Arduino.LOW);
arduino.digitalWrite(up, Arduino.LOW);
arduino.digitalWrite(down, Arduino.LOW);
case "Eraser":
parent.penColor = parent.color(0, 0, 0);
break;
t = 0;
t2 = 0;
t3 = 0;
t_temp = 0;
case "Line":
parent.clickGetter = new Line(parent.penColor, parent.penWidth)
.makeClickGetter(parent.projectorApplet);
break;
}
}
}
}
void Calibrate() {
frame.setLocation(0,0);
calibrator.toggle();
}
void Eraser() {
rVal = 0;
gVal = 0;
bVal = 0;
}
void Line() {
lineDrawer.reset();
drawtype = 'l';
}
*/

4
src/Procedure.java

@ -1,4 +0,0 @@
public interface Procedure {
void execute();
}

22
src/ProjectorApplet.java

@ -8,6 +8,8 @@ class ProjectorApplet extends PApplet {
final static int centerX = 860;
final static int centerY = 540;
int bgColor = color(0, 0, 0);
EuglenaApplet parent;
Calibrator calibrator;
@ -26,6 +28,7 @@ class ProjectorApplet extends PApplet {
@Override
public void setup() {
clear();
smooth();
// calibrator.activate(); //for testing
}
@ -43,6 +46,25 @@ class ProjectorApplet extends PApplet {
}
}
public void clear() {
fill(bgColor);
noStroke();
rectMode(CORNER);
rect(0, 0, width * 4, height * 4);
}
public void setBgColor(int c) {
bgColor = c;
}
public void setBgColor(int r, int b, int g) {
bgColor = color(r, g, b);
}
public int getBgColor() {
return bgColor;
}
public float convertXCoord(float x) {
return (x / calibrator.magx + width * calibrator.offsetx);
}

74
src/Rectangle.java

@ -0,0 +1,74 @@
import processing.core.*;
import static processing.core.PApplet.*;
class Rectangle {
float corner1x, corner1y, corner2x, corner2y;
int color, brushSize;
boolean visible;
private boolean corner1complete;
Rectangle(int color, int penWidth) {
this.color = color;
this.brushSize = penWidth;
this.visible = false;
this.corner1complete = false;
}
Rectangle(float corner1x, float corner1y, float corner2x, float corner2y, int color, int penWidth) {
this.corner1x = corner1x;
this.corner1y = corner1y;
this.corner2x = corner2x;
this.corner2y = corner2y;
this.color = color;
this.brushSize = penWidth;
this.visible = true;
this.corner1complete = true;
}
ProjectorCommand drawCommand() {
return (ProjectorApplet p) -> {
if (!visible) {
//done drawing already
return true;
}
float old_strokeWeight = p.g.strokeWeight;
int old_strokeColor = p.g.strokeColor;
p.rectMode(CORNERS);
p.strokeWeight(brushSize);
p.stroke(color);
p.noFill();
p.rect(p.convertXCoord(corner1x), p.convertYCoord(corner1y),
p.convertXCoord(corner2x), p.convertYCoord(corner2y));
p.strokeWeight(old_strokeWeight);
p.stroke(old_strokeColor);
return true;
};
}
ClickGetter makeClickGetter(ProjectorApplet p) {
return (int x, int y) -> {
if (!corner1complete){
corner1x = x;
corner1y = y;
corner1complete = true;
return false;
} else {
corner2x = x;
corner2y = y;
visible = true;
p.commandQueue.add(drawCommand());
return true;
}
};
}
}

88
src/RectangleClass.java

@ -1,88 +0,0 @@
//class RectangleDrawer {
//
// Rectangle rectangleinprogress;
//
// boolean corner1complete;
//
// void reset() {
// rectangleinprogress = new Rectangle(-1,-1,0,0);
// rectangleinprogress.visible = false;
// corner1complete = false;
//
// }
//
// RectangleDrawer(){
// this.reset();
// }
//
// void mouseClicked(float x, float y){
// if (!corner1complete){
// rectangleinprogress.corner1x = x;
// rectangleinprogress.corner1y = y;
// corner1complete = true;
//
// } else {
// rectangleinprogress.corner2x = x;
// rectangleinprogress.corner2y = y;
// rectangleinprogress.visible = true;
// rectangles.add(rectangleinprogress);
//
// rectangleinprogress.draw();
// this.reset();
// }
// }
//}
//
//class Rectangle {
//
// float corner1x, corner1y, corner2x, corner2y;
// int red, green, blue, brushSize;
// boolean visible;
//
// Rectangle(float corner1x, float corner1y, float corner2x, float corner2y) {
// this.corner1x = corner1x;
// this.corner1y = corner1y;
// this.corner2x = corner2x;
// this.corner2y = corner2y;
// this.red = rVal;
// this.green = gVal;
// this.blue = bVal;
// this.brushSize = penWidth;
// this.visible = true;
// }
//
// void draw() {
// if (visible) {
// float old_strokeWeight = g.strokeWeight;
// int old_strokeColor = g.strokeColor;
//
// rectMode(CORNERS);
// strokeWeight(brushSize);
// stroke(color(red, green, blue));
// noFill();
//
// rect(convertXCoord(corner1x), convertYCoord(corner1y), convertXCoord(corner2x), convertYCoord(corner2y));
// strokeWeight(old_strokeWeight);
// stroke(old_strokeColor);
//
// print(rVal);
// print(",");
// print(gVal);
// print(",");
// print(bVal);
// print("\n");
//
//
// /*
// print(convertXCoord(corner1x));
// print("\n");
// print(convertYCoord(corner1y));
// print("\n");
// print(convertXCoord(corner2x));
// print("\n");
// print(convertYCoord(corner2y));
// print("\n");
// */
// }
// }
//}

86
src/Triangle.java

@ -0,0 +1,86 @@
import processing.core.*;
import static processing.core.PApplet.*;
class Triangle {
float point1x, point1y, point2x, point2y, point3x, point3y;
int color, brushSize;
boolean visible;
private boolean point1complete, point2complete;
Triangle(int color, int penWidth) {
this.color = color;
this.brushSize = penWidth;
this.visible = false;
this.point1complete = false;
this.point2complete = false;
}
Triangle(float point1x, float point1y, float point2x, float point2y,
float point3x, float point3y, int color, int penWidth) {
this.point1x = point1x;
this.point1y = point1y;
this.point2x = point2x;
this.point2y = point2y;
this.point3x = point3x;
this.point3y = point3y;
this.color = color;
this.brushSize = penWidth;
this.visible = true;
this.point1complete = true;
this.point2complete = true;
}
ProjectorCommand drawCommand() {
return (ProjectorApplet p) -> {
if (!visible) {
//done drawing already
return true;
}
float old_strokeWeight = p.g.strokeWeight;
int old_strokeColor = p.g.strokeColor;
p.strokeWeight(brushSize);
p.stroke(color);
p.noFill();
p.triangle(p.convertXCoord(point1x), p.convertYCoord(point1y),
p.convertXCoord(point2x), p.convertYCoord(point2y),
p.convertXCoord(point3x), p.convertYCoord(point3y));
p.strokeWeight(old_strokeWeight);
p.stroke(old_strokeColor);
return true;
};
}
ClickGetter makeClickGetter(ProjectorApplet p) {
return (int x, int y) -> {
if (!point1complete){
point1x = x;
point1y = y;
point1complete = true;
return false;
} else if (!point2complete) {
point2x = x;
point2y = y;
point2complete = true;
return false;
} else {
point3x = x;
point3y = y;
visible = true;
p.commandQueue.add(drawCommand());
return true;
}
};
}
}

98
src/TriangleClass.java

@ -1,98 +0,0 @@
//class TriangleDrawer {
//
// Triangle triangleinprogress;
//
// boolean point1complete;
// boolean point2complete;
//
// void reset() {
// triangleinprogress = new Triangle(-1,-1,0,0,1,1);
// triangleinprogress.visible = false;
// point1complete = false;
// point2complete = false;
//
// }
//
// TriangleDrawer(){
// this.reset();
// }
//
// void mouseClicked(float x, float y){
// if (!point1complete){
// triangleinprogress.point1x = x;
// triangleinprogress.point1y = y;
// point1complete = true;
//
// } else if (!point2complete) {
// triangleinprogress.point2x = x;
// triangleinprogress.point2y = y;
// point2complete = true;
//
// } else {
// triangleinprogress.point3x = x;
// triangleinprogress.point3y = y;
// triangleinprogress.visible = true;
// triangles.add(triangleinprogress);
//
// triangleinprogress.draw();
// this.reset();
// }
// }
//}
//
//class Triangle {
//
// float point1x, point1y, point2x, point2y, point3x, point3y;
// int red, green, blue, brushSize;
// boolean visible;
//
// Triangle(float point1x, float point1y, float point2x, float point2y, float point3x, float point3y) {
// this.point1x = point1x;
// this.point1y = point1y;
// this.point2x = point2x;
// this.point2y = point2y;
// this.point3x = point3x;
// this.point3y = point3y;
// this.red = rVal;
// this.green = gVal;
// this.blue = bVal;
// this.brushSize = penWidth;
// this.visible = true;
// }
//
// void draw() {
// if (visible) {
// float old_strokeWeight = g.strokeWeight;
// int old_strokeColor = g.strokeColor;
//
// strokeWeight(brushSize);
// stroke(color(red, green, blue));
// noFill();
//
// triangle(convertXCoord(point1x), convertYCoord(point1y), convertXCoord(point2x), convertYCoord(point2y),
// convertXCoord(point3x), convertYCoord(point3y));
// strokeWeight(old_strokeWeight);
// stroke(old_strokeColor);
//
// /*
// print(rVal);
// print(",");
// print(gVal);
// print(",");
// print(bVal);
// print("\n");
// */
//
// /*
// print(convertXCoord(centerx));
// print("\n");
// print(convertYCoord(centery));
// print("\n");
// print(convertXDistance(width));
// print("\n");
// print(convertYDistance(height));
// print("\n");
// */
// }
// }
//}

12
src/clearDisplay.java

@ -1,12 +0,0 @@
/* Draws a black rectangle the size of the second monitor
completely covers whatever was beneath it so that it looks clear */
void clearDisplay() {
// second monitor
fill(color(bgR, bgG, bgB));
noStroke();
rectMode(CORNER);
rect(displayWidth,0,displayWidth*4,displayHeight-10);
}
Loading…
Cancel
Save