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
ConstructorDescriptionGAxis
(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()
void
draw
(Graphics2D g) Draws the component on the given graphicsvoid
drawLinesH
(boolean drawLinesH) Tells the Axis to draw the horizontal lines for the gridvoid
drawLinesV
(boolean drawLinesV) Tells the Axis to draw the vertical lines for the gridboolean
int
Retrieves the mayor tick size.int
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
(Paint paint) Sets the color for the grid (if shown).
The default value isColor.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 valuevoid
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 valuevoid
This method set's the origin of theCanvas
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
-
Constructor Details
-
GAxis
Copy constructor- Parameters:
e
-GAxis
to copy- Throws:
IllegalArgumentException
- ife
isnull
-
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
- ifh
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
- ifv
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 andfalse
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 andfalse
otherwise
-
setGridColor
Sets the color for the grid (if shown).
The default value isColor.LIGHT_GRAY
- Parameters:
paint
- The newPaint
for the grid- Throws:
IllegalArgumentException
- if the paint isnull
-
setOrigin
This method set's the origin of theCanvas
on 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:GraphicE
Traslates this element on X and Y -
draw
Description copied from class:GraphicE
Draws the component on the given graphics
-