Return-Path: Delivered-To: apmail-xmlgraphics-commits-archive@www.apache.org Received: (qmail 47936 invoked from network); 15 Sep 2006 15:29:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Sep 2006 15:29:29 -0000 Received: (qmail 92716 invoked by uid 500); 15 Sep 2006 15:29:18 -0000 Mailing-List: contact commits-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@xmlgraphics.apache.org Delivered-To: mailing list commits@xmlgraphics.apache.org Received: (qmail 92608 invoked by uid 99); 15 Sep 2006 15:29:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Sep 2006 08:29:17 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Sep 2006 08:29:13 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id D5EA01A981A; Fri, 15 Sep 2006 08:28:11 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r446632 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java status.xml Date: Fri, 15 Sep 2006 15:28:11 -0000 To: commits@xmlgraphics.apache.org From: jeremias@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060915152811.D5EA01A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jeremias Date: Fri Sep 15 08:28:11 2006 New Revision: 446632 URL: http://svn.apache.org/viewvc?view=rev&rev=446632 Log: Default implementation for AbstractGraphics2D.drawText(ACI, float, float) so PSGraphics2D supports painting text using the AttributedCharacterIterator. Submitted by: Max Berger Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java xmlgraphics/commons/trunk/status.xml Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java?view=diff&rev=446632&r1=446631&r2=446632 ============================================================================== --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java (original) +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/AbstractGraphics2D.java Fri Sep 15 08:28:11 2006 @@ -1,21 +1,22 @@ /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +/* $Id$ */ - */ package org.apache.xmlgraphics.java2d; import java.awt.AlphaComposite; @@ -32,6 +33,7 @@ import java.awt.Stroke; import java.awt.font.FontRenderContext; import java.awt.font.GlyphVector; +import java.awt.font.TextLayout; import java.awt.geom.AffineTransform; import java.awt.geom.Arc2D; import java.awt.geom.Ellipse2D; @@ -78,6 +80,11 @@ protected boolean textAsShapes = false; /** + * Protection agains infinite recursion + */ + protected boolean inPossibleRecursion = false; + + /** * @param textAsShapes if true, all text is turned into shapes in the * convertion. No text is output. * @@ -608,6 +615,25 @@ drawString(str, (float)x, (float)y); } + /** + * Generic implementation for drawing attributed strings using TextLayout. + * + * @param iterator the iterator whose text is to be rendered + * @param x the x coordinate where the iterator's text is to be rendered + * @param y the y coordinate where the iterator's text is to be rendered + * @see java.awt.Graphics2D#drawString (java.text.AttributedCharacterIterator, + * float, float) + */ + public void drawString(AttributedCharacterIterator iterator, float x, float y) { + if (inPossibleRecursion) { + System.err.println("Called itself: drawString(AttributedCharacterIterator)"); + } else { + inPossibleRecursion = true; + TextLayout layout = new TextLayout(iterator, getFontRenderContext()); + layout.draw(this, x, y); + inPossibleRecursion = false; + } + } /** * Draws the text given by the specified iterator, using this Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java?view=diff&rev=446632&r1=446631&r2=446632 ============================================================================== --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java (original) +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java Fri Sep 15 08:28:11 2006 @@ -20,7 +20,6 @@ package org.apache.xmlgraphics.java2d.ps; //Java -import java.text.AttributedCharacterIterator; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; @@ -675,66 +674,6 @@ } catch (IOException ioe) { handleIOException(ioe); } - } - - /** - * Renders the text of the specified iterator, using the - * Graphics2D context's current Paint. The - * iterator must specify a font - * for each character. The baseline of the - * first character is at position (xy) in the - * User Space. - * The rendering attributes applied include the Clip, - * Transform, Paint, and - * Composite attributes. - * For characters in script systems such as Hebrew and Arabic, - * the glyphs can be rendered from right to left, in which case the - * coordinate supplied is the location of the leftmost character - * on the baseline. - * @param iterator the iterator whose text is to be rendered - * @param x the x-coordinate where the iterator's text is to be - * rendered - * @param y the y-coordinate where the iterator's text is to be - * rendered - * @see #setPaint - * @see java.awt.Graphics#setColor - * @see #setTransform - * @see #setComposite - * @see #setClip - */ - public void drawString(AttributedCharacterIterator iterator, float x, - float y) { - preparePainting(); - System.err.println("NYI: drawString(AttributedCharacterIterator)"); - /* - try { - gen.writeln("BT"); - Shape imclip = getClip(); - writeClip(imclip); - establishColor(getColor()); - - AffineTransform trans = getTransform(); - trans.translate(x, y); - double[] vals = new double[6]; - trans.getMatrix(vals); - - for (char ch = iterator.first(); ch != CharacterIterator.DONE; - ch = iterator.next()) { - //Map attr = iterator.getAttributes(); - - gen.writeln(gen.formatDouble(vals[0]) + " " - + gen.formatDouble(vals[1]) + " " - + gen.formatDouble(vals[2]) + " " - + gen.formatDouble(vals[3]) + " " - + gen.formatDouble(vals[4]) + " " - + gen.formatDouble(vals[5]) + " " - + gen.formatDouble(vals[6]) + " Tm [" + ch - + "]"); - } - gen.writeln("ET"); - } catch (IOException ioe) { - handleIOException(ioe); - }*/ } /** Modified: xmlgraphics/commons/trunk/status.xml URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?view=diff&rev=446632&r1=446631&r2=446632 ============================================================================== --- xmlgraphics/commons/trunk/status.xml (original) +++ xmlgraphics/commons/trunk/status.xml Fri Sep 15 08:28:11 2006 @@ -28,6 +28,10 @@ + + Default implementation for AbstractGraphics2D.drawText(ACI, float, float) so + PSGraphics2D supports painting text using the AttributedCharacterIterator. + Bugfix: The generation of the PostScript setdash command was assuming that only integer values can be used but that isn't the case. --------------------------------------------------------------------- Apache XML Graphics Project URL: http://xmlgraphics.apache.org/ To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org For additional commands, e-mail: commits-help@xmlgraphics.apache.org