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 wo...@free.fr on 2005/06/30 12:50:18 UTC

RE:help me please clipping svg

ok but
for my job, the entreprise show a region ( "departement","comune" of a french
city)

And i want to save an area of the map and save it into an another svg
document.(clipping)
give an example of a this because i think can't understand easily.

thanks for all


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


Re: help me please clipping svg (see it thomas)

Posted by Bastien DEBLAIS <bd...@iftechnologies.net>.
When i code what you and with input.getDocument()

i have this code error :
org.apache.jasper.JasperException: domFactory should not be null


and the domFactory its the doc when i use it in th graphics2D



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


Re: help me please clipping svg (see it thomas)

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Bastien,

Bastien DEBLAIS wrote:
> This my new code of clipping
> but i cant associat the SVGGraphics2D with my svgreader
> see and tell me if my clipping is good and if something must be coded

    You need to build the GVT tree and call the paint method on the
root SVG element:

import org.apache.batik.bridge.UserAgent;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.bridge.DocumentLoader;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.gvt.GraphicsNode;


	SVGDocument    svgDoc;
         UserAgent      userAgent;
         DocumentLoader loader;
         BridgeContext  ctx;
         GVTBuilder     builder;
	GraphicsNode   gn;

         userAgent = new UserAgentAdapter();
         loader    = new DocumentLoader(userAgent);
	ctx       = new BridgeContext(userAgent, loader);
         builder   = new GVTBuilder();
         gn        = builder.build(ctx, svgDoc);
	gn.paint(svgGraphics2D);

         svgGraphics2D.stream(....);

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


Re: RE:help me please clipping svg (see it thomas)

Posted by Bastien DEBLAIS <bd...@iftechnologies.net>.
This my new code of clipping
but i cant associat the SVGGraphics2D with my svgreader
see and tell me if my clipping is good and if something must be coded

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




//int width = Integer.parseInt(parama);
          //int height = Integer.parseInt(paramb);

          SVGTranscoder trans = new SVGTranscoder();


          // Creation d un transcoder input
          FileInputStream instream = new FileInputStream(rep+Entree);
          InputStreamReader istream  = new InputStreamReader(instream);
          TranscoderInput input = new TranscoderInput(istream);

          String svgURI = new File(rep+Entree).toURL().toString();
          TranscoderInput input1 = new TranscoderInput(svgURI);


          //recupere le document pour le clipper
          Document doc = input1.getDocument();

          String moi = input1.getURI();
          out.println("moi = " + moi);

          //erreur dom factory should not be null->mon doc quand je le
recupere doit etre null
          //comment lire un fichier puis lui associe une action
          //construction du graphics2D mais associe avec le document ouvert




          SVGGraphics2D sg2D = new SVGGraphics2D(doc);
          sg2D.setClip(0,0,100,100);

          sg2D.stream(rep+Sortie);


          // Creation d un transcoder output
          /*  OutputStream ostream */
          /*
          FileOutputStream outstream = new FileOutputStream(rep+Sortie);
          OutputStreamWriter ostream = new OutputStreamWriter(outstream);
          TranscoderOutput output = new TranscoderOutput(ostream);

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

          // Sauvegarde de l image
          trans.transcode(input,output);

          */







/**************************************/
----- Original Message ----- 
From: "Bastien DEBLAIS" <bd...@iftechnologies.net>
Newsgroups: gmane.text.xml.batik.user
Sent: Thursday, June 30, 2005 1:52 PM
Subject: Re: RE:help me please clipping svg (see it thomas)


> re Thomas
> i already send an message before with my code see it
> just to tell ma how to save the clipping in an another svg
>
>
> thanks
>
>
>
>
> ----- Original Message ----- 
> From: <wo...@free.fr>
> Newsgroups: gmane.text.xml.batik.user
> Sent: Thursday, June 30, 2005 12:50 PM
> Subject: RE:help me please clipping svg
>
>
> > ok but
> > for my job, the entreprise show a region ( "departement","comune" of a
> french
> > city)
> >
> > And i want to save an area of the map and save it into an another svg
> > document.(clipping)
> > give an example of a this because i think can't understand easily.
> >
> > thanks for all




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


Re: RE:help me please clipping svg (see it thomas)

Posted by Bastien DEBLAIS <bd...@iftechnologies.net>.
see at wolfyp64 before i do a code and i want to clip a rectangle
(0,0100,100) but i cant arrive how to lie the read svg with the cliping and
save the clipping into an another svg
----- Original Message ----- 
From: "Bastien DEBLAIS" <bd...@iftechnologies.net>
Newsgroups: gmane.text.xml.batik.user
Sent: Thursday, June 30, 2005 1:52 PM
Subject: Re: RE:help me please clipping svg (see it thomas)


> re Thomas
> i already send an message before with my code see it
> just to tell ma how to save the clipping in an another svg
>
>
> thanks
>
>
>
>
> ----- Original Message ----- 
> From: <wo...@free.fr>
> Newsgroups: gmane.text.xml.batik.user
> Sent: Thursday, June 30, 2005 12:50 PM
> Subject: RE:help me please clipping svg
>
>
> > ok but
> > for my job, the entreprise show a region ( "departement","comune" of a
> french
> > city)
> >
> > And i want to save an area of the map and save it into an another svg
> > document.(clipping)
> > give an example of a this because i think can't understand easily.
> >
> > thanks for all




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


Re: RE:help me please clipping svg (see it thomas)

Posted by Bastien DEBLAIS <bd...@iftechnologies.net>.
re Thomas
i already send an message before with my code see it
just to tell ma how to save the clipping in an another svg


thanks




----- Original Message ----- 
From: <wo...@free.fr>
Newsgroups: gmane.text.xml.batik.user
Sent: Thursday, June 30, 2005 12:50 PM
Subject: RE:help me please clipping svg


> ok but
> for my job, the entreprise show a region ( "departement","comune" of a
french
> city)
>
> And i want to save an area of the map and save it into an another svg
> document.(clipping)
> give an example of a this because i think can't understand easily.
>
> thanks for all




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


Re: RE:help me please clipping svg

Posted by Bastien DEBLAIS <bd...@iftechnologies.net>.
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