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 es...@locus.apache.org on 2000/05/23 11:14:13 UTC

cvs commit: xml-fop/src/org/apache/fop/fo/flow DisplayGraphic.java

eschaeffer    00/05/23 02:14:10

  Modified:    src/org/apache/fop/fo/flow DisplayGraphic.java
  Log:
  changes in fo:display-graphic
  
  Revision  Changes    Path
  1.8       +50 -22    xml-fop/src/org/apache/fop/fo/flow/DisplayGraphic.java
  
  Index: DisplayGraphic.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/DisplayGraphic.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DisplayGraphic.java	1999/11/27 10:11:37	1.7
  +++ DisplayGraphic.java	2000/05/23 09:14:09	1.8
  @@ -1,4 +1,4 @@
  -/*-- $Id: DisplayGraphic.java,v 1.7 1999/11/27 10:11:37 jtauber Exp $ -- 
  +/*-- $Id: DisplayGraphic.java,v 1.8 2000/05/23 09:14:09 eschaeffer Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -48,6 +48,7 @@
    Software Foundation, please see <http://www.apache.org/>.
    
    */
  +/* Modified by Eric SCHAEFFER */
   
   package org.apache.fop.fo.flow;
   
  @@ -63,6 +64,8 @@
   // Java
   import java.util.Enumeration;
   import java.util.Hashtable;
  +import java.net.URL;
  +import java.net.MalformedURLException;
   
   public class DisplayGraphic extends FObj {
       public static class Maker extends FObj.Maker { 
  @@ -151,27 +154,52 @@
   	    this.marker = 0;
   	}
   
  -	if ((spaceBefore != 0) && (this.marker == 0)) {
  -	    area.addDisplaySpace(spaceBefore);
  -	}
  -
  -	FopImage img = FopImageFactory.Make(href, 0, 0, width, height);
  -
  -	this.imageArea = new ImageArea(fs,
  -				       img,
  -				       area.getAllocationWidth(),
  -				       img.getWidth(),
  -				       img.getHeight(),
  -				       startIndent, endIndent,
  -				       align);
  -
  -	imageArea.start();
  -	imageArea.end();
  -	area.addChild(imageArea);
  -	area.increaseHeight(imageArea.getHeight());
  -
  -	if (spaceAfter != 0) {
  -	    area.addDisplaySpace(spaceAfter);
  +	try {
  +		FopImage img = FopImageFactory.Make(href);
  +		// if width / height needs to be computed
  +		if ((width == 0) || (height == 0)) {
  +			// aspect ratio
  +			double imgWidth = img.getWidth();
  +			double imgHeight = img.getHeight();
  +			if ((width == 0) && (height == 0)) {
  +				width = (int) (imgWidth / 2d * 1000d);
  +				height = (int) (imgHeight / 2d * 1000d);
  +			} else if (height == 0) {
  +				height = (int) (imgHeight / imgWidth * ((double) width));
  +			} else if (width == 0) {
  +				width = (int) (imgWidth / imgHeight * ((double) height));
  +			}
  +		}
  +		this.imageArea = new ImageArea(
  +										fs,
  +										img,
  +										area.getAllocationWidth(),
  +										width,
  +										height,
  +										startIndent,
  +										endIndent,
  +										align
  +										);
  +
  +		if ((spaceBefore != 0) && (this.marker == 0)) {
  +		    area.addDisplaySpace(spaceBefore);
  +		}
  +
  +		imageArea.start();
  +		imageArea.end();
  +		area.addChild(imageArea);
  +		area.increaseHeight(imageArea.getHeight());
  +
  +		if (spaceAfter != 0) {
  +		    area.addDisplaySpace(spaceAfter);
  +		}
  +
  +	} catch (MalformedURLException urlex) {
  +		// bad URL
  +System.err.println("Error while creating area : " + urlex.getMessage());
  +	} catch (FopImageException imgex) {
  +		// image error
  +System.err.println("Error while creating area : " + imgex.getMessage());
   	}
   
   	if (area instanceof BlockArea) {