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 otisg <ot...@ureach.com> on 2004/01/15 23:09:06 UTC
Drawing vertices and edges - handwriting?
Hello,
I am wondering if Batik is the right tool to use for the
following:
I have a set of (x,y) coordinates and need to render an image
that follows these (x,y) pairs. These are (x,y) coordinates that
describe the movement of a pencil, so the end result is
basically an image that depicts a hand-written text.
In other words, I just need the ability to draw points
(vertices) and draw lines between them (edges).
Can I use Batik for this?
If so, could anyone please tell me what some of the relevant
classes are and/or point me in a direction an example that I
could use to get started?
Thanks,
Otis
________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Using Batik with jdk xml
Posted by Thomas DeWeese <Th...@Kodak.com>.
Dave Neuendorf wrote:
> I have an application that makes heavy use of the xml capabilities built
> into the latest jdk. Do I need to use redundant jars for xerces, etc in
> order to integrate batik into this app, or is batik compatible with the
> built-in xml support? I certainly don't want to convert the whole app to
> use non-jdk xml.
So Batik is very happy to use the JDK's SAX2 parser. It also
now uses the 'xml-apis' jar files for the W3C interfaces. However
due to the need to support CSS and a the SVG DOM Batik has it's
own DOM implementation. So if you have XML Documents that are
using the JDK's DOM implementation you will need to 'import'
them to the Batik DOM.
To convince Batik to use the JDK parser you need to do
one of several things:
Write a UserAgent subclass implementing 'getXMLParserClassName'
or modify the org.apache.batik.util.resources.XMLResourceDescriptor
resource file to reference your SAX Parser class.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Problems with the rotate method
Posted by Thomas DeWeese <Th...@Kodak.com>.
mohan rao wrote:
> I am using Batik to generate some basic shapes, which works fine till I
> introduce the "rotate()" method. It starts to throw an null pointer
> exception in the subsequent lines. Can anyone help.
> Thanking you in advance.
This should be fixed in the 1.5.1rc2 release.
> --Mohan
>
> The Details are below.
>
> * System Specifications *
>
> OS=Windows 2000 server edition
> IDE = Oracle Jdeveloper
> Java Version = 1.4.1_02
> JRE = Java(TM) 2 Runtime Environment
> Java VM version = 9.0.5.972 4dopv
>
>
> * Java Code *
>
> package test.svg;
>
> import java.awt.Color;
> import java.awt.Graphics2D;
> import java.awt.Rectangle;
>
> import java.io.FileOutputStream;
> import java.io.IOException;
> import java.io.OutputStreamWriter;
> import java.io.Writer;
>
> import org.apache.batik.dom.GenericDOMImplementation;
> import org.apache.batik.svggen.SVGGraphics2D;
>
> import org.w3c.dom.DOMImplementation;
> import org.w3c.dom.Document;
>
> public class TestSVGGen {
>
> public void paint(Graphics2D g2d) {
> g2d.rotate(0.1);
> g2d.setPaint(Color.red);
> g2d.fill(new Rectangle(10, 10, 100, 100));
> }
>
> public static void main(String [] args) throws IOException {
>
> // Get a DOMImplementation
> DOMImplementation domImpl =
> GenericDOMImplementation.getDOMImplementation();
>
> // Create an instance of org.w3c.dom.Document
> Document document = domImpl.createDocument(null, "svg", null);
>
> // Create an instance of the SVG Generator
> SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
>
> // Ask the test to render into the SVG Graphics2D implementation
> TestSVGGen test = new TestSVGGen();
> test.paint(svgGenerator);
> // Finally, stream out SVG to the standard output using UTF-8
> // character to byte encoding
> boolean useCSS = true; // Use CSS style attribute
> Writer out = new OutputStreamWriter(System.out, "UTF-8");
> svgGenerator.stream(out, useCSS);
> }
> }
>
>
>
> * Error Message *
>
> Exception in thread main
> java.lang.NullPointerException
>
> at org.apache.batik.svggen.SVGGeneratorContext.doubleString(Unknown Source)
>
> at org.apache.batik.svggen.AbstractSVGConverter.doubleString(Unknown
> Source)
>
> at org.apache.batik.svggen.SVGTransform.convertTransform(Unknown Source)
>
> at org.apache.batik.svggen.SVGTransform.toSVGTransform(Unknown Source)
>
> at org.apache.batik.svggen.SVGGraphicContextConverter.toSVG(Unknown Source)
>
> at org.apache.batik.svggen.DOMGroupManager.setTransform(Unknown Source)
>
> at org.apache.batik.svggen.DOMGroupManager.addElement(Unknown Source)
>
> at org.apache.batik.svggen.SVGGraphics2D.fill(Unknown Source)
>
> at test.svg.TestSVGGen.paint(TestSVGGen.java:24)
>
> at test.svg.TestSVGGen.main(TestSVGGen.java:40)
>
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> <http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/mail_footer_email/evt=21482/*http://hotjobs.sweepstakes.yahoo.com/signingbonus>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Problems with the rotate method
Posted by mohan rao <k_...@yahoo.com>.
I am using Batik to generate some basic shapes, which works fine till I introduce the "rotate()" method. It starts to throw an null pointer exception in the subsequent lines. Can anyone help.
Thanking you in advance.
--Mohan
The Details are below.
System Specifications
OS=Windows 2000 server edition
IDE = Oracle Jdeveloper
Java Version = 1.4.1_02
JRE = Java(TM) 2 Runtime Environment
Java VM version = 9.0.5.972 4dopv
Java Code
package test.svg;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.svggen.SVGGraphics2D;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
public class TestSVGGen {
public void paint(Graphics2D g2d) {
g2d.rotate(0.1);
g2d.setPaint(Color.red);
g2d.fill(new Rectangle(10, 10, 100, 100));
}
public static void main(String [] args) throws IOException {
// Get a DOMImplementation
DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document
Document document = domImpl.createDocument(null, "svg", null);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
// Ask the test to render into the SVG Graphics2D implementation
TestSVGGen test = new TestSVGGen();
test.paint(svgGenerator);
// Finally, stream out SVG to the standard output using UTF-8
// character to byte encoding
boolean useCSS = true; // Use CSS style attribute
Writer out = new OutputStreamWriter(System.out, "UTF-8");
svgGenerator.stream(out, useCSS);
}
}
Error Message
Exception in thread main
java.lang.NullPointerException
at org.apache.batik.svggen.SVGGeneratorContext.doubleString(Unknown Source)
at org.apache.batik.svggen.AbstractSVGConverter.doubleString(Unknown Source)
at org.apache.batik.svggen.SVGTransform.convertTransform(Unknown Source)
at org.apache.batik.svggen.SVGTransform.toSVGTransform(Unknown Source)
at org.apache.batik.svggen.SVGGraphicContextConverter.toSVG(Unknown Source)
at org.apache.batik.svggen.DOMGroupManager.setTransform(Unknown Source)
at org.apache.batik.svggen.DOMGroupManager.addElement(Unknown Source)
at org.apache.batik.svggen.SVGGraphics2D.fill(Unknown Source)
at test.svg.TestSVGGen.paint(TestSVGGen.java:24)
at test.svg.TestSVGGen.main(TestSVGGen.java:40)
---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
Using Batik with jdk xml
Posted by Dave Neuendorf <dw...@neusysinc.com>.
I have an application that makes heavy use of the xml capabilities built
into the latest jdk. Do I need to use redundant jars for xerces, etc in
order to integrate batik into this app, or is batik compatible with the
built-in xml support? I certainly don't want to convert the whole app to
use non-jdk xml.
Thanks,
Dave Neuendorf
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
R: Problem with text selection
Posted by Fabio Biscaro <bi...@webscience.it>.
> I worked with text selection and i have some questions:
>
> 1) In javascript I can use "selectSubString" to select a string in a
> text tag. What can I do to remove text selection? I tried
> selectSubString(0,0) but this command, without any sense, selects the
> whole line!!!!
You should call 'SVGSVGElement.deselectAll()' (probably on the root
SVG element). However this isn't currently implemented. I'm not sure
if this will be implemented before the 1.5.1 release.
There are a number of methods that I would like to see implemented
here (the interesection methods etc) but I would like the 1.5.1 release
be be an extremely stable release (our x.x.1 releases have traditionally
been very relyable).
Yes, I tried but it's not implemented yet. Is there another way to set
selection to none?
> 2) I got a bug!
> After you select some text:
> Error 1: If another graphic component is made visible over the
selected
> text, the selected text goes correctly back but the selection is
always
> in the top!
This is correct behaviour the selection highlight is (and probably
always will be) on top of everything. As an example the text could have
it's middle under a rectangle but if you drag from start to end it will
select across the rect.
Is it correct? Sigh.
> Error 2: If you hide the text element selection still remains active
> in the player!
I'm not as sure about this one, as long as the change is just
'visibility' this might be correct, however if the change is display it
is probably wrong.
I used visibility!
Maybe when a text element is hidden, it's selection still remains
visible over everythig?
> Do you think I should post them in bugzilla?
>
> Thanks, Fabio
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
Thanks again,
Fabio
---------------------------------------------------------------------
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: Problem with text selection
Posted by Thomas DeWeese <Th...@Kodak.com>.
Fabio Biscaro wrote:
> I worked with text selection and i have some questions:
>
> 1) In javascript I can use "selectSubString" to select a string in a
> text tag. What can I do to remove text selection? I tried
> selectSubString(0,0) but this command, without any sense, selects the
> whole line!!!!
You should call 'SVGSVGElement.deselectAll()' (probably on the
root SVG element). However this isn't currently implemented. I'm
not sure if this will be implemented before the 1.5.1 release.
There are a number of methods that I would like to see implemented
here (the interesection methods etc) but I would like the 1.5.1
release be be an extremely stable release (our x.x.1 releases have
traditionally been very relyable).
> 2) I got a bug!
> After you select some text:
> Error 1: If another graphic component is made visible over the selected
> text, the selected text goes correctly back but the selection is always
> in the top!
This is correct behaviour the selection highlight is (and probably
always will be) on top of everything. As an example the text could
have it's middle under a rectangle but if you drag from start to end
it will select across the rect.
> Error 2: If you hide the text element selection still remains active in
> the player!
I'm not as sure about this one, as long as the change is just
'visibility' this might be correct, however if the change is
display it is probably wrong.
> Do you think I should post them in bugzilla?
>
> Thanks, Fabio
>
>
> ---------------------------------------------------------------------
> 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
Problem with text selection
Posted by Fabio Biscaro <bi...@webscience.it>.
I worked with text selection and i have some questions:
1) In javascript I can use "selectSubString" to select a string in a
text tag. What can I do to remove text selection? I tried
selectSubString(0,0) but this command, without any sense, selects the
whole line!!!!
2) I got a bug!
After you select some text:
Error 1: If another graphic component is made visible over the selected
text, the selected text goes correctly back but the selection is always
in the top!
Error 2: If you hide the text element selection still remains active in
the player!
Do you think I should post them in bugzilla?
Thanks, Fabio
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: Drawing vertices and edges - handwriting?
Posted by Thomas DeWeese <Th...@Kodak.com>.
otisg wrote:
> I am wondering if Batik is the right tool to use for the
> following:
>
> I have a set of (x,y) coordinates and need to render an image
> that follows these (x,y) pairs. These are (x,y) coordinates that
> describe the movement of a pencil, so the end result is
> basically an image that depicts a hand-written text.
>
> In other words, I just need the ability to draw points
> (vertices) and draw lines between them (edges).
>
> Can I use Batik for this?
Yes, you can.
> If so, could anyone please tell me what some of the relevant
> classes are and/or point me in a direction an example that I
> could use to get started?
Well you can use the standard SVG DOM to do this.
Either have one SVG path element (update the 'd' attribute)
or add a new line element for each.
You might just use the standard Java2D API's. It's
not that hard to create the GeneralPath yourself. The
only slightly tricky bit is the display. I don't know how
demanding your display requirements are. If you only need
to put this up you may not want to deal with Batik but
if you want to serialize, do fancy stuff with display
(zoom/pan) etc then Batik might become an asset.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org