/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A CompositeType object provides a chained description of a type of
* algorithm for color compositing. The object will provide a single
* String constant descriptor which is one way of describing a particular
* compositing algorithm as well as a pointer to another CompositeType
* which describes a more general algorithm for achieving the same result.
* <p>
* A description of a more specific algorithm is considered a "subtype"
* and a description of a more general algorithm is considered a "supertype".
* Thus, the deriveSubType method provides a way to create a new CompositeType
* that is related to but more specific than an existing CompositeType and
* the getSuperType method provides a way to ask a given CompositeType
* for a more general algorithm to achieve the same result.
* <p>
* Note that you cannot construct a brand new root for a chain since
* the constructor is private. Every chain of types must at some point
* derive from the Any node provided here using the deriveSubType()
* method. The presence of this common Any node on every chain
* ensures that all chains end with the DESC_ANY descriptor so that
* a suitable General GraphicsPrimitive object can be obtained for
* the indicated algorithm if all of the more specific searches fail.
*/
public final class CompositeType {
/*
* CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE COMPOSITING
* ALGORITHMS THEY CAN PERFORM
*/
/**
* algorithm is a general algorithm that uses a CompositeContext
* to do the rendering.
*/
/**
* constant used to describe the Graphics.setXORMode() algorithm
*/
/**
* constants used to describe the various AlphaComposite
* algorithms.
*/
/**
* constants used to describe the two common cases of
* AlphaComposite algorithms that are simpler if there
* is not extraAlpha.
*/
public static final String
public static final String
/**
* constant used to describe an algorithm that implements all 8 of
* the Porter-Duff rules in one Primitive.
*/
/*
* END OF COMPOSITE ALGORITHM TYPE CONSTANTS
*/
/**
* The root CompositeType object for all chains of algorithm descriptions.
*/
public static final CompositeType
/*
* START OF CompositeeType OBJECTS FOR THE VARIOUS CONSTANTS
*/
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
public static final CompositeType
/*
* A special CompositeType for the case where we are filling in
* SrcOverNoEa mode with an opaque color. In that case then the
* best loop for us to use would be a SrcNoEa loop, but what if
* there is no such loop? In that case then we would end up
* backing off to a Src loop (which should still be fine) or an
* AnyAlpha loop which would be slower than a SrcOver loop in
* most cases.
* The fix is to use the following chain which looks for loops
* in the following order:
* SrcNoEa, Src, SrcOverNoEa, SrcOver, AnyAlpha
*/
public static final CompositeType
/*
* END OF CompositeType OBJECTS FOR THE VARIOUS CONSTANTS
*/
/**
* Return a new CompositeType object which uses this object as its
* more general "supertype" descriptor. If no operation can be
* found that implements the algorithm described more exactly
* by desc, then this object will define the more general
* compositing algorithm that can be used instead.
*/
return new CompositeType(this, desc);
}
/**
* Return a CompositeType object for the specified AlphaComposite
* rule.
*/
case AlphaComposite.CLEAR:
return Clear;
case AlphaComposite.SRC:
return SrcNoEa;
} else {
return Src;
}
case AlphaComposite.DST:
return Dst;
case AlphaComposite.SRC_OVER:
return SrcOverNoEa;
} else {
return SrcOver;
}
case AlphaComposite.DST_OVER:
return DstOver;
case AlphaComposite.SRC_IN:
return SrcIn;
case AlphaComposite.DST_IN:
return DstIn;
case AlphaComposite.SRC_OUT:
return SrcOut;
case AlphaComposite.DST_OUT:
return DstOut;
case AlphaComposite.SRC_ATOP:
return SrcAtop;
case AlphaComposite.DST_ATOP:
return DstAtop;
case AlphaComposite.XOR:
return AlphaXor;
default:
throw new InternalError("Unrecognized alpha rule");
}
}
private int uniqueID;
}
if (i == null) {
if (unusedUID > 255) {
throw new InternalError("composite type id overflow");
}
i = unusedUID++;
}
return i;
}
public int getUniqueID() {
return uniqueID;
}
return desc;
}
return next;
}
public int hashCode() {
}
CompositeType comptype = this;
do {
return true;
}
return false;
}
if (o instanceof CompositeType) {
}
return false;
}
return desc;
}
}