You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Thomas DeWeese <Th...@Kodak.com> on 2005/03/05 20:38:27 UTC

Re: Textselection always copied to clipboard?

Bjoern.Stenersen@si-software.de wrote:
> I did not encounter any problems, except the
> "Double-Click"-Problem. 

    This is now fixed in CVS, double click properly reports the
complete selection.

>  >     Thanks for considering contributing.
> 
> I attached some files to the bug, what do you think of them?

   I went a different route with this.  I pushed the copy to
clipboard up to the JGVTComponent and this can be controlled
by a getter/setter, it simply leverages the SelectionListener API.

   I did expose the TextSelectionManager on the Canvas.

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


Re: Textselection always copied to clipboard?

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Bjoern,

    This is now fixed in CVS.

> Bjoern.Stenersen@si-software.de wrote:
> 
>> When i click the mouse on a textnode and start dragging the textnode 
>> gets highlighted. [..] When i release the mousebutton outside
>> the textnodes box the node is highlighted correctly but no event is 
>> fired. When i call getSelection() on the
>> TextSelectionManager it returns null. Is that another bug?

Thomas DeWeese wrote:

>    Yes, I will work on fixing this.

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


Re: Textselection always copied to clipboard?

Posted by Thomas DeWeese <Th...@Kodak.com>.
Bjoern.Stenersen@si-software.de wrote:

> Unfortunately i encountered an error in the SelectionListener:
> When i click the mouse on a textnode and start dragging the textnode 
> gets highlighted. [..] When i release the mousebutton outside
> the textnodes box the node is highlighted correctly but no event 
> is fired. When i call getSelection() on the
> TextSelectionManager it returns null. Is that another bug?

    Yes, I will work on fixing this.

> (there is something like a box for a textnode, am i right?)

   Yes there is a 'char cell' that is computed from the font
metrics and what not, this is roughly what is highlighted.
Text selection seems to behave quite oddly if you restrict
yourself to the actual geometry.


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


Re: SVGDocument - Difference when building my own or using autogenerated

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

If the output can be parsed back by JSVGCanvas correctly, it seem that
your propietary XML output do things incorrectly. In your propietary XML
output, how do you print Text node? Make sure from the element, it get
the firstChild which is the text node, then print the Text Node.

Regards
Tonny Kohar

On Tue, 2005-03-08 at 11:32 +0100, Glenn Thomas Hvidsten wrote:
> I've just encountered another challenge in batik.
> I create a SVGDocument using this code I found on the Batik homepages:
> 
> String parser = XMLResourceDescriptor.getXMLParserClassName();
> SAXSVGDocumentFactory docFactory = new SAXSVGDocumentFactory(parser);
> svgDocument = (SVGDocument)
>      docFactory.createDocument(f.toURL().toString());
> 
> And I use this (very simplified) SVG file:
> 
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> 
> <svg width="260.0" height="450.0" 
> xmlns:xlink="http://www.w3.org/1999/xlink" 
> xmlns="http://www.w3.org/2000/svg">
>      <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
> stroke="none"/>
>      <text x="40.0" y="40.0" fill="#ffdd22" 
> style="font-family:arial;font-weight:bold">###TITLE###</text>
> </svg>
> 
> 
> When I now use this code:
> 
> svgCanvas.setSVGDocument(svgDocument);
> 
> What is drawn on the JSVGCanvas does not include the ###TITLE### text.
> Also, when I use this code:
> 
> svgCanvas.getSVGDocument().getDocumentElement()
> 
> and print the contents of the SVGDocument (using a proprietary XML 
> output class) I get this output:
> 
> <svg contentScriptType="text/ecmascript" width="260.0" 
> xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
> contentStyleType="text/css" height="450.0" preserveAspectRatio="xMidYMid 
> meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
> <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
> stroke="none"/>
> <text fill="#ffdd22" x="40.0" y="40.0" 
> style="font-family:arial;font-weight:bold"/>
> </svg>
> 
> As you can see, the text element has been drastically cut down.
> 
> When I use the JSVGCanvas itself to read the file by this code:
> 
> svgCanvas.setURI(f.toURL().toString());
> 
> The graphical output includes the text and the XML output looks like this:
> 
> <svg contentScriptType="text/ecmascript" width="260.0" 
> xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
> contentStyleType="text/css" height="450.0" preserveAspectRatio="xMidYMid 
> meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
> <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
> stroke="none"/>
> <text fill="#ffdd22" x="40.0" y="40.0" 
> style="font-family:arial;font-weight:bold">###TITLE###</text>
> </svg>
> 
> As you can see, the text is now as it should be.
> 
> How can I read the SVG file into an SVGDocument while still retaining 
> the text element?
> 
> (I want to read the SVG file into a SVGDocument and replace the 
> ###TITLE### with a user defined title. Using the SVGDocument itself 
> until it's ready to be drawn is more efficient than using JSVGCanvas 
> every time since JSVGCanvas renders the SVG each time. I only want to 
> render it when all replacements are done.)
> 
> 
> ---------------------------------------------------------------------
> 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


