

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object edu.neu.ccs.gui.PaintTools
The class PaintTools
contains static methods
that use PaintAlgorithm
objects to make other
useful objects such as TexturePaint
objects and
BufferedImage
objects; the class also contains
static methods that manipulate PaintAlgorithm
objects to create new objects that may be used to define
hatch patterns.
Constructor Summary  
private 
PaintTools()
This class cannot be instantiated. 
Method Summary  
static PaintAlgorithm 
brickEtoW(Color cellColor,
Color edgeColor,
int size)
Returns a brick pattern oriented horizontally (EW) such that the brick cell has dimensions width = 2 * size, height = size and uses the given cell color and edge color. 
static PaintAlgorithm 
brickNEtoSW(Color cellColor,
Color edgeColor,
int size)
Equivalent to turn45(brickEtoW(args)) . 
static PaintAlgorithm 
brickNtoS(Color cellColor,
Color edgeColor,
int size)
Equivalent to turn90(brickEtoW(args)) . 
static PaintAlgorithm 
brickNWtoSE(Color cellColor,
Color edgeColor,
int size)
Equivalent to turn135(brickEtoW(args)) . 
static PaintAlgorithm 
checkHatch(Color color1,
Color color2,
int width1,
int width2,
int height1,
int height2)
Returns a checker board hatch pattern. 
static PaintAlgorithm 
checkHatch(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int width1,
int width2,
int height1,
int height2)
Returns a check board hatch pattern. 
static PaintAlgorithm 
checkHatchDiagonal(Color color1,
Color color2,
int width1,
int width2,
int height1,
int height2)
Equivalent to turn45(checkHatch(args)) . 
static PaintAlgorithm 
checkHatchDiagonal(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int width1,
int width2,
int height1,
int height2)
Equivalent to turn45(checkHatch(args)) . 
static PaintAlgorithm 
crossHatch(Color color1,
Color color2,
int width1,
int width2,
int height1,
int height2)
Returns a cross hatch pattern. 
static PaintAlgorithm 
crossHatch(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int width1,
int width2,
int height1,
int height2)
Returns a cross hatch pattern. 
static PaintAlgorithm 
crossHatchDiagonal(Color color1,
Color color2,
int width1,
int width2,
int height1,
int height2)
Equivalent to turn45(crossHatch(args)) . 
static PaintAlgorithm 
crossHatchDiagonal(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int width1,
int width2,
int height1,
int height2)
Equivalent to turn45(crossHatch(args)) . 
static PaintAlgorithm 
dottedGrid(Color dotColor,
Color backColor,
int dotSize,
int gridSize)
Returns a dotted grid pattern with the given dot color and background color. 
static PaintAlgorithm 
dottedGridDiagonal(Color dotColor,
Color backColor,
int dotSize,
int gridSize)
Equivalent to turn45(dottedGrid(args)) . 
static BufferedImage 
makeBufferedImage(PaintAlgorithm algorithm)
Returns a BufferedImage object whose pixel colors
are defined by the given algorithm and whose size is determined
by the periods in the given algorithm. 
static BufferedImage 
makeBufferedImage(PaintAlgorithm algorithm,
int width,
int height)
Returns a BufferedImage object whose pixel colors
are defined by the given algorithm and whose size is determined
by the given width and height. 
static TexturePaint 
makePaint(PaintAlgorithm algorithm)
Returns a TexturePaint object whose pixel colors
are defined by the given algorithm and whose size is determined
by the periods in the given algorithm. 
static TexturePaint 
makePaint(PaintAlgorithm algorithm,
int width,
int height)
Returns a TexturePaint object whose pixel colors
are defined by the given algorithm and whose size is determined
by the given width and height. 
static PaintAlgorithm 
makePaintAlgorithm(BufferedImage image)
Returns a PaintAlgorithm whose color mapping is
determined by the color data in the given buffered image. 
static PaintAlgorithm 
reflect(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
reflects through the xaxis. 
static PaintAlgorithm 
solid(Color c)
Returns the PaintAlgorithm that returns
the given solid color for any x and y input. 
static PaintAlgorithm 
stripeEtoW(Color color1,
Color color2,
int thick1,
int thick2)
Returns the PaintAlgorithm that draws a pair
of stripes from east to west
with stripe 1 using color color1 with thickness thick1
and
with stripe 2 using color color2 with thickness thick2. 
static PaintAlgorithm 
stripeEtoW(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int thick1,
int thick2)
Returns the PaintAlgorithm that draws a pair
of stripes from east to west
with stripe 1 using algorithm1 with thickness thick1
and
with stripe 2 using algorithm2 with thickness thick2. 
static PaintAlgorithm 
stripeNEtoSW(Color color1,
Color color2,
int thick1,
int thick2)
Equivalent to turn45(stripeEtoW(args)) . 
static PaintAlgorithm 
stripeNEtoSW(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int thick1,
int thick2)
Equivalent to turn45(stripeEtoW(args)) . 
static PaintAlgorithm 
stripeNtoS(Color color1,
Color color2,
int thick1,
int thick2)
Equivalent to turn90(stripeEtoW(args)) . 
static PaintAlgorithm 
stripeNtoS(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int thick1,
int thick2)
Equivalent to turn90(stripeEtoW(args)) . 
static PaintAlgorithm 
stripeNWtoSE(Color color1,
Color color2,
int thick1,
int thick2)
Equivalent to turn135(stripeEtoW(args)) . 
static PaintAlgorithm 
stripeNWtoSE(PaintAlgorithm algorithm1,
PaintAlgorithm algorithm2,
int thick1,
int thick2)
Equivalent to turn135(stripeEtoW(args)) . 
static PaintAlgorithm 
translate(PaintAlgorithm algorithm,
int x0,
int y0)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
translates by the given x0, y0. 
static PaintAlgorithm 
turn135(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
rotates by 135 degrees. 
static PaintAlgorithm 
turn180(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
rotates by 180 degrees. 
static PaintAlgorithm 
turn225(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
rotates by 225 degrees. 
static PaintAlgorithm 
turn270(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
rotates by 270 degrees. 
static PaintAlgorithm 
turn315(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
rotates by 45 degrees. 
static PaintAlgorithm 
turn45(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
rotates by 45 degrees. 
static PaintAlgorithm 
turn90(PaintAlgorithm algorithm)
Returns a PaintAlgorithm constructed from the given
PaintAlgorithm by composition with a transform that
rotates by 90 degrees. 
Methods inherited from class java.lang.Object 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Constructor Detail 
private PaintTools()
Method Detail 
public static TexturePaint makePaint(PaintAlgorithm algorithm)
Returns a TexturePaint
object whose pixel colors
are defined by the given algorithm and whose size is determined
by the periods in the given algorithm.
Returns null
if the given algorithm is
null
.
algorithm
 the algorithm to construct the texture paint
public static TexturePaint makePaint(PaintAlgorithm algorithm, int width, int height)
Returns a TexturePaint
object whose pixel colors
are defined by the given algorithm and whose size is determined
by the given width and height.
Returns null
if the given algorithm is
null
or if either the given width or height
is less than or equal to zero.
algorithm
 the algorithm to construct the paintwidth
 the width of the texture paint swatchheight
 the height of the texture paint swatch
public static BufferedImage makeBufferedImage(PaintAlgorithm algorithm)
Returns a BufferedImage
object whose pixel colors
are defined by the given algorithm and whose size is determined
by the periods in the given algorithm.
Returns null
if the given algorithm is
null
.
algorithm
 the algorithm to construct the buffered image
public static BufferedImage makeBufferedImage(PaintAlgorithm algorithm, int width, int height)
Returns a BufferedImage
object whose pixel colors
are defined by the given algorithm and whose size is determined
by the given width and height.
Returns null
if the given algorithm is
null
or if either the given width or height
is less than or equal to zero.
algorithm
 the algorithm to construct the buffered imagewidth
 the width of the texture paint swatchheight
 the height of the texture paint swatch
public static PaintAlgorithm makePaintAlgorithm(BufferedImage image)
Returns a PaintAlgorithm
whose color mapping is
determined by the color data in the given buffered image.
Returns null
if the given buffered image
is null
or empty.
Copies the given buffered image information to provide permanent data for the algorithm.
image
 the buffered image to convert to an algorithm
public static PaintAlgorithm solid(Color c)
Returns the PaintAlgorithm
that returns
the given solid color for any x and y input.
The x and y periods of the algorithm are both 1.
If the given color is null
, this method
uses as its default Color.black
.
c
 the solid color for the algorithm
public static PaintAlgorithm turn45(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
rotates by 45 degrees.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color(x  y, x + y)
If this algorithm is used to construct a texture paint, it will appear that the new paint is geometrically contracted by sqrt(2) relative to the size of the old paint (as well as rotated).
The x and y periods of the resulting algorithm are both equal to the least common multiple of the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to rotate
public static PaintAlgorithm turn90(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
rotates by 90 degrees.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color( y, x)
If this algorithm is used to construct a texture paint, the new paint is geometrically the same size as the old paint (but rotated).
The x and y periods of the resulting algorithm are interchanged with the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to rotate
public static PaintAlgorithm turn135(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
rotates by 135 degrees.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color( x  y, x  y)
If this algorithm is used to construct a texture paint, it will appear that the new paint is geometrically contracted by sqrt(2) relative to the size of the old paint (as well as rotated).
The x and y periods of the resulting algorithm are both equal to the least common multiple of the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to rotate
public static PaintAlgorithm turn180(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
rotates by 180 degrees.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color( x,  y)
If this algorithm is used to construct a texture paint, the new paint is geometrically the same size as the old paint (but rotated).
The x and y periods of the resulting algorithm are the same as the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to rotate
public static PaintAlgorithm turn225(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
rotates by 225 degrees.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color( x + y,  x  y)
If this algorithm is used to construct a texture paint, it will appear that the new paint is geometrically contracted by sqrt(2) relative to the size of the old paint (as well as rotated).
The x and y periods of the resulting algorithm are both equal to the least common multiple of the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to rotate
public static PaintAlgorithm turn270(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
rotates by 270 degrees.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color(y,  x)
If this algorithm is used to construct a texture paint, the new paint is geometrically the same size as the old paint (but rotated).
The x and y periods of the resulting algorithm are interchanged with the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to rotate
public static PaintAlgorithm turn315(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
rotates by 45 degrees.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color(x + y,  x + y)
If this algorithm is used to construct a texture paint, it will appear that the new paint is geometrically contracted by sqrt(2) relative to the size of the old paint (as well as rotated).
The x and y periods of the resulting algorithm are both equal to the least common multiple of the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to rotate
public static PaintAlgorithm reflect(PaintAlgorithm algorithm)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
reflects through the xaxis.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color(x,  y)
If this algorithm is used to construct a texture paint, the new paint is geometrically the same size as the old paint (but reflected).
The x and y periods of the resulting algorithm are the same as the x and y periods of the given algorithm.
Other useful reflections may be obtained by compositions of the
form turnN(reflect(algorithm))
for N = 45, 90, 135, 180,
215, 270, 315. For this reason, such reflections are not given as
separate methods.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to reflect
public static PaintAlgorithm translate(PaintAlgorithm algorithm, int x0, int y0)
Returns a PaintAlgorithm
constructed from the given
PaintAlgorithm
by composition with a transform that
translates by the given x0, y0.
More precisely, for any (x, y), the new algorithm at (x, y) will be computed as:
algorithm.color(x  x0, y  y0)
The x and y periods of the resulting algorithm are the same as the x and y periods of the given algorithm.
If the given algorithm is null
, returns
null
.
algorithm
 the paint algorithm to reflectx0
 the x translationy0
 the y translation
public static PaintAlgorithm stripeEtoW(Color color1, Color color2, int thick1, int thick2)
Returns the PaintAlgorithm
that draws a pair
of stripes from east to west
with stripe 1 using color color1 with thickness thick1
and
with stripe 2 using color color2 with thickness thick2.
The x period is 1.
The y period is thick1 + thick2
.
color1
 the color for stripe 1color2
 the color for stripe 2thick1
 the thickness of stripe 1thick2
 the thickness of stripe 2
public static PaintAlgorithm stripeEtoW(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int thick1, int thick2)
Returns the PaintAlgorithm
that draws a pair
of stripes from east to west
with stripe 1 using algorithm1 with thickness thick1
and
with stripe 2 using algorithm2 with thickness thick2.
The x period is the least common multiple of the x periods of the given algorithms.
The y period is thick1 + thick2
.
If either algorithm is null
, returns
null
.
algorithm1
 the paint algorithm for stripe 1algorithm2
 the paint algorithm for stripe 2thick1
 the thickness of stripe 1thick2
 the thickness of stripe 2
public static PaintAlgorithm stripeNEtoSW(Color color1, Color color2, int thick1, int thick2)
Equivalent to turn45(stripeEtoW(args))
.
public static PaintAlgorithm stripeNEtoSW(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int thick1, int thick2)
Equivalent to turn45(stripeEtoW(args))
.
public static PaintAlgorithm stripeNtoS(Color color1, Color color2, int thick1, int thick2)
Equivalent to turn90(stripeEtoW(args))
.
public static PaintAlgorithm stripeNtoS(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int thick1, int thick2)
Equivalent to turn90(stripeEtoW(args))
.
public static PaintAlgorithm stripeNWtoSE(Color color1, Color color2, int thick1, int thick2)
Equivalent to turn135(stripeEtoW(args))
.
public static PaintAlgorithm stripeNWtoSE(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int thick1, int thick2)
Equivalent to turn135(stripeEtoW(args))
.
public static PaintAlgorithm checkHatch(Color color1, Color color2, int width1, int width2, int height1, int height2)
Returns a checker board hatch pattern.
The colors are arranged in the cells as follows:
color1 color2 color2 color1
The cell widths and heights use the given values.
The x period is width1 + width2
.
The y period is height1 + height2
.
color1
 the color for 2 of 4 cellscolor2
 the color for 2 of 4 cellswidth1
 the width of column 1width2
 the width of column 2height1
 the height of row 1height2
 the height of row 2
public static PaintAlgorithm checkHatch(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int width1, int width2, int height1, int height2)
Returns a check board hatch pattern.
The algorithms are applied to the cells as follows:
algorithm1 algorithm2 algorithm2 algorithm1
The cell widths and heights use the given values.
The x period is width1 + width2
.
The y period is height1 + height2
.
If either algorithm is null
, returns
null
.
algorithm1
 the algorithm for 2 of 4 cellsalgorithm2
 the algorithm for 2 of 4 cellswidth1
 the width of column 1width2
 the width of column 2height1
 the height of row 1height2
 the height of row 2
public static PaintAlgorithm checkHatchDiagonal(Color color1, Color color2, int width1, int width2, int height1, int height2)
Equivalent to turn45(checkHatch(args))
.
public static PaintAlgorithm checkHatchDiagonal(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int width1, int width2, int height1, int height2)
Equivalent to turn45(checkHatch(args))
.
public static PaintAlgorithm crossHatch(Color color1, Color color2, int width1, int width2, int height1, int height2)
Returns a cross hatch pattern.
The colors are arranged in the cells as follows:
color1 color1 color1 color2
The cell widths and heights use the given values.
The x period is width1 + width2
.
The y period is height1 + height2
.
color1
 the color for 3 of 4 cellscolor2
 the color for 1 of 4 cellswidth1
 the width of column 1width2
 the width of column 2height1
 the height of row 1height2
 the height of row 2
public static PaintAlgorithm crossHatch(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int width1, int width2, int height1, int height2)
Returns a cross hatch pattern.
The algorithms are applied to the cells as follows:
algorithm1 algorithm1 algorithm1 algorithm2
The cell widths and heights use the given values.
The x period is width1 + width2
.
The y period is height1 + height2
.
If either algorithm is null
, returns
null
.
algorithm1
 the algorithm for 3 of 4 cellsalgorithm2
 the algorithm for 1 of 4 cellswidth1
 the width of column 1width2
 the width of column 2height1
 the height of row 1height2
 the height of row 2
public static PaintAlgorithm crossHatchDiagonal(Color color1, Color color2, int width1, int width2, int height1, int height2)
Equivalent to turn45(crossHatch(args))
.
public static PaintAlgorithm crossHatchDiagonal(PaintAlgorithm algorithm1, PaintAlgorithm algorithm2, int width1, int width2, int height1, int height2)
Equivalent to turn45(crossHatch(args))
.
public static PaintAlgorithm dottedGrid(Color dotColor, Color backColor, int dotSize, int gridSize)
Returns a dotted grid pattern with the given dot color and background color.
If null
, the dot color is forced to black and
the background color to white.
The dot size is forced to at least 1.
If necessary, the grid size is forced upward to be a multiple of twice the dot size.
The x and y periods equal the adjusted grid size.
dotColor
 the dot colorbackColor
 the background colordotSize
 the dot sizegridSize
 the size of the dot grid
public static PaintAlgorithm dottedGridDiagonal(Color dotColor, Color backColor, int dotSize, int gridSize)
Equivalent to turn45(dottedGrid(args))
.
public static PaintAlgorithm brickEtoW(Color cellColor, Color edgeColor, int size)
Returns a brick pattern oriented horizontally (EW) such that the brick cell has dimensions width = 2 * size, height = size and uses the given cell color and edge color.
If null
, the cell color is forced to brown, that
is, R = 165, G = 42, B = 42.
If null
, the edge color is forced to black.
The size is forced to at least 2.
The x and y periods equal 2 * size + 4 to allow space for the edges.
cellColor
 the color that fills the brickedgeColor
 the color that outlines the bricksize
 the quantity that determines the brick dimensions
public static PaintAlgorithm brickNEtoSW(Color cellColor, Color edgeColor, int size)
Equivalent to turn45(brickEtoW(args))
.
public static PaintAlgorithm brickNtoS(Color cellColor, Color edgeColor, int size)
Equivalent to turn90(brickEtoW(args))
.
public static PaintAlgorithm brickNWtoSE(Color cellColor, Color edgeColor, int size)
Equivalent to turn135(brickEtoW(args))
.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 