Package com.dkt.graphics.extras
Class GFormula
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.elements.Graphic
com.dkt.graphics.extras.GFormula
This class represents a basic Formula.
It translates a
It translates a
Calculable into a Graphic.- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionGFormula(Calculable formula) Creates a newGFormulafor the givenCalculableobject -
Method Summary
Modifier and TypeMethodDescriptionvoidcalculate(double xs, double xf, double step) Calculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing.voidCalculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing.
Note: The element must be in the position(0, 0)otherwise it the graphics will be in the incorrect position.voidcalculateArea(double xs, double xf, double step) Calculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing.voidcalculatePath(double xs, double xf, double step) Calculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing.voidsetAreaPaint(Paint paint) Sets thePaintused for the area below the curveMethods inherited from class com.dkt.graphics.elements.Graphic
add, addAll, addCopyOfAll, clone, contains, draw, equals, flatten, getCount, hashCode, indexOf, isVisible, iterator, move, remove, removeAll, setVisible, traslateMethods inherited from class com.dkt.graphics.elements.GraphicE
getPaint, getStroke, setPaint, setStrokeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
GFormula
Creates a newGFormulafor the givenCalculableobject- Parameters:
formula- theCalculableobject that contains the relation- Throws:
IllegalArgumentException- if formula isnull
-
-
Method Details
-
calculate
Calculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing.- Parameters:
xs- The starting point of the intervalxf- The end point of the intervalstep- The step used to f- Throws:
IntervalException- ifxs < xforstep < 0orstep > xf - xs- See Also:
-
calculate
public void calculate(double xs, double xf, double step, GraphicE element) throws IntervalException, IllegalArgumentException Calculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing.
Note: The element must be in the position(0, 0)otherwise it the graphics will be in the incorrect position. Of course this will come in handy withGraphicthat have strange shapes.
Note 2: For some reason that I was unable to figure out yet, this method fails when usingGRegPoly.- Parameters:
xs- The starting point of the intervalxf- The end point of the intervalstep- The step used to felement- The element that will be copied and translated in order to generate this value- Throws:
IntervalException- ifxs < xforstep < 0orstep > xf - xsIllegalArgumentException- ifelementisnull- See Also:
-
calculatePath
Calculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing. The drawing will be based on lines.- Parameters:
xs- The starting point of the intervalxf- The end point of the intervalstep- The step used to f- Throws:
IntervalException- ifxs < xforstep < 0orstep > xf - xs- See Also:
-
setAreaPaint
Sets thePaintused for the area below the curve- Parameters:
paint- ThePaintthat will be used to render the area- Throws:
IllegalArgumentException- ifpaintisnull
-
calculateArea
Calculates the formula, this method must be called before the method is printed in the canvas, otherwise it will print nothing. The drawing will be based on areas.
Note: you must set the area paint first- Parameters:
xs- The starting point of the intervalxf- The end point of the intervalstep- The step used to f- Throws:
IntervalException- ifxs < xforstep < 0orstep > xf - xs- See Also:
-