Re: SVGDocument - Difference when building my own or using autogenerated

Posted by Glenn Thomas Hvidsten <gt...@corena.no>.
My problem appeared because I thought I was working on a copy of the 
SVGDocument, but since I was only working on a copy of the reference, I 
was working on the actual SVGDocument itself.
So when I first read it I created an svgDocumentOrg variable into which 
I placed the contents of the SVG file. When I printed the contents of 
svgDocumentOrg now everything was as it should be (I hadn't tried that 
when I wrote the first message. Stupid me :) I then performed my 
replacements on cues in the original SVG file on a variable I called 
svgDocumentCopy which was assigned as SVGDocument svgDocumentCopy = 
svgDocumentOrg. When I now printed svgDocumentOrg (as I originally did 
in the first message) all the text was gone since the text had been 
replaced by an empty string (which was what I wanted to do on the copy 
but not the original). I'm sure you can see my confusion when I thought 
I hadn't modified svgDocumentOrg at all and it's contents are not what I 
expect :D
This was the basis of my problems. I fixed it by making a proper copy of 
the contents of the svgDocumentOrg into svgDocumentCopy instead of 
simply copying its reference.
For others who might run into the same problem, here's how to copy the 
contents of one SVGDocument variable into another:

svgDocumentCopy = (SVGDocument)
     DOMUtilities.deepCloneDocument(
         svgDocumentOrg,
         svgDocumentOrg.getImplementation());



Glenn Thomas Hvidsten


Thomas DeWeese wrote:
> Hi Glenn,
> 
>    What happens if you print the Document you get back from
> SAXSVGDocumentFactory?
> 
>    I suspect that something in your code is deleting the
> text content.  The code you are using is essentially
> the same as the code used internally.
> 
>> I create a SVGDocument using this code I found on the Batik homepages:
>>
>> String parser = XMLResourceDescriptor.getXMLParserClassName();
>> SAXSVGDocumentFactory docFactory = new SAXSVGDocumentFactory(parser);
>> svgDocument = (SVGDocument)
>>     docFactory.createDocument(f.toURL().toString());
>>
>> And I use this (very simplified) SVG file:
>>
>> <?xml version="1.0" standalone="no"?>
>> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
>> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
>>
>> <svg width="260.0" height="450.0" 
>> xmlns:xlink="http://www.w3.org/1999/xlink" 
>> xmlns="http://www.w3.org/2000/svg">
>>     <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
>> stroke="none"/>
>>     <text x="40.0" y="40.0" fill="#ffdd22" 
>> style="font-family:arial;font-weight:bold">###TITLE###</text>
>> </svg>
>>
>>
>> When I now use this code:
>>
>> svgCanvas.setSVGDocument(svgDocument);
>>
>> What is drawn on the JSVGCanvas does not include the ###TITLE### text.
>> Also, when I use this code:
>>
>> svgCanvas.getSVGDocument().getDocumentElement()
>>
>> and print the contents of the SVGDocument (using a proprietary XML 
>> output class) I get this output:
>>
>> <svg contentScriptType="text/ecmascript" width="260.0" 
>> xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
>> contentStyleType="text/css" height="450.0" 
>> preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" 
>> version="1.0">
>> <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
>> stroke="none"/>
>> <text fill="#ffdd22" x="40.0" y="40.0" 
>> style="font-family:arial;font-weight:bold"/>
>> </svg>
>>
>> As you can see, the text element has been drastically cut down.
>>
>> When I use the JSVGCanvas itself to read the file by this code:
>>
>> svgCanvas.setURI(f.toURL().toString());
>>
>> The graphical output includes the text and the XML output looks like 
>> this:
>>
>> <svg contentScriptType="text/ecmascript" width="260.0" 
>> xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
>> contentStyleType="text/css" height="450.0" 
>> preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" 
>> version="1.0">
>> <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
>> stroke="none"/>
>> <text fill="#ffdd22" x="40.0" y="40.0" 
>> style="font-family:arial;font-weight:bold">###TITLE###</text>
>> </svg>
>>
>> As you can see, the text is now as it should be.
>>
>> How can I read the SVG file into an SVGDocument while still retaining 
>> the text element?
>>
>> (I want to read the SVG file into a SVGDocument and replace the 
>> ###TITLE### with a user defined title. Using the SVGDocument itself 
>> until it's ready to be drawn is more efficient than using JSVGCanvas 
>> every time since JSVGCanvas renders the SVG each time. I only want to 
>> render it when all replacements are done.)
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 


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


