← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 131: Update gis

 

------------------------------------------------------------
revno: 131
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Mon 2009-03-30 17:31:13 +0700
message:
  Update gis
added:
  dhis-2/dhis-web/dhis-web-gis/src/main/java/org/hisp/dhis/gis/util/SVGUtils.java

=== added file 'dhis-2/dhis-web/dhis-web-gis/src/main/java/org/hisp/dhis/gis/util/SVGUtils.java'
--- dhis-2/dhis-web/dhis-web-gis/src/main/java/org/hisp/dhis/gis/util/SVGUtils.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-gis/src/main/java/org/hisp/dhis/gis/util/SVGUtils.java	2009-03-30 10:31:13 +0000
@@ -0,0 +1,62 @@
+package org.hisp.dhis.gis.util;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.image.PNGTranscoder;
+
+public class SVGUtils
+{
+
+    public static void convertSVG2PNG( String inputPath, String outputPath, double w, double h )
+    {
+        // Create a JPEG transcoder
+        PNGTranscoder t = new PNGTranscoder();
+
+        // Set the transcoding hints.
+        t.addTranscodingHint( PNGTranscoder.KEY_HEIGHT,  new Float(h) );
+        t.addTranscodingHint( PNGTranscoder.KEY_WIDTH, new Float(w)  );
+
+        try
+        {
+            // Create the transcoder input.
+            String svgURI = new File( inputPath ).toURL().toString();
+            TranscoderInput input = new TranscoderInput( svgURI );
+            // Create the transcoder output.
+            OutputStream ostream = new FileOutputStream( outputPath );
+            TranscoderOutput output = new TranscoderOutput( ostream );
+
+            // Save the image.
+            t.transcode( input, output );
+
+            // Flush and close the stream.
+            ostream.flush();
+            ostream.close();
+        }
+        catch ( MalformedURLException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( FileNotFoundException e )
+        {            
+            e.printStackTrace();
+        }
+        catch ( TranscoderException e )
+        {           
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {            
+            e.printStackTrace();
+        }
+
+    }
+
+}



--
Trunk
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.