Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

InlineViewport.java 4.5KB

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
pirms 18 gadiem
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
pirms 18 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.inline;
  19. import java.awt.Rectangle;
  20. import java.awt.geom.Rectangle2D;
  21. import java.io.IOException;
  22. import java.util.TreeMap;
  23. import org.apache.fop.area.Area;
  24. import org.apache.fop.area.Viewport;
  25. /**
  26. * Inline viewport area.
  27. * This is an inline-level viewport area for inline container,
  28. * external graphic and instream foreign object. This viewport
  29. * holds the area and positions it.
  30. */
  31. public class InlineViewport extends InlineArea implements Viewport {
  32. private static final long serialVersionUID = 813338534627918689L;
  33. // contents could be container, foreign object or image
  34. private Area content;
  35. // clipping for the viewport
  36. private boolean clip;
  37. // position of the child area relative to this area
  38. private Rectangle2D contentPosition;
  39. /**
  40. * Create a new viewport area with the content area.
  41. *
  42. * @param child the child content area of this viewport
  43. */
  44. public InlineViewport(Area child) {
  45. this(child, -1);
  46. }
  47. /**
  48. * Create a new viewport area with the content area.
  49. *
  50. * @param child the child content area of this viewport
  51. * @param bidiLevel the bidirectional embedding level (or -1 if not defined)
  52. */
  53. public InlineViewport(Area child, int bidiLevel) {
  54. super(0, bidiLevel);
  55. this.content = child;
  56. }
  57. /**
  58. * Set the clip of this viewport.
  59. *
  60. * @param c true if this viewport should clip
  61. */
  62. public void setClip(boolean c) {
  63. this.clip = c;
  64. }
  65. /** {@inheritDoc} */
  66. public boolean hasClip() {
  67. return this.clip;
  68. }
  69. /** {@inheritDoc} */
  70. public Rectangle getClipRectangle() {
  71. if (clip) {
  72. return new Rectangle(getIPD(), getBPD());
  73. } else {
  74. return null;
  75. }
  76. }
  77. /**
  78. * Set the position and size of the content of this viewport.
  79. *
  80. * @param cp the position and size to place the content
  81. */
  82. public void setContentPosition(Rectangle2D cp) {
  83. this.contentPosition = cp;
  84. }
  85. /**
  86. * Get the position and size of the content of this viewport.
  87. *
  88. * @return the position and size to place the content
  89. */
  90. public Rectangle2D getContentPosition() {
  91. return this.contentPosition;
  92. }
  93. /**
  94. * Sets the content area.
  95. * @param content the content area
  96. */
  97. public void setContent(Area content) {
  98. this.content = content;
  99. }
  100. /**
  101. * Get the content area for this viewport.
  102. *
  103. * @return the content area
  104. */
  105. public Area getContent() {
  106. return this.content;
  107. }
  108. private void writeObject(java.io.ObjectOutputStream out)
  109. throws IOException {
  110. out.writeBoolean(contentPosition != null);
  111. if (contentPosition != null) {
  112. out.writeFloat((float) contentPosition.getX());
  113. out.writeFloat((float) contentPosition.getY());
  114. out.writeFloat((float) contentPosition.getWidth());
  115. out.writeFloat((float) contentPosition.getHeight());
  116. }
  117. out.writeBoolean(clip);
  118. out.writeObject((TreeMap)traits);
  119. out.writeObject(content);
  120. }
  121. private void readObject(java.io.ObjectInputStream in)
  122. throws IOException, ClassNotFoundException {
  123. if (in.readBoolean()) {
  124. contentPosition = new Rectangle2D.Float(in.readFloat(),
  125. in.readFloat(),
  126. in.readFloat(),
  127. in.readFloat());
  128. }
  129. this.clip = in.readBoolean();
  130. this.traits = (TreeMap) in.readObject();
  131. this.content = (Area) in.readObject();
  132. }
  133. }