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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a newGraphicEto 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.voidThis method adds all of the elements of a given set ofGraphiccomponents into the current element.voidaddCopyOfAll(Graphic... graphics) This method adds all of the elements of a given set ofGraphiccomponents into the current element.clone()booleanvoiddraw(Graphics2D g) Draws the component on the given graphicsbooleanvoidflatten()Flattens the structure of a Graphic, this method is very slow, but it will increase the performance of draw().intgetCount()Retrieves the number ofGraphicEcomponents that compose thisGraphic.inthashCode()intRetrieves the index of a given element on theGraphic.booleanTells ifGraphicwill be drawn in the canvasiterator()voidmove(int x, int y) Moves all the elements to a given location.
This method tends to ruin graphics...booleanvoidClears all the components from thisGraphicvoidsetVisible(boolean v) voidtraslate(int x, int y) Traslates this element on X and YMethods inherited from class com.dkt.graphics.elements.GraphicE
getPaint, getStroke, setPaint, setStrokeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Graphic
public Graphic() -
Graphic
public Graphic(int initialSize) -
Graphic
Copy constructor- Parameters:
e-Graphicto copy- Throws:
IllegalArgumentException- ifeisnull
-
-
Method Details
-
getCount
public int getCount()Retrieves the number ofGraphicEcomponents that compose thisGraphic. This method will not count recursively.- Returns:
- component count
-
add
Adds a newGraphicEto 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- ifeisnullInvalidArgumentException- ifeis this same object- See Also:
-
contains
- Parameters:
e- element to test- Returns:
trueif the element is contained andfalseotherwise- Throws:
IllegalArgumentException- ifeisnull- See Also:
-
remove
- Parameters:
e- element to remove- Returns:
trueif the element was contained andfalseotherwise- Throws:
IllegalArgumentException- ifeisnull- 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
-1if the element wasn't found - Throws:
IllegalArgumentException- ifeisnull- See Also:
-
removeAll
public void removeAll()Clears all the components from thisGraphic -
draw
Description copied from class:GraphicEDraws the component on the given graphics -
traslate
public void traslate(int x, int y) Description copied from class:GraphicETraslates 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 ofGraphiccomponents 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 ofGraphiccomponents into the current element.- Parameters:
graphics- array of graphics to merge- See Also:
-
isVisible
public boolean isVisible()Tells ifGraphicwill be drawn in the canvas- Returns:
trueif theGraphicis visible andflaseotherwise
-
setVisible
public void setVisible(boolean v) - Parameters:
v-trueif theGraphicwill visible andflaseotherwise
-
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 multipleGraphicobjects... basically, you'll never be able to find them if you need to enter each and everyGraphicobject to check. -
iterator
-
clone
-
hashCode
public int hashCode() -
equals
-