/** * Called to initialize the outline by setting the top level bookmark. * * @param bookmark top level bookmark. */ public void setFirstBookmark(final Bookmark bookmark) { final Vector activeVector = getActiveVector(); synchronized (activeVector) { final Hashtable parentMap = getParentMap(); parentMap.clear(); final Vector pagenoVector = getPagenoVector(); pagenoVector.setSize(0); getDepthMap().clear(); mapChildren(bookmark, parentMap, pagenoVector, new Integer(0)); activeVector.setSize(0); activeVector.addElement(bookmark); setCheckedItem(0, true); } }
/** * Query the maximum image size allowed. * * @return the maximum image size allowed. */ public Dimension getMaximumSize() { final Dimension retval = new Dimension(); final Hashtable depthMap = getDepthMap(); int item = 0; synchronized (getActiveVector()) { final Enumeration keys = getDepthMap().keys(); while (keys.hasMoreElements()) { final Bookmark bookmark = (Bookmark) keys.nextElement(); final Rectangle bounds = getTextBounds(item++, bookmark, depthMap.get(bookmark)); final int width = bounds.x + bounds.width; if (width > retval.width) { retval.width = width; } retval.height = bounds.y + bounds.height; } } retval.width += (2 * getFontMetrics(getFont()).getMaxAdvance()); retval.height += (2 * getFontHeight()); return retval; }
/** * Called to create a map the parent of each bookmark. * * @param parent top level bookmark. * @param parentMap map to add children to. * @param pagenoVector vector of page numbers. * @param depth object indicating bookmark depth. */ protected void mapChildren( final Bookmark parent, final Hashtable parentMap, final Vector pagenoVector, final Number depth) { getDepthMap().put(parent, depth); final int pageno = parent.getPageno(); if (pageno >= 0) { while (pageno >= pagenoVector.size()) { pagenoVector.addElement(null); } pagenoVector.setElementAt(parent, pageno); } final Enumeration e = parent.elements(); if (e.hasMoreElements()) { final Number childDepth = new Integer(depth.intValue() + 1); do { final Bookmark child = (Bookmark) e.nextElement(); parentMap.put(child, parent); mapChildren(child, parentMap, pagenoVector, childDepth); } while (e.hasMoreElements()); } }