org.dvb.ui
Class DVBGraphics

java.lang.Object
  extended by java.awt.Graphics
      extended by java.awt.Graphics2D
          extended by org.dvb.ui.DVBGraphics

public abstract class DVBGraphics
extends java.awt.Graphics2D

The DVBGraphics class is a adapter class to support alpha compositing in a GEM device. At all times, the DVBAlphaComposite returned by getDVBComposite and the Composite returned by the getComposite method inherited from Graphics2D shall be consistent. This means that the results of calling getRule and getAlpha on those shall be identical. In GEM devices all Graphics Objects are DVBGraphics objects. Thus one can get a DVBGraphics by casting a given Graphics object. The normal compositing rule used is DVBAlphaComposite.SRC_OVER. Note that the default rule of SRC_OVER may not give the highest performance. Under many circumstances, applications will find that the SRC rule will give higher performance. The intersection between setDVBComposite in this class and the setPaintMode and setXORMode methods inherited from java.awt.Graphics shall be as follows.

Note: Implementations of XOR mode may change colours with alpha to without and vice versa (reversibly).

Since:
MHP1.0
See Also:
Graphics

Method Summary
abstract  int[] getAvailableCompositeRules()
          Returns all available Porter-Duff Rules for this specific Graphics context.
 DVBColor getBestColorMatch(java.awt.Color c)
          Returns the best match for the specified Color as a DVBColor, in a device-dependent manner, as constrained by the GEM graphics reference model.
abstract  java.awt.Color getColor()
          Gets this graphics context's current color.
abstract  DVBAlphaComposite getDVBComposite()
          Returns the current DVBAlphaComposite in the DVBGraphics context.
 int getType()
          Returns the Sample Model (DVBBufferedImage.TYPE_BASE, DVBBufferedImage.TYPE_ADVANCED) which is used in the on/off screen buffer this graphics object draws into.
abstract  void setColor(java.awt.Color c)
          Sets this graphics context's current color to the specified color.
abstract  void setDVBComposite(DVBAlphaComposite comp)
          Sets the DVBAlphaComposite for the DVBGraphics context.
 java.lang.String toString()
          Returns a String object representing this DVBGraphics object's value.
 
Methods inherited from class java.awt.Graphics2D
addRenderingHints, clip, draw, draw3DRect, drawGlyphVector, drawImage, drawImage, drawRenderableImage, drawRenderedImage, drawString, drawString, drawString, drawString, fill, fill3DRect, getBackground, getComposite, getDeviceConfiguration, getFontRenderContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setBackground, setComposite, setPaint, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, transform, translate, translate
 
Methods inherited from class java.awt.Graphics
clearRect, clipRect, copyArea, create, create, dispose, drawArc, drawBytes, drawChars, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRoundRect, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillRoundRect, finalize, getClip, getClipBounds, getClipBounds, getClipRect, getFont, getFontMetrics, getFontMetrics, hitClip, setClip, setClip, setFont, setPaintMode, setXORMode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getAvailableCompositeRules

public abstract int[] getAvailableCompositeRules()
Returns all available Porter-Duff Rules for this specific Graphics context. E.g. a devices could support the SRC_OVER rule when using a destination which does not have Alpha or where the alpha is null, while this rule is not available when drawing on a graphic context where the destination has alpha. Which rules are supported for the different graphics objects is defined in the Minimum Platform Capabilities of the GEM spec.

Returns:
all available Porter-Duff Rules for this specific Graphics context.
Since:
MHP 1.0

getBestColorMatch

public DVBColor getBestColorMatch(java.awt.Color c)
Returns the best match for the specified Color as a DVBColor, in a device-dependent manner, as constrained by the GEM graphics reference model.

Parameters:
c - the specified Color.
Returns:
the best DVBColor match for the specified Color.
Since:
MHP 1.0

getColor

public abstract java.awt.Color getColor()
Gets this graphics context's current color. This will return a DVBColor cast to java.awt.Color.

Specified by:
getColor in class java.awt.Graphics
Returns:
this graphics context's current color.
Since:
MHP 1.0
See Also:
DVBColor, Color, setColor(java.awt.Color)

getDVBComposite

public abstract DVBAlphaComposite getDVBComposite()
Returns the current DVBAlphaComposite in the DVBGraphics context. This method could delegate to a java.awt.Graphics2D object where available

Returns:
the current DVBGraphics DVBAlphaComposite, which defines a compositing style.
Since:
MHP 1.0
See Also:
setDVBComposite(org.dvb.ui.DVBAlphaComposite)

getType

public int getType()
Returns the Sample Model (DVBBufferedImage.TYPE_BASE, DVBBufferedImage.TYPE_ADVANCED) which is used in the on/off screen buffer this graphics object draws into.

Returns:
the type of the Sample Model
Since:
MHP 1.0
See Also:
DVBBufferedImage

setColor

public abstract void setColor(java.awt.Color c)
Sets this graphics context's current color to the specified color. All subsequent graphics operations using this graphics context use this specified color. Note that color c can be a DVBColor

Specified by:
setColor in class java.awt.Graphics
Parameters:
c - the new rendering color.
Since:
MHP 1.0
See Also:
Color, DVBColor, getColor()

setDVBComposite

public abstract void setDVBComposite(DVBAlphaComposite comp)
                              throws UnsupportedDrawingOperationException
Sets the DVBAlphaComposite for the DVBGraphics context. The DVBAlphaComposite is used in all drawing methods such as drawImage, drawString, draw, and fill. It specifies how new pixels are to be combined with the existing pixels on the graphics device during the rendering process.

This method could delegate to a Graphics2D object or to an native implementation

Parameters:
comp - the DVBAlphaComposite object to be used for rendering
Throws:
UnsupportedDrawingOperationException - when the requested Porter-Duff rule is not supported by this graphics context
Since:
MHP 1.0
See Also:
Graphics.setXORMode(java.awt.Color), Graphics.setPaintMode(), DVBAlphaComposite

toString

public java.lang.String toString()
Returns a String object representing this DVBGraphics object's value.

Overrides:
toString in class java.awt.Graphics
Returns:
a string representation of this graphics context.
Since:
MHP 1.0