PageRenderTime 38ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/ppt/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java

https://github.com/minstrelsy/POI-Android
Java | 1773 lines | 382 code | 107 blank | 1284 comment | 17 complexity | c1eed61b5e85ccbd507d7e9acd97a919 MD5 | raw file
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hslf.model;
  16. import and.awt.*;
  17. import and.awt.Shape;
  18. import and.awt.font.FontRenderContext;
  19. import and.awt.font.GlyphVector;
  20. import and.awt.image.*;
  21. import and.awt.image.renderable.RenderableImage;
  22. import and.awt.geom.*;
  23. import java.text.AttributedCharacterIterator;
  24. import java.util.Map;
  25. import net.pbdavey.awt.Graphics2D;
  26. import net.pbdavey.awt.RenderingHints;
  27. import org.apache.poi.hslf.usermodel.RichTextRun;
  28. import org.apache.poi.hslf.exceptions.HSLFException;
  29. import org.apache.poi.util.POILogger;
  30. import org.apache.poi.util.POILogFactory;
  31. /**
  32. * Translates Graphics2D calls into PowerPoint.
  33. *
  34. * @author Yegor Kozlov
  35. */
  36. public final class PPGraphics2D extends Graphics2D implements Cloneable {
  37. protected POILogger log = POILogFactory.getLogger(this.getClass());
  38. //The ppt object to write into.
  39. private ShapeGroup _group;
  40. private AffineTransform _transform;
  41. private Stroke _stroke;
  42. private Paint _paint;
  43. private Font _font;
  44. private Color _foreground;
  45. private Color _background;
  46. private RenderingHints _hints;
  47. /**
  48. * Construct Java Graphics object which translates graphic calls in ppt drawing layer.
  49. *
  50. * @param group The shape group to write the graphics calls into.
  51. */
  52. public PPGraphics2D(ShapeGroup group){
  53. this._group = group;
  54. _transform = new AffineTransform();
  55. _stroke = new BasicStroke();
  56. _paint = Color.black;
  57. _font = new Font("Arial", Font.PLAIN, 12);
  58. _background = Color.black;
  59. _foreground = Color.white;
  60. _hints = new RenderingHints(null);
  61. }
  62. /**
  63. * @return the shape group being used for drawing
  64. */
  65. public ShapeGroup getShapeGroup(){
  66. return _group;
  67. }
  68. /**
  69. * Gets the current font.
  70. * @return this graphics context's current font.
  71. * @see and.awt.Font
  72. * @see and.awt.Graphics#setFont(Font)
  73. */
  74. public Font getFont(){
  75. return _font;
  76. }
  77. /**
  78. * Sets this graphics context's font to the specified font.
  79. * All subsequent text operations using this graphics context
  80. * use this font.
  81. * @param font the font.
  82. * @see and.awt.Graphics#getFont
  83. * @see and.awt.Graphics#drawString(java.lang.String, int, int)
  84. * @see and.awt.Graphics#drawBytes(byte[], int, int, int, int)
  85. * @see and.awt.Graphics#drawChars(char[], int, int, int, int)
  86. */
  87. public void setFont(Font font){
  88. this._font = font;
  89. }
  90. /**
  91. * Gets this graphics context's current color.
  92. * @return this graphics context's current color.
  93. * @see and.awt.Color
  94. * @see and.awt.Graphics#setColor
  95. */
  96. public Color getColor(){
  97. return _foreground;
  98. }
  99. /**
  100. * Sets this graphics context's current color to the specified
  101. * color. All subsequent graphics operations using this graphics
  102. * context use this specified color.
  103. * @param c the new rendering color.
  104. * @see and.awt.Color
  105. * @see and.awt.Graphics#getColor
  106. */
  107. public void setColor(Color c) {
  108. setPaint(c);
  109. }
  110. /**
  111. * Returns the current <code>Stroke</code> in the
  112. * <code>Graphics2D</code> context.
  113. * @return the current <code>Graphics2D</code> <code>Stroke</code>,
  114. * which defines the line style.
  115. * @see #setStroke
  116. */
  117. public Stroke getStroke(){
  118. return _stroke;
  119. }
  120. /**
  121. * Sets the <code>Stroke</code> for the <code>Graphics2D</code> context.
  122. * @param s the <code>Stroke</code> object to be used to stroke a
  123. * <code>Shape</code> during the rendering process
  124. */
  125. public void setStroke(Stroke s){
  126. this._stroke = s;
  127. }
  128. /**
  129. * Returns the current <code>Paint</code> of the
  130. * <code>Graphics2D</code> context.
  131. * @return the current <code>Graphics2D</code> <code>Paint</code>,
  132. * which defines a color or pattern.
  133. * @see #setPaint
  134. * @see and.awt.Graphics#setColor
  135. */
  136. public Paint getPaint(){
  137. return _paint;
  138. }
  139. /**
  140. * Sets the <code>Paint</code> attribute for the
  141. * <code>Graphics2D</code> context. Calling this method
  142. * with a <code>null</code> <code>Paint</code> object does
  143. * not have any effect on the current <code>Paint</code> attribute
  144. * of this <code>Graphics2D</code>.
  145. * @param paint the <code>Paint</code> object to be used to generate
  146. * color during the rendering process, or <code>null</code>
  147. * @see and.awt.Graphics#setColor
  148. */
  149. public void setPaint(Paint paint){
  150. if(paint == null) return;
  151. this._paint = paint;
  152. if (paint instanceof Color) _foreground = (Color)paint;
  153. }
  154. /**
  155. * Returns a copy of the current <code>Transform</code> in the
  156. * <code>Graphics2D</code> context.
  157. * @return the current <code>AffineTransform</code> in the
  158. * <code>Graphics2D</code> context.
  159. * @see #_transform
  160. * @see #setTransform
  161. */
  162. public AffineTransform getTransform(){
  163. return new AffineTransform(_transform);
  164. }
  165. /**
  166. * Sets the <code>Transform</code> in the <code>Graphics2D</code>
  167. * context.
  168. * @param Tx the <code>AffineTransform</code> object to be used in the
  169. * rendering process
  170. * @see #_transform
  171. * @see AffineTransform
  172. */
  173. public void setTransform(AffineTransform Tx) {
  174. _transform = new AffineTransform(Tx);
  175. }
  176. /**
  177. * Strokes the outline of a <code>Shape</code> using the settings of the
  178. * current <code>Graphics2D</code> context. The rendering attributes
  179. * applied include the <code>Clip</code>, <code>Transform</code>,
  180. * <code>Paint</code>, <code>Composite</code> and
  181. * <code>Stroke</code> attributes.
  182. * @param shape the <code>Shape</code> to be rendered
  183. * @see #setStroke
  184. * @see #setPaint
  185. * @see and.awt.Graphics#setColor
  186. * @see #_transform
  187. * @see #setTransform
  188. * @see #clip
  189. * @see #setClip
  190. * @see #setComposite
  191. */
  192. public void draw(Shape shape){
  193. GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
  194. Freeform p = new Freeform(_group);
  195. p.setPath(path);
  196. p.getFill().setForegroundColor(null);
  197. applyStroke(p);
  198. _group.addShape(p);
  199. }
  200. /**
  201. * Renders the text specified by the specified <code>String</code>,
  202. * using the current text attribute state in the <code>Graphics2D</code> context.
  203. * The baseline of the first character is at position
  204. * (<i>x</i>,&nbsp;<i>y</i>) in the User Space.
  205. * The rendering attributes applied include the <code>Clip</code>,
  206. * <code>Transform</code>, <code>Paint</code>, <code>Font</code> and
  207. * <code>Composite</code> attributes. For characters in script systems
  208. * such as Hebrew and Arabic, the glyphs can be rendered from right to
  209. * left, in which case the coordinate supplied is the location of the
  210. * leftmost character on the baseline.
  211. * @param s the <code>String</code> to be rendered
  212. * @param x the x coordinate of the location where the
  213. * <code>String</code> should be rendered
  214. * @param y the y coordinate of the location where the
  215. * <code>String</code> should be rendered
  216. * @throws NullPointerException if <code>str</code> is
  217. * <code>null</code>
  218. * @see #setPaint
  219. * @see and.awt.Graphics#setColor
  220. * @see and.awt.Graphics#setFont
  221. * @see #setTransform
  222. * @see #setComposite
  223. * @see #setClip
  224. */
  225. public void drawString(String s, float x, float y) {
  226. TextBox txt = new TextBox(_group);
  227. txt.getTextRun().supplySlideShow(_group.getSheet().getSlideShow());
  228. txt.getTextRun().setSheet(_group.getSheet());
  229. txt.setText(s);
  230. RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
  231. rt.setFontSize(_font.getSize());
  232. rt.setFontName(_font.getFamily());
  233. if (getColor() != null) rt.setFontColor(getColor());
  234. if (_font.isBold()) rt.setBold(true);
  235. if (_font.isItalic()) rt.setItalic(true);
  236. txt.setMarginBottom(0);
  237. txt.setMarginTop(0);
  238. txt.setMarginLeft(0);
  239. txt.setMarginRight(0);
  240. txt.setWordWrap(TextBox.WrapNone);
  241. txt.setHorizontalAlignment(TextBox.AlignLeft);
  242. txt.setVerticalAlignment(TextBox.AnchorMiddle);
  243. TextLayout layout = new TextLayout(s, _font, getFontRenderContext());
  244. float ascent = layout.getAscent();
  245. float width = (float) Math.floor(layout.getAdvance());
  246. /**
  247. * Even if top and bottom margins are set to 0 PowerPoint
  248. * always sets extra space between the text and its bounding box.
  249. *
  250. * The approximation height = ascent*2 works good enough in most cases
  251. */
  252. float height = ascent * 2;
  253. /*
  254. In powerpoint anchor of a shape is its top left corner.
  255. Java graphics sets string coordinates by the baseline of the first character
  256. so we need to shift up by the height of the textbox
  257. */
  258. y -= height / 2 + ascent / 2;
  259. /*
  260. In powerpoint anchor of a shape is its top left corner.
  261. Java graphics sets string coordinates by the baseline of the first character
  262. so we need to shift down by the height of the textbox
  263. */
  264. txt.setAnchor(new Rectangle2D.Float(x, y, width, height));
  265. _group.addShape(txt);
  266. }
  267. /**
  268. * Fills the interior of a <code>Shape</code> using the settings of the
  269. * <code>Graphics2D</code> context. The rendering attributes applied
  270. * include the <code>Clip</code>, <code>Transform</code>,
  271. * <code>Paint</code>, and <code>Composite</code>.
  272. * @param shape the <code>Shape</code> to be filled
  273. * @see #setPaint
  274. * @see and.awt.Graphics#setColor
  275. * @see #_transform
  276. * @see #setTransform
  277. * @see #setComposite
  278. * @see #clip
  279. * @see #setClip
  280. */
  281. public void fill(Shape shape){
  282. GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
  283. Freeform p = new Freeform(_group);
  284. p.setPath(path);
  285. applyPaint(p);
  286. p.setLineColor(null); //Fills must be "No Line"
  287. _group.addShape(p);
  288. }
  289. /**
  290. * Translates the origin of the graphics context to the point
  291. * (<i>x</i>,&nbsp;<i>y</i>) in the current coordinate system.
  292. * Modifies this graphics context so that its new origin corresponds
  293. * to the point (<i>x</i>,&nbsp;<i>y</i>) in this graphics context's
  294. * original coordinate system. All coordinates used in subsequent
  295. * rendering operations on this graphics context will be relative
  296. * to this new origin.
  297. * @param x the <i>x</i> coordinate.
  298. * @param y the <i>y</i> coordinate.
  299. */
  300. public void translate(int x, int y){
  301. _transform.translate(x, y);
  302. }
  303. /**
  304. * Intersects the current <code>Clip</code> with the interior of the
  305. * specified <code>Shape</code> and sets the <code>Clip</code> to the
  306. * resulting intersection. The specified <code>Shape</code> is
  307. * transformed with the current <code>Graphics2D</code>
  308. * <code>Transform</code> before being intersected with the current
  309. * <code>Clip</code>. This method is used to make the current
  310. * <code>Clip</code> smaller.
  311. * To make the <code>Clip</code> larger, use <code>setClip</code>.
  312. * The <i>user clip</i> modified by this method is independent of the
  313. * clipping associated with device bounds and visibility. If no clip has
  314. * previously been set, or if the clip has been cleared using
  315. * {@link and.awt.Graphics#setClip(Shape) setClip} with a
  316. * <code>null</code> argument, the specified <code>Shape</code> becomes
  317. * the new user clip.
  318. * @param s the <code>Shape</code> to be intersected with the current
  319. * <code>Clip</code>. If <code>s</code> is <code>null</code>,
  320. * this method clears the current <code>Clip</code>.
  321. */
  322. public void clip(Shape s){
  323. log.log(POILogger.WARN, "Not implemented");
  324. }
  325. /**
  326. * Gets the current clipping area.
  327. * This method returns the user clip, which is independent of the
  328. * clipping associated with device bounds and window visibility.
  329. * If no clip has previously been set, or if the clip has been
  330. * cleared using <code>setClip(null)</code>, this method returns
  331. * <code>null</code>.
  332. * @return a <code>Shape</code> object representing the
  333. * current clipping area, or <code>null</code> if
  334. * no clip is set.
  335. * @see and.awt.Graphics#getClipBounds()
  336. * @see and.awt.Graphics#clipRect
  337. * @see and.awt.Graphics#setClip(int, int, int, int)
  338. * @see and.awt.Graphics#setClip(Shape)
  339. * @since JDK1.1
  340. */
  341. public Shape getClip(){
  342. log.log(POILogger.WARN, "Not implemented");
  343. return null;
  344. }
  345. /**
  346. * Concatenates the current <code>Graphics2D</code>
  347. * <code>Transform</code> with a scaling transformation
  348. * Subsequent rendering is resized according to the specified scaling
  349. * factors relative to the previous scaling.
  350. * This is equivalent to calling <code>transform(S)</code>, where S is an
  351. * <code>AffineTransform</code> represented by the following matrix:
  352. * <pre>
  353. * [ sx 0 0 ]
  354. * [ 0 sy 0 ]
  355. * [ 0 0 1 ]
  356. * </pre>
  357. * @param sx the amount by which X coordinates in subsequent
  358. * rendering operations are multiplied relative to previous
  359. * rendering operations.
  360. * @param sy the amount by which Y coordinates in subsequent
  361. * rendering operations are multiplied relative to previous
  362. * rendering operations.
  363. */
  364. public void scale(double sx, double sy){
  365. _transform.scale(sx, sy);
  366. }
  367. /**
  368. * Draws an outlined round-cornered rectangle using this graphics
  369. * context's current color. The left and right edges of the rectangle
  370. * are at <code>x</code> and <code>x&nbsp;+&nbsp;width</code>,
  371. * respectively. The top and bottom edges of the rectangle are at
  372. * <code>y</code> and <code>y&nbsp;+&nbsp;height</code>.
  373. * @param x the <i>x</i> coordinate of the rectangle to be drawn.
  374. * @param y the <i>y</i> coordinate of the rectangle to be drawn.
  375. * @param width the width of the rectangle to be drawn.
  376. * @param height the height of the rectangle to be drawn.
  377. * @param arcWidth the horizontal diameter of the arc
  378. * at the four corners.
  379. * @param arcHeight the vertical diameter of the arc
  380. * at the four corners.
  381. * @see and.awt.Graphics#fillRoundRect
  382. */
  383. public void drawRoundRect(int x, int y, int width, int height,
  384. int arcWidth, int arcHeight){
  385. RoundRectangle2D rect = new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight);
  386. draw(rect);
  387. }
  388. /**
  389. * Draws the text given by the specified string, using this
  390. * graphics context's current font and color. The baseline of the
  391. * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in this
  392. * graphics context's coordinate system.
  393. * @param str the string to be drawn.
  394. * @param x the <i>x</i> coordinate.
  395. * @param y the <i>y</i> coordinate.
  396. * @see and.awt.Graphics#drawBytes
  397. * @see and.awt.Graphics#drawChars
  398. */
  399. public void drawString(String str, int x, int y){
  400. drawString(str, (float)x, (float)y);
  401. }
  402. /**
  403. * Fills an oval bounded by the specified rectangle with the
  404. * current color.
  405. * @param x the <i>x</i> coordinate of the upper left corner
  406. * of the oval to be filled.
  407. * @param y the <i>y</i> coordinate of the upper left corner
  408. * of the oval to be filled.
  409. * @param width the width of the oval to be filled.
  410. * @param height the height of the oval to be filled.
  411. * @see and.awt.Graphics#drawOval
  412. */
  413. public void fillOval(int x, int y, int width, int height){
  414. Ellipse2D oval = new Ellipse2D.Float(x, y, width, height);
  415. fill(oval);
  416. }
  417. /**
  418. * Fills the specified rounded corner rectangle with the current color.
  419. * The left and right edges of the rectangle
  420. * are at <code>x</code> and <code>x&nbsp;+&nbsp;width&nbsp;-&nbsp;1</code>,
  421. * respectively. The top and bottom edges of the rectangle are at
  422. * <code>y</code> and <code>y&nbsp;+&nbsp;height&nbsp;-&nbsp;1</code>.
  423. * @param x the <i>x</i> coordinate of the rectangle to be filled.
  424. * @param y the <i>y</i> coordinate of the rectangle to be filled.
  425. * @param width the width of the rectangle to be filled.
  426. * @param height the height of the rectangle to be filled.
  427. * @param arcWidth the horizontal diameter
  428. * of the arc at the four corners.
  429. * @param arcHeight the vertical diameter
  430. * of the arc at the four corners.
  431. * @see and.awt.Graphics#drawRoundRect
  432. */
  433. public void fillRoundRect(int x, int y, int width, int height,
  434. int arcWidth, int arcHeight){
  435. RoundRectangle2D rect = new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight);
  436. fill(rect);
  437. }
  438. /**
  439. * Fills a circular or elliptical arc covering the specified rectangle.
  440. * <p>
  441. * The resulting arc begins at <code>startAngle</code> and extends
  442. * for <code>arcAngle</code> degrees.
  443. * Angles are interpreted such that 0&nbsp;degrees
  444. * is at the 3&nbsp;o'clock position.
  445. * A positive value indicates a counter-clockwise rotation
  446. * while a negative value indicates a clockwise rotation.
  447. * <p>
  448. * The center of the arc is the center of the rectangle whose origin
  449. * is (<i>x</i>,&nbsp;<i>y</i>) and whose size is specified by the
  450. * <code>width</code> and <code>height</code> arguments.
  451. * <p>
  452. * The resulting arc covers an area
  453. * <code>width&nbsp;+&nbsp;1</code> pixels wide
  454. * by <code>height&nbsp;+&nbsp;1</code> pixels tall.
  455. * <p>
  456. * The angles are specified relative to the non-square extents of
  457. * the bounding rectangle such that 45 degrees always falls on the
  458. * line from the center of the ellipse to the upper right corner of
  459. * the bounding rectangle. As a result, if the bounding rectangle is
  460. * noticeably longer in one axis than the other, the angles to the
  461. * start and end of the arc segment will be skewed farther along the
  462. * longer axis of the bounds.
  463. * @param x the <i>x</i> coordinate of the
  464. * upper-left corner of the arc to be filled.
  465. * @param y the <i>y</i> coordinate of the
  466. * upper-left corner of the arc to be filled.
  467. * @param width the width of the arc to be filled.
  468. * @param height the height of the arc to be filled.
  469. * @param startAngle the beginning angle.
  470. * @param arcAngle the angular extent of the arc,
  471. * relative to the start angle.
  472. * @see and.awt.Graphics#drawArc
  473. */
  474. public void fillArc(int x, int y, int width, int height,
  475. int startAngle, int arcAngle){
  476. Arc2D arc = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.PIE);
  477. fill(arc);
  478. }
  479. /**
  480. * Draws the outline of a circular or elliptical arc
  481. * covering the specified rectangle.
  482. * <p>
  483. * The resulting arc begins at <code>startAngle</code> and extends
  484. * for <code>arcAngle</code> degrees, using the current color.
  485. * Angles are interpreted such that 0&nbsp;degrees
  486. * is at the 3&nbsp;o'clock position.
  487. * A positive value indicates a counter-clockwise rotation
  488. * while a negative value indicates a clockwise rotation.
  489. * <p>
  490. * The center of the arc is the center of the rectangle whose origin
  491. * is (<i>x</i>,&nbsp;<i>y</i>) and whose size is specified by the
  492. * <code>width</code> and <code>height</code> arguments.
  493. * <p>
  494. * The resulting arc covers an area
  495. * <code>width&nbsp;+&nbsp;1</code> pixels wide
  496. * by <code>height&nbsp;+&nbsp;1</code> pixels tall.
  497. * <p>
  498. * The angles are specified relative to the non-square extents of
  499. * the bounding rectangle such that 45 degrees always falls on the
  500. * line from the center of the ellipse to the upper right corner of
  501. * the bounding rectangle. As a result, if the bounding rectangle is
  502. * noticeably longer in one axis than the other, the angles to the
  503. * start and end of the arc segment will be skewed farther along the
  504. * longer axis of the bounds.
  505. * @param x the <i>x</i> coordinate of the
  506. * upper-left corner of the arc to be drawn.
  507. * @param y the <i>y</i> coordinate of the
  508. * upper-left corner of the arc to be drawn.
  509. * @param width the width of the arc to be drawn.
  510. * @param height the height of the arc to be drawn.
  511. * @param startAngle the beginning angle.
  512. * @param arcAngle the angular extent of the arc,
  513. * relative to the start angle.
  514. * @see and.awt.Graphics#fillArc
  515. */
  516. public void drawArc(int x, int y, int width, int height,
  517. int startAngle, int arcAngle) {
  518. Arc2D arc = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
  519. draw(arc);
  520. }
  521. /**
  522. * Draws a sequence of connected lines defined by
  523. * arrays of <i>x</i> and <i>y</i> coordinates.
  524. * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
  525. * The figure is not closed if the first point
  526. * differs from the last point.
  527. * @param xPoints an array of <i>x</i> points
  528. * @param yPoints an array of <i>y</i> points
  529. * @param nPoints the total number of points
  530. * @see and.awt.Graphics#drawPolygon(int[], int[], int)
  531. * @since JDK1.1
  532. */
  533. public void drawPolyline(int[] xPoints, int[] yPoints,
  534. int nPoints){
  535. if(nPoints > 0){
  536. GeneralPath path = new GeneralPath();
  537. path.moveTo(xPoints[0], yPoints[0]);
  538. for(int i=1; i<nPoints; i++)
  539. path.lineTo(xPoints[i], yPoints[i]);
  540. draw(path);
  541. }
  542. }
  543. /**
  544. * Draws the outline of an oval.
  545. * The result is a circle or ellipse that fits within the
  546. * rectangle specified by the <code>x</code>, <code>y</code>,
  547. * <code>width</code>, and <code>height</code> arguments.
  548. * <p>
  549. * The oval covers an area that is
  550. * <code>width&nbsp;+&nbsp;1</code> pixels wide
  551. * and <code>height&nbsp;+&nbsp;1</code> pixels tall.
  552. * @param x the <i>x</i> coordinate of the upper left
  553. * corner of the oval to be drawn.
  554. * @param y the <i>y</i> coordinate of the upper left
  555. * corner of the oval to be drawn.
  556. * @param width the width of the oval to be drawn.
  557. * @param height the height of the oval to be drawn.
  558. * @see and.awt.Graphics#fillOval
  559. */
  560. public void drawOval(int x, int y, int width, int height){
  561. Ellipse2D oval = new Ellipse2D.Float(x, y, width, height);
  562. draw(oval);
  563. }
  564. /**
  565. * Draws as much of the specified image as is currently available.
  566. * The image is drawn with its top-left corner at
  567. * (<i>x</i>,&nbsp;<i>y</i>) in this graphics context's coordinate
  568. * space. Transparent pixels are drawn in the specified
  569. * background color.
  570. * <p>
  571. * This operation is equivalent to filling a rectangle of the
  572. * width and height of the specified image with the given color and then
  573. * drawing the image on top of it, but possibly more efficient.
  574. * <p>
  575. * This method returns immediately in all cases, even if the
  576. * complete image has not yet been loaded, and it has not been dithered
  577. * and converted for the current output device.
  578. * <p>
  579. * If the image has not yet been completely loaded, then
  580. * <code>drawImage</code> returns <code>false</code>. As more of
  581. * the image becomes available, the process that draws the image notifies
  582. * the specified image observer.
  583. * @param img the specified image to be drawn.
  584. * @param x the <i>x</i> coordinate.
  585. * @param y the <i>y</i> coordinate.
  586. * @param bgcolor the background color to paint under the
  587. * non-opaque portions of the image.
  588. * @param observer object to be notified as more of
  589. * the image is converted.
  590. * @see and.awt.Image
  591. * @see and.awt.image.ImageObserver
  592. * @see and.awt.image.ImageObserver#imageUpdate(and.awt.Image, int, int, int, int, int)
  593. */
  594. public boolean drawImage(Image img, int x, int y,
  595. Color bgcolor,
  596. ImageObserver observer){
  597. log.log(POILogger.WARN, "Not implemented");
  598. return false;
  599. }
  600. /**
  601. * Draws as much of the specified image as has already been scaled
  602. * to fit inside the specified rectangle.
  603. * <p>
  604. * The image is drawn inside the specified rectangle of this
  605. * graphics context's coordinate space, and is scaled if
  606. * necessary. Transparent pixels are drawn in the specified
  607. * background color.
  608. * This operation is equivalent to filling a rectangle of the
  609. * width and height of the specified image with the given color and then
  610. * drawing the image on top of it, but possibly more efficient.
  611. * <p>
  612. * This method returns immediately in all cases, even if the
  613. * entire image has not yet been scaled, dithered, and converted
  614. * for the current output device.
  615. * If the current output representation is not yet complete then
  616. * <code>drawImage</code> returns <code>false</code>. As more of
  617. * the image becomes available, the process that draws the image notifies
  618. * the specified image observer.
  619. * <p>
  620. * A scaled version of an image will not necessarily be
  621. * available immediately just because an unscaled version of the
  622. * image has been constructed for this output device. Each size of
  623. * the image may be cached separately and generated from the original
  624. * data in a separate image production sequence.
  625. * @param img the specified image to be drawn.
  626. * @param x the <i>x</i> coordinate.
  627. * @param y the <i>y</i> coordinate.
  628. * @param width the width of the rectangle.
  629. * @param height the height of the rectangle.
  630. * @param bgcolor the background color to paint under the
  631. * non-opaque portions of the image.
  632. * @param observer object to be notified as more of
  633. * the image is converted.
  634. * @see and.awt.Image
  635. * @see and.awt.image.ImageObserver
  636. * @see and.awt.image.ImageObserver#imageUpdate(and.awt.Image, int, int, int, int, int)
  637. */
  638. public boolean drawImage(Image img, int x, int y,
  639. int width, int height,
  640. Color bgcolor,
  641. ImageObserver observer){
  642. log.log(POILogger.WARN, "Not implemented");
  643. return false;
  644. }
  645. /**
  646. * Draws as much of the specified area of the specified image as is
  647. * currently available, scaling it on the fly to fit inside the
  648. * specified area of the destination drawable surface. Transparent pixels
  649. * do not affect whatever pixels are already there.
  650. * <p>
  651. * This method returns immediately in all cases, even if the
  652. * image area to be drawn has not yet been scaled, dithered, and converted
  653. * for the current output device.
  654. * If the current output representation is not yet complete then
  655. * <code>drawImage</code> returns <code>false</code>. As more of
  656. * the image becomes available, the process that draws the image notifies
  657. * the specified image observer.
  658. * <p>
  659. * This method always uses the unscaled version of the image
  660. * to render the scaled rectangle and performs the required
  661. * scaling on the fly. It does not use a cached, scaled version
  662. * of the image for this operation. Scaling of the image from source
  663. * to destination is performed such that the first coordinate
  664. * of the source rectangle is mapped to the first coordinate of
  665. * the destination rectangle, and the second source coordinate is
  666. * mapped to the second destination coordinate. The subimage is
  667. * scaled and flipped as needed to preserve those mappings.
  668. * @param img the specified image to be drawn
  669. * @param dx1 the <i>x</i> coordinate of the first corner of the
  670. * destination rectangle.
  671. * @param dy1 the <i>y</i> coordinate of the first corner of the
  672. * destination rectangle.
  673. * @param dx2 the <i>x</i> coordinate of the second corner of the
  674. * destination rectangle.
  675. * @param dy2 the <i>y</i> coordinate of the second corner of the
  676. * destination rectangle.
  677. * @param sx1 the <i>x</i> coordinate of the first corner of the
  678. * source rectangle.
  679. * @param sy1 the <i>y</i> coordinate of the first corner of the
  680. * source rectangle.
  681. * @param sx2 the <i>x</i> coordinate of the second corner of the
  682. * source rectangle.
  683. * @param sy2 the <i>y</i> coordinate of the second corner of the
  684. * source rectangle.
  685. * @param observer object to be notified as more of the image is
  686. * scaled and converted.
  687. * @see and.awt.Image
  688. * @see and.awt.image.ImageObserver
  689. * @see and.awt.image.ImageObserver#imageUpdate(and.awt.Image, int, int, int, int, int)
  690. * @since JDK1.1
  691. */
  692. public boolean drawImage(Image img,
  693. int dx1, int dy1, int dx2, int dy2,
  694. int sx1, int sy1, int sx2, int sy2,
  695. ImageObserver observer){
  696. log.log(POILogger.WARN, "Not implemented");
  697. return false;
  698. }
  699. /**
  700. * Draws as much of the specified area of the specified image as is
  701. * currently available, scaling it on the fly to fit inside the
  702. * specified area of the destination drawable surface.
  703. * <p>
  704. * Transparent pixels are drawn in the specified background color.
  705. * This operation is equivalent to filling a rectangle of the
  706. * width and height of the specified image with the given color and then
  707. * drawing the image on top of it, but possibly more efficient.
  708. * <p>
  709. * This method returns immediately in all cases, even if the
  710. * image area to be drawn has not yet been scaled, dithered, and converted
  711. * for the current output device.
  712. * If the current output representation is not yet complete then
  713. * <code>drawImage</code> returns <code>false</code>. As more of
  714. * the image becomes available, the process that draws the image notifies
  715. * the specified image observer.
  716. * <p>
  717. * This method always uses the unscaled version of the image
  718. * to render the scaled rectangle and performs the required
  719. * scaling on the fly. It does not use a cached, scaled version
  720. * of the image for this operation. Scaling of the image from source
  721. * to destination is performed such that the first coordinate
  722. * of the source rectangle is mapped to the first coordinate of
  723. * the destination rectangle, and the second source coordinate is
  724. * mapped to the second destination coordinate. The subimage is
  725. * scaled and flipped as needed to preserve those mappings.
  726. * @param img the specified image to be drawn
  727. * @param dx1 the <i>x</i> coordinate of the first corner of the
  728. * destination rectangle.
  729. * @param dy1 the <i>y</i> coordinate of the first corner of the
  730. * destination rectangle.
  731. * @param dx2 the <i>x</i> coordinate of the second corner of the
  732. * destination rectangle.
  733. * @param dy2 the <i>y</i> coordinate of the second corner of the
  734. * destination rectangle.
  735. * @param sx1 the <i>x</i> coordinate of the first corner of the
  736. * source rectangle.
  737. * @param sy1 the <i>y</i> coordinate of the first corner of the
  738. * source rectangle.
  739. * @param sx2 the <i>x</i> coordinate of the second corner of the
  740. * source rectangle.
  741. * @param sy2 the <i>y</i> coordinate of the second corner of the
  742. * source rectangle.
  743. * @param bgcolor the background color to paint under the
  744. * non-opaque portions of the image.
  745. * @param observer object to be notified as more of the image is
  746. * scaled and converted.
  747. * @see and.awt.Image
  748. * @see and.awt.image.ImageObserver
  749. * @see and.awt.image.ImageObserver#imageUpdate(and.awt.Image, int, int, int, int, int)
  750. * @since JDK1.1
  751. */
  752. public boolean drawImage(Image img,
  753. int dx1, int dy1, int dx2, int dy2,
  754. int sx1, int sy1, int sx2, int sy2,
  755. Color bgcolor,
  756. ImageObserver observer){
  757. log.log(POILogger.WARN, "Not implemented");
  758. return false;
  759. }
  760. /**
  761. * Draws as much of the specified image as is currently available.
  762. * The image is drawn with its top-left corner at
  763. * (<i>x</i>,&nbsp;<i>y</i>) in this graphics context's coordinate
  764. * space. Transparent pixels in the image do not affect whatever
  765. * pixels are already there.
  766. * <p>
  767. * This method returns immediately in all cases, even if the
  768. * complete image has not yet been loaded, and it has not been dithered
  769. * and converted for the current output device.
  770. * <p>
  771. * If the image has completely loaded and its pixels are
  772. * no longer being changed, then
  773. * <code>drawImage</code> returns <code>true</code>.
  774. * Otherwise, <code>drawImage</code> returns <code>false</code>
  775. * and as more of
  776. * the image becomes available
  777. * or it is time to draw another frame of animation,
  778. * the process that loads the image notifies
  779. * the specified image observer.
  780. * @param img the specified image to be drawn. This method does
  781. * nothing if <code>img</code> is null.
  782. * @param x the <i>x</i> coordinate.
  783. * @param y the <i>y</i> coordinate.
  784. * @param observer object to be notified as more of
  785. * the image is converted.
  786. * @return <code>false</code> if the image pixels are still changing;
  787. * <code>true</code> otherwise.
  788. * @see and.awt.Image
  789. * @see and.awt.image.ImageObserver
  790. * @see and.awt.image.ImageObserver#imageUpdate(and.awt.Image, int, int, int, int, int)
  791. */
  792. public boolean drawImage(Image img, int x, int y,
  793. ImageObserver observer) {
  794. log.log(POILogger.WARN, "Not implemented");
  795. return false;
  796. }
  797. /**
  798. * Disposes of this graphics context and releases
  799. * any system resources that it is using.
  800. * A <code>Graphics</code> object cannot be used after
  801. * <code>dispose</code>has been called.
  802. * <p>
  803. * When a Java program runs, a large number of <code>Graphics</code>
  804. * objects can be created within a short time frame.
  805. * Although the finalization process of the garbage collector
  806. * also disposes of the same system resources, it is preferable
  807. * to manually free the associated resources by calling this
  808. * method rather than to rely on a finalization process which
  809. * may not run to completion for a long period of time.
  810. * <p>
  811. * Graphics objects which are provided as arguments to the
  812. * <code>paint</code> and <code>update</code> methods
  813. * of components are automatically released by the system when
  814. * those methods return. For efficiency, programmers should
  815. * call <code>dispose</code> when finished using
  816. * a <code>Graphics</code> object only if it was created
  817. * directly from a component or another <code>Graphics</code> object.
  818. * @see and.awt.Graphics#finalize
  819. * @see and.awt.Component#paint
  820. * @see and.awt.Component#update
  821. * @see and.awt.Component#getGraphics
  822. * @see and.awt.Graphics#create
  823. */
  824. public void dispose() {
  825. ;
  826. }
  827. /**
  828. * Draws a line, using the current color, between the points
  829. * <code>(x1,&nbsp;y1)</code> and <code>(x2,&nbsp;y2)</code>
  830. * in this graphics context's coordinate system.
  831. * @param x1 the first point's <i>x</i> coordinate.
  832. * @param y1 the first point's <i>y</i> coordinate.
  833. * @param x2 the second point's <i>x</i> coordinate.
  834. * @param y2 the second point's <i>y</i> coordinate.
  835. */
  836. public void drawLine(int x1, int y1, int x2, int y2){
  837. Line2D line = new Line2D.Float(x1, y1, x2, y2);
  838. draw(line);
  839. }
  840. /**
  841. * Fills a closed polygon defined by
  842. * arrays of <i>x</i> and <i>y</i> coordinates.
  843. * <p>
  844. * This method draws the polygon defined by <code>nPoint</code> line
  845. * segments, where the first <code>nPoint&nbsp;-&nbsp;1</code>
  846. * line segments are line segments from
  847. * <code>(xPoints[i&nbsp;-&nbsp;1],&nbsp;yPoints[i&nbsp;-&nbsp;1])</code>
  848. * to <code>(xPoints[i],&nbsp;yPoints[i])</code>, for
  849. * 1&nbsp;&le;&nbsp;<i>i</i>&nbsp;&le;&nbsp;<code>nPoints</code>.
  850. * The figure is automatically closed by drawing a line connecting
  851. * the final point to the first point, if those points are different.
  852. * <p>
  853. * The area inside the polygon is defined using an
  854. * even-odd fill rule, also known as the alternating rule.
  855. * @param xPoints a an array of <code>x</code> coordinates.
  856. * @param yPoints a an array of <code>y</code> coordinates.
  857. * @param nPoints a the total number of points.
  858. * @see and.awt.Graphics#drawPolygon(int[], int[], int)
  859. */
  860. public void fillPolygon(int[] xPoints, int[] yPoints,
  861. int nPoints){
  862. and.awt.Polygon polygon = new and.awt.Polygon(xPoints, yPoints, nPoints);
  863. fill(polygon);
  864. }
  865. /**
  866. * Fills the specified rectangle.
  867. * The left and right edges of the rectangle are at
  868. * <code>x</code> and <code>x&nbsp;+&nbsp;width&nbsp;-&nbsp;1</code>.
  869. * The top and bottom edges are at
  870. * <code>y</code> and <code>y&nbsp;+&nbsp;height&nbsp;-&nbsp;1</code>.
  871. * The resulting rectangle covers an area
  872. * <code>width</code> pixels wide by
  873. * <code>height</code> pixels tall.
  874. * The rectangle is filled using the graphics context's current color.
  875. * @param x the <i>x</i> coordinate
  876. * of the rectangle to be filled.
  877. * @param y the <i>y</i> coordinate
  878. * of the rectangle to be filled.
  879. * @param width the width of the rectangle to be filled.
  880. * @param height the height of the rectangle to be filled.
  881. * @see and.awt.Graphics#clearRect
  882. * @see and.awt.Graphics#drawRect
  883. */
  884. public void fillRect(int x, int y, int width, int height){
  885. Rectangle rect = new Rectangle(x, y, width, height);
  886. fill(rect);
  887. }
  888. /**
  889. * Draws the outline of the specified rectangle.
  890. * The left and right edges of the rectangle are at
  891. * <code>x</code> and <code>x&nbsp;+&nbsp;width</code>.
  892. * The top and bottom edges are at
  893. * <code>y</code> and <code>y&nbsp;+&nbsp;height</code>.
  894. * The rectangle is drawn using the graphics context's current color.
  895. * @param x the <i>x</i> coordinate
  896. * of the rectangle to be drawn.
  897. * @param y the <i>y</i> coordinate
  898. * of the rectangle to be drawn.
  899. * @param width the width of the rectangle to be drawn.
  900. * @param height the height of the rectangle to be drawn.
  901. * @see and.awt.Graphics#fillRect
  902. * @see and.awt.Graphics#clearRect
  903. */
  904. public void drawRect(int x, int y, int width, int height) {
  905. Rectangle rect = new Rectangle(x, y, width, height);
  906. draw(rect);
  907. }
  908. /**
  909. * Draws a closed polygon defined by
  910. * arrays of <i>x</i> and <i>y</i> coordinates.
  911. * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
  912. * <p>
  913. * This method draws the polygon defined by <code>nPoint</code> line
  914. * segments, where the first <code>nPoint&nbsp;-&nbsp;1</code>
  915. * line segments are line segments from
  916. * <code>(xPoints[i&nbsp;-&nbsp;1],&nbsp;yPoints[i&nbsp;-&nbsp;1])</code>
  917. * to <code>(xPoints[i],&nbsp;yPoints[i])</code>, for
  918. * 1&nbsp;&le;&nbsp;<i>i</i>&nbsp;&le;&nbsp;<code>nPoints</code>.
  919. * The figure is automatically closed by drawing a line connecting
  920. * the final point to the first point, if those points are different.
  921. * @param xPoints a an array of <code>x</code> coordinates.
  922. * @param yPoints a an array of <code>y</code> coordinates.
  923. * @param nPoints a the total number of points.
  924. * @see and.awt.Graphics#fillPolygon(int[],int[],int)
  925. * @see and.awt.Graphics#drawPolyline
  926. */
  927. public void drawPolygon(int[] xPoints, int[] yPoints,
  928. int nPoints){
  929. and.awt.Polygon polygon = new and.awt.Polygon(xPoints, yPoints, nPoints);
  930. draw(polygon);
  931. }
  932. /**
  933. * Intersects the current clip with the specified rectangle.
  934. * The resulting clipping area is the intersection of the current
  935. * clipping area and the specified rectangle. If there is no
  936. * current clipping area, either because the clip has never been
  937. * set, or the clip has been cleared using <code>setClip(null)</code>,
  938. * the specified rectangle becomes the new clip.
  939. * This method sets the user clip, which is independent of the
  940. * clipping associated with device bounds and window visibility.
  941. * This method can only be used to make the current clip smaller.
  942. * To set the current clip larger, use any of the setClip methods.
  943. * Rendering operations have no effect outside of the clipping area.
  944. * @param x the x coordinate of the rectangle to intersect the clip with
  945. * @param y the y coordinate of the rectangle to intersect the clip with
  946. * @param width the width of the rectangle to intersect the clip with
  947. * @param height the height of the rectangle to intersect the clip with
  948. * @see #setClip(int, int, int, int)
  949. * @see #setClip(Shape)
  950. */
  951. public void clipRect(int x, int y, int width, int height){
  952. clip(new Rectangle(x, y, width, height));
  953. }
  954. /**
  955. * Sets the current clipping area to an arbitrary clip shape.
  956. * Not all objects that implement the <code>Shape</code>
  957. * interface can be used to set the clip. The only
  958. * <code>Shape</code> objects that are guaranteed to be
  959. * supported are <code>Shape</code> objects that are
  960. * obtained via the <code>getClip</code> method and via
  961. * <code>Rectangle</code> objects. This method sets the
  962. * user clip, which is independent of the clipping associated
  963. * with device bounds and window visibility.
  964. * @param clip the <code>Shape</code> to use to set the clip
  965. * @see and.awt.Graphics#getClip()
  966. * @see and.awt.Graphics#clipRect
  967. * @see and.awt.Graphics#setClip(int, int, int, int)
  968. * @since JDK1.1
  969. */
  970. public void setClip(Shape clip) {
  971. log.log(POILogger.WARN, "Not implemented");
  972. }
  973. /**
  974. * Returns the bounding rectangle of the current clipping area.
  975. * This method refers to the user clip, which is independent of the
  976. * clipping associated with device bounds and window visibility.
  977. * If no clip has previously been set, or if the clip has been
  978. * cleared using <code>setClip(null)</code>, this method returns
  979. * <code>null</code>.
  980. * The coordinates in the rectangle are relative to the coordinate
  981. * system origin of this graphics context.
  982. * @return the bounding rectangle of the current clipping area,
  983. * or <code>null</code> if no clip is set.
  984. * @see and.awt.Graphics#getClip
  985. * @see and.awt.Graphics#clipRect
  986. * @see and.awt.Graphics#setClip(int, int, int, int)
  987. * @see and.awt.Graphics#setClip(Shape)
  988. * @since JDK1.1
  989. */
  990. public Rectangle getClipBounds(){
  991. Shape c = getClip();
  992. if (c==null) {
  993. return null;
  994. }
  995. return c.getBounds();
  996. }
  997. /**
  998. * Draws the text given by the specified iterator, using this
  999. * graphics context's current color. The iterator has to specify a font
  1000. * for each character. The baseline of the
  1001. * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in this
  1002. * graphics context's coordinate system.
  1003. * @param iterator the iterator whose text is to be drawn
  1004. * @param x the <i>x</i> coordinate.
  1005. * @param y the <i>y</i> coordinate.
  1006. * @see and.awt.Graphics#drawBytes
  1007. * @see and.awt.Graphics#drawChars
  1008. */
  1009. public void drawString(AttributedCharacterIterator iterator,
  1010. int x, int y){
  1011. drawString(iterator, (float)x, (float)y);
  1012. }
  1013. /**
  1014. * Clears the specified rectangle by filling it with the background
  1015. * color of the current drawing surface. This operation does not
  1016. * use the current paint mode.
  1017. * <p>
  1018. * Beginning with Java&nbsp;1.1, the background color
  1019. * of offscreen images may be system dependent. Applications should
  1020. * use <code>setColor</code> followed by <code>fillRect</code> to
  1021. * ensure that an offscreen image is cleared to a specific color.
  1022. * @param x the <i>x</i> coordinate of the rectangle to clear.
  1023. * @param y the <i>y</i> coordinate of the rectangle to clear.
  1024. * @param width the width of the rectangle to clear.
  1025. * @param height the height of the rectangle to clear.
  1026. * @see and.awt.Graphics#fillRect(int, int, int, int)
  1027. * @see and.awt.Graphics#drawRect
  1028. * @see and.awt.Graphics#setColor(and.awt.Color)
  1029. * @see and.awt.Graphics#setPaintMode
  1030. * @see and.awt.Graphics#setXORMode(and.awt.Color)
  1031. */
  1032. public void clearRect(int x, int y, int width, int height) {
  1033. Paint paint = getPaint();
  1034. setColor(getBackground());
  1035. fillRect(x, y, width, height);
  1036. setPaint(paint);
  1037. }
  1038. public void copyArea(int x, int y, int width, int height, int dx, int dy) {
  1039. ;
  1040. }
  1041. /**
  1042. * Sets the current clip to the rectangle specified by the given
  1043. * coordinates. This method sets the user clip, which is
  1044. * independent of the clipping associated with device bounds
  1045. * and window visibility.
  1046. * Rendering operations have no effect outside of the clipping area.
  1047. * @param x the <i>x</i> coordinate of the new clip rectangle.
  1048. * @param y the <i>y</i> coordinate of the new clip rectangle.
  1049. * @param width the width of the new clip rectangle.
  1050. * @param height the height of the new clip rectangle.
  1051. * @see and.awt.Graphics#clipRect
  1052. * @see and.awt.Graphics#setClip(Shape)
  1053. * @since JDK1.1
  1054. */
  1055. public void setClip(int x, int y, int width, int height){
  1056. setClip(new Rectangle(x, y, width, height));
  1057. }
  1058. /**
  1059. * Concatenates the current <code>Graphics2D</code>
  1060. * <code>Transform</code> with a rotation transform.
  1061. * Subsequent rendering is rotated by the specified radians relative
  1062. * to the previous origin.
  1063. * This is equivalent to calling <code>transform(R)</code>, where R is an
  1064. * <code>AffineTransform</code> represented by the following matrix:
  1065. * <pre>
  1066. * [ cos(theta) -sin(theta) 0 ]
  1067. * [ sin(theta) cos(theta) 0 ]
  1068. * [ 0 0 1 ]
  1069. * </pre>
  1070. * Rotating with a positive angle theta rotates points on the positive
  1071. * x axis toward the positive y axis.
  1072. * @param theta the angle of rotation in radians
  1073. */
  1074. public void rotate(double theta){
  1075. _transform.rotate(theta);
  1076. }
  1077. /**
  1078. * Concatenates the current <code>Graphics2D</code>
  1079. * <code>Transform</code> with a translated rotation
  1080. * transform. Subsequent rendering is transformed by a transform
  1081. * which is constructed by translating to the specified location,
  1082. * rotating by the specified radians, and translating back by the same
  1083. * amount as the original translation. This is equivalent to the
  1084. * following sequence of calls:
  1085. * <pre>
  1086. * translate(x, y);
  1087. * rotate(theta);
  1088. * translate(-x, -y);
  1089. * </pre>
  1090. * Rotating with a positive angle theta rotates points on the positive
  1091. * x axis toward the positive y axis.
  1092. * @param theta the angle of rotation in radians
  1093. * @param x x coordinate of the origin of the rotation
  1094. * @param y y coordinate of the origin of the rotation
  1095. */
  1096. public void rotate(double theta, double x, double y){
  1097. _transform.rotate(theta, x, y);
  1098. }
  1099. /**
  1100. * Concatenates the current <code>Graphics2D</code>
  1101. * <code>Transform</code> with a shearing transform.
  1102. * Subsequent renderings are sheared by the specified
  1103. * multiplier relative to the previous position.
  1104. * This is equivalent to calling <code>transform(SH)</code>, where SH
  1105. * is an <code>AffineTransform</code> represented by the following
  1106. * matrix:
  1107. * <pre>
  1108. * [ 1 shx 0 ]
  1109. * [ shy 1 0 ]
  1110. * [ 0 0 1 ]
  1111. * </pre>
  1112. * @param shx the multiplier by which coordinates are shifted in
  1113. * the positive X axis direction as a function of their Y coordinate
  1114. * @param shy the multiplier by which coordinates are shifted in
  1115. * the positive Y axis direction as a function of their X coordinate
  1116. */
  1117. public void shear(double shx, double shy){
  1118. _transform.shear(shx, shy);
  1119. }
  1120. /**
  1121. * Get the rendering context of the <code>Font</code> within this
  1122. * <code>Graphics2D</code> context.
  1123. * The {@link FontRenderContext}
  1124. * encapsulates application hints such as anti-aliasing and
  1125. * fractional metrics, as well as target device specific information
  1126. * such as dots-per-inch. This information should be provided by the
  1127. * application when using objects that perform typographical
  1128. * formatting, such as <code>Font</code> and
  1129. * <code>TextLayout</code>. This information should also be provided
  1130. * by applications that perform their own layout and need accurate
  1131. * measurements of various characteristics of glyphs such as advance
  1132. * and line height when various rendering hints have been applied to
  1133. * the text rendering.
  1134. *
  1135. * @return a reference to an instance of FontRenderContext.
  1136. * @see and.awt.font.FontRenderContext
  1137. * @see and.awt.Font#createGlyphVector(FontRenderContext,char[])
  1138. * @see and.awt.font.TextLayout
  1139. * @since JDK1.2
  1140. */
  1141. public FontRenderContext getFontRenderContext() {
  1142. boolean isAntiAliased = RenderingHints.VALUE_TEXT_ANTIALIAS_ON.equals(
  1143. getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING));
  1144. boolean usesFractionalMetrics = RenderingHints.VALUE_FRACTIONALMETRICS_ON.equals(
  1145. getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS));
  1146. return new FontRenderContext(new AffineTransform(), isAntiAliased, usesFractionalMetrics);
  1147. }
  1148. /**
  1149. * Composes an <code>AffineTransform</code> object with the
  1150. * <code>Transform</code> in this <code>Graphics2D</code> according
  1151. * to the rule last-specified-first-applied. If the current
  1152. * <code>Transform</code> is Cx, the result of composition
  1153. * with Tx is a new <code>Transform</code> Cx'. Cx' becomes the
  1154. * current <code>Transform</code> for this <code>Graphics2D</code>.
  1155. * Transforming a point p by the updated <code>Transform</code> Cx' is
  1156. * equivalent to first transforming p by Tx and then transforming
  1157. * the result by the original <code>Transform</code> Cx. In other
  1158. * words, Cx'(p) = Cx(Tx(p)). A copy of the Tx is made, if necessary,
  1159. * so further modifications to Tx do not affect rendering.
  1160. * @param Tx the <code>AffineTransform</code> object to be composed with
  1161. * the current <code>Transform</code>
  1162. * @see #setTransform
  1163. * @see AffineTransform
  1164. */
  1165. public void transform(AffineTransform Tx) {
  1166. _transform.concatenate(Tx);
  1167. }
  1168. /**
  1169. * Renders a <code>BufferedImage</code> that is
  1170. * filtered with a
  1171. * {@link BufferedImageOp}.
  1172. * The rendering attributes applied include the <code>Clip</code>,
  1173. * <code>Transform</code>
  1174. * and <code>Composite</code> attributes. This is equivalent to:
  1175. * <pre>
  1176. * img1 = op.filter(img, null);
  1177. * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
  1178. * </pre>
  1179. * @param img the <code>BufferedImage</code> to be rendered
  1180. * @param op the filter to be applied to the image before rendering
  1181. * @param x the x coordinate in user space where the image is rendered
  1182. * @param y the y coordinate in user space where the image is rendered
  1183. * @see #_transform
  1184. * @see #setTransform
  1185. * @see #setComposite
  1186. * @see #clip
  1187. * @see #setClip(Shape)
  1188. */
  1189. public void drawImage(BufferedImage img,
  1190. BufferedImageOp op,
  1191. int x,
  1192. int y){
  1193. img = op.filter(img, null);
  1194. drawImage(img, x, y, null);
  1195. }
  1196. /**
  1197. * Sets the background color for the <code>Graphics2D</code> context.
  1198. * The background color is used for clearing a region.
  1199. * When a <code>Graphics2D</code> is constructed for a
  1200. * <code>Component</code>, the background color is
  1201. * inherited from the <code>Component</code>. Setting the background color
  1202. * in the <code>Graphics2D</code> context only affects the subsequent
  1203. * <code>clearRect</code> calls and not the background color of the
  1204. * <code>Component</code>. To change the background
  1205. * of the <code>Component</code>, use appropriate methods of
  1206. * the <code>Component</code>.
  1207. * @param color the background color that isused in
  1208. * subsequent calls to <code>clearRect</code>
  1209. * @see #getBackground
  1210. * @see and.awt.Graphics#clearRect
  1211. */
  1212. public void setBackground(Color color) {
  1213. if(color == null)
  1214. return;
  1215. _background = color;
  1216. }
  1217. /**
  1218. * Returns the background color used for clearing a region.
  1219. * @return the current <code>Graphics2D</code> <code>Color</code>,
  1220. * which defines the background color.
  1221. * @see #setBackground
  1222. */
  1223. public Color getBackground(){
  1224. return _background;
  1225. }
  1226. /**
  1227. * Sets the <code>Composite</code> for the <code>Graphics2D</code> context.
  1228. * The <code>Composite</code> is used in all drawing methods such as
  1229. * <code>drawImage</code>, <code>drawString</code>, <code>draw</code>,
  1230. * and <code>fill</code>. It specifies how new pixels are to be combined
  1231. * with the existing pixels on the graphics device during the rendering
  1232. * process.
  1233. * <p>If this <code>Graphics2D</code> context is drawing to a
  1234. * <code>Component</code> on the display screen and the
  1235. * <code>Composite</code> is a custom object rather than an
  1236. * instance of the <code>AlphaComposite</code> class, and if
  1237. * there is a security manager, its <code>checkPermission</code>
  1238. * method is called with an <code>AWTPermission("readDisplayPixels")</code>
  1239. * permission.
  1240. *
  1241. * @param comp the <code>Composite</code> object to be used for rendering
  1242. * @throws SecurityException
  1243. * if a custom <code>Composite</code> object is being
  1244. * used to render to the screen and a security manager
  1245. * is set and its <code>checkPermission</code> method
  1246. * does not allow the operation.
  1247. * @see and.awt.Graphics#setXORMode
  1248. * @see and.awt.Graphics#setPaintMode
  1249. * @see and.awt.AlphaComposite
  1250. */
  1251. public void setComposite(Composite comp){
  1252. log.log(POILogger.WARN, "Not implemented");
  1253. }
  1254. /**
  1255. * Returns the current <code>Composite</code> in the
  1256. * <code>Graphics2D</code> context.
  1257. * @return the current <code>Graphics2D</code> <code>Composite</code>,
  1258. * which defines a compositing style.
  1259. * @see #setComposite
  1260. */
  1261. public Composite getComposite(){
  1262. log.log(POILogger.WARN, "Not implemented");
  1263. return null;
  1264. }
  1265. /**
  1266. * Returns the value of a single preference for the rendering algorithms.
  1267. * Hint categories include controls for rendering quality and overall
  1268. * time/quality trade-off in the rendering process. Refer to the
  1269. * <code>RenderingHints</code> class for definitions of some common
  1270. * keys and values.
  1271. * @param hintKey the key corresponding to the hint to get.
  1272. * @return an object representing the value for the specified hint key.
  1273. * Some of the keys and their associated values are defined in the
  1274. * <code>RenderingHints</code> class.
  1275. * @see RenderingHints
  1276. */
  1277. public Object getRenderingHint(RenderingHints.Key hintKey){
  1278. return _hints.get(hintKey);
  1279. }
  1280. /**
  1281. * Sets the value of a single preference for the rendering algorithms.
  1282. * Hint categories include controls for rendering quality and overall
  1283. * time/quality trade-off in the rendering process. Refer to the
  1284. * <code>RenderingHints</code> class for definitions of some common
  1285. * keys and values.
  1286. * @param hintKey the key of the hint to be set.
  1287. * @param hintValue the value indicating preferences for the specified
  1288. * hint category.
  1289. * @see RenderingHints
  1290. */
  1291. public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue){
  1292. _hints.put(hintKey, hintValue);
  1293. }
  1294. /**
  1295. * Renders the text of the specified
  1296. * {@link GlyphVector} using
  1297. * the <code>Graphics2D</code> context's rendering attributes.
  1298. * The rendering attributes applied include the <code>Clip</code>,
  1299. * <code>Transform</code>, <code>Paint</code>, and
  1300. * <code>Composite</code> attributes. The <code>GlyphVector</code>
  1301. * specifies individual glyphs from a {@link Font}.
  1302. * The <code>GlyphVector</code> can also contain the glyph positions.
  1303. * This is the fastest way to render a set of characters to the
  1304. * screen.
  1305. *
  1306. * @param g the <code>GlyphVector</code> to be rendered
  1307. * @param x the x position in user space where the glyphs should be
  1308. * rendered
  1309. * @param y the y position in user space where the glyphs should be
  1310. * rendered
  1311. *
  1312. * @see and.awt.Font#createGlyphVector(FontRenderContext, char[])
  1313. * @see and.awt.font.GlyphVector
  1314. * @see #setPaint
  1315. * @see and.awt.Graphics#setColor
  1316. * @see #setTransform
  1317. * @see #setComposite
  1318. * @see #setClip(Shape)
  1319. */
  1320. public void drawGlyphVector(GlyphVector g, float x, float y) {
  1321. Shape glyphOutline = g.getOutline(x, y);
  1322. fill(glyphOutline);
  1323. }
  1324. /**
  1325. * Returns the device configuration associated with this
  1326. * <code>Graphics2D</code>.
  1327. * @return the device configuration
  1328. */
  1329. public GraphicsConfiguration getDeviceConfiguration() {
  1330. return GraphicsEnvironment.getLocalGraphicsEnvironment().
  1331. getDefaultScreenDevice().getDefaultConfiguration();
  1332. }
  1333. /**
  1334. * Sets the values of an arbitrary number of preferences for the
  1335. * rendering algorithms.
  1336. * Only values for the rendering hints that are present in the
  1337. * specified <code>Map</code> object are modified.
  1338. * All other preferences not present in the specified
  1339. * object are left unmodified.
  1340. * Hint categories include controls for rendering quality and
  1341. * overall time/quality trade-off in the rendering process.
  1342. * Refer to the <code>RenderingHints</code> class for definitions of
  1343. * some common keys and values.
  1344. * @param hints the rendering hints to be set
  1345. * @see RenderingHints
  1346. */
  1347. public void addRenderingHints(Map hints){
  1348. this._hints.putAll(hints);
  1349. }
  1350. /**
  1351. * Concatenates the current
  1352. * <code>Graphics2D</code> <code>Transform</code>
  1353. * with a translation transform.
  1354. * Subsequent rendering is translated by the specified
  1355. * distance relative to the previous position.
  1356. * This is equivalent to calling transform(T), where T is an
  1357. * <code>AffineTransform</code> represented by the following matrix:
  1358. * <pre>
  1359. * [ 1 0 tx ]
  1360. * [ 0 1 ty ]
  1361. * [ 0 0 1 ]
  1362. * </pre>
  1363. * @param tx the distance to translate along the x-axis
  1364. * @param ty the distance to translate along the y-axis
  1365. */
  1366. public void translate(double tx, double ty){
  1367. _transform.translate(tx, ty);
  1368. }
  1369. /**
  1370. * Renders the text of the specified iterator, using the
  1371. * <code>Graphics2D</code> context's current <code>Paint</code>. The
  1372. * iterator must specify a font
  1373. * for each character. The baseline of the
  1374. * first character is at position (<i>x</i>,&nbsp;<i>y</i>) in the
  1375. * User Space.
  1376. * The rendering attributes applied include the <code>Clip</code>,
  1377. * <code>Transform</code>, <code>Paint</code>, and
  1378. * <code>Composite</code> attributes.
  1379. * For characters in script systems such as Hebrew and Arabic,
  1380. * the glyphs can be rendered from right to left, in which case the
  1381. * coordinate supplied is the location of the leftmost character
  1382. * on the baseline.
  1383. * @param iterator the iterator whose text is to be rendered
  1384. * @param x the x coordinate where the iterator's text is to be
  1385. * rendered
  1386. * @param y the y coordinate where the iterator's text is to be
  1387. * rendered
  1388. * @see #setPaint
  1389. * @see and.awt.Graphics#setColor
  1390. * @see #setTransform
  1391. * @see #setComposite
  1392. * @see #setClip
  1393. */
  1394. public void drawString(AttributedCharacterIterator iterator, float x, float y) {
  1395. log.log(POILogger.WARN, "Not implemented");
  1396. }
  1397. /**
  1398. * Checks whether or not the specified <code>Shape</code> intersects
  1399. * the specified {@link Rectangle}, which is in device
  1400. * space. If <code>onStroke</code> is false, this method checks
  1401. * whether or not the interior of the specified <code>Shape</code>
  1402. * intersects the specified <code>Rectangle</code>. If
  1403. * <code>onStroke</code> is <code>true</code>, this method checks
  1404. * whether or not the <code>Stroke</code> of the specified
  1405. * <code>Shape</code> outline intersects the specified
  1406. * <code>Rectangle</code>.
  1407. * The rendering attributes taken into account include the
  1408. * <code>Clip</code>, <code>Transform</code>, and <code>Stroke</code>
  1409. * attributes.
  1410. * @param rect the area in device space to check for a hit
  1411. * @param s the <code>Shape</code> to check for a hit
  1412. * @param onStroke flag used to choose between testing the
  1413. * stroked or the filled shape. If the flag is <code>true</code>, the
  1414. * <code>Stroke</code> oultine is tested. If the flag is
  1415. * <code>false</code>, the filled <code>Shape</code> is tested.
  1416. * @return <code>true</code> if there is a hit; <code>false</code>
  1417. * otherwise.
  1418. * @see #setStroke
  1419. * @see #fill(Shape)
  1420. * @see #draw(Shape)
  1421. * @see #_transform
  1422. * @see #setTransform
  1423. * @see #clip
  1424. * @see #setClip(Shape)
  1425. */
  1426. public boolean hit(Rectangle rect,
  1427. Shape s,
  1428. boolean onStroke){
  1429. if (onStroke) {
  1430. s = getStroke().createStrokedShape(s);
  1431. }
  1432. s = getTransform().createTransformedShape(s);
  1433. return s.intersects(rect);
  1434. }
  1435. /**
  1436. * Gets the preferences for the rendering algorithms. Hint categories
  1437. * include controls for rendering quality and overall time/quality
  1438. * trade-off in the rendering process.
  1439. * Returns all of the hint key/value pairs that were ever specified in
  1440. * one operation. Refer to the
  1441. * <code>RenderingHints</code> class for definitions of some common
  1442. * keys and values.
  1443. * @return a reference to an instance of <code>RenderingHints</code>
  1444. * that contains the current preferences.
  1445. * @see RenderingHints
  1446. */
  1447. public RenderingHints getRenderingHints(){
  1448. return _hints;
  1449. }
  1450. /**
  1451. * Replaces the values of all preferences for the rendering
  1452. * algorithms with the specified <code>hints</code>.
  1453. * The existing values for all rendering hints are discarded and
  1454. * the new set of known hints and values are initialized from the
  1455. * specified {@link Map} object.
  1456. * Hint categories include controls for rendering quality and
  1457. * overall time/quality trade-off in the rendering process.
  1458. * Refer to the <code>RenderingHints</code> class for definitions of
  1459. * some common keys and values.
  1460. * @param hints the rendering hints to be set
  1461. * @see RenderingHints
  1462. */
  1463. public void setRenderingHints(Map hints){
  1464. this._hints = new RenderingHints(hints);
  1465. }
  1466. /**
  1467. * Renders an image, applying a transform from image space into user space
  1468. * before drawing.
  1469. * The transformation from user space into device space is done with
  1470. * the current <code>Transform</code> in the <code>Graphics2D</code>.
  1471. * The specified transformation is applied to the image before the
  1472. * transform attribute in the <code>Graphics2D</code> context is applied.
  1473. * The rendering attributes applied include the <code>Clip</code>,
  1474. * <code>Transform</code>, and <code>Composite</code> attributes.
  1475. * Note that no rendering is done if the specified transform is
  1476. * noninvertible.
  1477. * @param img the <code>Image</code> to be rendered
  1478. * @param xform the transformation from image space into user space
  1479. * @param obs the {@link ImageObserver}
  1480. * to be notified as more of the <code>Image</code>
  1481. * is converted
  1482. * @return <code>true</code> if the <code>Image</code> is
  1483. * fully loaded and completely rendered;
  1484. * <code>false</code> if the <code>Image</code> is still being loaded.
  1485. * @see #_transform
  1486. * @see #setTransform
  1487. * @see #setComposite
  1488. * @see #clip
  1489. * @see #setClip(Shape)
  1490. */
  1491. public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
  1492. log.log(POILogger.WARN, "Not implemented");
  1493. return false;
  1494. }
  1495. /**
  1496. * Draws as much of the specified image as has already been scaled
  1497. * to fit inside the specified rectangle.
  1498. * <p>
  1499. * The image is drawn inside the specified rectangle of this
  1500. * graphics context's coordinate space, and is scaled if
  1501. * necessary. Transparent pixels do not affect whatever pixels
  1502. * are already there.
  1503. * <p>
  1504. * This method returns immediately in all cases, even if the
  1505. * entire image has not yet been scaled, dithered, and converted
  1506. * for the current output device.
  1507. * If the current output representation is not yet complete, then
  1508. * <code>drawImage</code> returns <code>false</code>. As more of
  1509. * the image becomes available, the process that loads the image notifies
  1510. * the image observer by calling its <code>imageUpdate</code> method.
  1511. * <p>
  1512. * A scaled version of an image will not necessarily be
  1513. * available immediately just because an unscaled version of the
  1514. * image has been constructed for this output device. Each size of
  1515. * the image may be cached separately and generated from the original
  1516. * data in a separate image production sequence.
  1517. * @param img the specified image to be drawn. This method does
  1518. * nothing if <code>img</code> is null.
  1519. * @param x the <i>x</i> coordinate.
  1520. * @param y the <i>y</i> coordinate.
  1521. * @param width the width of the rectangle.
  1522. * @param height the height of the rectangle.
  1523. * @param observer object to be notified as more of
  1524. * the image is converted.
  1525. * @return <code>false</code> if the image pixels are still changing;
  1526. * <code>true</code> otherwise.
  1527. * @see and.awt.Image
  1528. * @see and.awt.image.ImageObserver
  1529. * @see and.awt.image.ImageObserver#imageUpdate(and.awt.Image, int, int, int, int, int)
  1530. */
  1531. public boolean drawImage(Image img, int x, int y,
  1532. int width, int height,
  1533. ImageObserver observer) {
  1534. log.log(POILogger.WARN, "Not implemented");
  1535. return false;
  1536. }
  1537. /**
  1538. * Creates a new <code>Graphics</code> object that is
  1539. * a copy of this <code>Graphics</code> object.
  1540. * @return a new graphics context that is a copy of
  1541. * this graphics context.
  1542. */
  1543. public Graphics create() {
  1544. try {
  1545. return (Graphics)clone();
  1546. } catch (CloneNotSupportedException e){
  1547. throw new HSLFException(e);
  1548. }
  1549. }
  1550. /**
  1551. * Gets the font metrics for the specified font.
  1552. * @return the font metrics for the specified font.
  1553. * @param f the specified font
  1554. * @see and.awt.Graphics#getFont
  1555. * @see and.awt.FontMetrics
  1556. * @see and.awt.Graphics#getFontMetrics()
  1557. */
  1558. @SuppressWarnings("deprecation")
  1559. public FontMetrics getFontMetrics(Font f) {
  1560. return Toolkit.getDefaultToolkit().getFontMetrics(f);
  1561. }
  1562. /**
  1563. * Sets the paint mode of this graphics context to alternate between
  1564. * this graphics context's current color and the new specified color.
  1565. * This specifies that logical pixel operations are performed in the
  1566. * XOR mode, which alternates pixels between the current color and
  1567. * a specified XOR color.
  1568. * <p>
  1569. * When drawing operations are performed, pixels which are the
  1570. * current color are changed to the specified color, and vice versa.
  1571. * <p>
  1572. * Pixels that are of colors other than those two colors are changed
  1573. * in an unpredictable but reversible manner; if the same figure is
  1574. * drawn twice, then all pixels are restored to their original values.
  1575. * @param c1 the XOR alternation color
  1576. */
  1577. public void setXORMode(Color c1) {
  1578. log.log(POILogger.WARN, "Not implemented");
  1579. }
  1580. /**
  1581. * Sets the paint mode of this graphics context to overwrite the
  1582. * destination with this graphics context's current color.
  1583. * This sets the logical pixel operation function to the paint or
  1584. * overwrite mode. All subsequent rendering operations will
  1585. * overwrite the destination with the current color.
  1586. */
  1587. public void setPaintMode() {
  1588. log.log(POILogger.WARN, "Not implemented");
  1589. }
  1590. /**
  1591. * Renders a
  1592. * {@link RenderableImage},
  1593. * applying a transform from image space into user space before drawing.
  1594. * The transformation from user space into device space is done with
  1595. * the current <code>Transform</code> in the <code>Graphics2D</code>.
  1596. * The specified transformation is applied to the image before the
  1597. * transform attribute in the <code>Graphics2D</code> context is applied.
  1598. * The rendering attributes applied include the <code>Clip</code>,
  1599. * <code>Transform</code>, and <code>Composite</code> attributes. Note
  1600. * that no rendering is done if the specified transform is
  1601. * noninvertible.
  1602. *<p>
  1603. * Rendering hints set on the <code>Graphics2D</code> object might
  1604. * be used in rendering the <code>RenderableImage</code>.
  1605. * If explicit control is required over specific hints recognized by a
  1606. * specific <code>RenderableImage</code>, or if knowledge of which hints
  1607. * are used is required, then a <code>RenderedImage</code> should be
  1608. * obtained directly from the <code>RenderableImage</code>
  1609. * and rendered using
  1610. *{@link #drawRenderedImage(RenderedImage, AffineTransform) drawRenderedImage}.
  1611. * @param img the image to be rendered. This method does
  1612. * nothing if <code>img</code> is null.
  1613. * @param xform the transformation from image space into user space
  1614. * @see #_transform
  1615. * @see #setTransform
  1616. * @see #setComposite
  1617. * @see #clip
  1618. * @see #setClip
  1619. * @see #drawRenderedImage
  1620. */
  1621. public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
  1622. log.log(POILogger.WARN, "Not implemented");
  1623. }
  1624. /**
  1625. * Renders a {@link RenderedImage},
  1626. * applying a transform from image
  1627. * space into user space before drawing.
  1628. * The transformation from user space into device space is done with
  1629. * the current <code>Transform</code> in the <code>Graphics2D</code>.
  1630. * The specified transformation is applied to the image before the
  1631. * transform attribute in the <code>Graphics2D</code> context is applied.
  1632. * The rendering attributes applied include the <code>Clip</code>,
  1633. * <code>Transform</code>, and <code>Composite</code> attributes. Note
  1634. * that no rendering is done if the specified transform is
  1635. * noninvertible.
  1636. * @param img the image to be rendered. This method does
  1637. * nothing if <code>img</code> is null.
  1638. * @param xform the transformation from image space into user space
  1639. * @see #_transform
  1640. * @see #setTransform
  1641. * @see #setComposite
  1642. * @see #clip
  1643. * @see #setClip
  1644. */
  1645. public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
  1646. log.log(POILogger.WARN, "Not implemented");
  1647. }
  1648. protected void applyStroke(SimpleShape shape) {
  1649. if (_stroke instanceof BasicStroke){
  1650. BasicStroke bs = (BasicStroke)_stroke;
  1651. shape.setLineWidth(bs.getLineWidth());
  1652. float[] dash = bs.getDashArray();
  1653. if (dash != null) {
  1654. //TODO: implement more dashing styles
  1655. shape.setLineDashing(Line.PEN_DASH);
  1656. }
  1657. }
  1658. }
  1659. protected void applyPaint(SimpleShape shape) {
  1660. if (_paint instanceof Color) {
  1661. shape.getFill().setForegroundColor((Color)_paint);
  1662. }
  1663. }
  1664. }