Skip to content

Commit

Permalink
let people poke inside boxes
Browse files Browse the repository at this point in the history
show coords, length/size of objects
add global options
add 3d zoom with wheel
add setuplist.txt
fix import header
fixes for touch
  • Loading branch information
pfalstad committed Jan 8, 2017
1 parent 9fc8071 commit 6c96b20
Show file tree
Hide file tree
Showing 14 changed files with 352 additions and 67 deletions.
1 change: 1 addition & 0 deletions src/com/falstad/ripple/client/Box.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void prepare() {
RippleSim.drawWall(bottomLeft.x, bottomLeft.y, bottomRight.x, bottomRight.y);
}

// let people poke inside box
boolean hitTestInside(double x, double y) { return false; }

int getDumpType() { return 'b'; }
Expand Down
3 changes: 3 additions & 0 deletions src/com/falstad/ripple/client/Cavity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ void prepare() {
prepare();
}

// let people poke inside
boolean hitTestInside(double x, double y) { return false; }

int getDumpType() { return 'c'; }
}
9 changes: 9 additions & 0 deletions src/com/falstad/ripple/client/DragObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,13 @@ void rescale(double scale) {
}
setTransform();
}

String selectText() {
if (handles.size() != 2)
return null;
DragHandle dh1 = handles.get(0);
DragHandle dh2 = handles.get(1);
int len = (int) Math.round(Math.hypot(dh1.x-dh2.x, dh1.y-dh2.y));
return "length = " + len;
}
}
24 changes: 24 additions & 0 deletions src/com/falstad/ripple/client/EditOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.falstad.ripple.client;

public class EditOptions implements Editable {
RippleSim sim;
public EditOptions(RippleSim s) { sim = s; }
EditInfo offsetEditInfo;
public EditInfo getEditInfo(int n) {
if (n == 0)
return new EditInfo("Grid size", sim.windowWidth, 0, 0).setDimensionless();
if (n == 1)
return offsetEditInfo = new EditInfo("Absorbing area width", sim.windowOffsetX, 0, 0).setDimensionless();
return null;
}
public void setEditValue(int n, EditInfo ei) {
if (n == 0 && ei.value > 0) {
sim.setResolution((int)ei.value);
offsetEditInfo.value = sim.windowOffsetX;
EditDialog.theEditDialog.updateValue(offsetEditInfo);
}
if (n == 1 && ei.value > 0)
sim.setResolution(sim.windowWidth, (int)ei.value);
}

}
3 changes: 3 additions & 0 deletions src/com/falstad/ripple/client/MediumBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ void prepare() {
speedIndex, speedIndex);
}

// let people poke inside
boolean hitTestInside(double x, double y) { return false; }

public EditInfo getEditInfo(int n) {
if (n == 0)
return new EditInfo("Speed Index", speedIndex, 0, 1).
Expand Down
2 changes: 2 additions & 0 deletions src/com/falstad/ripple/client/MediumEllipse.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void prepare() {
return ht;
}

/*
@Override boolean hitTestInside(double x, double y) {
x -= (topLeft.x+topRight.x)/2;
y -= (topLeft.y+bottomLeft.y)/2;
Expand All @@ -27,6 +28,7 @@ void prepare() {
double ht = Math.sqrt(x*x/(a*a)+y*y/(b*b));
return ht <= 1;
}
*/

@Override void drawSelection() {
RippleSim.drawEllipse(
Expand Down
4 changes: 4 additions & 0 deletions src/com/falstad/ripple/client/ModeBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ public void setEditValue(int n, EditInfo ei) {
String dump() { return super.dump() + " " + xmode + " " + ymode + " " + randomize + " " + box; }

int getDumpType() { return 'M'; }

boolean hitTestInside(double x, double y) {
return false;
}
}
3 changes: 3 additions & 0 deletions src/com/falstad/ripple/client/Parabola.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ void prepare() {
prepare();
}

// let people poke inside
boolean hitTestInside(double x, double y) { return false; }

int getDumpType() { return 'p'; }

}
3 changes: 3 additions & 0 deletions src/com/falstad/ripple/client/RectDragObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,7 @@ String dumpHandles() {
return " " + topLeft.x + " " + topLeft.y + " " + bottomRight.x + " " + bottomRight.y;
}

String selectText() {
return "" + width() + " x " + height();
}
}
Loading

0 comments on commit 6c96b20

Please sign in to comment.