Package com.dkt.graphics.extras
Class GPVector
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.extras.GPVector
- All Implemented Interfaces:
Cloneable
This class represents a vector and it's projections, it's mainly used in
physics problems where you need to print how the orthogonal components of
a vector changes
- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
void
draw
(Graphics2D g) Draws the component on the given graphicsvoid
move
(int x, int y) Moves the start point of this vector to the selected coordinatesvoid
setArgument
(double a) Changes the argument of the main vectorvoid
setHCompPaint
(Paint paint) Sets thePaint
for the horizontal component of this vectorvoid
setModulus
(double m) Sets a new modulus to the main vector (that will also change the components)void
setModulus
(double x, double y) Sets a new modulus and argument to the main vector based on the modulus of the orthogonal componentsvoid
Sets thePaint
for the main vectorvoid
setVCompPaint
(Paint paint) Sets thePaint
for the vertical component of this vectorvoid
traslate
(int x, int y) Traslates this element on X and Y
-
Constructor Details
-
GPVector
-
GPVector
Creates a newGPVector
based on theGVector
passed as argument.
Note: this constructor uses a COPY of the vector, so if you need to change some parameters of the vector, you'll need to use:- Parameters:
v
- the vector used as base- Throws:
IllegalArgumentException
- ifv
isnull
-
GPVector
public GPVector(int x, int y, double l, double a) Creates a newGPVector
- Parameters:
x
- x coordinate of the application point of the vectory
- y coordinate of the application point of the vectorl
- vector modulusa
- vector angle (in degrees)
-
-
Method Details
-
setModulus
public void setModulus(double m) Sets a new modulus to the main vector (that will also change the components)- Parameters:
m
- modulus
-
setModulus
public void setModulus(double x, double y) Sets a new modulus and argument to the main vector based on the modulus of the orthogonal components- Parameters:
x
- x componenty
- y component
-
setArgument
public void setArgument(double a) Changes the argument of the main vector- Parameters:
a
- argument in degrees
-
setPaint
Sets thePaint
for the main vector- Overrides:
setPaint
in classGraphicE
- Parameters:
paint
- the paint use to render the main vector- Throws:
IllegalArgumentException
- if paint isnull
-
setHCompPaint
Sets thePaint
for the horizontal component of this vector- Parameters:
paint
- the paint use to render the horizontal component- Throws:
IllegalArgumentException
- if paint isnull
-
setVCompPaint
Sets thePaint
for the vertical component of this vector- Parameters:
paint
- the paint use to render the vertical component- Throws:
IllegalArgumentException
- if paint isnull
-
move
public void move(int x, int y) Moves the start point of this vector to the selected coordinates- Parameters:
x
- new x coordinatey
- new y coordinate
-
clone
-
traslate
public void traslate(int x, int y) Description copied from class:GraphicE
Traslates this element on X and Y -
draw
Description copied from class:GraphicE
Draws the component on the given graphics
-