// todo consider composite cache.
 public static Composite getInstance(Name modeName, float alpha) {
   // check for -1, value not set and default should be used.
   if (alpha == -1) {
     alpha = 1;
   }
   if (modeName.equals(NORMAL_VALUE) || modeName.equals(COMPATIBLE_VALUE)) {
     return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
     //            return new BlendComposite(BlendingMode.NORMAL, alpha);
   } else if (modeName.equals(MULTIPLY_VALUE)) {
     return new BlendComposite(BlendingMode.MULTIPLY, alpha);
   } else if (modeName.equals(SCREEN_VALUE)) {
     return new BlendComposite(BlendingMode.SCREEN, alpha);
   } else if (modeName.equals(OVERLAY_VALUE)) {
     return new BlendComposite(BlendingMode.OVERLAY, alpha);
   } else if (modeName.equals(DARKEN_VALUE)) {
     return new BlendComposite(BlendingMode.DARKEN, alpha);
   } else if (modeName.equals(LIGHTEN_VALUE)) {
     return new BlendComposite(BlendingMode.LIGHTEN, alpha);
   } else if (modeName.equals(COLOR_DODGE_VALUE)) {
     return new BlendComposite(BlendingMode.SOFT_DODGE, alpha);
   } else if (modeName.equals(COLOR_BURN_VALUE)) {
     return new BlendComposite(BlendingMode.SOFT_BURN, alpha);
   } else if (modeName.equals(HARD_LIGHT_VALUE)) {
     return new BlendComposite(BlendingMode.HARD_LIGHT, alpha);
   } else if (modeName.equals(SOFT_LIGHT_VALUE)) {
     return new BlendComposite(BlendingMode.SOFT_LIGHT, alpha);
   } else if (modeName.equals(DIFFERENCE_VALUE)) {
     return new BlendComposite(BlendingMode.DIFFERENCE, alpha);
   } else if (modeName.equals(EXCLUSION_VALUE)) {
     return new BlendComposite(BlendingMode.EXCLUSION, alpha);
   }
   //        return new BlendComposite(BlendingMode.NORMAL, alpha);
   return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
 }
 /**
  * Creates a new Annotation object using properties from the annotationState paramater. If no
  * annotaitonState is provided a LinkAnnotation is returned with with a black border. The rect
  * specifies where the annotation should be located in user space.
  *
  * <p>This call adds the new Annotation object to the document library as well as the document
  * StateManager.
  *
  * @param library library to register annotation with
  * @param subType type of annotation to create
  * @param rect bounds of new annotation specified in user space.
  * @return new annotation object with the same properties as the one specified in annotaiton
  *     state.
  */
 public static Annotation buildAnnotation(Library library, final Name subType, Rectangle rect) {
   // build up a link annotation
   if (subType.equals(Annotation.SUBTYPE_LINK)) {
     return LinkAnnotation.getInstance(library, rect);
   }
   // highlight version of a TextMarkup annotation.
   else if (subType.equals(TextMarkupAnnotation.SUBTYPE_HIGHLIGHT)
       || subType.equals(TextMarkupAnnotation.SUBTYPE_STRIKE_OUT)
       || subType.equals(TextMarkupAnnotation.SUBTYPE_UNDERLINE)) {
     return TextMarkupAnnotation.getInstance(library, rect, subType);
   } else if (subType.equals(Annotation.SUBTYPE_LINE)) {
     return LineAnnotation.getInstance(library, rect);
   } else if (subType.equals(Annotation.SUBTYPE_SQUARE)) {
     return SquareAnnotation.getInstance(library, rect);
   } else if (subType.equals(Annotation.SUBTYPE_CIRCLE)) {
     return CircleAnnotation.getInstance(library, rect);
   } else if (subType.equals(Annotation.SUBTYPE_INK)) {
     return InkAnnotation.getInstance(library, rect);
   } else if (subType.equals(Annotation.SUBTYPE_FREE_TEXT)) {
     return FreeTextAnnotation.getInstance(library, rect);
   } else if (subType.equals(Annotation.SUBTYPE_TEXT)) {
     return TextAnnotation.getInstance(library, rect);
   } else if (subType.equals(Annotation.SUBTYPE_POPUP)) {
     return PopupAnnotation.getInstance(library, rect);
   } else {
     logger.warning("Unsupported Annotation type. ");
     return null;
   }
 }