Package com.dkt.graphics.extras
Class GraphicCreator
java.lang.Object
com.dkt.graphics.extras.GraphicCreator
This class came as an exercise to create
This class is pretty handy to create simple drawing based GUIs, since manipulating strings is orders of magnitude easier than using Graphics. This is not meant to be a programming language, it's simply a way of creating simple (and not so simple) graphics.
Graphic objects from text
without modifying the classes themselves, it was later used on Graphic
Designer, and finally decided to add it to add it to the extras package.This class is pretty handy to create simple drawing based GUIs, since manipulating strings is orders of magnitude easier than using Graphics. This is not meant to be a programming language, it's simply a way of creating simple (and not so simple) graphics.
- Author:
- Federico Vera <[email protected]>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Set's the global color.Set's the global fill color.Sets a global font, if the argument isnothen it will reset the global fontintRetrieves the number of errors encountered during the parsing of a given text.intCreates a linear gradient betweencolorandcolorf, so they need to be set before calling this method.
The arguments should bex1, y1, x2, y2, that is, the coordinates of the first point of the gradient vector and the coordinates of the last pointCreates a linear cyclic gradient betweencolorandcolorf, so they need to be set before calling this method.
The arguments should bex1, y1, x2, y2, that is, the coordinates of the first point of the gradient vector and the coordinates of the last pointCreates a line based on cartesian coordinates.
The arguments arex1, y1, x2, y2.Creates a line based on polar coordinates.
The arguments arex, y, l, a.Parses aString(that respects the documentation) into aGraphicCreates a new point.
The first two arguments should bexandycoordinates of the point.Clears the global configurationscolor,colorf,stroke,paintandfont
-
Constructor Details
-
GraphicCreator
public GraphicCreator()
-
-
Method Details
-
clear
public void clear() -
parse
-
parse
Parses aString(that respects the documentation) into aGraphic- Parameters:
lines- String representation of the graphic- Returns:
Graphicobject
-
getErrorCount
public int getErrorCount()Retrieves the number of errors encountered during the parsing of a given text.- Returns:
- error count
-
getTotalLineCount
public int getTotalLineCount() -
stroke
-
reset
Clears the global configurationscolor,colorf,stroke,paintandfont- Parameters:
args- these are ignored- Returns:
null
-
font
Sets a global font, if the argument isnothen it will reset the global font- Parameters:
args- the arguments will be used inFont.decode(String), so for further documentation, please refer to it- Returns:
- Font
-
colorf
Set's the global fill color. If the argument isnothen it will reset the fill color. If this color is set allGFillableEwill be set to fill.
This color is also used as the secondary color on gradients.- If 3 arguments are passed there should be:
R[0-255] G[0-255] B[0-255], - if 4 arguments are passed the format should be:
A[0-255] R[0-255] G[0-255] B[0-255]
- Parameters:
args- color info- Returns:
- Fill color
- See Also:
- If 3 arguments are passed there should be:
-
color
Set's the global color. This color is also used as the primary color on gradients.- If 3 arguments are passed there should be:
R[0-255] G[0-255] B[0-255], - if 4 arguments are passed the format should be:
A[0-255] R[0-255] G[0-255] B[0-255]
- Parameters:
args- color info- Returns:
- Fill color
- See Also:
- If 3 arguments are passed there should be:
-
gradient
Creates a linear gradient betweencolorandcolorf, so they need to be set before calling this method.
The arguments should bex1, y1, x2, y2, that is, the coordinates of the first point of the gradient vector and the coordinates of the last point- Parameters:
args- vector arguments- Returns:
- Linear gradient
- See Also:
-
gradient2
Creates a linear cyclic gradient betweencolorandcolorf, so they need to be set before calling this method.
The arguments should bex1, y1, x2, y2, that is, the coordinates of the first point of the gradient vector and the coordinates of the last point- Parameters:
args- vector arguments- Returns:
- Linear cyclic gradient
- See Also:
-
for1
-
for2
-
for3
-
for4
-
clipadd
-
clipsub
-
clipoff
-
scale
-
rotate
-
traslate
-
transoff
- Throws:
NoninvertibleTransformException
-
point
Creates a new point.
The first two arguments should bexandycoordinates of the point. The third optional argument is the cross size used to represent the point- Parameters:
args- point arguments- Returns:
point
-
linec
Creates a line based on cartesian coordinates.
The arguments arex1, y1, x2, y2.- Parameters:
args- coordinates of the line- Returns:
- Line
-
linep
Creates a line based on polar coordinates.
The arguments arex, y, l, a. Withx, ybeing the initial point,lthe length of the vector andathe angle in degrees.- Parameters:
args- coordinates of the line- Returns:
- Line
-
lpath
-
rectf
-
rectc
-
circle
-
oval
-
polyp
-
polyn
-
vectc
-
vectp
-
arc
-
arcc
-
string
-
string2
-
grid
-