com.tensegrity.graphics.device.awt
Class AWTGradientPaintContext

java.lang.Object
  extended bycom.tensegrity.graphics.device.awt.AWTPaintContext
      extended bycom.tensegrity.graphics.device.awt.AWTGradientPaintContext
All Implemented Interfaces:
java.awt.PaintContext

public class AWTGradientPaintContext
extends com.tensegrity.graphics.device.awt.AWTPaintContext

The AWTGradientPaintContext is an implementation of the PaintContext interface that is used by the AWTDevice to render gradients.

Version:
$Id: AWTGradientPaintContext.java,v 1.8 2005/07/05 10:13:48 BurkhardWick Exp $
Author:
MichaelKegel

Field Summary
protected  int alpha
          instance variable for the alpha value when writing a pixel
static java.awt.image.ColorModel argbmodel
          constant that defines a ColorModel that do support alpha values
protected  double transparency
          instance variable for the transparency level in percent
protected  int txOrg
          instance variable for the origin translation in x direction
protected  int tyOrg
          instance variable for the origin translation in y direction
static java.awt.image.ColorModel xrgbmodel
          constant that defines a ColorModel that do not support alpha values
 
Constructor Summary
AWTGradientPaintContext(Gradient gradient, java.awt.Rectangle rcPaint, int transparency)
          Constructor that creates a AWTGradientPaintContext with the Gradient given by gradient, the transparency level given by transparency that renders within the Rectangle given by rcPaint.
 
Method Summary
 void dispose()
           
