Package com.dkt.graphics.extras
Class GAxis
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.extras.GAxis
- All Implemented Interfaces:
Cloneable
This class represents a pair of Cartesian axis.
- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionGAxis(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.Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionclone()voiddraw(Graphics2D g) Draws the component on the given graphicsvoiddrawLinesH(boolean drawLinesH) Tells the Axis to draw the horizontal lines for the gridvoiddrawLinesV(boolean drawLinesV) Tells the Axis to draw the vertical lines for the gridbooleanintRetrieves the mayor tick size.intRetrieves the minor tick size.inthashCode()voidmayorTicksH(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.voidmayorTicksV(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.voidminorTicksH(int h) Tells the axis to draw the minor ticks of the horizontal axis with a distance of 'h'voidminorTicksV(int v) Tells the axis to draw the minor ticks of the vertical axis with a distance of 'v'voidsetGridColor(Paint paint) Sets the color for the grid (if shown).
The default value isColor.LIGHT_GRAYvoidsetMayorTickSize(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 valuevoidsetMinorTickSize(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 valuevoidThis method set's the origin of theCanvason the correct place in order for the Axis to be completely displayed.voidtraslate(int x, int y) Traslates this element on X and Y
-
Constructor Details
-
GAxis
Copy constructor- Parameters:
e-GAxisto copy- Throws:
IllegalArgumentException- ifeisnull
-
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 axisxf- The ending point of the X axisys- The starting point of the Y axisyf- The ending point of the Y axis- Throws:
IntervalException- if either starting point is bigger than the corresponding end point- See Also:
-
-
Method Details
-
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- ifhis 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- ifvis 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-trueif you want to see the horizontal lines andfalseotherwise
-
drawLinesV
public void drawLinesV(boolean drawLinesV) Tells the Axis to draw the vertical lines for the grid- Parameters:
drawLinesV-trueif you want to see the vertical lines andfalseotherwise
-
setGridColor
Sets the color for the grid (if shown).
The default value isColor.LIGHT_GRAY- Parameters:
paint- The newPaintfor the grid- Throws:
IllegalArgumentException- if the paint isnull
-
setOrigin
This method set's the origin of theCanvason the correct place in order for the Axis to be completely displayed.- Parameters:
canvas- canvas you want to set- Throws:
IllegalArgumentException- if the canvas isnull
-
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
-
clone
-
hashCode
public int hashCode() -
equals
-
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
-