1 51 package org.apache.fop.fo.pagination; 52 53 import org.apache.fop.fo.*; 55 import org.apache.fop.fo.properties.*; 56 import org.apache.fop.layout.RegionArea; 57 import org.apache.fop.layout.BorderAndPadding; 58 import org.apache.fop.layout.BackgroundProps; 59 import org.apache.fop.apps.FOPException; 60 61 68 public class RegionBefore extends Region { 69 70 public static class Maker extends FObj.Maker { 71 public FObj make(FObj parent, PropertyList propertyList, 72 String systemId, int line, int column) 73 throws FOPException { 74 return new RegionBefore(parent, propertyList, 75 systemId, line, column); 76 } 77 78 } 79 80 public static FObj.Maker maker() { 81 return new RegionBefore.Maker(); 82 } 83 84 public static final String REGION_CLASS = "before"; 85 86 private int precedence; 87 88 protected RegionBefore(FObj parent, PropertyList propertyList, 89 String systemId, int line, int column) 90 throws FOPException { 91 super(parent, propertyList, systemId, line, column); 92 precedence = this.properties.get("precedence").getEnum(); 93 } 94 95 96 public String getName() { 97 return "fo:region-before"; 98 } 99 100 RegionArea makeRegionArea(int allocationRectangleXPosition, 101 int allocationRectangleYPosition, 102 int allocationRectangleWidth, 103 int allocationRectangleHeight) { 104 105 BorderAndPadding bap = propMgr.getBorderAndPadding(); 107 BackgroundProps bProps = propMgr.getBackgroundProps(); 108 109 int extent = this.properties.get("extent").getLength().mvalue(); 112 118 RegionArea area = new RegionArea(allocationRectangleXPosition, 119 allocationRectangleYPosition, 120 allocationRectangleWidth, extent); 121 area.setBackground(bProps); 122 return area; 123 } 124 125 RegionArea makeRegionArea(int allocationRectangleXPosition, 126 int allocationRectangleYPosition, 127 int allocationRectangleWidth, 128 int allocationRectangleHeight, 129 int startExtent, int endExtent) { 130 if (getPrecedence() == false) { 131 allocationRectangleXPosition += startExtent; 132 allocationRectangleWidth -= startExtent + endExtent; 133 } 134 return makeRegionArea(allocationRectangleXPosition, 135 allocationRectangleYPosition, 136 allocationRectangleWidth, 137 allocationRectangleHeight); 138 } 139 140 protected String getDefaultRegionName() { 141 return "xsl-region-before"; 142 } 143 144 public String getRegionClass() { 145 return REGION_CLASS; 146 } 147 148 public boolean getPrecedence() { 149 return (precedence == Precedence.TRUE ? true : false); 150 } 151 152 public int getExtent() { 153 return properties.get("extent").getLength().mvalue(); 154 } 155 } 156 | Popular Tags |