tkormann 01/09/13 06:10:55
Modified: sources/org/apache/batik/bridge BridgeEventSupport.java
SVGAltGlyphElementBridge.java
SVGFontElementBridge.java SVGFontUtilities.java
sources/org/apache/batik/gvt GraphicsNode.java
ImageNode.java RasterImageNode.java
RootGraphicsNode.java TextNode.java
Log:
Fix on bug in SVG font support. Use getElementsByTagNameNS instead of
getElementsByTagName.
Clean some javadoc on GVT
Revision Changes Path
1.14 +3 -2
xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java
Index: BridgeEventSupport.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeEventSupport.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- BridgeEventSupport.java 2001/09/05 13:08:36 1.13
+++ BridgeEventSupport.java 2001/09/13 13:10:54 1.14
@@ -53,7 +53,7 @@
* on the GVT root to propagate GVT events to the DOM.
* @author <a href="mailto:[EMAIL PROTECTED]>Christophe Jolif</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: BridgeEventSupport.java,v 1.13 2001/09/05 13:08:36 cjolif Exp $
+ * @version $Id: BridgeEventSupport.java,v 1.14 2001/09/13 13:10:54 tkormann Exp $
*/
class BridgeEventSupport implements SVGConstants {
private static final String[] EVENT_ATTRIBUTES_GRAPHICS = {
@@ -319,7 +319,8 @@
}
public static void loadScripts(BridgeContext ctx, Document doc) {
- NodeList list = doc.getElementsByTagName(SVG_SCRIPT_TAG);
+ NodeList list = doc.getElementsByTagNameNS(SVG_NAMESPACE_URI,
+ SVG_SCRIPT_TAG);
final UserAgent ua = ctx.getUserAgent();
String language = null;
Element selement = null;
1.5 +13 -7
xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java
Index: SVGAltGlyphElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGAltGlyphElementBridge.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SVGAltGlyphElementBridge.java 2001/08/02 07:49:35 1.4
+++ SVGAltGlyphElementBridge.java 2001/09/13 13:10:54 1.5
@@ -27,7 +27,7 @@
* Bridge class for the <altGlyph> element.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a>
- * @version $Id: SVGAltGlyphElementBridge.java,v 1.4 2001/08/02 07:49:35 bella Exp $
+ * @version $Id: SVGAltGlyphElementBridge.java,v 1.5 2001/09/13 13:10:54 tkormann
Exp $
*/
public class SVGAltGlyphElementBridge extends AbstractSVGBridge
implements ErrorConstants {
@@ -123,7 +123,8 @@
if (containsGlyphRefNodes) { // process the glyphRef children
NodeList glyphRefNodes
- = localRefElement.getElementsByTagName(SVG_GLYPH_REF_TAG);
+ = localRefElement.getElementsByTagNameNS(SVG_NAMESPACE_URI,
+ SVG_GLYPH_REF_TAG);
int numGlyphRefNodes = glyphRefNodes.getLength();
Glyph[] glyphArray = new Glyph[numGlyphRefNodes];
for (int i = 0; i < numGlyphRefNodes; i++) {
@@ -144,7 +145,8 @@
} else { // try looking for altGlyphItem children
NodeList altGlyphItemNodes
- = localRefElement.getElementsByTagName(SVG_ALT_GLYPH_ITEM_TAG);
+ = localRefElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_ALT_GLYPH_ITEM_TAG);
int numAltGlyphItemNodes = altGlyphItemNodes.getLength();
if (numAltGlyphItemNodes > 0) {
Glyph[] glyphArray = new Glyph[numAltGlyphItemNodes];
@@ -152,7 +154,8 @@
// try to find a resolvable glyphRef
Element altGlyphItemElement =
(Element)altGlyphItemNodes.item(i);
NodeList altGlyphRefNodes
- =
altGlyphItemElement.getElementsByTagName(SVG_GLYPH_REF_TAG);
+ = altGlyphItemElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_GLYPH_REF_TAG);
int numAltGlyphRefNodes = altGlyphRefNodes.getLength();
boolean foundMatchingGlyph = false;
for (int j = 0; j < numAltGlyphRefNodes; j++) {
@@ -231,7 +234,8 @@
localGlyphElement = refGlyphElement;
Element fontElement = (Element)localGlyphElement.getParentNode();
NodeList fontFaceElements
- = fontElement.getElementsByTagName(SVG_FONT_FACE_TAG);
+ = fontElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_FONT_FACE_TAG);
if (fontFaceElements.getLength() > 0) {
localFontFaceElement = (Element)fontFaceElements.item(0);
}
@@ -248,7 +252,8 @@
// get the local glyph element
String glyphId = refGlyphElement.getAttributeNS(null, SVG_ID_ATTRIBUTE);
- NodeList glyphElements =
localFontElement.getElementsByTagName(SVG_GLYPH_TAG);
+ NodeList glyphElements = localFontElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_GLYPH_TAG);
for (int i = 0; i < glyphElements.getLength(); i++) {
Element glyphElem = (Element)glyphElements.item(i);
if (glyphElem.getAttributeNS(null,
SVG_ID_ATTRIBUTE).equals(glyphId)) {
@@ -258,7 +263,8 @@
}
// get the local font-face element
NodeList fontFaceElements
- = localFontElement.getElementsByTagName(SVG_FONT_FACE_TAG);
+ = localFontElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_FONT_FACE_TAG);
if (fontFaceElements.getLength() > 0) {
localFontFaceElement = (Element)fontFaceElements.item(0);
}
1.5 +9 -5
xml-batik/sources/org/apache/batik/bridge/SVGFontElementBridge.java
Index: SVGFontElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFontElementBridge.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SVGFontElementBridge.java 2001/07/05 06:56:07 1.4
+++ SVGFontElementBridge.java 2001/09/13 13:10:54 1.5
@@ -17,7 +17,7 @@
* Bridge class for the <font> element.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a>
- * @version $Id: SVGFontElementBridge.java,v 1.4 2001/07/05 06:56:07 bella Exp $
+ * @version $Id: SVGFontElementBridge.java,v 1.5 2001/09/13 13:10:54 tkormann Exp $
*/
public class SVGFontElementBridge extends AbstractSVGBridge {
@@ -55,7 +55,8 @@
// construct a list of glyph codes that this font can display and
// a list of the glyph elements
- NodeList glyphElements = fontElement.getElementsByTagName(SVG_GLYPH_TAG);
+ NodeList glyphElements = fontElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_GLYPH_TAG);
int numGlyphs = glyphElements.getLength();
String[] glyphCodes = new String[numGlyphs];
String[] glyphNames = new String[numGlyphs];
@@ -81,14 +82,16 @@
}
// get the missing glyph element
- NodeList missingGlyphElements =
fontElement.getElementsByTagName(SVG_MISSING_GLYPH_TAG);
+ NodeList missingGlyphElements = fontElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_MISSING_GLYPH_TAG);
Element missingGlyphElement = null;
if (missingGlyphElements.getLength() > 0) {
missingGlyphElement = (Element)missingGlyphElements.item(0);
}
// get the hkern elements
- NodeList hkernElements = fontElement.getElementsByTagName(SVG_HKERN_TAG);
+ NodeList hkernElements = fontElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_HKERN_TAG);
Element[] hkernElementArray = new Element[hkernElements.getLength()];
for (int i = 0; i < hkernElementArray.length; i++) {
@@ -97,7 +100,8 @@
}
// get the vkern elements
- NodeList vkernElements = fontElement.getElementsByTagName(SVG_VKERN_TAG);
+ NodeList vkernElements = fontElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_VKERN_TAG);
Element[] vkernElementArray = new Element[vkernElements.getLength()];
for (int i = 0; i < vkernElementArray.length; i++) {
1.5 +8 -5 xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java
Index: SVGFontUtilities.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SVGFontUtilities.java 2001/07/05 06:56:08 1.4
+++ SVGFontUtilities.java 2001/09/13 13:10:54 1.5
@@ -27,7 +27,7 @@
* Utility class for SVG fonts.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Bella Robinson</a>
- * @version $Id: SVGFontUtilities.java,v 1.4 2001/07/05 06:56:08 bella Exp $
+ * @version $Id: SVGFontUtilities.java,v 1.5 2001/09/13 13:10:54 tkormann Exp $
*/
public abstract class SVGFontUtilities implements SVGConstants {
@@ -84,7 +84,8 @@
// try to find a matching SVGFontFace element
Document doc = textElement.getOwnerDocument();
- NodeList fontFaceElements = doc.getElementsByTagName(SVG_FONT_FACE_TAG);
+ NodeList fontFaceElements = doc.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_FONT_FACE_TAG);
Vector svgFontFamilies = new Vector();
@@ -108,11 +109,13 @@
fontElement = null;
- NodeList fontFaceSrcNodes =
fontFaceElement.getElementsByTagName(SVG_FONT_FACE_SRC_TAG);
+ NodeList fontFaceSrcNodes =
+ fontFaceElement.getElementsByTagNameNS
+ (SVG_NAMESPACE_URI, SVG_FONT_FACE_SRC_TAG);
if (fontFaceSrcNodes.getLength() > 0) {
Element fontFaceSrcElement =
(Element)fontFaceSrcNodes.item(0);
// see if there is a fontFaceUri child
- NodeList fontFaceUriNodes =
fontFaceSrcElement.getElementsByTagName(SVG_FONT_FACE_URI_TAG);
+ NodeList fontFaceUriNodes =
fontFaceSrcElement.getElementsByTagNameNS(SVG_NAMESPACE_URI, SVG_FONT_FACE_URI_TAG);
if (fontFaceUriNodes.getLength() > 0) {
Element fontFaceUriElement =
(Element)fontFaceUriNodes.item(0);
@@ -143,7 +146,7 @@
if (fontElement != null) {
// create a font face
- NodeList fontFaceChildren =
fontElement.getElementsByTagName(SVG_FONT_FACE_TAG);
+ NodeList fontFaceChildren =
fontElement.getElementsByTagNameNS(SVG_NAMESPACE_URI, SVG_FONT_FACE_TAG);
Element fontFaceChild = (Element)fontFaceChildren.item(0);
SVGFontFaceElementBridge fontFaceBridge
= (SVGFontFaceElementBridge)ctx.getBridge(fontFaceChild);
1.26 +1 -18 xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java
Index: GraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- GraphicsNode.java 2001/09/13 08:42:49 1.25
+++ GraphicsNode.java 2001/09/13 13:10:54 1.26
@@ -33,7 +33,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Emmanuel Tissandier</a>
- * @version $Id: GraphicsNode.java,v 1.25 2001/09/13 08:42:49 tkormann Exp $
+ * @version $Id: GraphicsNode.java,v 1.26 2001/09/13 13:10:54 tkormann Exp $
*/
public interface GraphicsNode {
@@ -167,8 +167,6 @@
* Paints this node.
*
* @param g2d the Graphics2D to use
- * @param rc the GraphicsNodeRenderContext to use was interrupted during
- * paint
*/
void paint(Graphics2D g2d, GraphicsNodeRenderContext rc);
@@ -176,7 +174,6 @@
* Paints this node without applying Filter, Mask, Composite, and clip.
*
* @param g2d the Graphics2D to use
- * @param rc the GraphicsNodeRenderContext to use
*/
void primitivePaint(Graphics2D g2d, GraphicsNodeRenderContext rc);
@@ -278,8 +275,6 @@
/**
* Returns the bounds of this node in user space. This includes primitive
* paint, filtering, clipping and masking.
- *
- * @param rc the GraphicsNodeRenderContext for which this dimension applies
*/
Rectangle2D getBounds(GraphicsNodeRenderContext rc);
@@ -289,15 +284,12 @@
*
* @param txf the affine transform with which this node's transform should
* be concatenated. Should not be null.
- * @param rc the GraphicsNodeRenderContext
*/
Rectangle2D getTransformedBounds(AffineTransform txf,
GraphicsNodeRenderContext rc);
/**
* Returns the bounds of the area covered by this node's primitive paint.
- *
- * @param rc the GraphicsNodeRenderContext for which this dimension applies
*/
Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc);
@@ -307,7 +299,6 @@
*
* @param txf the affine transform with which this node's transform should
* be concatenated. Should not be null.
- * @param rc the GraphicsNodeRenderContext
*/
Rectangle2D getTransformedPrimitiveBounds(AffineTransform txf,
GraphicsNodeRenderContext rc);
@@ -316,8 +307,6 @@
* Returns the bounds of the area covered by this node, without taking any
* of its rendering attribute into account. i.e., exclusive of any clipping,
* masking, filtering or stroking, for example.
- *
- * @param rc the GraphicsNodeRenderContext for which this dimension applies
*/
Rectangle2D getGeometryBounds(GraphicsNodeRenderContext rc);
@@ -330,7 +319,6 @@
*
* @param txf the affine transform with which this node's transform should
* be concatenated. Should not be null.
- * @param rc the GraphicsNodeRenderContext
*/
Rectangle2D getTransformedGeometryBounds(AffineTransform txf,
GraphicsNodeRenderContext rc);
@@ -340,7 +328,6 @@
* node, false otherwise.
*
* @param p the specified Point2D in the user space
- * @param rc the GraphicsNodeRenderContext for which this dimension applies
*/
boolean contains(Point2D p, GraphicsNodeRenderContext rc);
@@ -349,7 +336,6 @@
* specified Rectangle2D, false otherwise.
*
* @param r the specified Rectangle2D in the user node space
- * @param rc the GraphicsNodeRenderContext for which this dimension applies
*/
boolean intersects(Rectangle2D r, GraphicsNodeRenderContext rc);
@@ -358,14 +344,11 @@
* children is sensitive to mouse events at p.
*
* @param p the specified Point2D in the user space
- * @param rc the GraphicsNodeRenderContext for which this dimension applies
*/
GraphicsNode nodeHitAt(Point2D p, GraphicsNodeRenderContext rc);
/**
* Returns the outline of this node.
- *
- * @param rc the GraphicsNodeRenderContext for which this dimension applies
*/
Shape getOutline(GraphicsNodeRenderContext rc);
}
1.7 +10 -3 xml-batik/sources/org/apache/batik/gvt/ImageNode.java
Index: ImageNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ImageNode.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ImageNode.java 2001/03/21 15:03:23 1.6
+++ ImageNode.java 2001/09/13 13:10:55 1.7
@@ -18,7 +18,7 @@
* A graphics node that represents an image described as a graphics node.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: ImageNode.java,v 1.6 2001/03/21 15:03:23 cjolif Exp $
+ * @version $Id: ImageNode.java,v 1.7 2001/09/13 13:10:55 tkormann Exp $
*/
public class ImageNode extends CompositeGraphicsNode {
@@ -28,10 +28,9 @@
public ImageNode() {}
/**
- * Paints this node if visible.
+ * Paints this node.
*
* @param g2d the Graphics2D to use
- * @param rc the GraphicsNodeRenderContext to use
*/
public void paint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
if (isVisible) {
@@ -43,10 +42,18 @@
// Properties methods
//
+ /**
+ * Sets the graphics node that represents the image.
+ *
+ * @param newImage the new graphics node that represents the image
+ */
public void setImage(GraphicsNode newImage) {
getChildren().add(0, newImage);
}
+ /**
+ * Returns the graphics node that represents the image.
+ */
public GraphicsNode getImage() {
if (count > 0) {
return children[0];
1.7 +31 -11 xml-batik/sources/org/apache/batik/gvt/RasterImageNode.java
Index: RasterImageNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/RasterImageNode.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RasterImageNode.java 2001/04/24 21:34:52 1.6
+++ RasterImageNode.java 2001/09/13 13:10:55 1.7
@@ -22,7 +22,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
* @author <a href="mailto:[EMAIL PROTECTED]>Thomas DeWeese</a>
- * @version $Id: RasterImageNode.java,v 1.6 2001/04/24 21:34:52 deweese Exp $
+ * @version $Id: RasterImageNode.java,v 1.7 2001/09/13 13:10:55 tkormann Exp $
*/
public class RasterImageNode extends AbstractGraphicsNode {
@@ -36,8 +36,20 @@
*/
protected Rectangle2D imageBounds;
- protected AffineTransform img2usr, usr2img;
-
+ /**
+ * The transform that go from the image to the user coordinate system.
+ */
+ protected AffineTransform img2usr;
+
+ /**
+ * The transform that go from the user to the image coordinate system.
+ */
+ protected AffineTransform usr2img;
+
+ /**
+ * This flag indicates whether or not the affine transforms have been
+ * computed.
+ */
protected boolean calcAffine = true;
/**
@@ -51,6 +63,7 @@
/**
* Sets the raster image of this raster image node.
+ *
* @param newImage the new raster image of this raster image node
*/
public void setImage(Filter newImage) {
@@ -61,6 +74,7 @@
/**
* Returns the raster image of this raster image node.
+ *
* @return the raster image of this raster image node
*/
public Filter getImage() {
@@ -69,6 +83,7 @@
/**
* Sets the bounds of this raster image node.
+ *
* @param newBounds the new bounds of this raster image node
*/
public void setImageBounds(Rectangle2D newImageBounds) {
@@ -79,12 +94,16 @@
/**
* Returns the bounds of this raster image node.
+ *
* @return the bounds of this raster image node
*/
public Rectangle2D getImageBounds() {
return (Rectangle2D) imageBounds.clone();
}
+ /**
+ * Updates bith the user->image and image->user transform.
+ */
protected void updateAffine() {
float tx0 = image.getMinX();
@@ -117,27 +136,26 @@
* Paints this node without applying Filter, Mask, Composite and clip.
*
* @param g2d the Graphics2D to use
- * @param rc the GraphicsNodeRenderContext to use
*/
public void primitivePaint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
- if ((image == null)||
+ if ((image == null) ||
(imageBounds.getWidth() == 0) ||
(imageBounds.getHeight() == 0)) {
return;
}
- if (calcAffine)
+ if (calcAffine) {
updateAffine();
+ }
// get the current affine transform
rc.setTransform(img2usr);
-
rc.setAreaOfInterest(null);
GraphicsUtil.drawImage(g2d, image, rc);
// Restore default rendering attributes
- rc.setTransform (g2d.getTransform());
+ rc.setTransform(g2d.getTransform());
rc.setAreaOfInterest(g2d.getClip());
}
@@ -146,21 +164,23 @@
//
/**
- * Returns the primitive bounds in user space of this text node.
+ * Returns the bounds of the area covered by this node's primitive paint.
*/
public Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc) {
return (Rectangle2D) imageBounds.clone();
}
/**
- * Returns the geometric bounds in user space of this text node.
+ * Returns the bounds of the area covered by this node, without taking any
+ * of its rendering attribute into account. i.e., exclusive of any clipping,
+ * masking, filtering or stroking, for example.
*/
public Rectangle2D getGeometryBounds(GraphicsNodeRenderContext rc) {
return (Rectangle2D) imageBounds.clone();
}
/**
- * Returns a shape which matches the text's geometry.
+ * Returns the outline of this node.
*/
public Shape getOutline(GraphicsNodeRenderContext rc) {
return (Rectangle2D) imageBounds.clone();
1.5 +2 -2 xml-batik/sources/org/apache/batik/gvt/RootGraphicsNode.java
Index: RootGraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/RootGraphicsNode.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RootGraphicsNode.java 2001/01/24 16:03:30 1.4
+++ RootGraphicsNode.java 2001/09/13 13:10:55 1.5
@@ -11,8 +11,8 @@
/**
* The top-level graphics node of the GVT tree.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Emmanuel Tissandier</a>
- * @version $Id: RootGraphicsNode.java,v 1.4 2001/01/24 16:03:30 tkormann Exp $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
+ * @version $Id: RootGraphicsNode.java,v 1.5 2001/09/13 13:10:55 tkormann Exp $
*/
public class RootGraphicsNode extends CompositeGraphicsNode {
1.13 +108 -48 xml-batik/sources/org/apache/batik/gvt/TextNode.java
Index: TextNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/TextNode.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TextNode.java 2001/08/01 05:39:35 1.12
+++ TextNode.java 2001/09/13 13:10:55 1.13
@@ -31,7 +31,7 @@
* A graphics node that represents text.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: TextNode.java,v 1.12 2001/08/01 05:39:35 bella Exp $
+ * @version $Id: TextNode.java,v 1.13 2001/09/13 13:10:55 tkormann Exp $
*/
public class TextNode extends AbstractGraphicsNode implements Selectable {
@@ -47,6 +47,31 @@
protected AttributedCharacterIterator aci;
/**
+ * The text of this <tt>TextNode</tt>.
+ */
+ protected String text;
+
+ /**
+ * The begin mark.
+ */
+ protected Mark beginMark = null;
+
+ /**
+ * The end mark.
+ */
+ protected Mark endMark = null;
+
+ /**
+ * The list of text runs.
+ */
+ protected List textRuns;
+
+ /**
+ * An array of text chunks.
+ */
+ protected AttributedCharacterIterator[] chunkACIs = null;
+
+ /**
* Internal Cache: Bounds for this text node, without taking any of the
* rendering attributes (e.g., stroke) into account
*/
@@ -58,29 +83,43 @@
private Rectangle2D primitiveBounds;
/**
- * The text of this <tt>TextNode</tt>.
+ * Internal Cache: the outline.
*/
- protected String text;
-
- protected List textRuns;
-
+ private Shape outline;
/**
* Constructs a new empty <tt>TextNode</tt>.
*/
public TextNode() {}
-
+ /**
+ * Returns a list of text runs.
+ */
public List getTextRuns() {
return textRuns;
}
+
+ /**
+ * Sets the list of text runs of this text node.
+ *
+ * @param textRuns the new list of text runs
+ */
public void setTextRuns(List textRuns) {
this.textRuns = textRuns;
}
- public AttributedCharacterIterator[] chunkACIs = null;
+
+ /**
+ * Returns an array of text chuncks as AttributedCharacterIterator.
+ */
public AttributedCharacterIterator[] getChunkACIs() {
return chunkACIs;
}
+
+ /**
+ * Sets the text chunks of this text node.
+ *
+ * @param chunkACIs the new text chunks of this text node
+ */
public void setChunkACIs(AttributedCharacterIterator[] chunkACIs) {
this.chunkACIs = chunkACIs;
}
@@ -91,7 +130,9 @@
public String getText() {
if (text == null) {
StringBuffer buf = new StringBuffer(aci.getEndIndex());
- for (char c=aci.first(); c != CharacterIterator.DONE; c=aci.next()) {
+ for (char c = aci.first();
+ c != CharacterIterator.DONE;
+ c = aci.next()) {
buf.append(c);
}
text = buf.toString();
@@ -100,8 +141,9 @@
}
/**
- * Sets the location of this raster text node.
- * @param newLocation the new location of this raster image node
+ * Sets the location of this text node.
+ *
+ * @param newLocation the new location of this text node
*/
public void setLocation(Point2D newLocation){
invalidateGeometryCache();
@@ -109,8 +151,9 @@
}
/**
- * Returns the location of this raster image node.
- * @return the location of this raster image node
+ * Returns the location of this text node.
+ *
+ * @return the location of this text node
*/
public Point2D getLocation(){
return location;
@@ -118,6 +161,7 @@
/**
* Sets the attributed character iterator of this text node.
+ *
* @param newAci the new attributed character iterator
*/
public void setAttributedCharacterIterator(AttributedCharacterIterator
@@ -131,6 +175,7 @@
/**
* Returns the attributed character iterator of this text node.
+ *
* @return the attributed character iterator
*/
public AttributedCharacterIterator getAttributedCharacterIterator(){
@@ -142,9 +187,9 @@
//
/**
- * Invalidates this <tt>TextNode</tt>. This node and all its
- * ancestors have been informed that all its cached values related
- * to its bounds must be recomputed.
+ * Invalidates this <tt>TextNode</tt>. This node and all its ancestors have
+ * been informed that all its cached values related to its bounds must be
+ * recomputed.
*/
protected void invalidateGeometryCache() {
super.invalidateGeometryCache();
@@ -153,10 +198,9 @@
}
/**
- * Returns the primitive bounds in user space of this text node.
+ * Returns the bounds of the area covered by this node's primitive paint.
*/
public Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc){
-
if (primitiveBounds == null) {
if (aci != null) {
primitiveBounds = rc.getTextPainter().getPaintedBounds(this,
@@ -172,7 +216,9 @@
}
/**
- * Returns the geometric bounds in user space of this text node.
+ * Returns the bounds of the area covered by this node, without taking any
+ * of its rendering attribute into account. i.e., exclusive of any clipping,
+ * masking, filtering or stroking, for example.
*/
public Rectangle2D getGeometryBounds(GraphicsNodeRenderContext rc){
if (geometryBounds == null){
@@ -190,23 +236,27 @@
}
/**
- * Returns whether a given point is enclosed by the text node's bounds.
+ * Returns true if the specified Point2D is inside the boundary of this
+ * node, false otherwise.
+ *
+ * @param p the specified Point2D in the user space
*/
public boolean contains(Point2D p, GraphicsNodeRenderContext rc) {
return getBounds(rc).contains(p.getX(), p.getY());
}
/**
- * Returns a shape which matches the text's geometry.
+ * Returns the outline of this node.
*/
public Shape getOutline(GraphicsNodeRenderContext rc) {
- Shape outline;
- if (aci != null) {
- outline = rc.getTextPainter().getDecoratedShape(
- this, rc.getFontRenderContext());
- } else {
- outline = new Rectangle2D.Float(0, 0, 0, 0);
- }
+ Shape outline;
+ if (aci != null) {
+ outline = rc.getTextPainter().getDecoratedShape
+ (this, rc.getFontRenderContext());
+ } else {
+ // don't cache this now
+ return new Rectangle2D.Float(0, 0, 0, 0);
+ }
return outline;
}
@@ -214,11 +264,9 @@
// Selection methods
//
- Mark beginMark = null;
- Mark endMark = null;
-
/**
* Initializes the current selection to begin with the character at (x, y).
+ *
* @param the anchor of this node
*/
public boolean selectAt(double x, double y, GraphicsNodeRenderContext rc) {
@@ -228,22 +276,24 @@
/**
* Extends the current selection to the character at (x, y)..
+ *
* @param the anchor of this node
*/
public boolean selectTo(double x, double y, GraphicsNodeRenderContext rc) {
- Mark tmpMark = rc.getTextPainter().selectTo(x, y, beginMark, aci, this, rc);
- boolean result = false;
+ Mark tmpMark =
+ rc.getTextPainter().selectTo(x, y, beginMark, aci, this, rc);
+ boolean result = false;
if (tmpMark != endMark) {
endMark = tmpMark;
result = true;
}
-
return result;
}
/**
* Extends the current selection to the character at (x, y)..
+ *
* @param the anchor of this node
*/
public boolean selectAll(double x, double y, GraphicsNodeRenderContext rc) {
@@ -254,6 +304,7 @@
/**
* Gets the current text selection.
+ *
* @return an object containing the selected content.
*/
public Object getSelection(GraphicsNodeRenderContext rc) {
@@ -278,6 +329,8 @@
}
/**
+ * Returns the shape used to outline this text node.
+ *
* @return a Shape which encloses the current text selection.
*/
public Shape getHighlightShape(GraphicsNodeRenderContext rc) {
@@ -297,10 +350,9 @@
//
/**
- * Paints this node if visible.
+ * Paints this node.
*
* @param g2d the Graphics2D to use
- * @param rc the GraphicsNodeRenderContext to use
*/
public void paint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
if (isVisible) {
@@ -309,6 +361,11 @@
}
+ /**
+ * Paints this node without applying Filter, Mask, Composite, and clip.
+ *
+ * @param g2d the Graphics2D to use
+ */
public void primitivePaint(Graphics2D g2d, GraphicsNodeRenderContext rc) {
//
// DO NOT REMOVE: THE FOLLOWING IS A WORK AROUND
@@ -348,26 +405,29 @@
public static final int ANCHOR_END = 2;
/**
- * The anchor which enables the rendered characters to be
- * aligned such that the start of the text string is at the
- * initial current text location.
- */
+ * The anchor which enables the rendered characters to be aligned such
+ * that the start of the text string is at the initial current text
+ * location.
+ */
public static final Anchor START = new Anchor(ANCHOR_START);
/**
- * The anchor which enables the rendered characters to be
- * aligned such that the middle of the text string is at the
- * initial current text location.
- */
+ * The anchor which enables the rendered characters to be aligned such
+ * that the middle of the text string is at the initial current text
+ * location.
+ */
public static final Anchor MIDDLE = new Anchor(ANCHOR_MIDDLE);
/**
- * The anchor which enables the rendered characters to be
- * aligned such that the end of the text string is at the
- * initial current text location.
- */
+ * The anchor which enables the rendered characters to be aligned such
+ * that the end of the text string is at the initial current text
+ * location.
+ */
public static final Anchor END = new Anchor(ANCHOR_END);
+ /**
+ * The anchor type.
+ */
private int type;
/** No instance of this class. */
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]