You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ForeignObjectArea.java 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.layout.inline;
  8. // FOP
  9. import org.apache.fop.render.Renderer;
  10. import org.apache.fop.layout.*;
  11. // Java
  12. import java.util.Vector;
  13. import java.util.Enumeration;
  14. public class ForeignObjectArea extends InlineArea {
  15. protected int xOffset = 0;
  16. /* text-align of contents */
  17. protected int align;
  18. /* vertical align of contents */
  19. protected int valign;
  20. /* scaling method */
  21. protected int scaling;
  22. protected Area foreignObject;
  23. /* height according to the instream-foreign-object */
  24. protected int cheight;
  25. /* width according to the instream-foreign-object */
  26. protected int cwidth;
  27. /* width of the content */
  28. protected int awidth;
  29. /* height of the content */
  30. protected int aheight;
  31. /* width */
  32. protected int width;
  33. boolean wauto;
  34. boolean hauto;
  35. boolean cwauto;
  36. boolean chauto;
  37. int overflow;
  38. public ForeignObjectArea(FontState fontState, int width) {
  39. super(fontState, width, 0, 0, 0);
  40. }
  41. /**
  42. * This is NOT the content width of the instream-foreign-object.
  43. * This is the content width for a Box.
  44. */
  45. public int getContentWidth() {
  46. return getEffectiveWidth();
  47. }
  48. /**
  49. * This is NOT the content height of the instream-foreign-object.
  50. * This is the content height for a Box.
  51. */
  52. public int getHeight() {
  53. return getEffectiveHeight();
  54. }
  55. public int getXOffset() {
  56. return this.xOffset;
  57. }
  58. public void setStartIndent(int startIndent) {
  59. xOffset = startIndent;
  60. }
  61. public void setObject(Area fobject) {
  62. foreignObject = fobject;
  63. }
  64. public Area getObject() {
  65. return foreignObject;
  66. }
  67. public void setSizeAuto(boolean wa, boolean ha) {
  68. wauto = wa;
  69. hauto = ha;
  70. }
  71. public void setContentSizeAuto(boolean wa, boolean ha) {
  72. cwauto = wa;
  73. chauto = ha;
  74. }
  75. public boolean isContentWidthAuto() {
  76. return cwauto;
  77. }
  78. public boolean isContentHeightAuto() {
  79. return chauto;
  80. }
  81. public void setAlign(int align) {
  82. this.align = align;
  83. }
  84. public int getAlign() {
  85. return this.align;
  86. }
  87. public void setVerticalAlign(int align) {
  88. this.valign = align;
  89. }
  90. public int getVerticalAlign() {
  91. return this.valign;
  92. }
  93. public void setOverflow(int o) {
  94. this.overflow = o;
  95. }
  96. public int getOverflow() {
  97. return this.overflow;
  98. }
  99. public void setHeight(int height) {
  100. this.height = height;
  101. }
  102. public void setWidth(int width) {
  103. this.width = width;
  104. }
  105. public void setContentHeight(int cheight) {
  106. this.cheight = cheight;
  107. }
  108. public void setContentWidth(int cwidth) {
  109. this.cwidth = cwidth;
  110. }
  111. public void setScaling(int scaling) {
  112. this.scaling = scaling;
  113. }
  114. public int scalingMethod() {
  115. return this.scaling;
  116. }
  117. public void setIntrinsicWidth(int w) {
  118. awidth = w;
  119. }
  120. public void setIntrinsicHeight(int h) {
  121. aheight = h;
  122. }
  123. public int getIntrinsicHeight() {
  124. return aheight;
  125. }
  126. public int getIntrinsicWidth() {
  127. return awidth;
  128. }
  129. public int getEffectiveHeight() {
  130. if (this.hauto) {
  131. if (this.chauto) {
  132. return aheight;
  133. } else {
  134. // need to handle percentages, this would be a scaling factor on the
  135. // instrinsic height (content determined height)
  136. // if(this.properties.get("content-height").getLength().isPercentage()) {
  137. // switch(scaling) {
  138. // case Scaling.UNIFORM:
  139. // break;
  140. // case Scaling.NON_UNIFORM:
  141. // break;
  142. // }
  143. // } else {
  144. return this.cheight;
  145. }
  146. } else {
  147. return this.height;
  148. }
  149. }
  150. public int getEffectiveWidth() {
  151. if (this.wauto) {
  152. if (this.cwauto) {
  153. return awidth;
  154. } else {
  155. // need to handle percentages, this would be a scaling factor on the
  156. // instrinsic height (content determined height)
  157. // if(this.properties.get("content-width").getLength().isPercentage()) {
  158. // switch(scaling) {
  159. // case Scaling.UNIFORM:
  160. // break;
  161. // case Scaling.NON_UNIFORM:
  162. // break;
  163. // }
  164. // } else {
  165. return this.cwidth;
  166. }
  167. } else {
  168. return this.width;
  169. }
  170. }
  171. }