private void initHeight() { float h = (height * height) / handler.totalSize(); sliderh = PApplet.constrain(h, minHandleHeight, height/2); }
private void initWidth() { float w = (width * width) / handler.totalSize(); sliderw = PApplet.constrain(w, minSliderWidth, width/2); }
public int getFirstItemIndex() { int i0 = PApplet.constrain((int)(visX0.getTarget() / itemWidth), 0, getCount() - 1); return i0; }
public PVector worldToPixel(PVector pt, boolean undistort) { // Reprojection float invZ = 1.0f / pt.z; int px = PApplet.constrain(PApplet.round((pt.x * invZ * fx) + cx), 0, w - 1); int py = PApplet.constrain(PApplet.round((pt.y * invZ * fy) + cy), 0, h - 1); if (undistort && this.handleDistorsion) { double[] out = device.distort(px, py); return new PVector((float) out[0], (float) out[1]); } else { return new PVector(px, py); } }
String getColLabel() { if (view != null && (viewTask == null || viewTask.isDone())) { float x0 = x.get() - visX0.get() + padding; float y0 = y.get() + padding; float w0 = w - 2 * padding; float h0 = h.get() - 2 * padding; double valx = PApplet.constrain((mouseX - x0) / w0, 0, 1); double valy = PApplet.constrain((mouseY - y0) / h0, 0, 1); return view.getLabelX(valx, valy); } return ""; }
String getRowLabel() { if (view != null && (viewTask == null || viewTask.isDone())) { float x0 = x.get() - visX0.get() + padding; float y0 = y.get() + padding; float w0 = w - 2 * padding; float h0 = h.get() - 2 * padding; double valx = PApplet.constrain((mouseX - x0) / w0, 0, 1); double valy = PApplet.constrain((mouseY - y0) / h0, 0, 1); return view.getLabelY(valx, valy); } return ""; }
void mouseDragged() { if (focused) { dragging = true; float value = 0; if (side == LEFT) { value = PApplet.constrain(mouseX + dx0, 0, rightHandle.x0.get()); } else if (side == RIGHT) { value = PApplet.constrain(mouseX + dx0, leftHandle.x0.get(), width); } value = PApplet.map(value, 0, width, 0, 1); if (side == LEFT) { intf.invoke(NumericalRangeSelector.class, "setLeftValue", selVar, value, true); } else if (side == RIGHT) { intf.invoke(NumericalRangeSelector.class, "setRightValue", selVar, value, true); } resort = false; requestedRangeUpdate = true; } }
public float drag(float newp, float maxd) { float x1 = PApplet.constrain(newp, 0, maxd); int tot = colLabels.getTotItemsCount() - 1; int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot)); mira.browser.openColumn(idx); return x1; } public void stopDrag() {
public float press(float pos, float maxd) { float x1 = PApplet.constrain(pos, 0, maxd); int tot = rowBrowser.getChildrenCount() - 1; int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot)); goTo(idx); return x1; } public int pressSlider(float pos, float size) {
public float press(float pos, float maxd) { float x1 = PApplet.constrain(pos, 0, maxd); int tot = colLabels.getTotItemsCount() - 1; int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot)); mira.browser.openColumn(idx); return x1; } public int pressSlider(float pos, float size) {
public float drag(float newp, float maxd) { float x1 = PApplet.constrain(newp, 0, maxd); int tot = rowBrowser.getChildrenCount() - 1; int idx = PApplet.round(PApplet.map(x1, 0, maxd, 0, tot)); goTo(idx); return x1; } public void stopDrag() {
public float drag(float newp, float maxd) { float y1 = PApplet.constrain(newp, 0, maxd); int tot = rowBrowser.getTotItemsCount() - 1; int n = PApplet.round(PApplet.map(y1, 0, maxd, 0, tot)); RowScroller scroller = rowBrowser.getScroller(); scroller.jumpTo(n); return y1; } public void stopDrag() {
public float press(float pos, float maxd) { float y1 = PApplet.constrain(pos, 0, maxd); int tot = rowBrowser.getTotItemsCount() - 1; int n = PApplet.round(PApplet.map(y1, 0, maxd, 0, tot - 1)); RowScroller scroller = rowBrowser.getScroller(); scroller.jumpTo(n); return y1; } public int pressSlider(float pos, float size) {
public void snap() { if (getCount() == 0) return; float x0 = visX0.getTarget(); float x1 = visX1.getTarget(); int i0 = PApplet.constrain(PApplet.round(x0 / itemWidth), 0, getCount() - 1); int i1 = PApplet.constrain(PApplet.round(x1 / itemWidth), 0, getCount() - 1); if (PApplet.abs(i0 * itemWidth - x0) < SNAP_THRESHOLD) { visX0.setTarget(i0 * itemWidth); } else if (PApplet.abs(i1 * itemWidth - x1) < SNAP_THRESHOLD) { visX1.setTarget(i1 * itemWidth); } }
protected void resetValuesImpl(Variable var) { if (selVar != var) return; leftValue = 0; rightValue = 1; rangeBar.leftStr.set(selVar.formatValue(leftValue)); double sp = selVar.discrete() ? (leftValue < 1 ? 0.5d : 1d) / selVar.getCount() : 0; float svalue = PApplet.constrain((float)(leftValue - sp), 0, 1); rangeBar.targetLeft(svalue); leftHandle.target(svalue); rangeBar.rightStr.set(selVar.formatValue(rightValue)); sp = selVar.discrete() ? (0 < rightValue ? 0.5d : 1d) / selVar.getCount() : 0; svalue = PApplet.constrain((float)(rightValue + sp), 0, 1); rangeBar.targetRight(svalue); rightHandle.target(svalue); }
protected void targetRightValueImpl(Variable var, Float value, Boolean normalized) { if (selVar != var) return; rightValue = normalized ? value : selVar.normalize(value); rangeBar.rightStr.set(selVar.formatValue(rightValue)); double sp = selVar.discrete() ? (0 < rightValue ? 0.5d : 1d) / selVar.getCount() : 0; float svalue = PApplet.constrain((float)(rightValue + sp), 0, 1); rangeBar.targetRight(svalue); rightHandle.target(svalue); }
protected void targetLeftValueImpl(Variable var, Float value, Boolean normalized) { if (selVar != var) return; leftValue = normalized ? value : selVar.normalize(value); rangeBar.leftStr.set(selVar.formatValue(leftValue)); double sp = selVar.discrete() ? (leftValue < 1 ? 0.5d : 1d) / selVar.getCount() : 0; float svalue = PApplet.constrain((float)(leftValue - sp), 0, 1); rangeBar.targetLeft(svalue); leftHandle.target(svalue); }