本文整理汇总了Java中org.apache.batik.transcoder.Transcoder类的典型用法代码示例。如果您正苦于以下问题:Java Transcoder类的具体用法?Java Transcoder怎么用?Java Transcoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transcoder类属于org.apache.batik.transcoder包,在下文中一共展示了Transcoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTranscoder
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
/**
* Returns a transcoder object of the result image type.
*
* @return Transcoder object or <tt>null</tt> if there isn't a proper transcoder.
*/
protected Transcoder getTranscoder() {
switch (code) {
case PNG_CODE:
return new PNGTranscoder();
case JPEG_CODE:
return new JPEGTranscoder();
case TIFF_CODE:
return new TIFFTranscoder();
case PDF_CODE:
try {
Class pdfClass = Class.forName("org.apache.fop.svg.PDFTranscoder");
return (Transcoder) pdfClass.newInstance();
}
catch (Exception e) {
return null;
}
default:
return null;
}
}
示例2: streamOut
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
public void streamOut(OutputStream out) {
// Stream out SVG to the standard output using UTF-8 encoding.
try {
TranscoderInput input = new TranscoderInput(svg);
TranscoderOutput output = new TranscoderOutput(new BufferedWriter(new OutputStreamWriter(out, "UTF-8")));
Transcoder t = new SVGTranscoder();
t.transcode(input, output);
}
catch (TranscoderException e) {
e.printStackTrace();
}
catch (UnsupportedEncodingException uee) {
uee.printStackTrace();
}
}
示例3: setTranscoderRectangleHint
import org.apache.batik.transcoder.Transcoder; //导入依赖的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);
}
}
}
示例4: getTranscoder
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
/**
* Returns a transcoder object of the result image type.
*
* @return Transcoder object or <code>null</code> if there isn't a proper transcoder.
*/
protected Transcoder getTranscoder(){
switch(code) {
case PNG_CODE:
return new PNGTranscoder();
case JPEG_CODE:
return new JPEGTranscoder();
case TIFF_CODE:
return new TIFFTranscoder();
case PDF_CODE:
try {
Class pdfClass = Class.forName("org.apache.fop.svg.PDFTranscoder");
return (Transcoder)pdfClass.newInstance();
} catch(Exception e) {
return null;
}
default:
return null;
}
}
示例5: convert
import org.apache.batik.transcoder.Transcoder; //导入依赖的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);
}
}
示例6: convert
import org.apache.batik.transcoder.Transcoder; //导入依赖的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);
}
}
示例7: proceedWithComputedTask
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
public boolean proceedWithComputedTask(Transcoder transcoder,
Map hints,
List sources,
List dest){
System.out.println(Messages.formatMessage(MESSAGE_ABOUT_TO_TRANSCODE,
new Object[]{"" + sources.size()}));
return true;
}
示例8: export
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
@Override
public void export(Model model, OutputStream out) throws IOException, SerialisationException {
InputStream svg = SvgExportUtils.stream(model);
Transcoder transcoder = new EPSTranscoder();
TranscoderInput transcoderInput = new TranscoderInput(svg);
TranscoderOutput transcoderOutput = new TranscoderOutput(out);
try {
transcoder.transcode(transcoderInput, transcoderOutput);
} catch (TranscoderException e) {
throw new SerialisationException(e);
}
}
示例9: export
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
@Override
public void export(Model model, OutputStream out) throws IOException, SerialisationException {
InputStream svg = SvgExportUtils.stream(model);
Transcoder transcoder = new PSTranscoder();
TranscoderInput transcoderInput = new TranscoderInput(svg);
TranscoderOutput transcoderOutput = new TranscoderOutput(out);
try {
transcoder.transcode(transcoderInput, transcoderOutput);
} catch (TranscoderException e) {
throw new SerialisationException(e);
}
}
示例10: export
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
@Override
public void export(Model model, OutputStream out) throws IOException, SerialisationException {
InputStream svg = SvgExportUtils.stream(model);
Transcoder transcoder = new PDFTranscoder();
TranscoderInput transcoderInput = new TranscoderInput(svg);
TranscoderOutput transcoderOutput = new TranscoderOutput(out);
try {
transcoder.transcode(transcoderInput, transcoderOutput);
} catch (TranscoderException e) {
throw new SerialisationException(e);
}
}
示例11: export
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
@Override
public void export(Model model, OutputStream out) throws IOException, SerialisationException {
InputStream svg = SvgExportUtils.stream(model);
Transcoder transcoder = new PNGTranscoder();
TranscoderInput transcoderInput = new TranscoderInput(svg);
TranscoderOutput transcoderOutput = new TranscoderOutput(out);
try {
transcoder.transcode(transcoderInput, transcoderOutput);
} catch (TranscoderException e) {
throw new SerialisationException(e);
}
}
示例12: setTranscoderFloatHint
import org.apache.batik.transcoder.Transcoder; //导入依赖的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);
}
}
}
示例13: setTranscoderBooleanHint
import org.apache.batik.transcoder.Transcoder; //导入依赖的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);
}
}
示例14: setTranscoderStringHint
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
public static void setTranscoderStringHint(Transcoder transcoder,
String property,
TranscodingHints.Key key){
String str = System.getProperty(property);
if(str != null){
transcoder.addTranscodingHint(key, str);
}
}
示例15: proceedWithComputedTask
import org.apache.batik.transcoder.Transcoder; //导入依赖的package包/类
public boolean proceedWithComputedTask(Transcoder transcoder,
Map hints,
List sources,
List dest){
computedConfig = new Config();
computedConfig.transcoderClass = transcoder.getClass();
computedConfig.sources = new ArrayList( sources );
computedConfig.dest = new ArrayList( dest );
computedConfig.hints = new HashMap(hints);
return false; // Do not proceed with the convertion process,
// we are only checking the config in this test.
}