Hi, For a project I'm working on, I got around the lack of dynamic updates in Batik-1.1 by manually creating my SVGDocument with a new colour every time new colour was chosen.
In my case the colours were prechosen by the user, and all I had to do
was to create a number of SVGs, render them into PNGs and then display
them.
This is basically all I did, (with some other gunk missing).
Dont know if this helps :)
//
//
//
public class NewIcon
{
//
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation
();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument (svgNS, "svg", null);
// Elements
Element svgRoot = doc.getDocumentElement ();
Element circle = doc.createElementNS (svgNS, "circle");
Element line1 = doc.createElementNS (svgNS, "line");
public NewIcon (String strColor)
{
// Set attributes
circle.setAttributeNS (null,"style", "stroke-width: 2.5; stroke: "
+ strColor);
circle.setAttributeNS (null, "cx", Integer.toString (32));
circle.setAttributeNS (null, "cy", Integer.toString (25));
circle.setAttributeNS (null, "r", Integer.toString (12));
svgRoot.appendChild (circle);
}
public SVGDocument getDocument ()
{
return (SVGDocument)doc;
}
public ImageIcon SVGtoImage (SVGDocument svgDoc)
{
ImageIcon iconTemp = null;
PNGTranscoder t = new PNGTranscoder ();
ByteArrayOutputStream byteOut = new ByteArrayOutputStream ();
t.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
"org.apache.crimson.parser.XMLReaderImpl");
t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(64));
t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new
Float(80));
// create the transcoder input
try
{
TranscoderInput input = new TranscoderInput(svgDoc);
TranscoderOutput output = new TranscoderOutput(byteOut);
t.transcode(input, output);
// flush and close the stream then exit
byteOut.flush ();
byteOut.close ();
// now byteOut contains the raw image data
iconTemp = new ImageIcon (byteOut.toByteArray ());
//iconTemp.setImage (imageTemp);
}
catch (Exception e)
{
e.printStackTrace();
}
return iconTemp;
}
}
On Tue, 2002-07-16 at 03:51, Arvind Sareen wrote:
> Hi Bala,
>
> I do have access to SVGDocument object through the script but i do not have
> any idea about dynamic property. Can u give me some more detail or code
> which can help me out so that I can take input from the user and then set
> the color of the line on the basis of the input received from the user.
>
> Arvind
>
>
> >From: "K, Balamurugan (CORP, GEITC)" <[EMAIL PROTECTED]>
> >Reply-To: "Batik Users" <[EMAIL PROTECTED]>
> >To: Batik Users <[EMAIL PROTECTED]>
> >Subject: RE: To dynamicaly update colour on SVG file
> >Date: Fri, 12 Jul 2002 12:59:39 +0530
> >
> >Hi arvind,
> > If you have access to the SVGDocument object you can set the new
> >color in the dom and re-render it. OR there is something as dynamic
> >property
> >you can make use of it.
> >
> >Bala
> >
> >-----Original Message-----
> >From: Arvind Sareen [mailto:[EMAIL PROTECTED]]
> >Sent: Friday, July 12, 2002 12:34 PM
> >To: [EMAIL PROTECTED]
> >Subject: To dynamicaly update colour on SVG file
> >
> >
> >
> >Hi
> >
> >I need to dynamically update the colour of the line displayed in the SVG
> >file(i.e. once an SVG file is displayed , I need to change the colour of
> >the
> >
> >line depending upon the user input)
> >Can anybody provide a workaround or solution to the above problem.
> >
> >Arvind
> >
> >_________________________________________________________________
> >Join the world's largest e-mail service with MSN Hotmail.
> >http://www.hotmail.com
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >"THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
> >ADDRESSEE and may contain confidential and privileged information.
> >If the reader of this message is not the intended recipient,
> >you are notified that any dissemination, distribution or copy of this
> >communication is strictly Prohibited.
> >If you have received this message by error, please notify us
> >immediately, return the original mail to the sender and delete the
> >message from your system."
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
signature.asc
Description: This is a digitally signed message part
