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.

Block.java 3.8KB

New feature: "Intermediate format" (IF). The IF is basically the XML dialect written by the area tree renderer (XMLRenderer). A new parser for this format allows reparsing a serialized and possibly modified area tree and rendering it to the final target format. More details on the Wiki at http://wiki.apache.org/xmlgraphics-fop/AreaTreeIntermediateXml. No advanced features have been implemented, yet, only the basic functionality. The whole change should be fully backwards-compatible WRT the outer FOP API except maybe for FOTreeBuilder.addElementMapping(), and the area tree XML which got small changes. The area tree has been cleaned up. The serializability has been restored. The CachedRenderPagesModel works again and can, in certain situations, decrease the maximum amount of memory held at one point in time. Some adjustments were necessary in the area tree to help the work of the AreaTreeParser. The AreaTreeParser is new and is responsible for parsing area tree XML files and adding pages to a RenderPagesModel instance. It is SAX-based and should be pretty efficient. XMLUnit (http://xmlunit.sourceforge.net, BSD license) is a new dependency for the test code. It is used to verify the correctness of the intermediate format code. It doesn't have to be installed for the build to run through, though. ElementMapping got a new method getDOMImplementation() which provides the DOMImplementation used to handle a subdocument of a particular namespace. For example, SVG uses Batik's SVG DOM. The AreaTreeParser needs that to properly recreate foreign objects because it can't use the mechanism of the FO tree. The default implementation returns null. The ElementMapping instances are no longer maintained by the FOTreeBuilder, but by the newly created ElementMappingRegistry class. It is expected that the instance of this class is moved from the FOTreeBuilder and the AreaTreeParser's Handler class to the "environment class" once it is created to cut down on the startup time for each processed document. The XMLRenderer has been slightly modified to improve the serialization/deserialization qualities of the area tree XML format. The XMLRenderer can now mimic another renderer (see mimicRenderer(Renderer)) in order to use its font setup. That way it is made certain that the reparsed area tree will render to the final target format exactly as expected. Fixed a bug in the XMLHandlerRegistry which did not always return the right XMLHandler for every situation. Added a DefaultErrorListener to the util package. I've had problems with Xalan-J swallowing exceptions with its default ErrorListener, so I added a simple one for convenience and use in AreaTreeParser. Example code for working with the AreaTreeParser can be found in examples/embedding. Documentation will follow. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@369753 13f79535-47bb-0310-9956-ffa450edef68
18 years ago
New feature: "Intermediate format" (IF). The IF is basically the XML dialect written by the area tree renderer (XMLRenderer). A new parser for this format allows reparsing a serialized and possibly modified area tree and rendering it to the final target format. More details on the Wiki at http://wiki.apache.org/xmlgraphics-fop/AreaTreeIntermediateXml. No advanced features have been implemented, yet, only the basic functionality. The whole change should be fully backwards-compatible WRT the outer FOP API except maybe for FOTreeBuilder.addElementMapping(), and the area tree XML which got small changes. The area tree has been cleaned up. The serializability has been restored. The CachedRenderPagesModel works again and can, in certain situations, decrease the maximum amount of memory held at one point in time. Some adjustments were necessary in the area tree to help the work of the AreaTreeParser. The AreaTreeParser is new and is responsible for parsing area tree XML files and adding pages to a RenderPagesModel instance. It is SAX-based and should be pretty efficient. XMLUnit (http://xmlunit.sourceforge.net, BSD license) is a new dependency for the test code. It is used to verify the correctness of the intermediate format code. It doesn't have to be installed for the build to run through, though. ElementMapping got a new method getDOMImplementation() which provides the DOMImplementation used to handle a subdocument of a particular namespace. For example, SVG uses Batik's SVG DOM. The AreaTreeParser needs that to properly recreate foreign objects because it can't use the mechanism of the FO tree. The default implementation returns null. The ElementMapping instances are no longer maintained by the FOTreeBuilder, but by the newly created ElementMappingRegistry class. It is expected that the instance of this class is moved from the FOTreeBuilder and the AreaTreeParser's Handler class to the "environment class" once it is created to cut down on the startup time for each processed document. The XMLRenderer has been slightly modified to improve the serialization/deserialization qualities of the area tree XML format. The XMLRenderer can now mimic another renderer (see mimicRenderer(Renderer)) in order to use its font setup. That way it is made certain that the reparsed area tree will render to the final target format exactly as expected. Fixed a bug in the XMLHandlerRegistry which did not always return the right XMLHandler for every situation. Added a DefaultErrorListener to the util package. I've had problems with Xalan-J swallowing exceptions with its default ErrorListener, so I added a simple one for convenience and use in AreaTreeParser. Example code for working with the AreaTreeParser can be found in examples/embedding. Documentation will follow. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@369753 13f79535-47bb-0310-9956-ffa450edef68
18 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.area;
  19. // block areas hold either more block areas or line
  20. // areas can also be used as a block spacer
  21. // a block area may have children positioned by stacking
  22. // or by relative to the parent for floats, tables and lists
  23. // cacheable object
  24. // has id information
  25. /**
  26. * This is the block area class.
  27. * It holds child block areas such as other blocks or lines.
  28. */
  29. public class Block extends BlockParent {
  30. private static final long serialVersionUID = 6843727817993665788L;
  31. /**
  32. * Normally stacked with other blocks.
  33. */
  34. public static final int STACK = 0;
  35. /**
  36. * Placed relative to the flow position.
  37. * This effects the flow placement of stacking normally.
  38. */
  39. public static final int RELATIVE = 1;
  40. /**
  41. * Relative to the block parent but not effecting the stacking
  42. * Used for block-container, tables and lists.
  43. */
  44. public static final int ABSOLUTE = 2;
  45. /**
  46. * Relative to a viewport/page but not effecting the stacking
  47. * Used for block-container.
  48. */
  49. public static final int FIXED = 3;
  50. private int stacking = TB;
  51. private int positioning = STACK;
  52. /** if true, allow BPD update */
  53. protected transient boolean allowBPDUpdate = true;
  54. // a block with may contain the dominant styling info in
  55. // terms of most lines or blocks with info
  56. /**
  57. * Add the block to this block area.
  58. *
  59. * @param block the block area to add
  60. */
  61. public void addBlock(Block block) {
  62. addBlock(block, true);
  63. }
  64. /**
  65. * Add the block to this block area.
  66. *
  67. * @param block the block area to add
  68. * @param autoHeight increase the height of the block.
  69. */
  70. public void addBlock(Block block, boolean autoHeight) {
  71. if (autoHeight && allowBPDUpdate && block.isStacked()) {
  72. bpd += block.getAllocBPD();
  73. }
  74. addChildArea(block);
  75. }
  76. /**
  77. * Add the line area to this block area.
  78. *
  79. * @param line the line area to add
  80. */
  81. public void addLineArea(LineArea line) {
  82. bpd += line.getAllocBPD();
  83. addChildArea(line);
  84. }
  85. /**
  86. * Set the positioning of this area.
  87. *
  88. * @param pos the positioning to use when rendering this area
  89. */
  90. public void setPositioning(int pos) {
  91. positioning = pos;
  92. }
  93. /**
  94. * Get the positioning of this area.
  95. *
  96. * @return the positioning to use when rendering this area
  97. */
  98. public int getPositioning() {
  99. return positioning;
  100. }
  101. /**
  102. * Indicates whether this block is stacked, rather than absolutely positioned.
  103. * @return true if it is stacked
  104. */
  105. public boolean isStacked() {
  106. return (getPositioning() == Block.STACK || getPositioning() == Block.RELATIVE);
  107. }
  108. /**
  109. * @return the start-indent trait
  110. */
  111. public int getStartIndent() {
  112. Integer startIndent = (Integer)getTrait(Trait.START_INDENT);
  113. return (startIndent != null ? startIndent.intValue() : 0);
  114. }
  115. }