protected  void fillCenterCircle(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a concentric gradient from the center to all corners for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillCenterSquared(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a squared gradient from the center to all corners for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillDown(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from the left/top corner to the right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillDownCenter(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from the left/top corner to the center and vice versa from the center to the right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillHorizontalCenter(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from top to the center and vice versa from the center to bottom for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillLeftBottom(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a squared gradient from the left/bottom corner to the left/top and right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillLeftTop(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a squared gradient from the left/top corner to the left/bottom and right/top corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillLeftTopCircle(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a concentric gradient from the left/top corner to the left/bottom and right/top corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillRightBottom(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a squared gradient from the right/bottom corner to the right/top and left/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillRightLeft(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from right to left for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillRightTop(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a squared gradient from the right/top corner to the left/top and right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillRightTopCircle(java.awt.image.DataBuffer pixels, int w, int h)
          Renders a concentric gradient from the right/top corner to the right/bottom and left/top corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillTopBottom(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from top to bottom for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillUp(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from the left/bottom corner to the right/top corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillUpCenter(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from the left/bottom corner to the center and vice versa from the center to the right/top corner for the width and height given by w and h into the DataBuffer given by pixels.
protected  void fillVerticalCenter(java.awt.image.DataBuffer pixels, int w, int h)
          Renders the gradient from right to the center and vice versa from the center to the left for the width and height given by w and h into the DataBuffer given by pixels.
 java.awt.image.ColorModel getColorModel()
           
 java.awt.image.Raster getRaster(int x, int y, int w, int h)
           
static int[] renderColorGradient(int alpha, int rgbFrom, int rgbTo, boolean cyclic)
          Computes the color values used to render a gradient and returns them in an integer array.
 void setColorModel(boolean hasAlpha)
          Sets the ColorModel for the AWTPaintContext with respect to the flag given by hasAlpha that indicates whether the AWTPaintContext should support transparency or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xrgbmodel

public static java.awt.image.ColorModel xrgbmodel
constant that defines a ColorModel that do not support alpha values


argbmodel

public static java.awt.image.ColorModel argbmodel
constant that defines a ColorModel that do support alpha values


transparency

protected double transparency
instance variable for the transparency level in percent


alpha

protected int alpha
instance variable for the alpha value when writing a pixel


txOrg

protected int txOrg
instance variable for the origin translation in x direction


tyOrg

protected int tyOrg
instance variable for the origin translation in y direction

Constructor Detail

AWTGradientPaintContext

public AWTGradientPaintContext(Gradient gradient,
                               java.awt.Rectangle rcPaint,
                               int transparency)
Constructor that creates a AWTGradientPaintContext with the Gradient given by gradient, the transparency level given by transparency that renders within the Rectangle given by rcPaint.

Parameters:
gradient - the Gradient to use
rcPaint - the Rectangle to render within
transparency - the transparency level given in percent
Method Detail

getRaster

public java.awt.image.Raster getRaster(int x,
                                       int y,
                                       int w,
                                       int h)

fillRightLeft

protected void fillRightLeft(java.awt.image.DataBuffer pixels,
                             int w,
                             int h)
Renders the gradient from right to left for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillVerticalCenter

protected void fillVerticalCenter(java.awt.image.DataBuffer pixels,
                                  int w,
                                  int h)
Renders the gradient from right to the center and vice versa from the center to the left for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillTopBottom

protected void fillTopBottom(java.awt.image.DataBuffer pixels,
                             int w,
                             int h)
Renders the gradient from top to bottom for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillHorizontalCenter

protected void fillHorizontalCenter(java.awt.image.DataBuffer pixels,
                                    int w,
                                    int h)
Renders the gradient from top to the center and vice versa from the center to bottom for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillUp

protected void fillUp(java.awt.image.DataBuffer pixels,
                      int w,
                      int h)
Renders the gradient from the left/bottom corner to the right/top corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillUpCenter

protected void fillUpCenter(java.awt.image.DataBuffer pixels,
                            int w,
                            int h)
Renders the gradient from the left/bottom corner to the center and vice versa from the center to the right/top corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillDown

protected void fillDown(java.awt.image.DataBuffer pixels,
                        int w,
                        int h)
Renders the gradient from the left/top corner to the right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillDownCenter

protected void fillDownCenter(java.awt.image.DataBuffer pixels,
                              int w,
                              int h)
Renders the gradient from the left/top corner to the center and vice versa from the center to the right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillLeftBottom

protected void fillLeftBottom(java.awt.image.DataBuffer pixels,
                              int w,
                              int h)
Renders a squared gradient from the left/bottom corner to the left/top and right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillRightBottom

protected void fillRightBottom(java.awt.image.DataBuffer pixels,
                               int w,
                               int h)
Renders a squared gradient from the right/bottom corner to the right/top and left/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillLeftTop

protected void fillLeftTop(java.awt.image.DataBuffer pixels,
                           int w,
                           int h)
Renders a squared gradient from the left/top corner to the left/bottom and right/top corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillRightTop

protected void fillRightTop(java.awt.image.DataBuffer pixels,
                            int w,
                            int h)
Renders a squared gradient from the right/top corner to the left/top and right/bottom corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillCenterSquared

protected void fillCenterSquared(java.awt.image.DataBuffer pixels,
                                 int w,
                                 int h)
Renders a squared gradient from the center to all corners for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillCenterCircle

protected void fillCenterCircle(java.awt.image.DataBuffer pixels,
                                int w,
                                int h)
Renders a concentric gradient from the center to all corners for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillLeftTopCircle

protected void fillLeftTopCircle(java.awt.image.DataBuffer pixels,
                                 int w,
                                 int h)
Renders a concentric gradient from the left/top corner to the left/bottom and right/top corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

fillRightTopCircle

protected void fillRightTopCircle(java.awt.image.DataBuffer pixels,
                                  int w,
                                  int h)
Renders a concentric gradient from the right/top corner to the right/bottom and left/top corner for the width and height given by w and h into the DataBuffer given by pixels.

Parameters:
pixels - the DataBuffer to render the gradient into
w - the width for the gradient
h - the height for the gradient

renderColorGradient

public static int[] renderColorGradient(int alpha,
                                        int rgbFrom,
                                        int rgbTo,
                                        boolean cyclic)
Computes the color values used to render a gradient and returns them in an integer array. The computition starts by the color value given by rgbFrom and goes up to rgbTo. For a simple gradient this makes up 256 color values; for a cyclic gradient this makes up 512 color values. A cyclic gradient is indicated by the given flag cyclic.
NOTICE:The alpha values of the given rgb values are not taken in account. Instead the value given by alpha is used for each computet color value.

Parameters:
alpha - the alpha value for each computet color
rgbFrom - the rgb value where to start
rgbTo - the rgb value where to stop
cyclic - flag that indicates a cyclic gradient
Returns:
int[] the computet color values

setColorModel

public void setColorModel(boolean hasAlpha)
Sets the ColorModel for the AWTPaintContext with respect to the flag given by hasAlpha that indicates whether the AWTPaintContext should support transparency or not.

Parameters:
hasAlpha - flag that indicates whether alpha values should be supported or not

dispose

public void dispose()
Specified by:
dispose in interface java.awt.PaintContext

getColorModel

public java.awt.image.ColorModel getColorModel()
Specified by:
getColorModel in interface java.awt.PaintContext


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.