SVGGraphivs does not seem to recognize Line2D, unless the problem is somewhere else. Below is the error message.
I am following the example code given at Batik SvGGenerator page and trying to create a SVG file for the drawing.The code is inside of my main class:
public static void main(String argv[]) throws IOException {
frame = new MyFrame();
MyAdapter MyAdapterObject = new MyAdapter();
MyMotionAdapter MyMotionObject = new MyMotionAdapter();
frame.addMouseListener(MyAdapterObject);
frame.addMouseMotionListener(MyMotionObject);
frame.setSize(Size);
frame.setVisible(true);
frame.addWindowListener(new ApplicationClosingWindowListener());
}
}
The paint method I am trying to use is this one:
//
//
The other two paint methods that show on the error messages are:
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setXORMode(Color.white);
SegmentIterator si = iterator();
for (; si.hasNext();) {
Segment s = si.next();
s.paint(g2);
}
}
public void paint(Graphics g) { // paint needs to be changed to plot result segment & base line for test
CoordIterator it = iterator();
Graphics2D g2 = (Graphics2D)g;
if (it.hasNext()) {
Coord prev = it.next(); // go to the first element
while (it.hasNext()) {
Coord c = it.next(); // this is subsequent element
g2.draw(new Line2D.Double(prev.x, prev.y,c.x,c.y));
prev=c;
}
}
Error msg:
XOR Mode is not supported by Graphics2D SVG Generator
java.lang.NullPointerException
I would appreciate if someone can help me.
Alice
Alice Cristina Mello Cavallo
Interdisciplinary PhD Candidate at Tufts University
Learning, Technology and Drama
http://www.media.mit.edu/~mello/