From: Jordan Naftolin Date: Wed, 21 Jun 2000 23:40:41 +0000 (+0000) Subject: created initializeID method X-Git-Tag: pre-columns~453 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=637eba565897927257bf349bd150124f86069d15;p=xmlgraphics-fop.git created initializeID method git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193424 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/datatypes/IDReferences.java b/src/org/apache/fop/datatypes/IDReferences.java index 232e74360..c610525d6 100644 --- a/src/org/apache/fop/datatypes/IDReferences.java +++ b/src/org/apache/fop/datatypes/IDReferences.java @@ -59,13 +59,15 @@ import java.util.Hashtable; import java.util.Vector; import java.util.Enumeration; import java.util.NoSuchElementException; +import org.apache.fop.layout.Area; +import org.apache.fop.apps.FOPException; -public class IDReferences -{ +public class IDReferences { private Hashtable idReferences; private Vector idValidation; + final static int ID_PADDING = 5000; // space to add before id y position /** * Constructor for IDReferences @@ -77,6 +79,28 @@ public class IDReferences } + /** + * Initializes the specified id. This should be called everytime an id is encountered + * + * @param id The id to initialize + * @param area The area where this id was encountered + * @exception FOPException + */ + public void initializeID(String id, Area area) throws FOPException + { + if ( id!=null && !id.equals("") ) { + if ( doesIDExist(id) ) { + throw new FOPException("The id \""+id+"\" already exists in this document"); + } + else { + createNewId(id); + removeFromIdValidationList(id); + setYPosition(id,area.getPage().getBody().getYPosition() - area.getAbsoluteHeight()+ID_PADDING); + area.getPage().addToIDList(id); + } + } + } + /** * Adds id to validation list to be validated . This should be used if it is unsure whether the id is valid *