FileDocCategorySizeDatePackage
PaintServerReference.javaAPI DocphoneME MR2 API (J2ME)7281Wed May 02 18:00:34 BST 2007com.sun.perseus.model

PaintServerReference

public class PaintServerReference extends Object
The PaintServerReference object is used to handle references from a GraphicsNode to an actual Paint implementation. This is needed because paint references are not always resolved, for example when a document has forward references to paint servers.
version
$Id: PaintServerReference.java,v 1.5 2006/06/29 10:47:33 ln156897 Exp $

Fields Summary
static final com.sun.perseus.j2d.RGB
UNRESOLVED_PAINT
Paint used when the paint server reference has not been resolved yet. Fully transparent black.
Constructors Summary
Methods Summary
public static com.sun.perseus.j2d.PaintServerresolve(DocumentNode doc, com.sun.perseus.j2d.PaintTarget paintTarget, java.lang.String traitName, java.lang.String idRef)
If the requested idRef is resolved, this method checks it is a reference to a PaintServer and returns that PaintServer. If the resquested idRef cannot be resolved, then the method returns and PaintServerReference.Unresolved instance.

param
doc the Document scope.
param
paintTarget the PaintServer observer.
param
traitName the name of the trait for which the server is seeked.
param
idRef the id of the paint server reference.

        // Check if the paint server reference is already resolved.
        ElementNode ref = (ElementNode) doc.getElementById(idRef);
        if (ref != null) {
            if (!(ref instanceof PaintElement)) {
                throw new DOMException(
                        DOMException.INVALID_STATE_ERR,
                        Messages.formatMessage(
                            Messages.ERROR_INVALID_PAINT_SERVER_REFERENCE,
                            new String[] {
                                idRef,
                                ref.getNamespaceURI(),
                                ref.getLocalName()
                            }));
            } else {
                return ((PaintElement) ref).getPaintServer(traitName, 
                                                           paintTarget);
            }
        } 
        
        // The paint server reference is not resolved yet. We create an 
        // unresolved PaintServer.
        return new PaintServerReference.Unresolved(doc, 
                                                   paintTarget, 
                                                   traitName, 
                                                   idRef);