From: Keiron Liddle Date: Tue, 9 Jul 2002 09:43:14 +0000 (+0000) Subject: removed old id reference stuff X-Git-Tag: Alt-Design-integration-base~509 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d7a96441e6c5dcaf0663943e69f568ae006b16f9;p=xmlgraphics-fop.git removed old id reference stuff git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194989 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/datatypes/IDNode.java b/src/org/apache/fop/datatypes/IDNode.java deleted file mode 100644 index 4fd5a72ac..000000000 --- a/src/org/apache/fop/datatypes/IDNode.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.datatypes; - -import org.apache.fop.pdf.PDFGoTo; - - -public class IDNode { - private String idValue, internalLinkGoToPageReference; - - private PDFGoTo internalLinkGoTo; - - private int pageNumber = -1, xPosition = 0, // x position on page - yPosition = 0; // y position on page - - - /** - * Constructor for IDNode - * - * @param idValue The value of the id for this node - */ - protected IDNode(String idValue) { - this.idValue = idValue; - } - - - /** - * Sets the page number for this node - * - * @param number page number of node - */ - protected void setPageNumber(int number) { - pageNumber = number; - } - - - /** - * Returns the page number of this node - * - * @return page number of this node - */ - public String getPageNumber() { - return (pageNumber != -1) ? new Integer(pageNumber).toString() : null; - } - - - /** - * creates a new GoTo object for an internal link - * - * @param objectNumber - * the number to be assigned to the new object - */ - protected void createInternalLinkGoTo(int objectNumber) { - if (internalLinkGoToPageReference == null) { - internalLinkGoTo = new PDFGoTo(objectNumber, null); - } else { - internalLinkGoTo = new PDFGoTo(objectNumber, - internalLinkGoToPageReference); - } - - if (xPosition - != 0) // if the position is known (if x is known, then y is known) - { - internalLinkGoTo.setXPosition(xPosition); - internalLinkGoTo.setYPosition(yPosition); - } - - } - - - - /** - * sets the page reference for the internal link's GoTo. The GoTo will jump to this page reference. - * - * @param pageReference - * the page reference to which the internal link GoTo should jump - * ex. 23 0 R - */ - protected void setInternalLinkGoToPageReference(String pageReference) { - if (internalLinkGoTo != null) { - internalLinkGoTo.setPageReference(pageReference); - } else { - internalLinkGoToPageReference = pageReference; - } - - } - - - - /** - * Returns the reference to the Internal Link's GoTo object - * - * @return GoTo object reference - */ - protected String getInternalLinkGoToReference() { - return internalLinkGoTo.referencePDF(); - } - - - - /** - * Returns the id value of this node - * - * @return this node's id value - */ - protected String getIDValue() { - return idValue; - } - - - - /** - * Returns the PDFGoTo object associated with the internal link - * - * @return PDFGoTo object - */ - protected PDFGoTo getInternalLinkGoTo() { - return internalLinkGoTo; - } - - - /** - * Determines whether there is an internal link GoTo for this node - * - * @return true if internal link GoTo for this node is set, false otherwise - */ - protected boolean isThereInternalLinkGoTo() { - return internalLinkGoTo != null; - } - - - /** - * Sets the position of this node - * - * @param x the x position - * @param y the y position - */ - protected void setPosition(int x, int y) { - if (internalLinkGoTo != null) { - internalLinkGoTo.setXPosition(x); - internalLinkGoTo.setYPosition(y); - } else { - xPosition = x; - yPosition = y; - } - } - -} diff --git a/src/org/apache/fop/datatypes/IDReferences.java b/src/org/apache/fop/datatypes/IDReferences.java deleted file mode 100644 index 8ee8e3249..000000000 --- a/src/org/apache/fop/datatypes/IDReferences.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - -package org.apache.fop.datatypes; - -import org.apache.fop.pdf.PDFGoTo; - - -// Java -import java.util.Hashtable; -import java.util.Vector; -import java.util.Enumeration; -import java.util.NoSuchElementException; -import org.apache.fop.apps.FOPException; - -/** - IDReferences contains a map of IDs and the objects to which - they refer. It also contains a list of references to IDs which - have yet to be encountered. - - Modified by Mark Lillywhite mark-fop@inomial.com. Added - getInvalidElements() so that StreamRenderer cna tell what - hasn't been determined yet. - - Modified by lmckenzi@ca.ibm.com - Sometimes IDs are created, but not validated. This code fixes - the incorrect complaint that the ID already exists which prevents - basic-links from working (sometimes). - - */ -public class IDReferences { - private Hashtable idReferences, idValidation, idUnvalidated; - - final static int ID_PADDING = 5000; // space to add before id y position - - /** - * Constructor for IDReferences - */ - public IDReferences() { - idReferences = new Hashtable(); - idValidation = new Hashtable(); - idUnvalidated = new Hashtable(); - } - - /** - * Creates id entry - * - * @param id The id to create - * @param area The area where this id was encountered - * @exception FOPException - */ - public void createID(String id) throws FOPException { - if (id != null &&!id.equals("")) { - if (doesUnvalidatedIDExist(id)) { - removeFromUnvalidatedIDList(id); - //Steve's (gears@apache.org) comment: Is this right? - removeFromIdValidationList(id); - } - else if (doesIDExist(id)) { - throw new FOPException("The id \"" + id - + "\" already exists in this document"); - } else { - createNewId(id); - removeFromIdValidationList(id); - } - - } - } - - /** - * Creates id entry that hasn't been validated - * - * @param id The id to create - */ - public void createUnvalidatedID(String id) { - if (id != null &&!id.equals("")) { - if (!doesIDExist(id)) { - createNewId(id); - addToUnvalidatedIdList(id); - } - } - } - - /** - * Adds created id list of unvalidated ids that have already - * been created. This should be used if it is unsure whether - * the id is valid but it must be anyhow. - * - * @param id The id to create - */ - public void addToUnvalidatedIdList(String id) { - idUnvalidated.put(id,""); - } - - /** - * Removes id from list of unvalidated ids. - * This should be used if the id has been determined - * to be valid. - * - * @param id The id to remove - */ - public void removeFromUnvalidatedIDList(String id) { - idUnvalidated.remove(id); - } - - /** - * Determines whether specified id already exists in - * idUnvalidated - * - * @param id The id to search for - * @return true if ID was found, false otherwise - */ - public boolean doesUnvalidatedIDExist(String id) { - return idUnvalidated.containsKey(id); - } - - /** - * Adds id to validation list to be validated . This should be used if it is unsure whether the id is valid - * - * @param id id to be added - */ - public void addToIdValidationList(String id) { - idValidation.put(id, ""); - } - - - - /** - * Removes id from validation list. This should be used if the id has been determined to be valid - * - * @param id the id to remove - */ - public void removeFromIdValidationList(String id) { - idValidation.remove(id); - } - - - /** - * Removes id from IDReferences - * - * @param id The id to remove - */ - public void removeID(String id) { - idReferences.remove(id); - } - - - /** - * Determines whether all id's are valid - * - * @return true if all id's are valid, false otherwise - */ - public boolean isEveryIdValid() { - return (idValidation.size() == 0); - } - - - - /** - * Returns all invalid id's still remaining in the validation list - * - * @return invalid ids from validation list - */ - public String getInvalidIds() { - StringBuffer list = new StringBuffer(); - Enumeration enum = idValidation.keys(); - while (enum.hasMoreElements()) { - list.append("\n\"").append(enum.nextElement().toString()).append("\" "); - } - return list.toString(); - } - - - /** - * Determines whether specified id already exists in IDReferences - * - * @param id the id to search for - * @return true if ID was found, false otherwise - */ - public boolean doesIDExist(String id) { - return idReferences.containsKey(id); - } - - - /** - * Determines whether the GoTo reference for the specified id is defined - * - * @param id the id to search for - * @return true if GoTo reference is defined, false otherwise - */ - public boolean doesGoToReferenceExist(String id) { - IDNode node = (IDNode)idReferences.get(id); - return node.isThereInternalLinkGoTo(); - } - - - - - /** - * Returns the reference to the GoTo object used for the internal link - * - * @param id the id whose reference to use - * @return reference to GoTo object - */ - public String getInternalLinkGoToReference(String id) { - IDNode node = (IDNode)idReferences.get(id); - return node.getInternalLinkGoToReference(); - } - - - - /** - * creates an Internal Link GoTo object for this id - * - * @param id The id for which to set the Internal Link Go To - * @param objectNumber - * The object number to use for the GoTo object - * @return the object reference of the new GoTo object - */ - public String createInternalLinkGoTo(String id, int objectNumber) { - IDNode node = (IDNode)idReferences.get(id); // retrieve id node - node.createInternalLinkGoTo(objectNumber); // create Internal Link GoTo object - return node.getInternalLinkGoToReference(); // return Internal Link Go To object reference - } - - - - /** - * Adds an id to IDReferences - * - * @param id the id to add - */ - public void createNewId(String id) { - IDNode node = new IDNode(id); - idReferences.put(id, node); - } - - - /** - * Returns the PDFGoTo object for the specified id - * - * @param id the id for which the PDFGoTo to be retrieved is associated - * @return the PDFGoTo object associated with the specified id - */ - public PDFGoTo getPDFGoTo(String id) { - IDNode node = (IDNode)idReferences.get(id); - return node.getInternalLinkGoTo(); - } - - - /** - * sets the page reference for the internal link's GoTo. The GoTo will jump to this page reference. - * - * @param pageReference - * the page reference to which the internal link GoTo should jump - * ex. 23 0 R - */ - public void setInternalGoToPageReference(String id, - String pageReference) { - IDNode node = (IDNode)idReferences.get(id); - if (node != null) { - node.setInternalLinkGoToPageReference(pageReference); - } - } - - - /** - * Sets the page number for the specified id - * - * @param id The id whose page number is being set - * @param pageNumber The page number of the specified id - */ - public void setPageNumber(String id, int pageNumber) { - IDNode node = (IDNode)idReferences.get(id); - node.setPageNumber(pageNumber); - } - - - /** - * Returns the page number where the specified id is found - * - * @param id The id whose page number to return - * @return the page number of the id, or null if the id does not exist - */ - public String getPageNumber(String id) { - if (doesIDExist(id)) { - IDNode node = (IDNode)idReferences.get(id); - return node.getPageNumber(); - } else { - addToIdValidationList(id); - return null; - } - } - - - /** - * Sets the x and y position of specified id - * - * @param id the id whose position is to be set - * @param x x position of id - * @param y y position of id - */ - public void setPosition(String id, int x, int y) { - IDNode node = (IDNode)idReferences.get(id); - node.setPosition(x, y); - } - - public Enumeration getInvalidElements() { - return idValidation.keys(); - } -} diff --git a/src/org/apache/fop/fo/XMLObj.java b/src/org/apache/fop/fo/XMLObj.java index b356d6849..f0ac6fcb3 100644 --- a/src/org/apache/fop/fo/XMLObj.java +++ b/src/org/apache/fop/fo/XMLObj.java @@ -11,7 +11,6 @@ package org.apache.fop.fo; import org.apache.fop.fo.*; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.IDReferences; import org.w3c.dom.*; import org.xml.sax.Attributes; diff --git a/src/org/apache/fop/render/awt/AWTRenderer.java b/src/org/apache/fop/render/awt/AWTRenderer.java index d4634b6eb..b7ec5c5e5 100644 --- a/src/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/org/apache/fop/render/awt/AWTRenderer.java @@ -67,8 +67,6 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable protected Hashtable fontStyles = new Hashtable(); protected Color saveColor = null; - protected IDReferences idReferences = null; - /** * Image Object and Graphics Object. The Graphics Object is the Graphics * object that is contained within the Image Object. diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 177d17cae..bb62565ae 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -19,7 +19,6 @@ import org.apache.fop.datatypes.*; import org.apache.fop.pdf.*; import org.apache.fop.image.*; import org.apache.fop.extensions.*; -import org.apache.fop.datatypes.IDReferences; import org.apache.fop.render.pdf.fonts.LazyFont; import org.apache.fop.area.*; diff --git a/src/org/apache/fop/render/ps/PSRenderer.java b/src/org/apache/fop/render/ps/PSRenderer.java index 9e629256e..67cdf8c4e 100644 --- a/src/org/apache/fop/render/ps/PSRenderer.java +++ b/src/org/apache/fop/render/ps/PSRenderer.java @@ -97,8 +97,6 @@ public class PSRenderer extends AbstractRenderer { private FontInfo fontInfo; - protected IDReferences idReferences; - /** * set the document's producer * diff --git a/src/org/apache/fop/render/svg/SVGRenderer.java b/src/org/apache/fop/render/svg/SVGRenderer.java index 474a7217c..d6c6dbc7d 100644 --- a/src/org/apache/fop/render/svg/SVGRenderer.java +++ b/src/org/apache/fop/render/svg/SVGRenderer.java @@ -10,7 +10,6 @@ package org.apache.fop.render.svg; import org.apache.fop.apps.FOPException; import org.apache.fop.area.*; import org.apache.fop.area.inline.*; -import org.apache.fop.datatypes.IDReferences; import org.apache.fop.datatypes.ColorType; import org.apache.fop.image.*; import org.apache.fop.svg.SVGUtilities; @@ -84,8 +83,6 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { protected HashMap fontStyles = new HashMap(); protected Color saveColor = null; - protected IDReferences idReferences = null; - /** * The current (internal) font name */