xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan" <jvd...@hotmail.com>
Subject Automatically size svg drawing to applet window?
Date Wed, 28 Dec 2005 17:28:05 GMT
Hi,



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.



Regards, 

 

Jan



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());

        svgCanvas.setURI(url.toString());

        getContentPane().add(svgCanvas);
 }
}

The applet is called as follows:

<HTML>
<HEAD>
<TITLE>',imgtitle,'</TITLE>
<STYLE type="text/css">
body {background-color: white; color: black; text-align: center;
</STYLE>
</HEAD>
<BODY>
<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"/>
</APPLET>
<br />Use: <b>SHIFT left mouse button</b> to zoom and <b>SHIFT right
mouse button</b> to pan
</BODY>
</HTML>
Mime
View raw message