|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--grad.GradientSegment
A portion of a gradient, from a Color c1 to a Color c2, in either RGB space or HSB space. Every gradient segment is defined as a particular portion of a gradient, where every gradient goes from 0.0 to 1.0. By using multiple GradientSegments, you can use a GradientPainter to get very fancy effects.
This is for Java 1.1. Java 2 already has gradient painting support.
| Field Summary | |
protected java.awt.Color |
c1c
|
protected float[] |
c1p
|
protected java.awt.Color |
c2c
|
protected float[] |
c2p
|
protected float |
end
|
protected float |
start
|
protected boolean |
useHSB
|
| Constructor Summary | |
GradientSegment(java.awt.Color c1,
java.awt.Color c2)
Create a simple GradientSegment in RGB space, from color c1 to c2 on range 0.0 to 1.0. |
|
GradientSegment(java.awt.Color c1,
java.awt.Color c2,
double s,
double e,
boolean isHSB)
Create a GradientSegment from a Color c1 to a Color 2, over the specified range s to e. |
|
GradientSegment(java.awt.Color c1,
java.awt.Color c2,
float s,
float e,
boolean isHSB)
Create a GradientSegment from Color c1 to c2, over the specified range s to e. |
|
| Method Summary | |
java.lang.Object |
clone()
Create a new GradientSegment that is the same as this one. |
void |
flip()
Flip the colors of this segment. |
java.awt.Color |
getColor(float v)
Get a Color corresponding to the value on the range 0.0 to 1.0. |
boolean |
getColor(float v,
float[] r)
Get a Color corresponding to the value on the range 0.0 to 1.0 and write the RGB components into the given float array. |
java.awt.Color |
getColor1()
Retrieve the start color |
java.awt.Color |
getColor2()
Retrieve the end color |
int |
getColorInt(double v)
Get a Color as an int with format 0x00RRGGBB. |
float |
getRangeEnd()
Retrieve the end of the range |
float |
getRangeStart()
Retrieve the start of the range |
protected void |
getRGBColorComponents(java.awt.Color c,
float[] f)
|
boolean |
getUseHSB()
Retrieve the HSB/RGB flag. |
protected void |
prepareColors()
|
void |
setColor1(java.awt.Color c)
Set the start color |
void |
setColor2(java.awt.Color c)
Set the end color |
void |
setRange(float s,
float e)
Set the start and end values |
void |
setUseHSB(boolean isHSB)
Set the HSB/RGB flag |
GradientSegment[] |
split()
Split a segment into two segments at its midpoint, the segments will be contiguous, so the overall gradient would not be affected by replacing the original segment with this pair. |
java.lang.String |
toCodeFragment(java.lang.String addToPainter)
Render this GradientSegment as a code fragment that is a call to the 5-arg constructor. |
java.lang.String |
toShortString()
Render this GradientSegment as a short, informative string. |
java.lang.String |
toString()
Render this GradientSegment as a String. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.awt.Color c1c
protected java.awt.Color c2c
protected float[] c1p
protected float[] c2p
protected float start
protected float end
protected boolean useHSB
| Constructor Detail |
public GradientSegment(java.awt.Color c1,
java.awt.Color c2)
public GradientSegment(java.awt.Color c1,
java.awt.Color c2,
double s,
double e,
boolean isHSB)
s - Start of range, s>=0.0, s<1.0e - End of range, e>0.0, e<=1.0, e>s
public GradientSegment(java.awt.Color c1,
java.awt.Color c2,
float s,
float e,
boolean isHSB)
| Method Detail |
public GradientSegment[] split()
protected void prepareColors()
protected void getRGBColorComponents(java.awt.Color c,
float[] f)
public java.awt.Color getColor1()
public java.awt.Color getColor2()
public void setColor1(java.awt.Color c)
public void setColor2(java.awt.Color c)
public float getRangeStart()
public float getRangeEnd()
public void setRange(float s,
float e)
public void setUseHSB(boolean isHSB)
isHSB - Set to true to use HSB, false for RGBpublic boolean getUseHSB()
public java.awt.Color getColor(float v)
public void flip()
public final int getColorInt(double v)
v - gradient value on the range [0,1]Color
public boolean getColor(float v,
float[] r)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toShortString()
public java.lang.String toCodeFragment(java.lang.String addToPainter)
painter1.addSegment(new GradientSegment(new Color(-519),new Color(-1),0.0, 0.5, false));
addToPainter - name of a notional GradientPainter variablepublic java.lang.Object clone()
clone in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||