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.

AFPGraphics2D.java 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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.AlphaComposite;
  20. import java.awt.BasicStroke;
  21. import java.awt.Color;
  22. import java.awt.Dimension;
  23. import java.awt.Font;
  24. import java.awt.FontMetrics;
  25. import java.awt.Graphics;
  26. import java.awt.GraphicsConfiguration;
  27. import java.awt.Image;
  28. import java.awt.Paint;
  29. import java.awt.Rectangle;
  30. import java.awt.Shape;
  31. import java.awt.Stroke;
  32. import java.awt.TexturePaint;
  33. import java.awt.geom.AffineTransform;
  34. import java.awt.geom.Ellipse2D;
  35. import java.awt.geom.Line2D;
  36. import java.awt.geom.PathIterator;
  37. import java.awt.geom.Rectangle2D;
  38. import java.awt.image.BufferedImage;
  39. import java.awt.image.ImageObserver;
  40. import java.awt.image.RenderedImage;
  41. import java.awt.image.renderable.RenderableImage;
  42. import java.io.IOException;
  43. import org.apache.commons.io.output.ByteArrayOutputStream;
  44. import org.apache.commons.logging.Log;
  45. import org.apache.commons.logging.LogFactory;
  46. import org.apache.fop.afp.goca.GraphicsSetLineType;
  47. import org.apache.fop.afp.modca.GraphicsObject;
  48. import org.apache.fop.afp.svg.AFPGraphicsConfiguration;
  49. import org.apache.fop.fonts.FontInfo;
  50. import org.apache.fop.svg.NativeImageHandler;
  51. import org.apache.xmlgraphics.image.loader.ImageInfo;
  52. import org.apache.xmlgraphics.image.loader.ImageSize;
  53. import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
  54. import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
  55. import org.apache.xmlgraphics.java2d.GraphicContext;
  56. import org.apache.xmlgraphics.java2d.StrokingTextHandler;
  57. import org.apache.xmlgraphics.java2d.TextHandler;
  58. import org.apache.xmlgraphics.ps.ImageEncodingHelper;
  59. import org.apache.xmlgraphics.util.MimeConstants;
  60. /**
  61. * This is a concrete implementation of <tt>AbstractGraphics2D</tt> (and
  62. * therefore of <tt>Graphics2D</tt>) which is able to generate GOCA byte
  63. * codes.
  64. *
  65. * @see org.apache.xmlgraphics.java2d.AbstractGraphics2D
  66. */
  67. public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHandler {
  68. private static final Log log = LogFactory.getLog(AFPGraphics2D.class);
  69. private static final int X = 0;
  70. private static final int Y = 1;
  71. private static final int X1 = 0;
  72. private static final int Y1 = 1;
  73. private static final int X2 = 2;
  74. private static final int Y2 = 3;
  75. private static final int X3 = 4;
  76. private static final int Y3 = 5;
  77. /** graphics object */
  78. private GraphicsObject graphicsObj = null;
  79. /** Fallback text handler */
  80. protected TextHandler fallbackTextHandler = new StrokingTextHandler();
  81. /** Custom text handler */
  82. protected TextHandler customTextHandler = null;
  83. /** AFP resource manager */
  84. private AFPResourceManager resourceManager = null;
  85. /** AFP resource info */
  86. private AFPResourceInfo resourceInfo = null;
  87. /** Current AFP state */
  88. private AFPPaintingState paintingState = null;
  89. /** AFP graphics configuration */
  90. private final AFPGraphicsConfiguration graphicsConfig = new AFPGraphicsConfiguration();
  91. /** The AFP FontInfo */
  92. private FontInfo fontInfo;
  93. /**
  94. * Main constructor
  95. *
  96. * @param textAsShapes
  97. * if true, all text is turned into shapes in the convertion. No
  98. * text is output.
  99. * @param paintingState painting state
  100. * @param resourceManager resource manager
  101. * @param resourceInfo resource info
  102. * @param fontInfo font info
  103. */
  104. public AFPGraphics2D(boolean textAsShapes, AFPPaintingState paintingState,
  105. AFPResourceManager resourceManager, AFPResourceInfo resourceInfo,
  106. FontInfo fontInfo) {
  107. super(textAsShapes);
  108. this.paintingState = paintingState;
  109. this.resourceManager = resourceManager;
  110. this.resourceInfo = resourceInfo;
  111. this.fontInfo = fontInfo;
  112. }
  113. /**
  114. * Copy Constructor
  115. *
  116. * @param g2d
  117. * a AFPGraphics2D whose properties should be copied
  118. */
  119. public AFPGraphics2D(AFPGraphics2D g2d) {
  120. super(g2d);
  121. this.paintingState = g2d.paintingState;
  122. this.resourceManager = g2d.resourceManager;
  123. this.resourceInfo = g2d.resourceInfo;
  124. this.fontInfo = g2d.fontInfo;
  125. this.graphicsObj = g2d.graphicsObj;
  126. this.fallbackTextHandler = g2d.fallbackTextHandler;
  127. this.customTextHandler = g2d.customTextHandler;
  128. }
  129. /**
  130. * Sets the AFP resource manager
  131. *
  132. * @param resourceManager the AFP resource manager
  133. */
  134. public void setResourceManager(AFPResourceManager resourceManager) {
  135. this.resourceManager = resourceManager;
  136. }
  137. /**
  138. * Sets the AFP resource info
  139. *
  140. * @param resourceInfo the AFP resource info
  141. */
  142. public void setResourceInfo(AFPResourceInfo resourceInfo) {
  143. this.resourceInfo = resourceInfo;
  144. }
  145. /**
  146. * Sets the GraphicContext
  147. *
  148. * @param gc
  149. * GraphicContext to use
  150. */
  151. public void setGraphicContext(GraphicContext gc) {
  152. this.gc = gc;
  153. }
  154. /**
  155. * Apply the stroke to the AFP graphics object.
  156. * This takes the java stroke and outputs the appropriate settings
  157. * to the AFP graphics object so that the stroke attributes are handled.
  158. *
  159. * @param stroke the java stroke
  160. */
  161. protected void applyStroke(Stroke stroke) {
  162. if (stroke instanceof BasicStroke) {
  163. BasicStroke basicStroke = (BasicStroke) stroke;
  164. // set line width
  165. float lineWidth = basicStroke.getLineWidth();
  166. graphicsObj.setLineWidth(Math.round(lineWidth / 2));
  167. // set line type/style (note: this is an approximation at best!)
  168. float[] dashArray = basicStroke.getDashArray();
  169. if (paintingState.setDashArray(dashArray)) {
  170. byte type = GraphicsSetLineType.DEFAULT; // normally SOLID
  171. if (dashArray != null) {
  172. type = GraphicsSetLineType.DOTTED; // default to plain DOTTED if dashed line
  173. // float offset = basicStroke.getDashPhase();
  174. if (dashArray.length == 2) {
  175. if (dashArray[0] < dashArray[1]) {
  176. type = GraphicsSetLineType.SHORT_DASHED;
  177. } else if (dashArray[0] > dashArray[1]) {
  178. type = GraphicsSetLineType.LONG_DASHED;
  179. }
  180. } else if (dashArray.length == 4) {
  181. if (dashArray[0] > dashArray[1]
  182. && dashArray[2] < dashArray[3]) {
  183. type = GraphicsSetLineType.DASH_DOT;
  184. } else if (dashArray[0] < dashArray[1]
  185. && dashArray[2] < dashArray[3]) {
  186. type = GraphicsSetLineType.DOUBLE_DOTTED;
  187. }
  188. } else if (dashArray.length == 6) {
  189. if (dashArray[0] > dashArray[1]
  190. && dashArray[2] < dashArray[3]
  191. && dashArray[4] < dashArray[5]) {
  192. type = GraphicsSetLineType.DASH_DOUBLE_DOTTED;
  193. }
  194. }
  195. }
  196. graphicsObj.setLineType(type);
  197. }
  198. } else {
  199. log.warn("Unsupported Stroke: " + stroke.getClass().getName());
  200. }
  201. }
  202. /**
  203. * Apply the java paint to the AFP.
  204. * This takes the java paint sets up the appropriate AFP commands
  205. * for the drawing with that paint.
  206. * Currently this supports the gradients and patterns from batik.
  207. *
  208. * @param paint the paint to convert to AFP
  209. * @param fill true if the paint should be set for filling
  210. * @return true if the paint is handled natively, false if the paint should be rasterized
  211. */
  212. private boolean applyPaint(Paint paint, boolean fill) {
  213. if (paint instanceof Color) {
  214. return true;
  215. }
  216. log.debug("NYI: applyPaint() " + paint + " fill=" + fill);
  217. if (paint instanceof TexturePaint) {
  218. // TexturePaint texturePaint = (TexturePaint)paint;
  219. // BufferedImage bufferedImage = texturePaint.getImage();
  220. // AffineTransform at = paintingState.getTransform();
  221. // int x = (int)Math.round(at.getTranslateX());
  222. // int y = (int)Math.round(at.getTranslateY());
  223. // drawImage(bufferedImage, x, y, null);
  224. }
  225. return false;
  226. }
  227. /**
  228. * Handle the Batik drawing event
  229. *
  230. * @param shape
  231. * the shape to draw
  232. * @param fill
  233. * true if the shape is to be drawn filled
  234. */
  235. private void doDrawing(Shape shape, boolean fill) {
  236. if (!fill) {
  237. graphicsObj.newSegment();
  238. }
  239. graphicsObj.setColor(gc.getColor());
  240. applyPaint(gc.getPaint(), fill);
  241. if (fill) {
  242. graphicsObj.beginArea();
  243. } else {
  244. applyStroke(gc.getStroke());
  245. }
  246. AffineTransform trans = gc.getTransform();
  247. PathIterator iter = shape.getPathIterator(trans);
  248. if (shape instanceof Line2D) {
  249. double[] dstPts = new double[6];
  250. iter.currentSegment(dstPts);
  251. int[] coords = new int[4];
  252. coords[X1] = (int) Math.round(dstPts[X]);
  253. coords[Y1] = (int) Math.round(dstPts[Y]);
  254. iter.next();
  255. iter.currentSegment(dstPts);
  256. coords[X2] = (int) Math.round(dstPts[X]);
  257. coords[Y2] = (int) Math.round(dstPts[Y]);
  258. graphicsObj.addLine(coords);
  259. } else if (shape instanceof Rectangle2D) {
  260. double[] dstPts = new double[6];
  261. iter.currentSegment(dstPts);
  262. int[] coords = new int[4];
  263. coords[X2] = (int) Math.round(dstPts[X]);
  264. coords[Y2] = (int) Math.round(dstPts[Y]);
  265. iter.next();
  266. iter.next();
  267. iter.currentSegment(dstPts);
  268. coords[X1] = (int) Math.round(dstPts[X]);
  269. coords[Y1] = (int) Math.round(dstPts[Y]);
  270. graphicsObj.addBox(coords);
  271. } else if (shape instanceof Ellipse2D) {
  272. double[] dstPts = new double[6];
  273. Ellipse2D elip = (Ellipse2D) shape;
  274. double scale = trans.getScaleX();
  275. double radiusWidth = elip.getWidth() / 2;
  276. double radiusHeight = elip.getHeight() / 2;
  277. graphicsObj.setArcParams(
  278. (int)Math.round(radiusWidth * scale),
  279. (int)Math.round(radiusHeight * scale),
  280. 0,
  281. 0
  282. );
  283. double[] srcPts = new double[] {elip.getCenterX(), elip.getCenterY()};
  284. trans.transform(srcPts, 0, dstPts, 0, 1);
  285. final int mh = 1;
  286. final int mhr = 0;
  287. graphicsObj.addFullArc(
  288. (int)Math.round(dstPts[X]),
  289. (int)Math.round(dstPts[Y]),
  290. mh,
  291. mhr
  292. );
  293. } else {
  294. processPathIterator(iter);
  295. }
  296. if (fill) {
  297. graphicsObj.endArea();
  298. }
  299. }
  300. /**
  301. * Processes a path iterator generating the necessary painting operations.
  302. *
  303. * @param iter PathIterator to process
  304. */
  305. private void processPathIterator(PathIterator iter) {
  306. double[] dstPts = new double[6];
  307. for (int[] openingCoords = new int[2]; !iter.isDone(); iter.next()) {
  308. switch (iter.currentSegment(dstPts)) {
  309. case PathIterator.SEG_LINETO:
  310. graphicsObj.addLine(new int[] {
  311. (int)Math.round(dstPts[X]),
  312. (int)Math.round(dstPts[Y])
  313. }, true);
  314. break;
  315. case PathIterator.SEG_QUADTO:
  316. graphicsObj.addFillet(new int[] {
  317. (int)Math.round(dstPts[X1]),
  318. (int)Math.round(dstPts[Y1]),
  319. (int)Math.round(dstPts[X2]),
  320. (int)Math.round(dstPts[Y2])
  321. }, true);
  322. break;
  323. case PathIterator.SEG_CUBICTO:
  324. graphicsObj.addFillet(new int[] {
  325. (int)Math.round(dstPts[X1]),
  326. (int)Math.round(dstPts[Y1]),
  327. (int)Math.round(dstPts[X2]),
  328. (int)Math.round(dstPts[Y2]),
  329. (int)Math.round(dstPts[X3]),
  330. (int)Math.round(dstPts[Y3])
  331. }, true);
  332. break;
  333. case PathIterator.SEG_MOVETO:
  334. openingCoords = new int[] {
  335. (int)Math.round(dstPts[X]),
  336. (int)Math.round(dstPts[Y])
  337. };
  338. graphicsObj.setCurrentPosition(openingCoords);
  339. break;
  340. case PathIterator.SEG_CLOSE:
  341. graphicsObj.addLine(openingCoords, true);
  342. break;
  343. default:
  344. log.debug("Unrecognised path iterator type");
  345. break;
  346. }
  347. }
  348. }
  349. /** {@inheritDoc} */
  350. public void draw(Shape shape) {
  351. log.debug("draw() shape=" + shape);
  352. doDrawing(shape, false);
  353. }
  354. /** {@inheritDoc} */
  355. public void fill(Shape shape) {
  356. log.debug("fill() shape=" + shape);
  357. doDrawing(shape, true);
  358. }
  359. /**
  360. * Central handler for IOExceptions for this class.
  361. *
  362. * @param ioe
  363. * IOException to handle
  364. */
  365. public void handleIOException(IOException ioe) {
  366. // TODO Surely, there's a better way to do this.
  367. log.error(ioe.getMessage());
  368. ioe.printStackTrace();
  369. }
  370. /** {@inheritDoc} */
  371. public void drawString(String str, float x, float y) {
  372. try {
  373. if (customTextHandler != null && !textAsShapes) {
  374. customTextHandler.drawString(this, str, x, y);
  375. } else {
  376. fallbackTextHandler.drawString(this, str, x, y);
  377. }
  378. } catch (IOException ioe) {
  379. handleIOException(ioe);
  380. }
  381. }
  382. /** {@inheritDoc} */
  383. public GraphicsConfiguration getDeviceConfiguration() {
  384. return graphicsConfig;
  385. }
  386. /** {@inheritDoc} */
  387. public Graphics create() {
  388. return new AFPGraphics2D(this);
  389. }
  390. /** {@inheritDoc} */
  391. public void dispose() {
  392. this.graphicsObj = null;
  393. }
  394. /** {@inheritDoc} */
  395. public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
  396. return drawImage(img, x, y, img.getWidth(observer), img.getHeight(observer), observer);
  397. }
  398. private BufferedImage buildBufferedImage(Dimension size) {
  399. return new BufferedImage(size.width, size.height,
  400. BufferedImage.TYPE_INT_ARGB);
  401. }
  402. private AFPImageObjectInfo createImageObjectInfo(
  403. RenderedImage img, int x, int y, int width, int height) throws IOException {
  404. ImageInfo imageInfo = new ImageInfo(null, "image/unknown");
  405. ImageSize size = new ImageSize(img.getWidth(), img.getHeight(), 72);
  406. imageInfo.setSize(size);
  407. ImageRendered imageRendered = new ImageRendered(imageInfo, img, null);
  408. RenderedImage renderedImage = imageRendered.getRenderedImage();
  409. // create image object info
  410. AFPImageObjectInfo imageObjectInfo = new AFPImageObjectInfo();
  411. imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45);
  412. int bitsPerPixel = paintingState.getBitsPerPixel();
  413. imageObjectInfo.setBitsPerPixel(bitsPerPixel);
  414. imageObjectInfo.setResourceInfo(resourceInfo);
  415. int dataHeight = renderedImage.getHeight();
  416. imageObjectInfo.setDataHeight(dataHeight);
  417. int dataWidth = renderedImage.getWidth();
  418. imageObjectInfo.setDataWidth(dataWidth);
  419. boolean colorImages = paintingState.isColorImages();
  420. imageObjectInfo.setColor(colorImages);
  421. ByteArrayOutputStream boas = new ByteArrayOutputStream();
  422. ImageEncodingHelper.encodeRenderedImageAsRGB(renderedImage, boas);
  423. byte[] imageData = boas.toByteArray();
  424. // convert to grayscale
  425. if (!colorImages) {
  426. boas.reset();
  427. imageObjectInfo.setBitsPerPixel(bitsPerPixel);
  428. ImageEncodingHelper.encodeRGBAsGrayScale(
  429. imageData, dataWidth, dataHeight, bitsPerPixel, boas);
  430. imageData = boas.toByteArray();
  431. }
  432. imageObjectInfo.setData(imageData);
  433. if (imageInfo != null) {
  434. imageObjectInfo.setUri(imageInfo.getOriginalURI());
  435. }
  436. // create object area info
  437. AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
  438. objectAreaInfo.setX(x);
  439. objectAreaInfo.setY(y);
  440. objectAreaInfo.setWidth(width);
  441. objectAreaInfo.setHeight(height);
  442. int resolution = paintingState.getResolution();
  443. objectAreaInfo.setWidthRes(resolution);
  444. objectAreaInfo.setHeightRes(resolution);
  445. imageObjectInfo.setObjectAreaInfo(objectAreaInfo);
  446. return imageObjectInfo;
  447. }
  448. /**
  449. * Draws an AWT image into a BufferedImage using an AWT Graphics2D implementation
  450. *
  451. * @param img the AWT image
  452. * @param bufferedImage the AWT buffered image
  453. * @param width the image width
  454. * @param height the image height
  455. * @param observer the image observer
  456. * @return true if the image was drawn
  457. */
  458. private boolean drawBufferedImage(Image img, BufferedImage bufferedImage,
  459. int width, int height, ImageObserver observer) {
  460. java.awt.Graphics2D g2d = bufferedImage.createGraphics();
  461. try {
  462. g2d.setComposite(AlphaComposite.SrcOver);
  463. Color color = new Color(1, 1, 1, 0);
  464. g2d.setBackground(color);
  465. g2d.setPaint(color);
  466. g2d.fillRect(0, 0, width, height);
  467. int imageWidth = bufferedImage.getWidth();
  468. int imageHeight = bufferedImage.getHeight();
  469. Rectangle clipRect = new Rectangle(0, 0, imageWidth, imageHeight);
  470. g2d.clip(clipRect);
  471. g2d.setComposite(gc.getComposite());
  472. return g2d.drawImage(img, 0, 0, imageWidth, imageHeight, observer);
  473. } finally {
  474. g2d.dispose(); //drawn so dispose immediately to free system resource
  475. }
  476. }
  477. /** {@inheritDoc} */
  478. public boolean drawImage(Image img, int x, int y, int width, int height,
  479. ImageObserver observer) {
  480. // draw with AWT Graphics2D
  481. Dimension imageSize = new Dimension(width, height);
  482. BufferedImage bufferedImage = buildBufferedImage(imageSize);
  483. boolean drawn = drawBufferedImage(img, bufferedImage, width, height, observer);
  484. if (drawn) {
  485. AffineTransform at = gc.getTransform();
  486. float[] srcPts = new float[] {x, y};
  487. float[] dstPts = new float[srcPts.length];
  488. at.transform(srcPts, 0, dstPts, 0, 1);
  489. x = Math.round(dstPts[X]);
  490. y = Math.round(dstPts[Y]);
  491. try {
  492. // get image object info
  493. AFPImageObjectInfo imageObjectInfo
  494. = createImageObjectInfo(bufferedImage, x, y, width, height);
  495. // create image resource
  496. resourceManager.createObject(imageObjectInfo);
  497. return true;
  498. } catch (IOException ioe) {
  499. handleIOException(ioe);
  500. }
  501. }
  502. return false;
  503. }
  504. /** {@inheritDoc} */
  505. public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
  506. int imgWidth = img.getWidth();
  507. int imgHeight = img.getHeight();
  508. AffineTransform at = paintingState.getData().getTransform();
  509. AffineTransform gat = gc.getTransform();
  510. int graphicsObjectHeight
  511. = graphicsObj.getObjectEnvironmentGroup().getObjectAreaDescriptor().getHeight();
  512. int x = (int)Math.round(at.getTranslateX() + gat.getTranslateX());
  513. int y = (int)Math.round(at.getTranslateY() - (gat.getTranslateY() - graphicsObjectHeight));
  514. int width = (int)Math.round(imgWidth * gat.getScaleX());
  515. int height = (int)Math.round(imgHeight * -gat.getScaleY());
  516. try {
  517. // get image object info
  518. AFPImageObjectInfo imageObjectInfo
  519. = createImageObjectInfo(img, x, y, width, height);
  520. // create image resource
  521. resourceManager.createObject(imageObjectInfo);
  522. } catch (IOException ioe) {
  523. handleIOException(ioe);
  524. }
  525. }
  526. /**
  527. * Sets a custom TextHandler implementation that is responsible for painting
  528. * text. The default TextHandler paints all text as shapes. A custom
  529. * implementation can implement text painting using text painting operators.
  530. *
  531. * @param handler
  532. * the custom TextHandler implementation
  533. */
  534. public void setCustomTextHandler(TextHandler handler) {
  535. this.customTextHandler = handler;
  536. }
  537. /**
  538. * Returns the GOCA graphics object
  539. *
  540. * @return the GOCA graphics object
  541. */
  542. public GraphicsObject getGraphicsObject() {
  543. return this.graphicsObj;
  544. }
  545. /**
  546. * Sets the GOCA graphics object
  547. *
  548. * @param obj the GOCA graphics object
  549. */
  550. public void setGraphicsObject(GraphicsObject obj) {
  551. this.graphicsObj = obj;
  552. }
  553. /**
  554. * Sets the AFP painting state
  555. *
  556. * @param paintingState the AFP painting state
  557. */
  558. public void setPaintingState(AFPPaintingState paintingState) {
  559. this.paintingState = paintingState;
  560. }
  561. /**
  562. * Returns the AFP painting state
  563. *
  564. * @return the AFP painting state
  565. */
  566. public AFPPaintingState getPaintingState() {
  567. return this.paintingState;
  568. }
  569. /**
  570. * Sets the FontInfo
  571. *
  572. * @param the FontInfo
  573. */
  574. public void setFontInfo(FontInfo fontInfo) {
  575. this.fontInfo = fontInfo;
  576. }
  577. /**
  578. * Returns the FontInfo
  579. *
  580. * @return the FontInfo
  581. */
  582. public FontInfo getFontInfo() {
  583. return this.fontInfo;
  584. }
  585. /** {@inheritDoc} */
  586. public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
  587. log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform);
  588. }
  589. /** {@inheritDoc} */
  590. public FontMetrics getFontMetrics(Font f) {
  591. log.debug("getFontMetrics() NYI: f=" + f);
  592. return null;
  593. }
  594. /** {@inheritDoc} */
  595. public void setXORMode(Color col) {
  596. log.debug("setXORMode() NYI: col=" + col);
  597. }
  598. /** {@inheritDoc} */
  599. public void addNativeImage(org.apache.xmlgraphics.image.loader.Image image,
  600. float x, float y, float width, float height) {
  601. log.debug("NYI: addNativeImage() "+ "image=" + image
  602. + ",x=" + x + ",y=" + y + ",width=" + width + ",height=" + height);
  603. }
  604. /** {@inheritDoc} */
  605. public void copyArea(int x, int y, int width, int height, int dx, int dy) {
  606. log.debug("copyArea() NYI: ");
  607. }
  608. }