• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TranscodingHints类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.batik.transcoder.TranscodingHints的典型用法代码示例。如果您正苦于以下问题:Java TranscodingHints类的具体用法?Java TranscodingHints怎么用?Java TranscodingHints使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TranscodingHints类属于org.apache.batik.transcoder包,在下文中一共展示了TranscodingHints类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setTranscoderRectangleHint

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
public static void setTranscoderRectangleHint(Transcoder transcoder,
                                              String property,
                                              TranscodingHints.Key key){
    String str = System.getProperty(property);
    if(str != null){
        StringTokenizer st = new StringTokenizer(str, " ,");
        if(st.countTokens() != 4){
            handleValueError(property, str);
        }

        try{
            String x = st.nextToken();
            String y = st.nextToken();
            String width = st.nextToken();
            String height = st.nextToken();
            Rectangle2D r = new Rectangle2D.Float(Float.parseFloat(x),
                                                  Float.parseFloat(y),
                                                  Float.parseFloat(width),
                                                  Float.parseFloat(height));
            transcoder.addTranscodingHint(key, r);
        }catch(NumberFormatException e){
            handleValueError(property, str);
        }
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:26,代码来源:PrintTranscoder.java


示例2: convert

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
private void convert(String svgFileName, String pngFileName)
{
	Transcoder transcoder = new PNGTranscoder();
       Map<TranscodingHints.Key, Float> hints = 
       	new HashMap<TranscodingHints.Key, Float>();
       hints.put(ImageTranscoder.KEY_MAX_HEIGHT, new Float(750));
       hints.put(ImageTranscoder.KEY_MAX_WIDTH, new Float(750));
       transcoder.setTranscodingHints(hints);
	
       try {
        TranscoderInput input = 
        	new TranscoderInput(new File(svgFileName).toURI().toString());
		TranscoderOutput output =
			new TranscoderOutput(new FileOutputStream(pngFileName));
	
		transcoder.transcode(input, output);
	} catch (Exception e) {
		throw new RuntimeException("Transcoding failed.", e);
	}
}
 
开发者ID:donkirkby,项目名称:donkirkby,代码行数:21,代码来源:PaintWriter.java


示例3: convert

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
private void convert(String svgFileName, String pngFileName)
{
	Transcoder transcoder = new PNGTranscoder();
       Map<TranscodingHints.Key, Float> hints = 
       	new HashMap<TranscodingHints.Key, Float>();
       hints.put(ImageTranscoder.KEY_MAX_HEIGHT, new Float(200));
       hints.put(ImageTranscoder.KEY_MAX_WIDTH, new Float(750));
       transcoder.setTranscodingHints(hints);
	
       try {
        TranscoderInput input = 
        	new TranscoderInput(new File(svgFileName).toURI().toString());
		TranscoderOutput output =
			new TranscoderOutput(new FileOutputStream(pngFileName));
	
		transcoder.transcode(input, output);
	} catch (Exception e) {
		throw new RuntimeException("Transcoding failed.", e);
	}
}
 
开发者ID:donkirkby,项目名称:donkirkby,代码行数:21,代码来源:PaintWriter.java


示例4: setTranscoderFloatHint

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
public static void setTranscoderFloatHint(Transcoder transcoder,
                                          String property,
                                          TranscodingHints.Key key){
    String str = System.getProperty(property);
    if(str != null){
        try{
            Float value = new Float(Float.parseFloat(str));
            transcoder.addTranscodingHint(key, value);
        }catch(NumberFormatException e){
            handleValueError(property, str);
        }
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:14,代码来源:PrintTranscoder.java


示例5: setTranscoderBooleanHint

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
public static void setTranscoderBooleanHint(Transcoder transcoder,
                                            String property,
                                            TranscodingHints.Key key){
    String str = System.getProperty(property);
    if(str != null){
        Boolean value = "true".equalsIgnoreCase(str) ? Boolean.TRUE : Boolean.FALSE;
        transcoder.addTranscodingHint(key, value);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:10,代码来源:PrintTranscoder.java


示例6: setTranscoderStringHint

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
public static void setTranscoderStringHint(Transcoder transcoder,
                                          String property,
                                          TranscodingHints.Key key){
    String str = System.getProperty(property);
    if(str != null){
        transcoder.addTranscodingHint(key, str);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:9,代码来源:PrintTranscoder.java


示例7: doExport

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
@Override
@HandlerMethodActivation
public  <T extends FsSecureBusinessObject> byte[] doExport(T sbo, Object params){
	Map<TranscodingHints.Key, Object> hints = new HashMap<TranscodingHints.Key, Object>();
	
	hints.put(PNGTranscoder.KEY_MAX_WIDTH, WIDTH);
	hints.put(PNGTranscoder.KEY_MAX_HEIGHT, HEIGHT);
	
	return getImage(RepresentationType.PNG_SMALL, new PNGTranscoder(), sbo, hints);
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:11,代码来源:ThumbnailHandler.java


示例8: writeImage

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
/**
 * @throws TranscoderException 
 * @see org.apache.batik.transcoder.image.PNGTranscoder.WriteAdapter#writeImage(org.apache.batik.transcoder.image.PNGTranscoder, java.awt.image.BufferedImage, org.apache.batik.transcoder.TranscoderOutput)
 */
public void writeImage(PNGTranscoder transcoder, BufferedImage img,
        TranscoderOutput output) throws TranscoderException {

    TranscodingHints hints = transcoder.getTranscodingHints();

    int n = -1;
    if (hints.containsKey(PNGTranscoder.KEY_INDEXED)) {
        n=((Integer)hints.get(PNGTranscoder.KEY_INDEXED)).intValue();
        if (n==1||n==2||n==4||n==8) 
            //PNGEncodeParam.Palette can handle these numbers only.
            img = IndexImage.getIndexedImage(img, 1<<n);
    }

    ImageWriter writer = ImageWriterRegistry.getInstance()
        .getWriterFor("image/png");
    ImageWriterParams params = new ImageWriterParams();

    /* NYI!!!!!
    PNGEncodeParam params = PNGEncodeParam.getDefaultEncodeParam(img);
    if (params instanceof PNGEncodeParam.RGB) {
        ((PNGEncodeParam.RGB)params).setBackgroundRGB
            (new int [] { 255, 255, 255 });
    }*/

    // If they specify GAMMA key with a value of '0' then omit
    // gamma chunk.  If they do not provide a GAMMA then just
    // generate an sRGB chunk. Otherwise supress the sRGB chunk
    // and just generate gamma and chroma chunks.
    /* NYI!!!!!!
    if (hints.containsKey(PNGTranscoder.KEY_GAMMA)) {
        float gamma = ((Float)hints.get(PNGTranscoder.KEY_GAMMA)).floatValue();
        if (gamma > 0) {
            params.setGamma(gamma);
        }
        params.setChromaticity(PNGTranscoder.DEFAULT_CHROMA);
    }  else {
        // We generally want an sRGB chunk and our encoding intent
        // is perceptual
        params.setSRGBIntent(PNGEncodeParam.INTENT_PERCEPTUAL);
    }*/


    float PixSzMM = transcoder.getUserAgent().getPixelUnitToMillimeter();
    int PixSzInch = (int)(25.4 / PixSzMM + 0.5);
    params.setResolution(PixSzInch);

    try {
        OutputStream ostream = output.getOutputStream();
        writer.writeImage(img, ostream, params);
        ostream.flush();
    } catch (IOException ex) {
        throw new TranscoderException(ex);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:59,代码来源:PNGTranscoderImageIOWriteAdapter.java


示例9: writeImage

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
/**
 * @throws TranscoderException
 * @see org.apache.batik.transcoder.image.PNGTranscoder.WriteAdapter#writeImage(org.apache.batik.transcoder.image.PNGTranscoder, java.awt.image.BufferedImage, org.apache.batik.transcoder.TranscoderOutput)
 */
public void writeImage(PNGTranscoder transcoder, BufferedImage img,
        TranscoderOutput output) throws TranscoderException {
    TranscodingHints hints = transcoder.getTranscodingHints();

    int n=-1;
    if (hints.containsKey(PNGTranscoder.KEY_INDEXED)) {
        n=((Integer)hints.get(PNGTranscoder.KEY_INDEXED)).intValue();
        if (n==1||n==2||n==4||n==8)
            //PNGEncodeParam.Palette can handle these numbers only.
            img = IndexImage.getIndexedImage(img,1<<n);
    }

    PNGEncodeParam params = PNGEncodeParam.getDefaultEncodeParam(img);
    if (params instanceof PNGEncodeParam.RGB) {
        ((PNGEncodeParam.RGB)params).setBackgroundRGB
            (new int [] { 255, 255, 255 });
    }

    // If they specify GAMMA key with a value of '0' then omit
    // gamma chunk.  If they do not provide a GAMMA then just
    // generate an sRGB chunk. Otherwise supress the sRGB chunk
    // and just generate gamma and chroma chunks.
    if (hints.containsKey(PNGTranscoder.KEY_GAMMA)) {
        float gamma = ((Float)hints.get(PNGTranscoder.KEY_GAMMA)).floatValue();
        if (gamma > 0) {
            params.setGamma(gamma);
        }
        params.setChromaticity(PNGTranscoder.DEFAULT_CHROMA);
    }  else {
        // We generally want an sRGB chunk and our encoding intent
        // is perceptual
        params.setSRGBIntent(PNGEncodeParam.INTENT_PERCEPTUAL);
    }


    float PixSzMM = transcoder.getUserAgent().getPixelUnitToMillimeter();
    // num Pixs in 1 Meter
    int numPix      = (int)((1000/PixSzMM)+0.5);
    params.setPhysicalDimension(numPix, numPix, 1); // 1 means 'pix/meter'

    try {
        OutputStream ostream = output.getOutputStream();
        PNGImageEncoder pngEncoder = new PNGImageEncoder(ostream, params);
        pngEncoder.encode(img);
        ostream.flush();
    } catch (IOException ex) {
        throw new TranscoderException(ex);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:54,代码来源:PNGTranscoderInternalCodecWriteAdapter.java


示例10: rasterize

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
public static BufferedImage rasterize(File svgFile) throws IOException {

	    final BufferedImage[] imagePointer = new BufferedImage[1];

	    // Rendering hints can't be set programatically, so
	    // we override defaults with a temporary stylesheet.
	    // These defaults emphasize quality and precision, and
	    // are more similar to the defaults of other SVG viewers.
	    // SVG documents can still override these defaults.
	    String css = "svg {" +
	            "shape-rendering: geometricPrecision;" +
	            "text-rendering:  geometricPrecision;" +
	            "color-rendering: optimizeQuality;" +
	            "image-rendering: optimizeQuality;" +
	            "}";
	    File cssFile = File.createTempFile("batik-default-override-", ".css");
	    FileUtils.writeStringToFile(cssFile, css);

	    TranscodingHints transcoderHints = new TranscodingHints();
	    transcoderHints.put(ImageTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE);
	    transcoderHints.put(ImageTranscoder.KEY_DOM_IMPLEMENTATION,
	            SVG12DOMImplementation.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());

	    try {

	        TranscoderInput input = new TranscoderInput(new FileInputStream(svgFile));

	        ImageTranscoder t = new ImageTranscoder() {

	            @Override
	            public BufferedImage createImage(int w, int h) {
	                return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
	            }

	            @Override
	            public void writeImage(BufferedImage image, TranscoderOutput out)
	                    throws TranscoderException {
	                imagePointer[0] = image;
	            }
	        };
	        t.setTranscodingHints(transcoderHints);
	        t.transcode(input, null);
	    }
	    catch (TranscoderException ex) {
	        ex.printStackTrace();
	        throw new IOException("Couldn't convert " + svgFile);
	    }
	    finally {
	        cssFile.delete();
	    }

	    return imagePointer[0];
	}
 
开发者ID:BuZZ-dEE,项目名称:skat09,代码行数:58,代码来源:SvgImageProcessing.java


示例11: getSymbolGraphic

import org.apache.batik.transcoder.TranscodingHints; //导入依赖的package包/类
public ImageIcon getSymbolGraphic(String[] symbolNames, boolean isEgo, boolean isAttached) {
        HashMap<Set<String>, ImageIcon> symbolMap;
        if (isAttached) {
            if (isEgo) {
                symbolMap = symbolMapEgoAttached;
            } else {
                symbolMap = symbolMapAlterAttached;
            }
        } else {
            if (isEgo) {
                symbolMap = symbolMapEgo;
            } else {
                symbolMap = symbolMapAlter;
            }
        }
        final Set<String> symbolNamesList = new HashSet(Arrays.asList(symbolNames));
        if (symbolMap.containsKey(symbolNamesList)) {
            return symbolMap.get(symbolNamesList);
        }
        System.out.println("generating symbol for symbolNames:" + symbolNamesList + " : " + isEgo + " : " + isAttached);
        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
        SVGDocument doc = (SVGDocument) impl.createDocument(svgNS, "svg", null);
        // in order to be in sync with the symbols in the actual document, these symbols are copied from the parent document
        // copy the kin symbols from the users diagram
        Element kinSymbols = svgDocument.getElementById("KinSymbols");
        Node newNode = doc.importNode(kinSymbols, true);
        doc.getDocumentElement().appendChild(newNode);

        int symbolSize = EntitySvg.symbolSize;
        Arrays.sort(symbolNames); // we sort the symbol names so that they are always consistent
        for (String currentSymbol : symbolNames) {
            Element symbolNode;
            symbolNode = doc.createElementNS(svgNS, "use");
            symbolNode.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#" + currentSymbol); // the xlink: of "xlink:href" is required for some svg viewers to render correctly
            if (isEgo) {
                if (isAttached) {
                    symbolNode.setAttribute("stroke", "black");
                    symbolNode.setAttribute("fill", "black");
                } else {
                    symbolNode.setAttribute("stroke", "grey");
                    symbolNode.setAttribute("fill", "grey");
                }
            } else {
                symbolNode.setAttribute("fill", "none");
                if (isAttached) {
                    symbolNode.setAttribute("stroke", "black");
                } else {
                    symbolNode.setAttribute("stroke", "grey");
                }
            }
            symbolNode.setAttribute("stroke-width", "2");

            Element svgRoot = doc.getDocumentElement();
            svgRoot.appendChild(symbolNode);
        }
        ImageIconTranscoder transcoder = new ImageIconTranscoder();
        TranscodingHints hints = new TranscodingHints();
        hints.put(ImageTranscoder.KEY_WIDTH, (float) symbolSize);
        hints.put(ImageTranscoder.KEY_HEIGHT, (float) symbolSize);
//        hints.put(ImageTranscoder.KEY_MAX_WIDTH, (float) symbolSize);
//        hints.put(ImageTranscoder.KEY_MAX_HEIGHT, (float) symbolSize);
        transcoder.setTranscodingHints(hints);
        try {
            transcoder.transcode(new TranscoderInput(doc), null);
            BufferedImage bufferedImage = transcoder.getImage();
            ImageIcon imageIcon = new ImageIcon(bufferedImage);
            symbolMap.put(symbolNamesList, imageIcon);
            return imageIcon;
        } catch (TranscoderException exception) {
            BugCatcherManager.getBugCatcher().logError(exception);
            return null;
        }
    }
 
开发者ID:KinshipSoftware,项目名称:KinOathKinshipArchiver,代码行数:75,代码来源:SymbolGraphic.java



注:本文中的org.apache.batik.transcoder.TranscodingHints类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebServiceProvider类代码示例发布时间:2022-05-21
下一篇:
Java EventQueueDelegate类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap