public static Annotation buildAnnotation(Library library,
                                             int type,
                                             Rectangle rect,
                                             AnnotationState annotationState) {
        // state manager 
        StateManager stateManager = library.getStateManager();

        // create a new entries to hold the annotation properties
        Hashtable<Name, Object> entries = new Hashtable<Name, Object>();
        // set default link annotation values. 
        entries.put(Dictionary.TYPE_KEY, Annotation.TYPE_VALUE);
        entries.put(Dictionary.SUBTYPE_KEY, Annotation.SUBTYPE_LINK);
        // coordinates
        if (rect != null) {
            entries.put(Annotation.RECTANGLE_KEY,
                    PRectangle.getPRectangleVector(rect));
        } else {
            entries.put(Annotation.RECTANGLE_KEY, new Rectangle(10, 10, 50, 100));
        }
        // build up a link annotation
        if (type == LINK_ANNOTATION) {
            // we only support one type of annotation creation for now
            LinkAnnotation linkAnnotation = new LinkAnnotation(library, entries);
            linkAnnotation.setPObjectReference(stateManager.getNewReferencNumber());
            linkAnnotation.setNew(true);

            // apply state
            if (annotationState != null) {
                annotationState.restore(linkAnnotation);
            }
            // some defaults just for display purposes.
            else {
                annotationState = new AnnotationState(
                        Annotation.VISIBLE_RECTANGLE,
                        LinkAnnotation.HIGHLIGHT_INVERT, 1f,
                        BorderStyle.BORDER_STYLE_SOLID, Color.RED);
                annotationState.restore(linkAnnotation);
            }
            return linkAnnotation;
        } else {
            logger.warning("Unsupported Annotation type. ");
            return null;
        }

    }