Package com.dkt.graphics.elements
Class Graphic
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.elements.Graphic
- Direct Known Subclasses:
GFormula
This class represents a Graphic made by a collection of
Note: this class is a
GraphicE
components.Note: this class is a
GraphicE
on itself, so you can add it to
Graphics.- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a newGraphicE
to this Graphic
Note: all the elements that are added will be automatically traslated the same amount as the sum of the traslations up to this moment Note 2:This method doesn't check if the element is already contained on theGraphic
, this mean, that you can add elements twice, the downside (or amazing feature, according to a couple of comments) is that the elements that are added twice will be traslated twice as much as the other elements.void
This method adds all of the elements of a given set ofGraphic
components into the current element.void
addCopyOfAll
(Graphic... graphics) This method adds all of the elements of a given set ofGraphic
components into the current element.clone()
boolean
void
draw
(Graphics2D g) Draws the component on the given graphicsboolean
void
flatten()
Flattens the structure of a Graphic, this method is very slow, but it will increase the performance of draw().int
getCount()
Retrieves the number ofGraphicE
components that compose thisGraphic
.int
hashCode()
int
Retrieves the index of a given element on theGraphic
.boolean
Tells ifGraphic
will be drawn in the canvasiterator()
void
move
(int x, int y) Moves all the elements to a given location.
This method tends to ruin graphics...boolean
void
Clears all the components from thisGraphic
void
setVisible
(boolean v) void
traslate
(int x, int y) Traslates this element on X and YMethods inherited from class com.dkt.graphics.elements.GraphicE
getPaint, getStroke, setPaint, setStroke
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Graphic
public Graphic() -
Graphic
public Graphic(int initialSize) -
Graphic
Copy constructor- Parameters:
e
-Graphic
to copy- Throws:
IllegalArgumentException
- ife
isnull
-
-
Method Details
-
getCount
public int getCount()Retrieves the number ofGraphicE
components that compose thisGraphic
. This method will not count recursively.- Returns:
- component count
-
add
Adds a newGraphicE
to this Graphic
Note: all the elements that are added will be automatically traslated the same amount as the sum of the traslations up to this moment Note 2:This method doesn't check if the element is already contained on theGraphic
, this mean, that you can add elements twice, the downside (or amazing feature, according to a couple of comments) is that the elements that are added twice will be traslated twice as much as the other elements.- Parameters:
e
- element to add- Throws:
IllegalArgumentException
- ife
isnull
InvalidArgumentException
- ife
is this same object- See Also:
-
contains
- Parameters:
e
- element to test- Returns:
true
if the element is contained andfalse
otherwise- Throws:
IllegalArgumentException
- ife
isnull
- See Also:
-
remove
- Parameters:
e
- element to remove- Returns:
true
if the element was contained andfalse
otherwise- Throws:
IllegalArgumentException
- ife
isnull
- See Also:
-
indexOf
Retrieves the index of a given element on theGraphic
.- Parameters:
e
- element- Returns:
- The index number of the first occurrence of the element, or
-1
if the element wasn't found - Throws:
IllegalArgumentException
- ife
isnull
- See Also:
-
removeAll
public void removeAll()Clears all the components from thisGraphic
-
draw
Description copied from class:GraphicE
Draws the component on the given graphics -
traslate
public void traslate(int x, int y) Description copied from class:GraphicE
Traslates this element on X and Y -
move
public void move(int x, int y) Moves all the elements to a given location.
This method tends to ruin graphics... use it with care.- Parameters:
x
- new X coordinatey
- new Y coordinate
-
addAll
This method adds all of the elements of a given set ofGraphic
components into the current element.- Parameters:
graphics
- array of graphics to merge- See Also:
-
addCopyOfAll
This method adds all of the elements of a given set ofGraphic
components into the current element.- Parameters:
graphics
- array of graphics to merge- See Also:
-
isVisible
public boolean isVisible()Tells ifGraphic
will be drawn in the canvas- Returns:
true
if theGraphic
is visible andflase
otherwise
-
setVisible
public void setVisible(boolean v) - Parameters:
v
-true
if theGraphic
will visible andflase
otherwise
-
flatten
public void flatten()Flattens the structure of a Graphic, this method is very slow, but it will increase the performance of draw().
This method is specially useful when you use the GraphicCreator, or when combining severalGraphic
. Consider trying to search for a specific element when having multipleGraphic
objects... basically, you'll never be able to find them if you need to enter each and everyGraphic
object to check. -
iterator
-
clone
-
hashCode
public int hashCode() -
equals
-