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
ConstructorDescriptionGFormula
(Calculable formula) Creates a newGFormula
for the givenCalculable
object -
Method Summary
Modifier and TypeMethodDescriptionvoid
calculate
(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.void
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.void
calculateArea
(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.void
calculatePath
(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.void
setAreaPaint
(Paint paint) Sets thePaint
used 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, traslate
Methods inherited from class com.dkt.graphics.elements.GraphicE
getPaint, getStroke, setPaint, setStroke
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
GFormula
Creates a newGFormula
for the givenCalculable
object- Parameters:
formula
- theCalculable
object 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 < xf
orstep < 0
orstep > 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 withGraphic
that 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 < xf
orstep < 0
orstep > xf - xs
IllegalArgumentException
- ifelement
isnull
- 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 < xf
orstep < 0
orstep > xf - xs
- See Also:
-
setAreaPaint
Sets thePaint
used for the area below the curve- Parameters:
paint
- ThePaint
that will be used to render the area- Throws:
IllegalArgumentException
- ifpaint
isnull
-
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 < xf
orstep < 0
orstep > xf - xs
- See Also:
-