Class GPVector

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class GPVector
    extends GraphicE
    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
    • Field Summary

    • Constructor Summary

      Constructors 
      Constructor Description
      GPVector​(int x, int y, double l, double a)
      Creates a new GPVector
      GPVector​(GVector v)
      Creates a new GPVector based on the GVector passed as argument.
      GPVector​(GPVector e)
      Copy constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      GPVector clone()  
      void draw​(java.awt.Graphics2D g)
      Draws the component on the given graphics
      void move​(int x, int y)
      Moves the start point of this vector to the selected coordinates
      void setArgument​(double a)
      Changes the argument of the main vector
      void setHCompPaint​(java.awt.Paint paint)
      Sets the Paint for the horizontal component of this vector
      void 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 components
      void setPaint​(java.awt.Paint paint)
      Sets the Paint for the main vector
      void setVCompPaint​(java.awt.Paint paint)
      Sets the Paint for the vertical component of this vector
      void traslate​(int x, int y)
      Traslates this element on X and Y
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GPVector

        public GPVector​(GPVector e)
        Copy constructor.
        Parameters:
        e - GPVector to copy
      • GPVector

        public GPVector​(int x,
                        int y,
                        double l,
                        double a)
        Creates a new GPVector
        Parameters:
        x - x coordinate of the application point of the vector
        y - y coordinate of the application point of the vector
        l - vector modulus
        a - vector angle (in degrees)
    • Method Detail

      • 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 component
        y - y component
      • setArgument

        public void setArgument​(double a)
        Changes the argument of the main vector
        Parameters:
        a - argument in degrees
      • setPaint

        public void setPaint​(java.awt.Paint paint)
        Sets the Paint for the main vector
        Overrides:
        setPaint in class GraphicE
        Parameters:
        paint - the paint use to render the main vector
        Throws:
        java.lang.IllegalArgumentException - if paint is null
      • setHCompPaint

        public void setHCompPaint​(java.awt.Paint paint)
        Sets the Paint for the horizontal component of this vector
        Parameters:
        paint - the paint use to render the horizontal component
        Throws:
        java.lang.IllegalArgumentException - if paint is null
      • setVCompPaint

        public void setVCompPaint​(java.awt.Paint paint)
        Sets the Paint for the vertical component of this vector
        Parameters:
        paint - the paint use to render the vertical component
        Throws:
        java.lang.IllegalArgumentException - if paint is null
      • move

        public void move​(int x,
                         int y)
        Moves the start point of this vector to the selected coordinates
        Parameters:
        x - new x coordinate
        y - new y coordinate
      • traslate

        public void traslate​(int x,
                             int y)
        Description copied from class: GraphicE
        Traslates this element on X and Y
        Specified by:
        traslate in class GraphicE
        Parameters:
        x - size in px of the horizontal translation
        y - size in px of the vertical translation
      • draw

        public void draw​(java.awt.Graphics2D g)
        Description copied from class: GraphicE
        Draws the component on the given graphics
        Specified by:
        draw in class GraphicE
        Parameters:
        g - where to draw