You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2001/09/27 22:09:11 UTC

cvs commit: xml-batik/sources/org/apache/batik/util ParsedURL.java ParsedURLData.java ParsedURLDataProtocolHandler.java ParsedURLDefaultProtocolHandler.java

deweese     01/09/27 13:09:11

  Modified:    sources/org/apache/batik/gvt TextNode.java TextPainter.java
               sources/org/apache/batik/gvt/renderer BasicTextPainter.java
                        StaticRenderer.java StrokingTextPainter.java
               sources/org/apache/batik/gvt/text Mark.java TextHit.java
               sources/org/apache/batik/util ParsedURL.java
                        ParsedURLData.java
                        ParsedURLDataProtocolHandler.java
                        ParsedURLDefaultProtocolHandler.java
  Log:
  1) Modified/Cleaned up the text selection API's and classes to remove some
     unused 'history'.
  2) Added new method to TextNode to get Markers (used for text selection)
     for particular characters
  3) Added an interface to set a nodes selection.
  4) Added author and id tags to ParsedURL stuff.
  
  Revision  Changes    Path
  1.19      +25 -11    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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TextNode.java	2001/09/19 15:09:29	1.18
  +++ TextNode.java	2001/09/27 20:09:10	1.19
  @@ -35,7 +35,7 @@
    * A graphics node that represents text.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: TextNode.java,v 1.18 2001/09/19 15:09:29 tkormann Exp $
  + * @version $Id: TextNode.java,v 1.19 2001/09/27 20:09:10 deweese Exp $
    */
   public class TextNode extends AbstractGraphicsNode implements Selectable {
   
  @@ -283,9 +283,22 @@
           return outline;
       }
   
  +    /**
  +     * Return the marker for the character at index in this nodes
  +     * AttributedCharacterIterator.  Before Char indicates if the
  +     * Marker should be considered before or after char.
  +     */
  +    public Mark getMarkerForChar(int index, boolean beforeChar) {
  +        return textPainter.getMark(this, index, beforeChar);
  +    }
  +
       //
       // Selection methods
       //
  +    public void setSelection(Mark begin, Mark end) {
  +        beginMark = begin;
  +        endMark   = end;
  +    }
   
       /**
        * Initializes the current selection to begin with the character at (x, y).
  @@ -293,8 +306,8 @@
        * @param the anchor of this node
        */
       public boolean selectAt(double x, double y) {
  -	beginMark = textPainter.selectAt(x, y, aci, this);
  -	return true; // assume this always changes selection, for now.
  +        beginMark = textPainter.selectAt(x, y, this);
  +        return true; // assume this always changes selection, for now.
       }
   
       /**
  @@ -303,23 +316,24 @@
        * @param the anchor of this node
        */
       public boolean selectTo(double x, double y) {
  -        Mark tmpMark = textPainter.selectTo(x, y, beginMark, aci, this);
  -        boolean result = false;
  +        Mark tmpMark = textPainter.selectTo(x, y, beginMark);
  +        if (tmpMark == null)
  +            return false;
           if (tmpMark != endMark) {
               endMark = tmpMark;
  -            result = true;
  +            return true;
           }
  -        return result;
  +        return false;
       }
   
       /**
  -     * Extends the current selection to the character at (x, y)..
  +     * Selects all the text in this TextNode...
        *
        * @param the anchor of this node
        */
       public boolean selectAll(double x, double y) {
  -        beginMark = textPainter.selectFirst(x, y, aci, this);
  -        endMark = textPainter.selectLast(x, y, aci, this);
  +        beginMark = textPainter.selectFirst(this);
  +        endMark = textPainter.selectLast(this);
           return true;
       }
   
  @@ -330,7 +344,7 @@
        */
       public Object getSelection() {
   
  -        int[] ranges = textPainter.getSelected(aci, beginMark, endMark);
  +        int[] ranges = textPainter.getSelected(beginMark, endMark);
           Object o = null;
   
   	// TODO: later we can return more complex things like
  
  
  
  1.14      +14 -27    xml-batik/sources/org/apache/batik/gvt/TextPainter.java
  
  Index: TextPainter.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/TextPainter.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TextPainter.java	2001/09/18 21:19:00	1.13
  +++ TextPainter.java	2001/09/27 20:09:10	1.14
  @@ -21,7 +21,7 @@
    * Renders the attributed character iterator of a <tt>TextNode</tt>.
    *
    * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
  - * @version $Id: TextPainter.java,v 1.13 2001/09/18 21:19:00 deweese Exp $
  + * @version $Id: TextPainter.java,v 1.14 2001/09/27 20:09:10 deweese Exp $
    */
   public interface TextPainter {
   
  @@ -40,42 +40,32 @@
        * Initiates a text selection on a particular AttributedCharacterIterator,
        * using the text/font metrics employed by this TextPainter instance.
        */
  -    Mark selectAt(double x, 
  -		  double y, 
  -		  AttributedCharacterIterator aci,
  -		  TextNode node);
  +    Mark selectAt(double x, double y, TextNode node);
   
       /**
        * Continues a text selection on a particular AttributedCharacterIterator,
        * using the text/font metrics employed by this TextPainter instance.
        */
  -    Mark selectTo(double x, double y, Mark beginMark,
  -		  AttributedCharacterIterator aci,
  -		  TextNode node);
  +    Mark selectTo(double x, double y, Mark beginMark);
   
       /**
  -     * Select all of the text represented by an AttributedCharacterIterator,
  -     * using the text/font metrics employed by this TextPainter instance.
  +     * Selects the first glyph in the text node.
        */
  -    Mark selectAll(double x, double y,
  -		   AttributedCharacterIterator aci,
  -		   TextNode node);
  +    Mark selectFirst(TextNode node);
   
   
       /**
  -     * Selects the first glyph in the text node.
  +     * Selects the last glyph in the text node.
        */
  -    Mark selectFirst(double x, double y,
  -		     AttributedCharacterIterator aci,
  -		     TextNode node);
  +    Mark selectLast(TextNode node);
   
  -
       /**
  -     * Selects the last glyph in the text node.
  +     * Returns a mark for the char at index in node's
  +     * AttributedCharacterIterator.  Leading edge indicates if the 
  +     * mark should be considered immediately 'before' glyph or
  +     * after
        */
  -    Mark selectLast(double x, double y,
  -		    AttributedCharacterIterator aci,
  -		    TextNode node);
  +     Mark getMark(TextNode node, int index, boolean beforeGlyph);
   
       /*
        * Get an array of index pairs corresponding to the indices within an
  @@ -84,11 +74,8 @@
        * Note that the instances of Mark passed to this function <em>must
        * come</em> from the same TextPainter that generated them via selectAt()
        * and selectTo(), since the TextPainter implementation may rely on hidden
  -     * implementation details of its own Mark implementation.  
  -     */
  -    int[] getSelected(AttributedCharacterIterator aci,
  -		      Mark start, 
  -		      Mark finish);
  +     * implementation details of its own Mark implementation.  */
  +    int[] getSelected(Mark start, Mark finish);
       
   
       /*
  
  
  
  1.10      +25 -73    xml-batik/sources/org/apache/batik/gvt/renderer/BasicTextPainter.java
  
  Index: BasicTextPainter.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/BasicTextPainter.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BasicTextPainter.java	2001/09/18 21:19:01	1.9
  +++ BasicTextPainter.java	2001/09/27 20:09:11	1.10
  @@ -44,7 +44,7 @@
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
    * @author <a href="vincent.hardy@sun.com>Vincent Hardy</a>
  - * @version $Id: BasicTextPainter.java,v 1.9 2001/09/18 21:19:01 deweese Exp $
  + * @version $Id: BasicTextPainter.java,v 1.10 2001/09/27 20:09:11 deweese Exp $
    */
   public abstract class BasicTextPainter implements TextPainter {
   
  @@ -57,22 +57,6 @@
       protected FontRenderContext fontRenderContext =
   	new FontRenderContext(new AffineTransform(), true, true);
   
  -    /**
  -     * Internal Cache.
  -     */
  -    protected Mark cachedMark = null;
  -
  -    /**
  -     * Internal Cache.
  -     */
  -    protected AttributedCharacterIterator cachedACI = null;
  -
  -    /**
  -     * Internal Cache.
  -     */
  -    protected TextHit cachedHit = null;
  -
  -
       protected TextLayoutFactory getTextLayoutFactory() {
           return textLayoutFactory;
       }
  @@ -83,12 +67,8 @@
        * The standard order of method calls for selection is:
        * selectAt(); [selectTo(),...], selectTo(); getSelection().
        */
  -    public Mark selectAt(double x, double y,
  -                         AttributedCharacterIterator aci,
  -                         TextNode node) {
  -        Mark newMark = hitTest(x, y, aci, node);
  -        cachedHit = null;
  -        return newMark;
  +    public Mark selectAt(double x, double y, TextNode node) {
  +        return hitTest(x, y, node);
       }
   
       /**
  @@ -97,44 +77,26 @@
        * The standard order of method calls for selection is:
        * selectAt(); [selectTo(),...], selectTo(); getSelection().
        */
  -    public Mark selectTo(double x, 
  -			 double y,
  -			 Mark beginMark,
  -			 AttributedCharacterIterator aci,
  -			 TextNode node) {
  -        return hitTest(x, y, aci, node);
  -    }
  -
  -    /**
  -     * Select the entire contents of an
  -     * AttributedCharacterIterator, and
  -     * return a Mark which encapsulates that selection action.
  -     */
  -    public Mark selectAll(double x, 
  -			  double y,
  -			  AttributedCharacterIterator aci,
  -			  TextNode node) {
  -        return hitTest(x, y, aci, node);
  +    public Mark selectTo(double x, double y, Mark beginMark) {
  +        return hitTest(x, y, beginMark.getTextNode());
       }
   
  -
       /**
  -     * Gets a Rectangle2D in userspace coords which encloses the textnode glyphs
  -     * composed from an AttributedCharacterIterator.
  +     * Gets a Rectangle2D in userspace coords which encloses the
  +     * textnode glyphs composed from an AttributedCharacterIterator.
        *
  -     * @param node the TextNode to measure
  -     */
  +     * @param node the TextNode to measure */
        public Rectangle2D getBounds(TextNode node) {
            return getBounds(node, false, false);
        }
   
       /**
  -     * Gets a Rectangle2D in userspace coords which encloses the textnode glyphs
  -     * composed from an AttributedCharacterIterator, inclusive of glyph
  -     * decoration (underline, overline, strikethrough).
  +     * Gets a Rectangle2D in userspace coords which encloses the
  +     * textnode glyphs composed from an AttributedCharacterIterator,
  +     * inclusive of glyph decoration (underline, overline,
  +     * strikethrough).
        *
  -     * @param node the TextNode to measure
  -     */
  +     * @param node the TextNode to measure */
        public Rectangle2D getDecoratedBounds(TextNode node) {
            return getBounds(node, true, false);
        }
  @@ -211,10 +173,7 @@
       /**
        * Returns the mark for the specified parameters.
        */
  -    protected abstract Mark hitTest(double x, 
  -				    double y, 
  -				    AttributedCharacterIterator aci,
  -				    TextNode node);
  +    protected abstract Mark hitTest(double x, double y, TextNode node);
   
   
       // ------------------------------------------------------------------------
  @@ -226,38 +185,31 @@
        */
       protected static class BasicMark implements Mark {
   	
  -        private TextHit hit;
  +        private TextNode       node;
           private TextSpanLayout layout;
  -        private double x;
  -        private double y;
  +        private TextHit        hit;
   
   	/**
   	 * Constructs a new Mark with the specified parameters.
   	 */
  -        protected BasicMark(double x, 
  -			    double y, 
  -			    TextSpanLayout layout, 
  -			    TextHit hit) {
  -            this.x = x;
  -            this.y = y;
  +        protected BasicMark(TextNode node,
  +                            TextSpanLayout layout, 
  +                            TextHit hit) {
  +            this.hit    = hit;
  +            this.node   = node;
               this.layout = layout;
  -            this.hit = hit;
           }
   
           public TextHit getHit() {
               return hit;
           }
   
  -        public TextSpanLayout getLayout() {
  -            return layout;
  -        }
  -
  -        public double getX() {
  -            return x;
  +        public TextNode getTextNode() {
  +            return node;
           }
   
  -        public double getY() {
  -            return y;
  +        public TextSpanLayout getLayout() {
  +            return layout;
           }
       }
   }
  
  
  
  1.17      +14 -7     xml-batik/sources/org/apache/batik/gvt/renderer/StaticRenderer.java
  
  Index: StaticRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/StaticRenderer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- StaticRenderer.java	2001/09/18 21:19:01	1.16
  +++ StaticRenderer.java	2001/09/27 20:09:11	1.17
  @@ -43,7 +43,7 @@
    * rendering in an offscreen buffer image.
    *
    * @author <a href="mailto:vincent.hardy@eng.sun.com>Vincent Hardy</a>
  - * @version $Id: StaticRenderer.java,v 1.16 2001/09/18 21:19:01 deweese Exp $
  + * @version $Id: StaticRenderer.java,v 1.17 2001/09/27 20:09:11 deweese Exp $
    */
   public class StaticRenderer implements ImageRenderer {
       /**
  @@ -88,6 +88,16 @@
       protected RenderingHints renderingHints;
       protected AffineTransform usr2dev;
   
  +    protected static RenderingHints defaultRenderingHints;
  +    static {
  +        defaultRenderingHints = new RenderingHints(null);
  +        defaultRenderingHints.put(RenderingHints.KEY_ANTIALIASING,
  +                                  RenderingHints.VALUE_ANTIALIAS_ON);
  +
  +        defaultRenderingHints.put(RenderingHints.KEY_INTERPOLATION,
  +                                  RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  +    }
  +
       /**
        * @param rh Hints for rendering.
        * @param at Starting user to device coordinate system transform.
  @@ -102,12 +112,7 @@
        * @param offScreen image where the Renderer should do its rendering
        */
       public StaticRenderer(){
  -        renderingHints = new RenderingHints(null);
  -        renderingHints.put(RenderingHints.KEY_ANTIALIASING,
  -                           RenderingHints.VALUE_ANTIALIAS_ON);
  -
  -        renderingHints.put(RenderingHints.KEY_INTERPOLATION,
  -                           RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  +        renderingHints = new RenderingHints(defaultRenderingHints);
           usr2dev = new AffineTransform();
       }
   
  @@ -148,6 +153,8 @@
           currentOffScreen = null;
           currentBaseRaster = null;
           currentRaster = null;
  +
  +        // renderingHints = new RenderingHints(defaultRenderingHints);
       }
   
       /**
  
  
  
  1.16      +97 -76    xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
  
  Index: StrokingTextPainter.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- StrokingTextPainter.java	2001/09/19 15:09:30	1.15
  +++ StrokingTextPainter.java	2001/09/27 20:09:11	1.16
  @@ -60,7 +60,7 @@
    * @see org.apache.batik.gvt.text.GVTAttributedCharacterIterator
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
  - * @version $Id: StrokingTextPainter.java,v 1.15 2001/09/19 15:09:30 tkormann Exp $
  + * @version $Id: StrokingTextPainter.java,v 1.16 2001/09/27 20:09:11 deweese Exp $
    */
   public class StrokingTextPainter extends BasicTextPainter {
   
  @@ -150,10 +150,10 @@
               chunkACIs[currentChunk].first();
   
               chunk = getTextChunk(node, 
  -				 chunkACIs[currentChunk], 
  -				 textRuns,
  +                                 chunkACIs[currentChunk], 
  +                                 textRuns,
                                    beginChunk, 
  -				 lastChunkAdvance);
  +                                 lastChunkAdvance);
   	    
               // Adjust according to text-anchor property value
               chunkACIs[currentChunk].first();
  @@ -177,7 +177,8 @@
        * Returns an array of ACIs, one for each text chunck within the given
        * text node.
        */
  -    private AttributedCharacterIterator[] getTextChunkACIs(AttributedCharacterIterator aci) {
  +    private AttributedCharacterIterator[] getTextChunkACIs
  +        (AttributedCharacterIterator aci) {
   
           List aciVector = new ArrayList();
           aci.first();
  @@ -259,17 +260,19 @@
           if (aci.current() != CharacterIterator.DONE) {
               int chunkStartIndex = aci.getIndex();
   
  -            // find out if this chunck is the start or end of a text path chunck
  -            // if it is, then we ignore any previous advance
  -            TextPath chunkTextPath = (TextPath) aci.getAttribute(
  -                   GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
  +            // find out if this chunck is the start or end of a text
  +            // path chunck if it is, then we ignore any previous
  +            // advance
  +            TextPath chunkTextPath = (TextPath) aci.getAttribute
  +                (GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
               TextPath prevChunkTextPath = null;
               if (chunkStartIndex > 0) {
                   aci.setIndex(chunkStartIndex-1);
                   prevChunkTextPath = (TextPath) aci.getAttribute
  -		    (GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
  +                    (GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
                   aci.setIndex(chunkStartIndex);
               }
  +
               if (prevChunkTextPath != chunkTextPath) {
                   advance = new Point2D.Float(0,0);
               }
  @@ -322,7 +325,7 @@
                                                      (float)advance.getY());
                       }
                       TextSpanLayout layout = getTextLayoutFactory().
  -                                       createTextLayout(runaci, offset, fontRenderContext);
  +                        createTextLayout(runaci, offset, fontRenderContext);
                       TextRun run = new TextRun(layout, runaci, isChunkStart);
                       textRuns.add(run);
                       Point2D layoutAdvance = layout.getAdvance2D();
  @@ -356,8 +359,8 @@
        *
        * @return The new modified aci.
        */
  -    private AttributedCharacterIterator createModifiedACIForFontMatching(
  -                               TextNode node, AttributedCharacterIterator aci) {
  +    private AttributedCharacterIterator createModifiedACIForFontMatching
  +        (TextNode node, AttributedCharacterIterator aci) {
   
           aci.first();
           AttributedCharacterSpanIterator acsi = 
  @@ -1080,13 +1083,38 @@
       }
   
   
  -    TextNode cachedNode;
  +    public Mark getMark(TextNode node, int index, boolean leadingEdge) {
  +        AttributedCharacterIterator aci;
  +        aci = node.getAttributedCharacterIterator();
  +        aci.setIndex(index);
  +        int charIndex = ((Integer)aci.getAttribute
  +         (GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
   
  -    protected Mark hitTest(double x, 
  -			   double y, 
  -			   AttributedCharacterIterator aci,
  -			   TextNode node) {
  +        // get the list of text runs
  +        List textRuns = getTextRuns(node, aci);
   
  +        // for each text run, append any highlight it may contain for
  +        // the current selection
  +        for (int i = 0; i < textRuns.size(); ++i) {
  +            TextRun textRun = (TextRun)textRuns.get(i);
  +            TextSpanLayout layout = textRun.getLayout();
  +
  +            int idx = layout.getGlyphIndex(index);
  +            if (idx != -1) {
  +                TextHit textHit = new TextHit(charIndex, leadingEdge);
  +                return new BasicTextPainter.BasicMark
  +                    (node, layout, textHit);
  +                                                      
  +            }
  +        }
  +        // Couldn't find it's layout....
  +        return null;
  +    }
  +
  +    protected Mark hitTest(double x, double y, TextNode node) {
  +        AttributedCharacterIterator aci;
  +        aci = node.getAttributedCharacterIterator();
  +                           
           // get the list of text runs
           List textRuns = getTextRuns(node, aci);
   
  @@ -1096,81 +1124,51 @@
               TextSpanLayout layout = textRun.getLayout();
               TextHit textHit = layout.hitTestChar((float) x, (float) y);
               if (textHit != null && layout.getBounds().contains(x,y)) {
  -                textHit.setTextNode(node);
  -                textHit.setFontRenderContext(fontRenderContext);
  -                cachedMark = new BasicTextPainter.BasicMark
  -		    (x, y, layout, textHit);
  -                cachedNode = node;
  -                return cachedMark;
  +                return new BasicTextPainter.BasicMark(node, layout, textHit);
               }
           }
   
  -        if (cachedNode != node) {
  -            // did not hit any of the layouts and the cachedMark is invalid for
  -            // this text node, so create a dummy mark
  -            TextHit textHit = new TextHit(0, false);
  -            textHit.setTextNode(node);
  -            textHit.setFontRenderContext(fontRenderContext);
  -            cachedMark = new BasicTextPainter.BasicMark
  -		(x,y,((TextRun)textRuns.get(0)).getLayout(), textHit);
  -
  -            cachedNode = node;
  -        }
  -
  -	return cachedMark;
  +        return null;
       }
   
       /**
        * Selects the first glyph in the text node.
        */
  -    public Mark selectFirst(double x, 
  -			    double y, 
  -			    AttributedCharacterIterator aci,
  -			    TextNode node) {
  +    public Mark selectFirst(TextNode node) {
  +        AttributedCharacterIterator aci;
  +        aci = node.getAttributedCharacterIterator();
   
           // get the list of text runs
           List textRuns = getTextRuns(node, aci);
   
           aci.first();
           int charIndex = ((Integer)aci.getAttribute
  -			 (GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
  +                         (GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
           TextHit textHit = new TextHit(charIndex, false);
  -        textHit.setTextNode(node);
  -        textHit.setFontRenderContext(fontRenderContext);
  -        cachedMark = new BasicTextPainter.BasicMark
  -	    (x,y,((TextRun)textRuns.get(0)).getLayout(), textHit);
  -
  -        cachedNode = node;
  -
  -        return cachedMark;
  +        return new BasicTextPainter.BasicMark
  +            (node, ((TextRun)textRuns.get(0)).getLayout(), textHit);
       }
   
       /**
        * Selects the last glyph in the text node.
        */
  -    public Mark selectLast(double x, 
  -			   double y, 
  -			   AttributedCharacterIterator aci,
  -			   TextNode node) {
  +    public Mark selectLast(TextNode node) {
   	
  +        AttributedCharacterIterator aci;
  +        aci = node.getAttributedCharacterIterator();
  +
           // get the list of text runs
           List textRuns = getTextRuns(node, aci);
   
           TextSpanLayout lastLayout = 
  -	    ((TextRun)textRuns.get(textRuns.size()-1)).getLayout();
  +            ((TextRun)textRuns.get(textRuns.size()-1)).getLayout();
   
           int lastGlyphIndex = lastLayout.getGlyphCount()-1;
           aci.last();
   
  -        int charIndex = ((Integer)aci.getAttribute(
  -            GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
  +        int charIndex = ((Integer)aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
           TextHit textHit = new TextHit(charIndex, false);
  -        textHit.setTextNode(node);
  -        textHit.setFontRenderContext(fontRenderContext);
  -        cachedMark = new BasicTextPainter.BasicMark(x,y,lastLayout,textHit);
  -        cachedNode = node;
  -
  -        return cachedMark;
  +        return  new BasicTextPainter.BasicMark(node, lastLayout, textHit);
       }
   
       /**
  @@ -1180,8 +1178,7 @@
        * <em>Note: The Mark instances passed must have been instantiated by
        * an instance of this enclosing TextPainter implementation.</em>
        */
  -    public int[] getSelected(AttributedCharacterIterator aci,
  -                             Mark startMark,
  +    public int[] getSelected(Mark startMark,
                                Mark finishMark) {
   
           if (startMark == null || finishMark == null) {
  @@ -1196,6 +1193,14 @@
               throw new
               Error("This Mark was not instantiated by this TextPainter class!");
           }
  +
  +        TextNode textNode = start.getTextNode();
  +        if (textNode != finish.getTextNode()) 
  +            throw new Error("Markers are from different TextNodes!");
  +
  +        AttributedCharacterIterator aci;
  +        aci = textNode.getAttributedCharacterIterator();
  +                             
           int[] result = new int[2];
           result[0] = start.getHit().getCharIndex();
           result[1] = finish.getHit().getCharIndex();
  @@ -1244,39 +1249,55 @@
               begin = (BasicTextPainter.BasicMark) beginMark;
               end = (BasicTextPainter.BasicMark) endMark;
           } catch (ClassCastException cce) {
  -            throw new
  -            Error("This Mark was not instantiated by this TextPainter class!");
  +            throw new Error
  +                ("This Mark was not instantiated by this TextPainter class!");
           }
   
  +        TextNode textNode = begin.getTextNode();
  +        if (textNode != end.getTextNode()) 
  +            throw new Error("Markers are from different TextNodes!");
  +
           int beginIndex = begin.getHit().getCharIndex();
  -        int endIndex = end.getHit().getCharIndex();
  +        int endIndex   = end.getHit().getCharIndex();
  +        if (beginIndex > endIndex) {
  +            // Swap them...
  +            BasicTextPainter.BasicMark tmpMark = begin;
  +            begin = end; end = tmpMark;
  +
  +            int tmpIndex = beginIndex;
  +            beginIndex = endIndex; endIndex = tmpIndex;
  +        }
   
           TextSpanLayout beginLayout = null;
           TextSpanLayout endLayout = null;
  -        if (begin != null && end != null) {
  +        if ((begin != null) && (end != null)) {
               beginLayout = begin.getLayout();
  -            endLayout = end.getLayout();
  +            endLayout   = end.getLayout();
           }
  -        if (beginLayout == null || endLayout == null) {
  +
  +        if ((beginLayout == null) || (endLayout == null)) {
               return null;
           }
   
           // get the list of text runs
  -        TextNode textNode = begin.getHit().getTextNode();
  -        List textRuns = getTextRuns(textNode, textNode.getAttributedCharacterIterator());
  +        List textRuns = getTextRuns
  +            (textNode, textNode.getAttributedCharacterIterator());
   
           GeneralPath highlightedShape = new GeneralPath();
   
  -        // for each text run, append any highlight it may contain for the current selection
  +        // for each text run, append any highlight it may contain for
  +        // the current selection
           for (int i = 0; i < textRuns.size(); ++i) {
               TextRun textRun = (TextRun)textRuns.get(i);
               TextSpanLayout layout = textRun.getLayout();
   
  -            Shape layoutHighlightedShape = layout.getHighlightShape(beginIndex, endIndex);
  +            Shape layoutHighlightedShape = layout.getHighlightShape
  +                (beginIndex, endIndex);
   
               // append the highlighted shape of this layout to the
               // overall hightlighted shape
  -            if (layoutHighlightedShape != null && !layoutHighlightedShape.getBounds().isEmpty()) {
  +            if (( layoutHighlightedShape != null) && 
  +                (!layoutHighlightedShape.getBounds().isEmpty())) {
                   highlightedShape.append(layoutHighlightedShape, false);
               }
           }
  
  
  
  1.2       +8 -14     xml-batik/sources/org/apache/batik/gvt/text/Mark.java
  
  Index: Mark.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/Mark.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Mark.java	2000/10/10 18:40:01	1.1
  +++ Mark.java	2001/09/27 20:09:11	1.2
  @@ -7,24 +7,18 @@
    *****************************************************************************/
   
   package org.apache.batik.gvt.text;
  +import org.apache.batik.gvt.TextNode;
   
   /**
  - * Marker interface, mostly, that encapsulates information about a selection
  - * gesture.
  - * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
  - * @version $Id: Mark.java,v 1.1 2000/10/10 18:40:01 hillion Exp $
  + * Marker interface, mostly, that encapsulates information about a
  + * selection gesture.
  + *
  + * @author <a href="mailto:bill.haneman@ireland.sun.com">Bill Haneman</a>
  + * @version $Id: Mark.java,v 1.2 2001/09/27 20:09:11 deweese Exp $ 
    */
  -
   public interface Mark {
  -
  -    /*
  -     * Return the x coordinate associated with this mark.
  -     */
  -    public double getX();
  -
       /*
  -     * Return the y coordinate associated with this mark.
  +     * Return the TextNode this Mark is associated with 
        */
  -    public double getY();
  -
  +    TextNode getTextNode();
   }
  
  
  
  1.9       +7 -45     xml-batik/sources/org/apache/batik/gvt/text/TextHit.java
  
  Index: TextHit.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/TextHit.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TextHit.java	2001/09/13 08:42:49	1.8
  +++ TextHit.java	2001/09/27 20:09:11	1.9
  @@ -17,23 +17,22 @@
    * @see org.apache.batik.gvt.text.TextSpanLayout
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
  - * @version $Id: TextHit.java,v 1.8 2001/09/13 08:42:49 tkormann Exp $
  + * @version $Id: TextHit.java,v 1.9 2001/09/27 20:09:11 deweese Exp $
    */
   public class TextHit {
   
       private int charIndex;
       private boolean leadingEdge;
  -    private TextNode textNode;
  -    private FontRenderContext frc;
   
       /**
        * Constructs a TextHit with the specified values.
        *
  -     * @param charIndex The index of the character that has been hit. In the
  -     * case of bidirectional text this will be the logical character index not
  -     * the visual index. The index is relative to whole text within the selected
  -     * TextNode.
  -     * @param leadingEdge Indicates which side of the character has been hit.
  +     * @param charIndex The index of the character that has been
  +     * hit. In the case of bidirectional text this will be the logical
  +     * character index not the visual index. The index is relative to
  +     * whole text within the selected TextNode.
  +     * @param leadingEdge Indicates which side of the character has
  +     * been hit.  
        */
       public TextHit(int charIndex, boolean leadingEdge) {
           this.charIndex = charIndex;
  @@ -56,43 +55,6 @@
        */
       public boolean isLeadingEdge() {
           return leadingEdge;
  -    }
  -
  -    /**
  -     * Sets the TextNode that is associated with this hit.
  -     *
  -     * @param textNode The textNode that has been hit.
  -     */
  -    public void setTextNode(TextNode textNode) {
  -        this.textNode = textNode;
  -    }
  -
  -
  -    /**
  -     * Sets the font render context at the time of the hit.
  -     *
  -     * @param frc The current font render context.
  -     */
  -    public void setFontRenderContext(FontRenderContext frc) {
  -        this.frc = frc;
  -    }
  -
  -    /**
  -     * Returns the text node associated with this text hit.
  -     *
  -     * @return The text node that has been hit.
  -     */
  -    public TextNode getTextNode() {
  -        return textNode;
  -    }
  -
  -    /**
  -     * Returns the font render context at the time of the text hit.
  -     *
  -     * @return The font render context.
  -     */
  -    public FontRenderContext getFontRenderContext() {
  -        return frc;
       }
   }
   
  
  
  
  1.9       +3 -0      xml-batik/sources/org/apache/batik/util/ParsedURL.java
  
  Index: ParsedURL.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURL.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ParsedURL.java	2001/09/26 12:40:51	1.8
  +++ ParsedURL.java	2001/09/27 20:09:11	1.9
  @@ -41,6 +41,9 @@
    * for compatability with core URL), in spite of the fact that the
    * real implemenation uses the protocol handlers as factories for
    * protocol specific instances of the ParsedURLData class.
  + *
  + * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
  + * @version $Id: ParsedURL.java,v 1.9 2001/09/27 20:09:11 deweese Exp $ 
    */
   public class ParsedURL {
   
  
  
  
  1.4       +6 -0      xml-batik/sources/org/apache/batik/util/ParsedURLData.java
  
  Index: ParsedURLData.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLData.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ParsedURLData.java	2001/07/18 22:04:54	1.3
  +++ ParsedURLData.java	2001/09/27 20:09:11	1.4
  @@ -21,6 +21,12 @@
   import java.util.LinkedList;
   import java.util.List;
   
  +/**
  + * Holds the data for more URL's
  + *
  + * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
  + * @version $Id: ParsedURLData.java,v 1.4 2001/09/27 20:09:11 deweese Exp $ 
  + */
   public class ParsedURLData {
       
       String HTTP_USER_AGENT_HEADER      = "User-Agent";
  
  
  
  1.3       +3 -0      xml-batik/sources/org/apache/batik/util/ParsedURLDataProtocolHandler.java
  
  Index: ParsedURLDataProtocolHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLDataProtocolHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParsedURLDataProtocolHandler.java	2001/07/18 22:04:54	1.2
  +++ ParsedURLDataProtocolHandler.java	2001/09/27 20:09:11	1.3
  @@ -15,6 +15,9 @@
   
   /**
    * Protocol Handler for the 'data' protocol.
  + *
  + * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
  + * @version $Id: ParsedURLDataProtocolHandler.java,v 1.3 2001/09/27 20:09:11 deweese Exp $ 
    */
   public class ParsedURLDataProtocolHandler 
       extends AbstractParsedURLProtocolHandler {
  
  
  
  1.5       +3 -0      xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java
  
  Index: ParsedURLDefaultProtocolHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/ParsedURLDefaultProtocolHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ParsedURLDefaultProtocolHandler.java	2001/09/27 11:33:20	1.4
  +++ ParsedURLDefaultProtocolHandler.java	2001/09/27 20:09:11	1.5
  @@ -20,6 +20,9 @@
    * protocols, such as 'file' 'http' 'ftp'.
    * The parsing should be general enought to support most
    * 'normal' URL formats, so in many cases 
  + *
  + * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
  + * @version $Id: ParsedURLDefaultProtocolHandler.java,v 1.5 2001/09/27 20:09:11 deweese Exp $ 
    */
   public class ParsedURLDefaultProtocolHandler 
       extends AbstractParsedURLProtocolHandler {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org