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 kloassie <sp...@hotmail.com> on 2006/06/14 16:18:29 UTC

scaling the document itself, not the image on display

Hi there,

is there in the batik library a method to scale all the elements of an svg
document? All I could find is ways to scale the image build from the
document at the moment you want to display it.

Best regards,

Klaas
--
View this message in context: http://www.nabble.com/scaling-the-document-itself%2C-not-the-image-on-display-t1786437.html#a4865733
Sent from the Batik - Users forum at Nabble.com.


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


Re: scaling the document itself, not the image on display

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

On Wed, 2006-06-14 at 07:18 -0700, kloassie wrote:
> Hi there,
> 
> is there in the batik library a method to scale all the elements of an svg
> document? All I could find is ways to scale the image build from the
> document at the moment you want to display it.

There are several ways to scale svg
1) use g element with transform scale attribute and put everything under
that g element
2) use viewbox attribute 
3) iterate over all element, and scale it one by one
4) etc

Depending on your need, some scale methods may or may not appropriate.

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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


Re: How to rotate a complete SVG ?

Posted by André Ávila <as...@nextech.com.br>.
Hi Maik,

If you're using the JSVGCanvas you can simply create a rotate
AffineTransform, concatenate it with the current transform (obtained by
calling getRenderingTransform()) and apply the fnal transform to the
JSVGCanvas (with setRenderingTransform()).

----- Original Message ----- 
From: "Maik Schürer" <Ma...@proveo.de>
To: <ba...@xmlgraphics.apache.org>
Sent: Wednesday, June 28, 2006 11:36 AM
Subject: How to rotate a complete SVG ?


> Hi there,
> I want to rotate the whole SVG (root Element) for a given value of
> degrees. How can I do that?
> Best regards,
> Maik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


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


RE: How to rotate a complete SVG ?

Posted by sugawara <su...@humane-systems.co.jp>.
Hi Maik,

Rotation is not available for the root element.
Instead, you can do it by specifying a <g> element
with a transform attribute like follows:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="400px" height="400px" version="1.1"
xmlns="http://www.w3.org/2000/svg">
    <g transform="rotate(45 200 200)">
        <!-- all elements under ur original root element here -->
    </g>
</svg>

Hope it helps,
Shin

> -----Original Message-----
> From: Maik SchEer [mailto:Maik.Schuerer@proveo.de]
> Sent: Wednesday, June 28, 2006 11:37 PM
> To: batik-users@xmlgraphics.apache.org
> Subject: How to rotate a complete SVG ?
>
>
> Hi there,
> I want to rotate the whole SVG (root Element) for a given value of
> degrees. How can I do that?
> Best regards,
> Maik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>



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


How to rotate a complete SVG ?

Posted by Maik Schürer <Ma...@proveo.de>.
Hi there,
I want to rotate the whole SVG (root Element) for a given value of 
degrees. How can I do that?
Best regards,
Maik


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


RE: Streaming SVG Document without creating temporary file

Posted by Dylan Browne <db...@mango-solutions.com>.
Thanks Javid and Thomas for the replies,

 

Have got it working now after reading your suggestions.... just to close the
thread in case anyone else is looking for similar in the future, required
code looks something like this (of course adding the flushing/closing of
streams).....

 

            TranscoderInput input = new TranscoderInput(doc);

            OutputStream ostream = new ByteArrayOutputStream();

            TranscoderOutput output = new TranscoderOutput(ostream);

            t.transcode(input, output);

            ByteArrayOutputStream result =
(ByteArrayOutputStream)output.getOutputStream();

byte[] bytes = result.toByteArray();

 

Thanks as ever for the help,

 

Cheers,

Dylan.

 

 

-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Sent: 19 June 2006 21:07
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: Re: Streaming SVG Document without creating temporary file

 

Hi Dylan,

 

"Dylan Browne" <db...@mango-solutions.com> wrote on 06/19/2006 07:25:57 

AM:

 

> I was looking for way to improve my code where I stream an SVG Document 

> (created using Batik DOM) to a browser. So basically I need to get from 

SVG 

> Document to a byte[] which can be passed via Servlet which sets the Mime 

type,

> and so displayed. 

 

   Well the transcoder can take _any_ OutputStream.  Usually the

servlet provides an output stream that could be passed directly to

the Transcoder.  Alternately you can use java.io.ByteArrayOutputStream

which simply stores all the content in memory which you can retrieve

as a byte[].

 

> Currently I use my method below, but as part of this method I am 

creating a 

> file object and retrieving my byte[] from that. Ideally (it may actually 

 

> become a requirement) I?d like to avoid this step and be able to 

retrieve a 

> byte[] without creating a file object.

 

>             OutputStream ostream = new FileOutputStream("c:\\out." + 

mimeType);

>             TranscoderOutput output = new TranscoderOutput(ostream);

 

 

---------------------------------------------------------------------

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org

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


Re: Streaming SVG Document without creating temporary file

Posted by th...@kodak.com.
Hi Dylan,

"Dylan Browne" <db...@mango-solutions.com> wrote on 06/19/2006 07:25:57 
AM:

