Class GAxis

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class GAxis
    extends GraphicE
    This class represents a pair of Cartesian axis.
    • Field Summary

    • Constructor Summary

      Constructors 
      Constructor Description
      GAxis​(int xs, int xf, int ys, int yf)
      Main constructor of the Axis.
      This constructor asks for the dimensions of the axis, but if you want it centered in the drawable area of the canvas, you'll need to set the origin of the canvas in the correct position.
      GAxis​(GAxis e)
      Copy constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      GAxis clone()  
      void draw​(java.awt.Graphics2D g)
      Draws the component on the given graphics
      void drawLinesH​(boolean drawLinesH)
      Tells the Axis to draw the horizontal lines for the grid
      void drawLinesV​(boolean drawLinesV)
      Tells the Axis to draw the vertical lines for the grid
      boolean equals​(java.lang.Object obj)  
      int getMayorTickSize()
      Retrieves the mayor tick size.
      int getMinorTickSize()
      Retrieves the minor tick size.
      int hashCode()  
      void mayorTicksH​(int h)
      Tells the axis to draw the mayor ticks of the horizontal axis with a distance of 'h'.
      Note: The mayor ticks MUST correspond to a minor tick.
      void mayorTicksV​(int v)
      Tells the axis to draw the mayor ticks of the vertical axis with a distance of 'v'.
      Note: The mayor ticks MUST correspond to a minor tick.
      void minorTicksH​(int h)
      Tells the axis to draw the minor ticks of the horizontal axis with a distance of 'h'
      void minorTicksV​(int v)
      Tells the axis to draw the minor ticks of the vertical axis with a distance of 'v'
      void setGridColor​(java.awt.Paint paint)
      Sets the color for the grid (if shown).
      The default value is Color.LIGHT_GRAY
      void setMayorTickSize​(int MTS)
      Sets the mayor tick size
      Note: This size is used at both sides of the axis so the final length of the tick will be two times this value
      void setMinorTickSize​(int mTS)
      Sets the minor tick size
      Note: This size is used at both sides of the axis so the final length of the tick will be two times this value
      void setOrigin​(Canvas canvas)
      This method set's the origin of the Canvas on the correct place in order for the Axis to be completely displayed.
      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

      • GAxis

        public GAxis​(GAxis e)
        Copy constructor
        Parameters:
        e - GAxis to copy
        Throws:
        java.lang.IllegalArgumentException - if e is null
      • GAxis

        public GAxis​(int xs,
                     int xf,
                     int ys,
                     int yf)
        Main constructor of the Axis.
        This constructor asks for the dimensions of the axis, but if you want it centered in the drawable area of the canvas, you'll need to set the origin of the canvas in the correct position.
        Parameters:
        xs - The starting point of the X axis
        xf - The ending point of the X axis
        ys - The starting point of the Y axis
        yf - The ending point of the Y axis
        Throws:
        IntervalException - if either starting point is bigger than the corresponding end point
        See Also:
        setOrigin(Canvas)
    • Method Detail

      • minorTicksH

        public void minorTicksH​(int h)
        Tells the axis to draw the minor ticks of the horizontal axis with a distance of 'h'
        Parameters:
        h - the vertical
        Throws:
        InvalidArgumentException - if h is smaller than 1
      • mayorTicksH

        public void mayorTicksH​(int h)
        Tells the axis to draw the mayor ticks of the horizontal axis with a distance of 'h'.
        Note: The mayor ticks MUST correspond to a minor tick. What does this mean? that the minor tick 'h' and the mayor tick 'h' must be perfect integer multiples.
                          MTickH = mTickH * i (i = 2,3,4,5,6,....)
        Parameters:
        h - the new distance between mayor horizontal ticks
        Throws:
        InvalidArgumentException - if 'h' is smaller than the minor tick space or if 'h' is not a perfect multiple of mtx
      • minorTicksV

        public void minorTicksV​(int v)
        Tells the axis to draw the minor ticks of the vertical axis with a distance of 'v'
        Parameters:
        v - the vertical
        Throws:
        InvalidArgumentException - if v is smaller than 1
      • mayorTicksV

        public void mayorTicksV​(int v)
        Tells the axis to draw the mayor ticks of the vertical axis with a distance of 'v'.
        Note: The mayor ticks MUST correspond to a minor tick. What does this mean? that the minor tick 'v' and the mayor tick 'v' must be perfect integer multiples.
                          MTickV = mTickV * i (i = 2,3,4,5,6,....)
        Parameters:
        v - the new distance between mayor horizontal ticks
        Throws:
        InvalidArgumentException - if 'v' is smaller than the minor tick space or if 'v' is not a perfect multiple of mty
      • drawLinesH

        public void drawLinesH​(boolean drawLinesH)
        Tells the Axis to draw the horizontal lines for the grid
        Parameters:
        drawLinesH - true if you want to see the horizontal lines and false otherwise
      • drawLinesV

        public void drawLinesV​(boolean drawLinesV)
        Tells the Axis to draw the vertical lines for the grid
        Parameters:
        drawLinesV - true if you want to see the vertical lines and false otherwise
      • setGridColor

        public void setGridColor​(java.awt.Paint paint)
        Sets the color for the grid (if shown).
        The default value is Color.LIGHT_GRAY
        Parameters:
        paint - The new Paint for the grid
        Throws:
        java.lang.IllegalArgumentException - if the paint is null
      • setOrigin

        public void setOrigin​(Canvas canvas)
        This method set's the origin of the Canvas on the correct place in order for the Axis to be completely displayed.
        Parameters:
        canvas - canvas you want to set
        Throws:
        java.lang.IllegalArgumentException - if the canvas is null
      • setMinorTickSize

        public void setMinorTickSize​(int mTS)
        Sets the minor tick size
        Note: This size is used at both sides of the axis so the final length of the tick will be two times this value
        Parameters:
        mTS - minor tick size
      • getMinorTickSize

        public int getMinorTickSize()
        Retrieves the minor tick size. The default value is 2.
        Returns:
        minor tick size
      • setMayorTickSize

        public void setMayorTickSize​(int MTS)
        Sets the mayor tick size
        Note: This size is used at both sides of the axis so the final length of the tick will be two times this value
        Parameters:
        MTS - mayor tick size
      • getMayorTickSize

        public int getMayorTickSize()
        Retrieves the mayor tick size. The default value is 5.
        Returns:
        mayor tick size
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class GraphicE
      • 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