Re: SVGDocument - Difference when building my own or using autogenerated

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Glenn,

    What happens if you print the Document you get back from
SAXSVGDocumentFactory?

    I suspect that something in your code is deleting the
text content.  The code you are using is essentially
the same as the code used internally.

    Finally on the last point of modifying the document
before it is displayed, you can register a listener for
the SVGLoad event which would allow you to modify the document
before the document is displayed.  However the two should
be essentially identical.

Glenn Thomas Hvidsten wrote:
> I've just encountered another challenge in batik.
> I create a SVGDocument using this code I found on the Batik homepages:
> 
> String parser = XMLResourceDescriptor.getXMLParserClassName();
> SAXSVGDocumentFactory docFactory = new SAXSVGDocumentFactory(parser);
> svgDocument = (SVGDocument)
>     docFactory.createDocument(f.toURL().toString());
> 
> And I use this (very simplified) SVG file:
> 
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
> "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> 
> <svg width="260.0" height="450.0" 
> xmlns:xlink="http://www.w3.org/1999/xlink" 
> xmlns="http://www.w3.org/2000/svg">
>     <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
> stroke="none"/>
>     <text x="40.0" y="40.0" fill="#ffdd22" 
> style="font-family:arial;font-weight:bold">###TITLE###</text>
> </svg>
> 
> 
> When I now use this code:
> 
> svgCanvas.setSVGDocument(svgDocument);
> 
> What is drawn on the JSVGCanvas does not include the ###TITLE### text.
> Also, when I use this code:
> 
> svgCanvas.getSVGDocument().getDocumentElement()
> 
> and print the contents of the SVGDocument (using a proprietary XML 
> output class) I get this output:
> 
> <svg contentScriptType="text/ecmascript" width="260.0" 
> xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
> contentStyleType="text/css" height="450.0" preserveAspectRatio="xMidYMid 
> meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
> <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
> stroke="none"/>
> <text fill="#ffdd22" x="40.0" y="40.0" 
> style="font-family:arial;font-weight:bold"/>
> </svg>
> 
> As you can see, the text element has been drastically cut down.
> 
> When I use the JSVGCanvas itself to read the file by this code:
> 
> svgCanvas.setURI(f.toURL().toString());
> 
> The graphical output includes the text and the XML output looks like this:
> 
> <svg contentScriptType="text/ecmascript" width="260.0" 
> xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
> contentStyleType="text/css" height="450.0" preserveAspectRatio="xMidYMid 
> meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
> <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
> stroke="none"/>
> <text fill="#ffdd22" x="40.0" y="40.0" 
> style="font-family:arial;font-weight:bold">###TITLE###</text>
> </svg>
> 
> As you can see, the text is now as it should be.
> 
> How can I read the SVG file into an SVGDocument while still retaining 
> the text element?
> 
> (I want to read the SVG file into a SVGDocument and replace the 
> ###TITLE### with a user defined title. Using the SVGDocument itself 
> until it's ready to be drawn is more efficient than using JSVGCanvas 
> every time since JSVGCanvas renders the SVG each time. I only want to 
> render it when all replacements are done.)
> 
> 
> ---------------------------------------------------------------------
> 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


