xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Burgin <jbur...@onboard-software.com>
Subject RE: GraphicsNode MouseSupport
Date Wed, 17 Apr 2002 16:54:52 GMT
Sorry, didn't mean to be proprietary or anything, just not proud of this
kludge.
Here is the code. added to my child class of JSVGCanvas.  Basically this
listener checks for a hit
on each run and then checks to see if the delimiter is an <a> element.  The
<a> element does not show up
in the GVT tree in any other fashion (to my understanding).

Sorry about the formatting etc.  I'll have to clean this code later.

protected void newEventHandler(){
  eventDispatcher.addGraphicsNodeMouseListener(new
GraphicsNodeMouseAdapter(){
	public void mouseClicked(GraphicsNodeMouseEvent evt){
								
		GraphicsNode _gnode = evt.getRelatedNode();
				
		if(!(_gnode instanceof TextNode))
			 return;
					
		TextNode _textNode = (TextNode)_gnode;
								
		System.out.println("x = " + evt.getX() + " y = " +
evt.getY());
		java.util.List _list = _textNode.getTextRuns();
		for(int i = 0 ; i < _list.size(); i++){
	
org.apache.batik.gvt.renderer.StrokingTextPainter.TextRun
			 run =
(org.apache.batik.gvt.renderer.StrokingTextPainter.TextRun)_list.get(i);
				 AttributedCharacterIterator aci =
run.getACI();
				 TextSpanLayout layout = run.getLayout();

				 TextHit textHit =
layout.hitTestChar(evt.getX(), evt.getY() - 10);
				 if (textHit != null && layout.getBounds()
	
.contains(evt.getX(), 
	
evt.getY()-10)) {
					  System.out.println("delim =" + 
	
aci.getAttribute(TextAttribute.TEXT_COMPOUND_DELIMITER));
					  Object _delimiter = aci
	
.getAttribute(TextAttribute.TEXT_COMPOUND_DELIMITER);
					  if(! (_delimiter instanceof
SVGAElement))
						break;
					  String _href = XLinkSupport
						.getXLinkHref((SVGAElement)
_delimiter);
					  System.out.println("Href = " +
_href);
					  loadSVGDocument(_href);
				 }//if texthit
		}//for runs

	  }//mouseClicked(..)
  });//addlistener
};//newEventHandler()

-----Original Message-----
From: Stephane Hillion [mailto:shillion@ilog.fr]
Sent: Wednesday, April 17, 2002 11:39 AM
To: Batik Users
Subject: RE: GraphicsNode MouseSupport


> I had to listen for clicks and
> then check all the runs of the GVTTextNode for one who's
> TextAttribute.TEXT_COMPOUND_DELIMITER was an SVGAElement.
>
> This is kinda clunky.  Anyone have a better idea?
>

No better idea, but perhaps can we integrate something like this in Batik to
make the anchors work in text elements.
It would be cool if you could give us more details (pseudo code?) about the
way you handled that.
Thanks,
Stephane.


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

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


Mime
View raw message