/** converts the mouse's y into the corresponding value in the function's range */ protected double realY(int mouseY) { if (fvar.isConstant()) return fvar.getYmax(); int h = getHeight(); double ymax = fvar.getYmax(); return ymax + (fvar.getYmin() - ymax) * (mouseY - h * (1 - croppingFactor) * 0.5) / h / croppingFactor; }
/** converts some y in the fun's range into a mouse y coordinate */ protected int getY(double y) { int h = getHeight(); if (fvar.isConstant()) return (int) h / 2; else { double ymax = fvar.getYmax(); return (int) ((h * (1 - croppingFactor) / 2.0) + h * croppingFactor * (y - ymax) / (fvar.getYmin() - ymax)); } }