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 Bastien DEBLAIS <bd...@iftechnologies.net> on 2005/07/01 10:47:14 UTC

Re: RE:help me please clipping svg

i have the same problem. Link (associate) the svg document with the
graphics2D

this my code to do a clipping with a svg document :

/******************************************/


<FORM>
   fichier (*.svg): <INPUT NAME="Ficsvg"><BR>
   nouveau_fichier (*.svg): <INPUT NAME="Ficnsvg"><BR>
   dimension (WIDTH): <INPUT NAME="width"><BR>
   dimension (HEIGHT): <INPUT NAME="height"><P>
   <INPUT TYPE=SUBMIT VALUE="Send It!">
   </FORM>
   <%

   String Entree = (String) request.getParameter("Ficsvg");
   String Sortie = (String) request.getParameter("Ficnsvg");

    //declaration variable
    String rep="c:/pierrestage/WebApplication3/";

    if((Entree!=null)&&(Sortie!=null))
    {
     File fic = new File(rep+Entree);
     out.println("Le fichier existe : " + fic.exists());
     if(fic.exists()==true)
     {
        String parama = (String)request.getParameter("width");
        String paramb = (String)request.getParameter("height");

        if((parama==null)&&(paramb==null))
         {
         out.println("entrez les valeurs width et height de l image a
afficher");
         }
        else
         {
          //int width = Integer.parseInt(parama);
          //int height = Integer.parseInt(paramb);

          String svgURI = new File(rep+Entree).toURL().toString();
          out.println("svgURI = "+svgURI);

          DOMImplementation impl =
GenericDOMImplementation.getDOMImplementation();

          //normalement je recupere a partir de svgURI et je met sous forme
d un document
          //le probleme se trouve soit a ce niveau pour charger le input
          //soit c'est le stream pour creer le fichier de Sortie
          //ici je creer un nouveau document c'est pas bon
          Document doc = impl.createDocument(svgURI, "svg", null);

          //comment lire un fichier puis lui associe une action
          //construction du graphics2D mais associe avec le document ouvert
svg
          SVGGraphics2D sg2D = new SVGGraphics2D(doc);

          //fais le clipping un rectagle
          sg2D.setClip(0,0,300,300);
          sg2D.drawString("test marche ou pas",100,150);
          sg2D.drawLine(200,200,250,200) ;
          sg2D.setSVGCanvasSize(new Dimension(640,480));
          //le clipping marche donc je ne charge pas le document
          /*change la valeur height et width de mon clipping
          le texte s affiche en entier ou pas en fonction de cette taille
          /*ca marche pour l affichage d un texte
          pourkoi pour le clipping: je ne charge pas le document svg*/
           //ecrit normalement sur le fichier de sortie mon clipping
          sg2D.stream(rep+Sortie);

          out.println("fichier " + Sortie + " a été généré");

        %>
             <embed id="idEmbedMap"  src="<%=rep+Sortie%>"
type="image/svg+xml" width="800" height="600">
     </embed>
        <%
          }
        }
     }
    %>


/******************************************/


thanks if you find my problem and explain me how to solve this




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