You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@apache.org on 2002/07/18 12:59:58 UTC

cvs commit: xml-fop/src/org/apache/fop/pdf PDFDocument.java PDFFunction.java

keiron      2002/07/18 03:59:58

  Modified:    src/org/apache/fop/pdf PDFDocument.java PDFFunction.java
  Log:
  reuse functions to reduce file size
  
  Revision  Changes    Path
  1.46      +47 -5     xml-fop/src/org/apache/fop/pdf/PDFDocument.java
  
  Index: PDFDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFDocument.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- PDFDocument.java	4 Jul 2002 14:08:19 -0000	1.45
  +++ PDFDocument.java	18 Jul 2002 10:59:57 -0000	1.46
  @@ -138,6 +138,7 @@
       protected HashMap filterMap = new HashMap();
   
       protected ArrayList gstates = new ArrayList();
  +    protected ArrayList functions = new ArrayList();
   
       /**
        * creates an empty PDF document <p>
  @@ -302,7 +303,15 @@
                                                  theFunctionDataStream,
                                                  theFilter);
   
  -        this.objects.add(function);
  +        PDFFunction oldfunc = findFunction(function);
  +        if(oldfunc == null) {
  +            functions.add(function);
  +            this.objects.add(function);
  +        } else {
  +            this.objectcount--;
  +            function = oldfunc;
  +        }
  +
           return (function);
       }
   
  @@ -339,11 +348,28 @@
                                                  theFunctionType, theDomain,
                                                  theRange, theCZero, theCOne,
                                                  theInterpolationExponentN);
  +        PDFFunction oldfunc = findFunction(function);
  +        if(oldfunc == null) {
  +            functions.add(function);
  +            this.objects.add(function);
  +        } else {
  +            this.objectcount--;
  +            function = oldfunc;
  +        }
   
  -        this.objects.add(function);
           return (function);
       }
   
  +    private PDFFunction findFunction(PDFFunction compare) {
  +        for(Iterator iter = functions.iterator(); iter.hasNext(); ) {
  +            Object func = iter.next();
  +            if(compare.equals(func)) {
  +                return (PDFFunction)func;
  +            }
  +        }
  +        return null;
  +    }
  +
       /**
        * Make a Type 3 Stitching function
        *
  @@ -386,7 +412,15 @@
                                                  theRange, theFunctions,
                                                  theBounds, theEncode);
   
  -        this.objects.add(function);
  +        PDFFunction oldfunc = findFunction(function);
  +        if(oldfunc == null) {
  +            functions.add(function);
  +            this.objects.add(function);
  +        } else {
  +            this.objectcount--;
  +            function = oldfunc;
  +        }
  +
           return (function);
       }
   
  @@ -407,7 +441,15 @@
                                                  theRange,
                                                  theFunctionDataStream);
   
  -        this.objects.add(function);
  +        PDFFunction oldfunc = findFunction(function);
  +        if(oldfunc == null) {
  +            functions.add(function);
  +            this.objects.add(function);
  +        } else {
  +            this.objectcount--;
  +            function = oldfunc;
  +        }
  +
           return (function);
   
       }
  
  
  
  1.9       +101 -1    xml-fop/src/org/apache/fop/pdf/PDFFunction.java
  
  Index: PDFFunction.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFFunction.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PDFFunction.java	2 Nov 2001 11:06:07 -0000	1.8
  +++ PDFFunction.java	18 Jul 2002 10:59:58 -0000	1.9
  @@ -667,4 +667,104 @@
   
       }
   
  +    public boolean equals(Object obj) {
  +        if(obj == null) {
  +            return false;
  +        }
  +        if(!(obj instanceof PDFFunction)) {
  +            return false;
  +        }
  +        PDFFunction func = (PDFFunction)obj;
  +        if(functionType != func.functionType) {
  +            return false;
  +        }
  +        if(bitsPerSample != func.bitsPerSample) {
  +            return false;
  +        }
  +        if(order != func.order) {
  +            return false;
  +        }
  +        if(interpolationExponentN != func.interpolationExponentN) {
  +            return false;
  +        }
  +        if(domain != null) {
  +            if(!domain.equals(func.domain)) {
  +                return false;
  +            }
  +        } else if(func.domain != null) {
  +            return false;
  +        }
  +        if(range != null) {
  +            if(!range.equals(func.range)) {
  +                return false; 
  +            }
  +        } else if(func.range != null) {
  +            return false;
  +        }
  +        if(size != null) {
  +            if(!size.equals(func.size)) {
  +                return false; 
  +            }
  +        } else if(func.size != null) {
  +            return false;
  +        }
  +        if(encode != null) {
  +            if(!encode.equals(func.encode)) {
  +                return false; 
  +            }
  +        } else if(func.encode != null) {
  +            return false;
  +        }
  +        if(decode != null) {
  +            if(!decode.equals(func.decode)) {
  +                return false; 
  +            }
  +        } else if(func.decode != null) {
  +            return false;
  +        }
  +        if(functionDataStream != null) {
  +            if(!functionDataStream.equals(func.functionDataStream)) {
  +                return false; 
  +            }
  +        } else if(func.functionDataStream != null) {
  +            return false;
  +        }
  +        if(filter != null) {
  +            if(!filter.equals(func.filter)) {
  +                return false;
  +            }
  +        } else if(func.filter != null) {
  +            return false;
  +        }
  +        if(cZero != null) {
  +            if(!cZero.equals(func.cZero)) {
  +                return false;
  +            }
  +        } else if(func.cZero != null) {
  +            return false;
  +        }
  +        if(cOne != null) {
  +            if(!cOne.equals(func.cOne)) {
  +                return false;
  +            }
  +        } else if(func.cOne != null) {
  +            return false;
  +        }
  +        if(functions != null) {
  +            if(!functions.equals(func.functions)) {
  +                return false;
  +            }
  +        } else if(func.functions != null) {
  +            return false;
  +        }
  +        if(bounds != null) {
  +            if(!bounds.equals(func.bounds)) {
  +                return false;
  +            }
  +        } else if(func.bounds != null) {
  +            return false;
  +        }
  +        return true;
  +    }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org