From: Keiron Liddle Date: Thu, 21 Mar 2002 09:34:19 +0000 (+0000) Subject: changed property to trait for areas X-Git-Tag: fop-0_20_4-doc~103 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5bbf82caf4d455907eb5581c6993b4d30fc19ac9;p=xmlgraphics-fop.git changed property to trait for areas added ipd to area git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194713 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/area/Area.java b/src/org/apache/fop/area/Area.java index 2b429d5bc..f041f9227 100644 --- a/src/org/apache/fop/area/Area.java +++ b/src/org/apache/fop/area/Area.java @@ -46,6 +46,7 @@ public class Area implements Serializable { private int areaClass=CLASS_NORMAL; private FObj genFObj; + private int ipd; protected Area parent =null; // Doesn't need to be saved in serialization @@ -57,6 +58,14 @@ public class Area implements Serializable { this.areaClass = areaClass; } + public void setIPD(int i) { + ipd = i; + } + + public int getIPD() { + return ipd; + } + /** * Return a length range describing the minimum, optimum and maximum * lengths available for content in the block-progression-direction. diff --git a/src/org/apache/fop/area/Block.java b/src/org/apache/fop/area/Block.java index ccad5f345..9073c23a7 100644 --- a/src/org/apache/fop/area/Block.java +++ b/src/org/apache/fop/area/Block.java @@ -59,16 +59,17 @@ public class Block extends BlockParent implements Serializable { } // store properties in array list, need better solution - ArrayList props = null; + ArrayList traits = null; - public void addProperty(Property prop) { - if (props == null) { - props = new ArrayList(); + public void addTrait(Trait prop) { + if (traits == null) { + traits = new ArrayList(); } - props.add(prop); + traits.add(prop); } - public List getPropertyList() { - return props; + public List getTraitList() { + return traits; } } + diff --git a/src/org/apache/fop/area/LineArea.java b/src/org/apache/fop/area/LineArea.java index 8184d332a..5da4fee09 100644 --- a/src/org/apache/fop/area/LineArea.java +++ b/src/org/apache/fop/area/LineArea.java @@ -50,14 +50,14 @@ public class LineArea extends Area { // store properties in array list, need better solution ArrayList props = null; - public void addProperty(Property prop) { + public void addTrait(Trait prop) { if (props == null) { props = new ArrayList(); } props.add(prop); } - public List getPropertyList() { + public List getTraitList() { return props; } } diff --git a/src/org/apache/fop/area/LineProperty.java b/src/org/apache/fop/area/LineProperty.java deleted file mode 100644 index d5eb3dad9..000000000 --- a/src/org/apache/fop/area/LineProperty.java +++ /dev/null @@ -1,13 +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.area; - -public class LineProperty extends Property { - int[] range; -} - diff --git a/src/org/apache/fop/area/LineTrait.java b/src/org/apache/fop/area/LineTrait.java new file mode 100644 index 000000000..e02725c28 --- /dev/null +++ b/src/org/apache/fop/area/LineTrait.java @@ -0,0 +1,13 @@ +/* + * $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.area; + +public class LineTrait extends Trait { + int[] range; +} + diff --git a/src/org/apache/fop/area/Property.java b/src/org/apache/fop/area/Property.java deleted file mode 100644 index 61d7b3bc2..000000000 --- a/src/org/apache/fop/area/Property.java +++ /dev/null @@ -1,45 +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.area; - -import org.apache.fop.datatypes.ColorType; - -import java.io.Serializable; - -// properties should be serialized by the holder -public class Property implements Serializable { - public static final int ID_LINK = 0; - public static final int INTERNAL_LINK = 1; //resolved - public static final int EXTERNAL_LINK = 2; - public static final int FONT_FAMILY = 3; - public static final int FONT_SIZE = 4; - public static final int FONT_WEIGHT = 5; - public static final int FONT_STYLE = 6; - public static final int COLOR = 7; - public static final int ID_AREA = 8; - public static final int BACKGROUND = 9; - public static final int UNDERLINE = 10; - public static final int OVERLINE = 11; - public static final int LINETHROUGH = 12; - public static final int OFFSET = 13; - public static final int SHADOW = 14; - - public static final int FONT_STATE = 100; - - public int propType; - public Object data; - - public static class Background { - ColorType color; - String url; - int repeat; - int horiz; - int vertical; - } -} - diff --git a/src/org/apache/fop/area/Trait.java b/src/org/apache/fop/area/Trait.java new file mode 100644 index 000000000..7ac537a79 --- /dev/null +++ b/src/org/apache/fop/area/Trait.java @@ -0,0 +1,45 @@ +/* + * $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.area; + +import org.apache.fop.datatypes.ColorType; + +import java.io.Serializable; + +// properties should be serialized by the holder +public class Trait implements Serializable { + public static final int ID_LINK = 0; + public static final int INTERNAL_LINK = 1; //resolved + public static final int EXTERNAL_LINK = 2; + public static final int FONT_FAMILY = 3; + public static final int FONT_SIZE = 4; + public static final int FONT_WEIGHT = 5; + public static final int FONT_STYLE = 6; + public static final int COLOR = 7; + public static final int ID_AREA = 8; + public static final int BACKGROUND = 9; + public static final int UNDERLINE = 10; + public static final int OVERLINE = 11; + public static final int LINETHROUGH = 12; + public static final int OFFSET = 13; + public static final int SHADOW = 14; + + public static final int FONT_STATE = 100; + + public int propType; + public Object data; + + public static class Background { + ColorType color; + String url; + int repeat; + int horiz; + int vertical; + } +} + diff --git a/src/org/apache/fop/area/inline/InlineArea.java b/src/org/apache/fop/area/inline/InlineArea.java index 5a63ef0ed..b105846fb 100644 --- a/src/org/apache/fop/area/inline/InlineArea.java +++ b/src/org/apache/fop/area/inline/InlineArea.java @@ -9,7 +9,7 @@ package org.apache.fop.area.inline; import org.apache.fop.area.Area; import org.apache.fop.area.MinOptMax; -import org.apache.fop.area.Property; +import org.apache.fop.area.Trait; import org.apache.fop.render.Renderer; import java.util.List; @@ -46,6 +46,14 @@ public class InlineArea extends Area { return width; } + public void setHeight(int h) { + height = h; + } + + public int getHeight() { + return height; + } + public MinOptMax getAllocationIPD() { // Should also account for any borders and padding in the // inline progression dimension @@ -60,14 +68,14 @@ public class InlineArea extends Area { return verticalPosition; } - public void addProperty(Property prop) { + public void addTrait(Trait prop) { if (props == null) { props = new ArrayList(); } props.add(prop); } - public List getPropertyList() { + public List getTraitList() { return props; } } diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 4713c38ef..0db612f8d 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -266,10 +266,10 @@ public class PDFRenderer extends PrintRenderer { FontState fs = null; - List props = word.getPropertyList(); + List props = word.getTraitList(); for(int count = 0; count < props.size(); count++) { - Property pro = (Property)props.get(count); - if(pro.propType == Property.FONT_STATE) { + Trait pro = (Trait)props.get(count); + if(pro.propType == Trait.FONT_STATE) { fs = (FontState)pro.data; } } @@ -289,7 +289,7 @@ public class PDFRenderer extends PrintRenderer { int rx = currentBlockIPPosition; // int bl = pageHeight - currentBPPosition; - int bl = currentBPPosition; + int bl = currentBPPosition + word.getOffset(); // Set letterSpacing //float ls = fs.getLetterSpacing() / this.currentFontSize; @@ -530,7 +530,7 @@ public class PDFRenderer extends PrintRenderer { public void renderDocument(Document doc, String ns) { RendererContext context; context = new RendererContext(mimeType); - context.setLogger(log); + context.setUserAgent(userAgent); context.setProperty(PDFXMLHandler.PDF_DOCUMENT, pdfDoc); context.setProperty(PDFXMLHandler.PDF_STREAM, currentStream); diff --git a/src/org/apache/fop/render/xml/XMLRenderer.java b/src/org/apache/fop/render/xml/XMLRenderer.java index 999e983d4..8e9218eea 100644 --- a/src/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/org/apache/fop/render/xml/XMLRenderer.java @@ -277,7 +277,7 @@ public class XMLRenderer extends AbstractRenderer { protected void renderBlock(Block block) { String prop = ""; - List list = block.getPropertyList(); + List list = block.getTraitList(); if (list != null) { prop = " props=\"" + getPropString(list) + "\""; } @@ -288,7 +288,7 @@ public class XMLRenderer extends AbstractRenderer { protected void renderLineArea(LineArea line) { String prop = ""; - List list = line.getPropertyList(); + List list = line.getTraitList(); if (list != null) { prop = " props=\"" + getPropString(list) + "\""; } @@ -326,7 +326,7 @@ public class XMLRenderer extends AbstractRenderer { public void renderCharacter(org.apache.fop.area.inline.Character ch) { String prop = ""; - List list = ch.getPropertyList(); + List list = ch.getTraitList(); if (list != null) { prop = " props=\"" + getPropString(list) + "\""; } @@ -339,7 +339,7 @@ public class XMLRenderer extends AbstractRenderer { public void renderWord(Word word) { String prop = ""; - List list = word.getPropertyList(); + List list = word.getTraitList(); if (list != null) { prop = " props=\"" + getPropString(list) + "\""; } @@ -376,45 +376,45 @@ public class XMLRenderer extends AbstractRenderer { protected String getPropString(List list) { String str = ""; for (int count = 0; count < list.size(); count++) { - Property prop = (Property) list.get(count); + Trait prop = (Trait) list.get(count); switch (prop.propType) { - case Property.INTERNAL_LINK: + case Trait.INTERNAL_LINK: str += "internal-link:" + prop.data; break; - case Property.EXTERNAL_LINK: + case Trait.EXTERNAL_LINK: str += "external-link:" + prop.data; break; - case Property.FONT_FAMILY: + case Trait.FONT_FAMILY: str += "font-family:" + prop.data; break; - case Property.FONT_SIZE: + case Trait.FONT_SIZE: str += "font-size:" + prop.data; break; - case Property.FONT_WEIGHT: + case Trait.FONT_WEIGHT: str += "font-weight:" + prop.data; break; - case Property.FONT_STYLE: + case Trait.FONT_STYLE: str += "font-style:" + prop.data; break; - case Property.COLOR: + case Trait.COLOR: str += "color:" + prop.data; break; - case Property.BACKGROUND: + case Trait.BACKGROUND: str += "background:" + prop.data; break; - case Property.UNDERLINE: + case Trait.UNDERLINE: str += "underline:" + prop.data; break; - case Property.OVERLINE: + case Trait.OVERLINE: str += "overline:" + prop.data; break; - case Property.LINETHROUGH: + case Trait.LINETHROUGH: str += "linethrough:" + prop.data; break; - case Property.OFFSET: + case Trait.OFFSET: str += "offset:" + prop.data; break; - case Property.SHADOW: + case Trait.SHADOW: str += "shadow:" + prop.data; break; default: diff --git a/src/org/apache/fop/tools/AreaTreeBuilder.java b/src/org/apache/fop/tools/AreaTreeBuilder.java index 3528f8b97..0f1529643 100644 --- a/src/org/apache/fop/tools/AreaTreeBuilder.java +++ b/src/org/apache/fop/tools/AreaTreeBuilder.java @@ -428,7 +428,7 @@ class TreeLoader { Block block = new Block(); List props = getProperties((Element) obj); for (int count = 0; count < props.size(); count++) { - block.addProperty((Property) props.get(count)); + block.addTrait((Trait) props.get(count)); } addBlockChildren(block, (Element) obj); list.add(block); @@ -457,7 +457,7 @@ class TreeLoader { LineArea line = new LineArea(); List props = getProperties((Element) obj); for (int count = 0; count < props.size(); count++) { - line.addProperty((Property) props.get(count)); + line.addTrait((Trait) props.get(count)); } String height = ((Element) obj).getAttribute("height"); int h = Integer.parseInt(height); @@ -521,10 +521,10 @@ class TreeLoader { e.printStackTrace(); } Word word = getWord((Element) obj); - Property prop = new Property(); - prop.propType = Property.FONT_STATE; + Trait prop = new Trait(); + prop.propType = Trait.FONT_STATE; prop.data = currentFontState; - word.addProperty(prop); + word.addTrait(prop); if (word != null) { list.add(word); } @@ -672,7 +672,7 @@ class TreeLoader { public void addProperties(Element ele, InlineArea inline) { List props = getProperties(ele); for (int count = 0; count < props.size(); count++) { - inline.addProperty((Property) props.get(count)); + inline.addTrait((Trait) props.get(count)); } String str = ele.getAttribute("width"); @@ -687,57 +687,57 @@ class TreeLoader { int index = tok.indexOf(":"); String id = tok.substring(0, index); String val = tok.substring(index + 1); - Property prop = new Property(); + Trait prop = new Trait(); if ("internal-link".equals(id)) { - prop.propType = Property.INTERNAL_LINK; + prop.propType = Trait.INTERNAL_LINK; prop.data = val; list.add(prop); } else if ("external-link".equals(id)) { - prop.propType = Property.EXTERNAL_LINK; + prop.propType = Trait.EXTERNAL_LINK; prop.data = val; list.add(prop); } else if ("font-family".equals(id)) { - prop.propType = Property.FONT_FAMILY; + prop.propType = Trait.FONT_FAMILY; prop.data = val; list.add(prop); } else if ("font-size".equals(id)) { - prop.propType = Property.FONT_SIZE; + prop.propType = Trait.FONT_SIZE; prop.data = Integer.valueOf(val); list.add(prop); } else if ("font-weight".equals(id)) { - prop.propType = Property.FONT_WEIGHT; + prop.propType = Trait.FONT_WEIGHT; prop.data = val; list.add(prop); } else if ("font-style".equals(id)) { - prop.propType = Property.FONT_STYLE; + prop.propType = Trait.FONT_STYLE; prop.data = val; list.add(prop); } else if ("color".equals(id)) { - prop.propType = Property.COLOR; + prop.propType = Trait.COLOR; prop.data = val; list.add(prop); } else if ("background".equals(id)) { - prop.propType = Property.BACKGROUND; + prop.propType = Trait.BACKGROUND; prop.data = val; list.add(prop); } else if ("underline".equals(id)) { - prop.propType = Property.UNDERLINE; + prop.propType = Trait.UNDERLINE; prop.data = new Boolean(val); list.add(prop); } else if ("overline".equals(id)) { - prop.propType = Property.OVERLINE; + prop.propType = Trait.OVERLINE; prop.data = new Boolean(val); list.add(prop); } else if ("linethrough".equals(id)) { - prop.propType = Property.LINETHROUGH; + prop.propType = Trait.LINETHROUGH; prop.data = new Boolean(val); list.add(prop); } else if ("offset".equals(id)) { - prop.propType = Property.OFFSET; + prop.propType = Trait.OFFSET; prop.data = Integer.valueOf(val); list.add(prop); } else if ("shadow".equals(id)) { - prop.propType = Property.SHADOW; + prop.propType = Trait.SHADOW; prop.data = val; list.add(prop); }