edu.rit.draw.item
Class ColorFill
- java.lang.Object
-
- edu.rit.draw.item.ColorFill
-
- All Implemented Interfaces:
- Fill, java.io.Externalizable, java.io.Serializable
public class ColorFill extends java.lang.Object implements Fill
Class ColorFill provides an object that fills an area in a DrawingItem with a solid color.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static ColorFillBLACKColor fill object for the color black.static ColorFillBLUEColor fill object for the color blue.static ColorFillCYANColor fill object for the color cyan.static ColorFillDARK_GRAYColor fill object for the color dark gray.static ColorFillGRAYColor fill object for the color gray.static ColorFillGREENColor fill object for the color green.static ColorFillLIGHT_GRAYColor fill object for the color light gray.static ColorFillMAGENTAColor fill object for the color magenta.static ColorFillNORMAL_FILLThe normal color fill object (white).static ColorFillORANGEColor fill object for the color orange.static ColorFillPINKColor fill object for the color pink.static ColorFillREDColor fill object for the color red.static ColorFillWHITEColor fill object for the color white.static ColorFillYELLOWColor fill object for the color yellow.
-
Constructor Summary
Constructors Constructor and Description ColorFill()Construct a new color fill object with the normal fill color (white).ColorFill(ColorFill theColorFill)Construct a new color fill object with the same color as the given color fill object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.awt.Colorcolor()Returns the color of this color fill object.ColorFillcolor(java.awt.Color theColor)Set this color fill object to the given color.ColorFillgray(float grayLevel)Set this color fill object to the given shade of gray.ColorFillgray(int grayLevel)Set this color fill object to the given shade of gray.voidreadExternal(java.io.ObjectInput in)Read this color fill object from the given object input stream.ColorFillrgb(float red, float green, float blue)Set this color fill object to the color with the given red, green, and blue components.ColorFillrgb(int red, int green, int blue)Set this color fill object to the color with the given red, green, and blue components.voidsetGraphicsContext(java.awt.Graphics2D g2d)Set the given graphics context's paint attribute as specified by this fill object.voidwriteExternal(java.io.ObjectOutput out)Write this color fill object to the given object output stream.
-
-
-
Field Detail
-
WHITE
public static final ColorFill WHITE
Color fill object for the color white.
-
LIGHT_GRAY
public static final ColorFill LIGHT_GRAY
Color fill object for the color light gray.
-
GRAY
public static final ColorFill GRAY
Color fill object for the color gray.
-
DARK_GRAY
public static final ColorFill DARK_GRAY
Color fill object for the color dark gray.
-
BLACK
public static final ColorFill BLACK
Color fill object for the color black.
-
RED
public static final ColorFill RED
Color fill object for the color red.
-
PINK
public static final ColorFill PINK
Color fill object for the color pink.
-
ORANGE
public static final ColorFill ORANGE
Color fill object for the color orange.
-
YELLOW
public static final ColorFill YELLOW
Color fill object for the color yellow.
-
GREEN
public static final ColorFill GREEN
Color fill object for the color green.
-
MAGENTA
public static final ColorFill MAGENTA
Color fill object for the color magenta.
-
CYAN
public static final ColorFill CYAN
Color fill object for the color cyan.
-
BLUE
public static final ColorFill BLUE
Color fill object for the color blue.
-
NORMAL_FILL
public static final ColorFill NORMAL_FILL
The normal color fill object (white).
-
-
Constructor Detail
-
ColorFill
public ColorFill()
Construct a new color fill object with the normal fill color (white).
-
ColorFill
public ColorFill(ColorFill theColorFill)
Construct a new color fill object with the same color as the given color fill object.- Parameters:
theColorFill- Color fill object.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theColorFill is null.
-
-
Method Detail
-
color
public java.awt.Color color()
Returns the color of this color fill object.- Returns:
- Color.
-
gray
public ColorFill gray(int grayLevel)
Set this color fill object to the given shade of gray.- Parameters:
grayLevel- Gray level in the range 0 (black) through 255 (white).- Returns:
- This color fill object.
-
gray
public ColorFill gray(float grayLevel)
Set this color fill object to the given shade of gray.- Parameters:
grayLevel- Gray level in the range 0.0f (black) through 1.0f (white).- Returns:
- This color fill object.
-
rgb
public ColorFill rgb(int red, int green, int blue)
Set this color fill object to the color with the given red, green, and blue components.- Parameters:
red- Red component in the range 0 through 255.green- Green component in the range 0 through 255.blue- Blue component in the range 0 through 255.- Returns:
- This color fill object.
-
rgb
public ColorFill rgb(float red, float green, float blue)
Set this color fill object to the color with the given red, green, and blue components.- Parameters:
red- Red component in the range 0.0f through 1.0f.green- Green component in the range 0.0f through 1.0f.blue- Blue component in the range 0.0f through 1.0f.- Returns:
- This color fill object.
-
color
public ColorFill color(java.awt.Color theColor)
Set this color fill object to the given color.- Parameters:
theColor- Color.- Returns:
- This color fill object.
- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theColor is null.
-
setGraphicsContext
public void setGraphicsContext(java.awt.Graphics2D g2d)
Set the given graphics context's paint attribute as specified by this fill object.- Specified by:
setGraphicsContextin interfaceFill- Parameters:
g2d- 2-D graphics context.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite this color fill object to the given object output stream.- Specified by:
writeExternalin interfacejava.io.Externalizable- Parameters:
out- Object output stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOExceptionRead this color fill object from the given object input stream.- Specified by:
readExternalin interfacejava.io.Externalizable- Parameters:
in- Object input stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
-
DMelt 3.0 © DataMelt by jWork.ORG