xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan" <jvd...@hotmail.com>
Subject Re: Automatically size svg drawing to applet window?
Date Sat, 31 Dec 2005 11:39:37 GMT

I finally found out why my svg images didn't size to the applet window; during the testing
I removed the width, height and viewbox by mistake. When you set the viewbox to width and
hight of the svg or when you set the width and hight to 100%, the svg is automatically scalled
to the canvas size.

  ----- Original Message ----- 
  From: Jan 
  To: batik-users@xmlgraphics.apache.org 
  Sent: Wednesday, December 28, 2005 6:28 PM
  Subject: Automatically size svg drawing to applet window?


  I think the mail didn't work, so excuse me if you got this message twice.


  A colleague of my made an applet to draw SVG images in an applet window. I changed it a
little to let it work in the Jetty web server. Now it works fine. The applet opens full screen,
but the SVG is drawn in the upper left corner. I can zoom and pan, but I would like the applet
to open full screen with the SVG maximized. To be honest I new very little about Java. I can
understand the code and compile Java, but know too little to write Java that opens the SVG
full screen. 


  Can somebody help me? 


  The applet and the HTML code to call the applet are given below.




  The applet I use to draw the SVG is as follows:

  import java.awt.*;
  import java.awt.event.*;
  import java.io.*;
  import java.net.URL;
  import java.net.MalformedURLException;
  import javax.swing.JApplet;
  import org.apache.batik.swing.*;
  import org.apache.batik.swing.gvt.*;

  import org.w3c.dom.DOMException;
  import org.w3c.dom.svg.SVGRect;

  public class ShowImage extends JApplet {

   JSVGCanvas svgCanvas;

     public void init() {
        svgCanvas = new JSVGCanvas();
        this.add(svgCanvas, BorderLayout.CENTER);
          String img;         //the images to be displayed
          URL url = null;

          //Get the applet parameters.
          String at = getParameter("imageName");
          img = (at != null) ? at : "image";
          System.err.println("parameter imageName: " + img);

          try {
              url = new URL(img);
          } catch (MalformedURLException e) {
              System.err.println("Malformed URL: " + img);
          System.err.println("URL: " + url.toString());



  The applet is called as follows:

  <STYLE type="text/css">
  body {background-color: white; color: black; text-align: center;
  <APPLET code="ShowImage" codebase="lib/" archive="batik-all.jar,xerces_2_5_0.jar,xml-apis.jar"
width="95%" height="95%" >
  <PARAM name="imageName" value="http://localhost:8585/data/images/svg/fig918220244700500.svg"/>
  <br />Use: <b>SHIFT left mouse button</b> to zoom and <b>SHIFT right
mouse button</b> to pan
View raw message