Changeset 30226 in osm for applications/editors/josm/plugins/smed2/jrender/src/jrender/Jrender.java
- Timestamp:
- 2014-01-25T17:56:23+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/jrender/src/jrender/Jrender.java
r30184 r30226 11 11 12 12 import java.io.File; 13 import java.io.FileOutputStream; 14 import java.io.IOException; 15 import java.io.OutputStreamWriter; 16 import java.io.Writer; 17 import java.util.ArrayList; 13 18 import java.awt.Color; 19 import java.awt.Dimension; 14 20 import java.awt.Graphics; 15 21 import java.awt.Graphics2D; … … 21 27 import javax.swing.JFrame; 22 28 29 import org.apache.batik.svggen.SVGGraphics2D; 30 import org.apache.batik.svggen.SVGGraphics2DIOException; 31 import org.apache.batik.dom.GenericDOMImplementation; 32 import org.w3c.dom.Document; 33 import org.w3c.dom.DOMImplementation; 34 23 35 import symbols.*; 24 import symbols.Symbols. Scheme;36 import symbols.Symbols.*; 25 37 import render.*; 26 38 27 39 public class Jrender extends Panel { 28 private static final long serialVersionUID = 1L;29 40 30 41 public static void main(String[] args) { … … 38 49 frame.setSize(256, 256); 39 50 frame.setVisible(true); 40 /*41 for (int x = 0; x < 4; x++) {42 for (int y = 0; y < 4; y++) {43 img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);44 g2 = img.createGraphics();45 g2.translate(-(x*256), -(y*256));46 drawRendering(g2);47 try {48 ImageIO.write(img, "png", new File("tst" + x + "_" + y + ".png"));49 } catch (IOException e) {50 System.out.println("IO Exception");51 }52 }53 }*/54 51 55 img = new BufferedImage( 64, 64, BufferedImage.TYPE_INT_ARGB);52 img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); 56 53 g2 = img.createGraphics(); 57 g2.translate(-32, -32);58 54 drawRendering(g2); 59 55 try { … … 63 59 } 64 60 61 DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); 62 String svgNS = "http://www.w3.org/2000/svg"; 63 Document document = domImpl.createDocument(svgNS, "svg", null); 64 SVGGraphics2D svgGenerator = new SVGGraphics2D(document); 65 svgGenerator.setSVGCanvasSize(new Dimension(256, 256)); 66 drawRendering(svgGenerator); 67 boolean useCSS = true; 68 Writer out = null; 69 try { 70 out = new OutputStreamWriter(new FileOutputStream("/Users/mherring/Desktop/export.svg"), "UTF-8"); 71 } catch (IOException e1) { 72 System.out.println("Exception"); 73 } 74 try { 75 svgGenerator.stream(out, useCSS); 76 } catch (SVGGraphics2DIOException e) { 77 System.out.println("Exception"); 78 } 65 79 } 66 80 67 81 public static void drawRendering(Graphics2D g2) { 68 double scale = Renderer.symbolScale[ 7];82 double scale = Renderer.symbolScale[8]; 69 83 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 70 84 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); 71 // System.out.println("hello"); 72 73 Symbols.drawSymbol(g2, Areas.Seaplane, scale/2, 64.0, 64.0, new Scheme(Color.green), null); 85 Scheme scheme = new Scheme(); scheme.pat.add(Patt.H); scheme.col.add(Color.red); scheme.col.add(Color.yellow); scheme.col.add(Color.green); 86 Symbols.drawSymbol(g2, Buoys.Pillar, scale, 128.0, 128.0, scheme, null); 74 87 } 75 88
Note:
See TracChangeset
for help on using the changeset viewer.