]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
created initializeID method
authorJordan Naftolin <jordan@apache.org>
Wed, 21 Jun 2000 23:40:41 +0000 (23:40 +0000)
committerJordan Naftolin <jordan@apache.org>
Wed, 21 Jun 2000 23:40:41 +0000 (23:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193424 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/datatypes/IDReferences.java

index 232e74360a185897bc8f8117b8faa00ae4a9b481..c610525d672886a67540c6d435a420f0aa24bc19 100644 (file)
@@ -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
      *