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.

AFPGraphicsObjectInfo.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.afp;
  19. import java.awt.Rectangle;
  20. import java.awt.geom.Rectangle2D;
  21. import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
  22. import org.apache.xmlgraphics.util.MimeConstants;
  23. /**
  24. * A graphics object info which contains necessary painting objects
  25. */
  26. public class AFPGraphicsObjectInfo extends AFPDataObjectInfo {
  27. /** the graphics object painter implementation */
  28. private Graphics2DImagePainter painter;
  29. /** the graphics object area */
  30. private Rectangle2D area;
  31. /** the AFP graphics 2d implementation */
  32. private AFPGraphics2D g2d;
  33. /**
  34. * Returns the graphics painter
  35. *
  36. * @return the graphics painter
  37. */
  38. public Graphics2DImagePainter getPainter() {
  39. return this.painter;
  40. }
  41. /**
  42. * Sets the graphics painter
  43. *
  44. * @param graphicsPainter the graphics painter
  45. */
  46. public void setPainter(Graphics2DImagePainter graphicsPainter) {
  47. this.painter = graphicsPainter;
  48. }
  49. /**
  50. * Returns the graphics area
  51. *
  52. * @return the graphics area
  53. */
  54. public Rectangle2D getArea() {
  55. AFPObjectAreaInfo objectAreaInfo = getObjectAreaInfo();
  56. int width = objectAreaInfo.getWidth();
  57. int height = objectAreaInfo.getHeight();
  58. return new Rectangle(width, height);
  59. }
  60. /**
  61. * Sets the graphics area area
  62. *
  63. * @param area the graphics object area
  64. */
  65. public void setArea(Rectangle2D area) {
  66. this.area = area;
  67. }
  68. /**
  69. * Sets the AFP graphics 2D implementation
  70. *
  71. * @param g2d the AFP graphics 2D implementation
  72. */
  73. public void setGraphics2D(AFPGraphics2D g2d) {
  74. this.g2d = g2d;
  75. }
  76. /**
  77. * Returns the AFP graphics 2D implementation
  78. *
  79. * @return the AFP graphics 2D implementation
  80. */
  81. public AFPGraphics2D getGraphics2D() {
  82. return this.g2d;
  83. }
  84. /** {@inheritDoc} */
  85. public String toString() {
  86. return "GraphicsObjectInfo{" + super.toString() + "}";
  87. }
  88. /** {@inheritDoc} */
  89. public String getMimeType() {
  90. return MimeConstants.MIME_SVG;
  91. }
  92. }