public void drawFunctionToGraphic(Graphics2D g, int x, int y, int UNITYX, int UNITYY) { int _x, _y; g.setColor(Color.red); g.drawString("f(x) = " + F.toString(), 15, 20); g.setColor(Color.blue); for (double i = 0; ; i += EPSILON) { _x = (int) (i * UNITYX) + x / 2; _y = -(int) (F.evaluate(i) * UNITYY) + y / 2; g.drawLine( _x, _y, (int) ((i + EPSILON) * UNITYX) + x / 2, -(int) (F.evaluate(i + EPSILON) * UNITYY) + y / 2); if (_x < 0 || _x > x || _y < 0 || _y > y) break; } for (double i = 0; ; i -= EPSILON) { _x = (int) (i * UNITYX) + x / 2; _y = -(int) (F.evaluate(i) * UNITYY) + y / 2; g.drawLine( _x, _y, (int) ((i + EPSILON) * UNITYX) + x / 2, -(int) (F.evaluate(i + EPSILON) * UNITYY) + y / 2); if (_x < 0 || _x > x || _y < 0 || _y > y) break; } }
public double evaluate_1(double value) { return F.evaluate_1(value); }