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(); }
@Override public void setInput(Object pInput, boolean seekForwardOnly, boolean ignoreMetadata) { super.setInput(pInput, seekForwardOnly, ignoreMetadata); if (imageInput != null) { TranscoderInput input = new TranscoderInput(IIOUtil.createStreamAdapter(imageInput)); rasterizer.setInput(input); } }
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(); }
String uri = input.getURI(); if (input.getDocument() != null) { document = input.getDocument(); } else { String parserClassname = f.setValidating(validating); try { if (input.getInputStream() != null) { document = f.createDocument(namespaceURI, documentElement, input.getURI(), input.getInputStream()); } else if (input.getReader() != null) { document = f.createDocument(namespaceURI, documentElement, input.getURI(), input.getReader()); } else if (input.getXMLReader() != null) { document = f.createDocument(namespaceURI, documentElement, input.getURI(), input.getXMLReader()); } else if (uri != null) { document = f.createDocument(namespaceURI,
/** * Transcodes the specified input in the specified output. * @param input the input to transcode * @param output the ouput where to transcode * @exception TranscoderException if an error occured while transcoding */ public void transcode(TranscoderInput input, TranscoderOutput output) throws TranscoderException { Reader r = input.getReader(); Writer w = output.getWriter(); if (r == null) { Document d = input.getDocument(); if (d == null) { throw new Error("Reader or Document expected"); } StringWriter sw = new StringWriter( 1024 ); try { DOMUtilities.writeDocument(d, sw); } catch ( IOException ioEx ) { throw new Error("IO:" + ioEx.getMessage() ); } r = new StringReader(sw.toString()); } if (w == null) { throw new Error("Writer expected"); } prettyPrint(r, w); }
InputStream in = input.getInputStream(); if (in != null){ return new DataInputStream(new BufferedInputStream(in)); String uri = input.getURI(); if (uri != null){ try{
TranscoderInput input = new TranscoderInput(new FileInputStream(svgFile));
String uri = input.getURI(); if (input.getDocument() != null) { document = input.getDocument(); } else { String parserClassname = f.setValidating(validating); try { if (input.getInputStream() != null) { document = f.createDocument(namespaceURI, documentElement, input.getURI(), input.getInputStream()); } else if (input.getReader() != null) { document = f.createDocument(namespaceURI, documentElement, input.getURI(), input.getReader()); } else if (input.getXMLReader() != null) { document = f.createDocument(namespaceURI, documentElement, input.getURI(), input.getXMLReader()); } else if (uri != null) { document = f.createDocument(namespaceURI,
/** * Transcodes the specified input in the specified output. * @param input the input to transcode * @param output the ouput where to transcode * @exception TranscoderException if an error occured while transcoding */ public void transcode(TranscoderInput input, TranscoderOutput output) throws TranscoderException { Reader r = input.getReader(); Writer w = output.getWriter(); if (r == null) { Document d = input.getDocument(); if (d == null) { throw new RuntimeException("Reader or Document expected"); } StringWriter sw = new StringWriter( 1024 ); try { DOMUtilities.writeDocument(d, sw); } catch ( IOException ioEx ) { throw new RuntimeException("IO:" + ioEx.getMessage() ); } r = new StringReader(sw.toString()); } if (w == null) { throw new RuntimeException("Writer expected"); } prettyPrint(r, w); }
InputStream in = input.getInputStream(); if (in != null){ return new DataInputStream(new BufferedInputStream(in)); String uri = input.getURI(); if (uri != null){ try{
transcoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH, w); transcoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, h); transcoder.transcode(new TranscoderInput(in), new TranscoderOutput(out));
TranscoderInput input = new TranscoderInput(new FileInputStream(svgFile)); ImageTranscoder t = new ImageTranscoder() {
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); } }
/** * Constructs a new SVGRasterizer converter. * * @param istream the input stream that represents the SVG document to * rasterize */ public SVGRasterizer(InputStream istream) { this.input = new TranscoderInput(istream); }
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()))); } }
/** * Constructs a new SVGRasterizer. * * @param uri the uri of the document to rasterize */ public SVGRasterizer(String uri) { this.input = new TranscoderInput(uri); }
TranscoderInput input = new TranscoderInput(svgStream); TranscoderOutput output = new TranscoderOutput(outStream);
/** * Constructs a new SVGRasterizer converter. * * @param reader the reader that represents the SVG document to rasterize */ public SVGRasterizer(Reader reader) { this.input = new TranscoderInput(reader); }