SVGDocument - Difference when building my own or using autogenerated

Posted by Glenn Thomas Hvidsten <gt...@corena.no>.
I've just encountered another challenge in batik.
I create a SVGDocument using this code I found on the Batik homepages:

String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory docFactory = new SAXSVGDocumentFactory(parser);
svgDocument = (SVGDocument)
     docFactory.createDocument(f.toURL().toString());

And I use this (very simplified) SVG file:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<svg width="260.0" height="450.0" 
xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns="http://www.w3.org/2000/svg">
     <rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
stroke="none"/>
     <text x="40.0" y="40.0" fill="#ffdd22" 
style="font-family:arial;font-weight:bold">###TITLE###</text>
</svg>


When I now use this code:

svgCanvas.setSVGDocument(svgDocument);

What is drawn on the JSVGCanvas does not include the ###TITLE### text.
Also, when I use this code:

svgCanvas.getSVGDocument().getDocumentElement()

and print the contents of the SVGDocument (using a proprietary XML 
output class) I get this output:

<svg contentScriptType="text/ecmascript" width="260.0" 
xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
contentStyleType="text/css" height="450.0" preserveAspectRatio="xMidYMid 
meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
<rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
stroke="none"/>
<text fill="#ffdd22" x="40.0" y="40.0" 
style="font-family:arial;font-weight:bold"/>
</svg>

As you can see, the text element has been drastically cut down.

When I use the JSVGCanvas itself to read the file by this code:

svgCanvas.setURI(f.toURL().toString());

The graphical output includes the text and the XML output looks like this:

<svg contentScriptType="text/ecmascript" width="260.0" 
xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" 
contentStyleType="text/css" height="450.0" preserveAspectRatio="xMidYMid 
meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
<rect x="20.0" y="20.0" fill="#b04c7e" width="75.0" height="95.0" 
stroke="none"/>
<text fill="#ffdd22" x="40.0" y="40.0" 
style="font-family:arial;font-weight:bold">###TITLE###</text>
</svg>

As you can see, the text is now as it should be.

How can I read the SVG file into an SVGDocument while still retaining 
the text element?

(I want to read the SVG file into a SVGDocument and replace the 
###TITLE### with a user defined title. Using the SVGDocument itself 
until it's ready to be drawn is more efficient than using JSVGCanvas 
every time since JSVGCanvas renders the SVG each time. I only want to 
render it when all replacements are done.)


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


Re: Textselection always copied to clipboard?

Posted by Bj...@si-software.de.
Hi, I did a little test on the cvs-version. The corrections seem to work 
fine, thanks for that. 
Unfortunately i encountered an error in the SelectionListener:
When i click the mouse on a textnode and start dragging the textnode gets 
highlighted. When i release the mousebutton
and the cursor is inside the textnode a SelectionEvent is fired 
(selectionDone). When i release the mousebutton outside
the textnodes box (there is something like a box for a textnode, am i 
right?) the node is highlighted correctly but no event is fired. When i 
call getSelection() on the
TextSelectionManager it returns null. Is that another bug?



Thomas DeWeese <Th...@Kodak.com> schrieb am 05.03.2005 20:38:27:

> Bjoern.Stenersen@si-software.de wrote:
> > I did not encounter any problems, except the
> > "Double-Click"-Problem. 
> 
>     This is now fixed in CVS, double click properly reports the
> complete selection.
> 
> >  >     Thanks for considering contributing.
> > 
> > I attached some files to the bug, what do you think of them?
> 
>    I went a different route with this.  I pushed the copy to
> clipboard up to the JGVTComponent and this can be controlled
> by a getter/setter, it simply leverages the SelectionListener API.
> 
>    I did expose the TextSelectionManager on the Canvas.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>