> I was looking for way to improve my code where I stream an SVG Document 
> (created using Batik DOM) to a browser. So basically I need to get from 
SVG 
> Document to a byte[] which can be passed via Servlet which sets the Mime 
type,
> and so displayed. 

   Well the transcoder can take _any_ OutputStream.  Usually the
servlet provides an output stream that could be passed directly to
the Transcoder.  Alternately you can use java.io.ByteArrayOutputStream
which simply stores all the content in memory which you can retrieve
as a byte[].

> Currently I use my method below, but as part of this method I am 
creating a 
> file object and retrieving my byte[] from that. Ideally (it may actually 

> become a requirement) I?d like to avoid this step and be able to 
retrieve a 
> byte[] without creating a file object.

>             OutputStream ostream = new FileOutputStream("c:\\out." + 
mimeType);
>             TranscoderOutput output = new TranscoderOutput(ostream);


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


RE: Streaming SVG Document without creating temporary file

Posted by Javid Alimohideen <ja...@gmail.com>.
Hi Dylan,
When you say streaming, do you mean something like streaming animation, or
its just a dynamic document that is rendered on the server side.. The way I
do it in my application I render the SVG on the server side and just stream
the pixels to the client side (application, or a browser window). You could
acheive the same with servlet too. If you would like to do offscreen server
side rendering, take a look at the Batik wiki pages.

Thanks,
Javid
  -----Original Message-----
  From: Dylan Browne [mailto:dbrowne@mango-solutions.com]
  Sent: Monday, June 19, 2006 6:26 AM
  To: batik-users@xmlgraphics.apache.org
  Subject: Streaming SVG Document without creating temporary file


  Hi,



  I was looking for way to improve my code where I stream an SVG Document
(created using Batik DOM) to a browser. So basically I need to get from SVG
Document to a byte[] which can be passed via Servlet which sets the Mime
type, and so displayed.



  Currently I use my method below, but as part of this method I am creating
a file object and retrieving my byte[] from that. Ideally (it may actually
become a requirement) I'd like to avoid this step and be able to retrieve a
byte[] without creating a file object.



  Thanks in advance for any help,



  Regards,

  Dylan







      public static void streamSVGIntoImageFormat(HttpSession session,
Document doc, String mimeType) {

          try {

              ImageTranscoder t = null;

              if (mimeType.equals(Config.JPEG)) {

                  t = new JPEGTranscoder();

                  t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new
Float(.8));

              } else if (mimeType.equals(Config.PNG)) {

                  t = new PNGTranscoder();

              } else if (mimeType.equals(Config.TIFF)) {

                  t = new TIFFTranscoder();

              } else {

                  System.out.println("ERROR: A request to stream an image
was recieved with an unsupported mime type: " + mimeType);

                  return;

              }

              TranscoderInput input = new TranscoderInput(doc);

              OutputStream ostream = new FileOutputStream("c:\\out." +
mimeType);

              TranscoderOutput output = new TranscoderOutput(ostream);

              t.transcode(input, output);

              ostream.flush();

              ostream.close();

              byte[] bytes = getBytesFromFile(new File("c:\\out." +
mimeType));

              session.setAttribute("jpegbytes", bytes);

              session.setAttribute("mimeType", mimeType);

          } catch (Exception e) {

              e.printStackTrace();

              System.out.println("Error in streaming SVG because " +
e.getMessage());

          }

      }







Streaming SVG Document without creating temporary file

Posted by Dylan Browne <db...@mango-solutions.com>.
Hi,

 

I was looking for way to improve my code where I stream an SVG Document
(created using Batik DOM) to a browser. So basically I need to get from SVG
Document to a byte[] which can be passed via Servlet which sets the Mime
type, and so displayed. 

 

Currently I use my method below, but as part of this method I am creating a
file object and retrieving my byte[] from that. Ideally (it may actually
become a requirement) I'd like to avoid this step and be able to retrieve a
byte[] without creating a file object.

 

Thanks in advance for any help,

 

Regards,

Dylan

 

 

 

    public static void streamSVGIntoImageFormat(HttpSession session,
Document doc, String mimeType) {

        try {

            ImageTranscoder t = null;

            if (mimeType.equals(Config.JPEG)) {

                t = new JPEGTranscoder();

                t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new
Float(.8));

            } else if (mimeType.equals(Config.PNG)) {

                t = new PNGTranscoder();

            } else if (mimeType.equals(Config.TIFF)) {

                t = new TIFFTranscoder();

            } else {

                System.out.println("ERROR: A request to stream an image was
recieved with an unsupported mime type: " + mimeType);

                return;

            }

            TranscoderInput input = new TranscoderInput(doc);

            OutputStream ostream = new FileOutputStream("c:\\out." +
mimeType);

            TranscoderOutput output = new TranscoderOutput(ostream);

            t.transcode(input, output);

            ostream.flush();

            ostream.close();

            byte[] bytes = getBytesFromFile(new File("c:\\out." +
mimeType));

            session.setAttribute("jpegbytes", bytes);

            session.setAttribute("mimeType", mimeType);

        } catch (Exception e) {

            e.printStackTrace();

            System.out.println("Error in streaming SVG because " +
e.getMessage());

        }

    }