MyTranscoder transcoder = new MyTransCoder(); TranscodingHints hints = new TranscodingHints(); hints.put(ImageTranscoder.KEY_WIDTH, width); hints.put(ImageTranscoder.KEY_HEIGHT, height); transcoder.setTranscodingHints(hints); transcoder.transcode(new TranscoderInput(url), null); BufferedImage image = transcoder.getImage();
DOMImplementation impl = (DOMImplementation) hints.get(KEY_DOM_IMPLEMENTATION); document = DOMUtilities.deepCloneDocument(document, impl); (hints.containsKey(KEY_EXECUTE_ONLOAD) && (Boolean) hints.get(KEY_EXECUTE_ONLOAD) && BaseScriptingEnvironment.isDynamicDocument(ctx, svgDoc));
/** * Sets the uri of the user stylesheet. The user stylesheet can be used to * override styles. * * @param uri the uri of the user stylesheet */ public void setUserStyleSheetURI(String uri) { hints.put(ImageTranscoder.KEY_USER_STYLESHEET_URI, uri); }
/** * Returns the pixel to millimeter conversion factor specified in the * <code>TranscodingHints</code> or 0.26458333 if not specified. */ public float getPixelUnitToMillimeter() { Object obj = SVGAbstractTranscoder.this.hints.get (KEY_PIXEL_UNIT_TO_MILLIMETER); if (obj != null) { return ((Float)obj).floatValue(); } return super.getPixelUnitToMillimeter(); }
/** * Copies all of the mappings from the specified <code>Map</code> * to this <code>TranscodingHints</code>. * * @param m mappings to be stored in this <code>TranscodingHints</code>. * @exception ClassCastException key is not of type * <code>TranscodingHints.Key</code> */ public void putAll(Map m) { if (m instanceof TranscodingHints) { putAll(((TranscodingHints) m)); } else { for (Object o : m.entrySet()) { Map.Entry entry = (Map.Entry) o; put(entry.getKey(), entry.getValue()); } } }
/** * Returns a copy of the transcoding hints of this transcoder. */ public TranscodingHints getTranscodingHints() { return new TranscodingHints(hints); }
public PDFPrinter(List<String> svg) throws TranscoderException { this.svg = svg; graphics = new PDFDocumentGraphics2D(isTextStroked()); graphics.getPDFDocument().getInfo().setProducer("Apache FOP Version " + Version.getVersion() + ": PDF Transcoder for Batik"); if (hints.containsKey(KEY_DEVICE_RESOLUTION)) { graphics.setDeviceDPI(getDeviceResolution()); } try { Configuration effCfg = getEffectiveConfiguration(); if (effCfg != null) { PDFDocumentGraphics2DConfigurator configurator = new PDFDocumentGraphics2DConfigurator(); boolean useComplexScriptFeatures = false; //TODO - FIX ME configurator.configure(graphics, effCfg, useComplexScriptFeatures); } else { graphics.setupDefaultFontInfo(); } ((FOPTranscoderUserAgent) userAgent).setFontFamilyResolver( new FOPFontFamilyResolverImpl(graphics.getFontInfo())); } catch (Exception e) { throw new TranscoderException( "Error while setting up PDFDocumentGraphics2D", e); } }
/** * Replaces the values of all preferences for the transcoding algorithms * with the specified hints. * @param hints the rendering hints to be set */ public void setTranscodingHints(Map hints) { this.hints.putAll(hints); }
/** * Removes the value of a single preference for the transcoding process. * @param key the key of the hint to remove */ public void removeTranscodingHint(TranscodingHints.Key key) { hints.remove(key); }
if (hints.containsKey(KEY_AOI)) { Rectangle2D aoi = (Rectangle2D) hints.get(KEY_AOI); if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) { Paint bgcolor = (Paint) hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR); g2d.setComposite(AlphaComposite.SrcOver); g2d.setPaint(bgcolor);
/** * Sets the alternate stylesheet to use. For further details, you can have * a look at the <a href="http://www.w3.org/TR/xml-stylesheet/">Associating * Style Sheets with XML documents</a>. * * @param alternateStylesheet the alternate stylesheet to use if possible */ public void setAlternateStylesheet(String alternateStylesheet) { hints.put(ImageTranscoder.KEY_ALTERNATE_STYLESHEET, alternateStylesheet); }
/** * Returns this user agent's CSS media. */ public String getMedia() { String s = (String)hints.get(KEY_MEDIA); if (s != null) return s; return super.getMedia(); }
/** * Copies all of the mappings from the specified <code>Map</code> * to this <code>TranscodingHints</code>. * * @param m mappings to be stored in this <code>TranscodingHints</code>. * @exception ClassCastException key is not of type * <code>TranscodingHints.Key</code> */ public void putAll(Map m) { if (m instanceof TranscodingHints) { putAll(((TranscodingHints) m)); } else { Iterator iter = m.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Returns a copy of the transcoding hints of this transcoder. */ public TranscodingHints getTranscodingHints() { return new TranscodingHints(hints); }
/** * Constructs a new <code>TranscodingHints</code> with keys and values * initialized from the specified Map object (which may be null). * * @param init a map of key/value pairs to initialize the hints * or null if the object should be empty */ public TranscodingHints(Map init) { super(7); if (init != null) { putAll(init); } }
/** * Removes the value of a single preference for the transcoding process. * @param key the key of the hint to remove */ public void removeTranscodingHint(TranscodingHints.Key key) { hints.remove(key); }
/** * Returns the device resolution that has been set up. * @return the device resolution (in dpi) */ protected float getDeviceResolution() { if (hints.containsKey(KEY_DEVICE_RESOLUTION)) { return (Float) hints.get(KEY_DEVICE_RESOLUTION); } else { return GraphicsConstants.DEFAULT_DPI; } }
/** * Constructs a new transcoder that produces tiff images. */ public TIFFTranscoder() { hints.put(KEY_FORCE_TRANSPARENT_WHITE, Boolean.FALSE); }
FileUtils.writeStringToFile(cssFile, css); TranscodingHints transcoderHints = new TranscodingHints(); transcoderHints.put(ImageTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE); transcoderHints.put(ImageTranscoder.KEY_DOM_IMPLEMENTATION, SVGDOMImplementation.getDOMImplementation()); transcoderHints.put(ImageTranscoder.KEY_DOCUMENT_ELEMENT_NAMESPACE_URI, SVGConstants.SVG_NAMESPACE_URI); transcoderHints.put(ImageTranscoder.KEY_DOCUMENT_ELEMENT, "svg"); transcoderHints.put(ImageTranscoder.KEY_USER_STYLESHEET_URI, cssFile.toURI().toString());
/** * Returns the user stylesheet specified in the * <code>TranscodingHints</code> or null if any. */ public String getUserStyleSheetURI() { String s = (String)SVGAbstractTranscoder.this.hints.get (KEY_USER_STYLESHEET_URI); if (s != null) return s; return super.getUserStyleSheetURI(); }