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.

Viewport.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.area.inline;
  8. import org.apache.fop.area.Area;
  9. import org.apache.fop.render.Renderer;
  10. import java.io.IOException;
  11. import java.awt.geom.Rectangle2D;
  12. public class Viewport extends InlineArea {
  13. // contents could be container, foreign object or image
  14. Area content;
  15. // an inline-level viewport area for graphic and instream foreign object
  16. boolean clip = false;
  17. // position relative to this area
  18. Rectangle2D contentPosition;
  19. public Viewport(Area child) {
  20. content = child;
  21. }
  22. public Area getContent() {
  23. return content;
  24. }
  25. public void render(Renderer renderer) {
  26. renderer.renderViewport(this);
  27. }
  28. private void writeObject(java.io.ObjectOutputStream out)
  29. throws IOException {
  30. out.writeBoolean(contentPosition != null);
  31. if (contentPosition != null) {
  32. out.writeFloat((float) contentPosition.getX());
  33. out.writeFloat((float) contentPosition.getY());
  34. out.writeFloat((float) contentPosition.getWidth());
  35. out.writeFloat((float) contentPosition.getHeight());
  36. }
  37. out.writeBoolean(clip);
  38. out.writeObject(content);
  39. }
  40. private void readObject(java.io.ObjectInputStream in)
  41. throws IOException, ClassNotFoundException {
  42. if (in.readBoolean()) {
  43. contentPosition = new Rectangle2D.Float(in.readFloat(),
  44. in.readFloat(), in.readFloat(), in.readFloat());
  45. }
  46. clip = in.readBoolean();
  47. content = (Area) in.readObject();
  48. }
  49. }