Refine search
@PutMapping(value = "/{modelId}") @ResponseStatus(value = HttpStatus.OK) @Authorize(action = Permission.ACTION_UPDATE) public void saveModel(@PathVariable String modelId, @RequestParam Map<String, String> values) throws TranscoderException, IOException { Model model = repositoryService.getModel(modelId); JSONObject modelJson = JSON.parseObject(model.getMetaInfo()); modelJson.put(MODEL_NAME, values.get("name")); modelJson.put(MODEL_DESCRIPTION, values.get("description")); model.setMetaInfo(modelJson.toString()); model.setName(values.get("name")); repositoryService.saveModel(model); repositoryService.addModelEditorSource(model.getId(), values.get("json_xml").getBytes("utf-8")); InputStream svgStream = new ByteArrayInputStream(values.get("svg_xml").getBytes("utf-8")); TranscoderInput input = new TranscoderInput(svgStream); PNGTranscoder transcoder = new PNGTranscoder(); // Setup output ByteArrayOutputStream outStream = new ByteArrayOutputStream(); TranscoderOutput output = new TranscoderOutput(outStream); // Do the transformation transcoder.transcode(input, output); final byte[] result = outStream.toByteArray(); repositoryService.addModelEditorSourceExtra(model.getId(), result); outStream.close(); }
public void run() { try { currentSavePath = f; OutputStream ostream = new BufferedOutputStream(new FileOutputStream(f)); trans.writeImage(img, new TranscoderOutput(ostream)); ostream.close(); } catch (Exception ex) { } statusBar.setMessage (resources.getString("Message.done")); } }.start();
public void transcode(TranscoderOutput output) throws Exception { OutputStream out = output.getOutputStream(); if (!(out instanceof BufferedOutputStream)) { out = new BufferedOutputStream(out); } graphics.setupDocument(out, 800, 1000); graphics.setSVGDimension(width, height); if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) { graphics.setBackgroundColor( (Color) hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR)); } graphics.setGraphicContext( new org.apache.xmlgraphics.java2d.GraphicContext()); graphics.setRenderingHint( RenderingHintsKeyExt.KEY_TRANSCODING, RenderingHintsKeyExt.VALUE_TRANSCODING_VECTOR); for (String s : svg) { transcode(new TranscoderInput(new StringReader(s)), output); graphics.nextPage(); } graphics.finish(); }
TranscoderOutput output = new TranscoderOutput(stringWriter); output.setOutputStream(System.out); X.transcode(input, output);
OutputStream ostream = output.getOutputStream(); int w = img.getWidth(); int h = img.getHeight();
TranscoderOutput output) throws TranscoderException { Document doc = output.getDocument(); XMLFilter xmlFilter = output.getXMLFilter(); if (xmlFilter != null) { handler.fatalError(new TranscoderException("" + ERROR_INCOMPATIBLE_OUTPUT_TYPE)); OutputStream os = output.getOutputStream(); if (os != null) { svgGenerator.stream(svgRoot, new OutputStreamWriter(os), false, escaped); Writer wr = output.getWriter(); if (wr != null) { svgGenerator.stream(svgRoot, wr, false, escaped); String uri = output.getURI(); if ( uri != null ){ try{
/** Create an empty Document from a TranscoderOutput. * <ul> * <li>If the TranscoderOutput already contains an empty Document : returns this * Document</li> * <li>else create a new empty DOM Document</li> * </ul> */ protected Document createDocument(TranscoderOutput output) { // Use SVGGraphics2D to generate SVG content Document doc; if (output.getDocument() == null) { DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation(); doc = domImpl.createDocument(SVG_NAMESPACE_URI, SVG_SVG_TAG, null); } else { doc = output.getDocument(); } return doc; }
public void run() { try { currentSavePath = f; OutputStream ostream = new BufferedOutputStream(new FileOutputStream(f)); trans.writeImage(img, new TranscoderOutput(ostream)); ostream.close(); } catch (Exception ex) { } statusBar.setMessage (resources.getString("Message.done")); } }.start();
OutputStream ostream = output.getOutputStream(); int w = img.getWidth(); int h = img.getHeight();
TranscoderOutput output) throws TranscoderException { Document doc = output.getDocument(); XMLFilter xmlFilter = output.getXMLFilter(); if (xmlFilter != null) { handler.fatalError(new TranscoderException("" + ERROR_INCOMPATIBLE_OUTPUT_TYPE)); OutputStream os = output.getOutputStream(); if (os != null) { svgGenerator.stream(svgRoot, new OutputStreamWriter(os), false, escaped); Writer wr = output.getWriter(); if (wr != null) { svgGenerator.stream(svgRoot, wr, false, escaped); String uri = output.getURI(); if ( uri != null ){ try{
/** Create an empty Document from a TranscoderOutput. * <ul> * <li>If the TranscoderOutput already contains an empty Document : returns this * Document</li> * <li>else create a new empty DOM Document</li> * </ul> */ protected Document createDocument(TranscoderOutput output) { // Use SVGGraphics2D to generate SVG content Document doc; if (output.getDocument() == null) { DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation(); doc = domImpl.createDocument(SVG_NAMESPACE_URI, SVG_SVG_TAG, null); } else { doc = output.getDocument(); } return doc; }
transcoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH, w); transcoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, h); transcoder.transcode(new TranscoderInput(in), new TranscoderOutput(out));
public void run() { try { currentSavePath = f; OutputStream ostream = new BufferedOutputStream(new FileOutputStream(f)); trans.writeImage(img, new TranscoderOutput(ostream)); ostream.close(); } catch (Exception ex) {} statusBar.setMessage (resources.getString("Message.done")); } }.start();
OutputStream ostream = output.getOutputStream(); int w = img.getWidth(); int h = img.getHeight();
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import org.apache.batik.transcoder.Transcoder; import org.apache.batik.transcoder.TranscoderException; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.fop.svg.PDFTranscoder; public class Test { public static void main(String[] argv) throws TranscoderException, FileNotFoundException { Transcoder transcoder = new PDFTranscoder(); TranscoderInput transcoderInput = new TranscoderInput(new FileInputStream(new File("/tmp/test.svg"))); TranscoderOutput transcoderOutput = new TranscoderOutput(new FileOutputStream(new File("/tmp/test.pdf"))); transcoder.transcode(transcoderInput, transcoderOutput); } }
public void run() { try { currentSavePath = f; OutputStream ostream = new BufferedOutputStream (new FileOutputStream(f)); trans.writeImage (img, new TranscoderOutput(ostream)); ostream.close(); } catch (Exception ex) {} statusBar.setMessage (resources.getString("Message.done")); } }.start();
OutputStream ostream = output.getOutputStream(); int w = img.getWidth(); int h = img.getHeight();
private synchronized void init() throws IOException { // Need the extra test, to avoid throwing an IOException from the Transcoder if (imageInput == null) { throw new IllegalStateException("input == null"); } if (reader == null) { WMFTranscoder transcoder = new WMFTranscoder(); ByteArrayOutputStream output = new ByteArrayOutputStream(); Writer writer = new OutputStreamWriter(output, "UTF8"); try { TranscoderInput in = new TranscoderInput(IIOUtil.createStreamAdapter(imageInput)); TranscoderOutput out = new TranscoderOutput(writer); // TODO: Transcodinghints? transcoder.transcode(in, out); } catch (TranscoderException e) { throw new IIOException(e.getMessage(), e); } reader = new SVGImageReader(getOriginatingProvider()); reader.setInput(ImageIO.createImageInputStream(new ByteArrayInputStream(output.toByteArray()))); } }
public void run() { try { currentSavePath = f; OutputStream ostream = new BufferedOutputStream (new FileOutputStream(f)); trans.writeImage (img, new TranscoderOutput(ostream)); ostream.close(); } catch (Exception ex) {} statusBar.setMessage (resources.getString("Message.done")); } }.start();
OutputStream ostream = output.getOutputStream(); writer.writeImage(img, ostream, params); ostream.flush();