All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dvb.ui.DVBGraphics Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
package org.dvb.ui;

import java.awt.*;
import java.awt.image.ImageObserver;
import java.io.*;
import java.lang.*;
import java.util.*;



/**
 * The DVBGraphics class is a adapter class to support alpha compositing in an MHP device. Most methods directly delegate to java.awt.Graphics other methods could delegate to the appropriate methods in java.awt.Graphics2D where available or could be implemented in native code. In implementations where the class java.awt.Graphics2D is visible to MHP applications, org.dvb.ui.DVBGraphics inherits from java.awt.Graphics2D. Otherwise, org.dvb.ui.DVBGraphics  inherits from java.awt.Graphics. In MHP 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 setDVBCompsite in this class and the setPaintMode and setXORMode methods inherited from java.awt.Graphics  shall be as follows. 
  • Calling setPaintMode on an instance of this class shall be equivalent to calling setDVBComposite(DVBAlphaComposite.SrcOver).
  • Calling setXORMode on an instance of this class shall be equivalent to calling setDVBComposite with a special and implementation dependent DVBAlphaComposite object which implements the semantics specified for this method in the parent class.
  • Calling getDVBComposite when setXORMode is the last DVBComposite set shall return this implementation dependent object. Conformant MHP applications shall not do anything with or to this object including calling any methods on it.
  • The present document does not tighten, refine or detail the definition of the setXORMode beyond what is specified for the parent class.

Note: Implementations of XOR mode may change colours with alpha to without and vice versa (reversibly). * @see java.awt.Graphics * @since MHP1.0 */ public abstract class DVBGraphics extends Graphics { /** * Constructs a new DVBGraphics object. * This constructor is the default constructor for a graphics * context. *

* Since DVBGraphics is an abstract class, applications * cannot call this constructor directly. DVBGraphics contexts are * obtained from other DVBGraphics contexts or are created by casting java.awt.Graphics to DVBGraphics. * @see java.awt.Graphics#create() * @see java.awt.Component#getGraphics * @since MHP 1.0 */ protected DVBGraphics() { } /** * 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 MHP spec. * * * @return all available Porter-Duff Rules for this specific Graphics context. * @since MHP 1.0 */ public abstract int[] getAvailableCompositeRules(); /** * Returns the best match for the specified Color as a DVBColor, in a * device-dependent manner, as constrained by the MHP graphics reference model. * * @param c the specified Color. * @return the best DVBColor match for the specified Color. * @since MHP 1.0 */ public DVBColor getBestColorMatch(java.awt.Color c) { return null; } /** * Gets this graphics context's current color. This will return a DVBColor cast to java.awt.Color. * @return this graphics context's current color. * @see DVBColor * @see java.awt.Color * @see #setColor * @since MHP 1.0 */ public abstract java.awt.Color getColor(); /** * Returns the current DVBAlphaComposite in the * DVBGraphics context. * This method could delegate to a java.awt.Graphics2D object where available * @return the current DVBGraphics DVBAlphaComposite, * which defines a compositing style. * @see #setDVBComposite * @since MHP 1.0 */ public abstract DVBAlphaComposite getDVBComposite(); /** * Returns the Sample Model (DVBBufferedImage.TYPE_BASE, DVBBufferedImage.TYPE_ADVANCED) * which is used in the on/off screen buffer this graphics object draws into. * @return the type of the Sample Model * @see org.dvb.ui.DVBBufferedImage * @since MHP 1.0 */ public int getType() { return 0; } /** * 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 * @param c the new rendering color. * @see java.awt.Color * @see DVBColor * @see org.dvb.ui.DVBGraphics#getColor * @since MHP 1.0 * */ public abstract void setColor(java.awt.Color c); /** * 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 * @param comp the DVBAlphaComposite object to be used for rendering * @throws UnsupportedDrawingOperationException when the requested Porter-Duff rule is not supported by this graphics context * @see java.awt.Graphics#setXORMode * @see java.awt.Graphics#setPaintMode * @see org.dvb.ui.DVBAlphaComposite * @since MHP 1.0 */ public abstract void setDVBComposite(DVBAlphaComposite comp) throws UnsupportedDrawingOperationException; /** * Returns a String object representing this * DVBGraphics object's value. * @return a string representation of this graphics context. * @since MHP 1.0 */ public String toString() { return getClass().getName() + "[font=" + getFont() + ",color=" + getColor() + "]"; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy