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
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionclone()voiddraw(Graphics2D g) Draws the component on the given graphicsvoidmove(int x, int y) Moves the start point of this vector to the selected coordinatesvoidsetArgument(double a) Changes the argument of the main vectorvoidsetHCompPaint(Paint paint) Sets thePaintfor the horizontal component of this vectorvoidsetModulus(double m) Sets a new modulus to the main vector (that will also change the components)voidsetModulus(double x, double y) Sets a new modulus and argument to the main vector based on the modulus of the orthogonal componentsvoidSets thePaintfor the main vectorvoidsetVCompPaint(Paint paint) Sets thePaintfor the vertical component of this vectorvoidtraslate(int x, int y) Traslates this element on X and Y 
- 
Constructor Details
- 
GPVector
 - 
GPVector
Creates a newGPVectorbased on theGVectorpassed 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- ifvisnull
 - 
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 thePaintfor the main vector- Overrides:
 setPaintin classGraphicE- Parameters:
 paint- the paint use to render the main vector- Throws:
 IllegalArgumentException- if paint isnull
 - 
setHCompPaint
Sets thePaintfor the horizontal component of this vector- Parameters:
 paint- the paint use to render the horizontal component- Throws:
 IllegalArgumentException- if paint isnull
 - 
setVCompPaint
Sets thePaintfor 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:GraphicETraslates this element on X and Y - 
draw
Description copied from class:GraphicEDraws the component on the given graphics 
 -