本文整理汇总了Java中org.apache.batik.transcoder.SVGAbstractTranscoder类的典型用法代码示例。如果您正苦于以下问题:Java SVGAbstractTranscoder类的具体用法?Java SVGAbstractTranscoder怎么用?Java SVGAbstractTranscoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SVGAbstractTranscoder类属于org.apache.batik.transcoder包,在下文中一共展示了SVGAbstractTranscoder类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadSvg
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
private static BufferedImage loadSvg(DomApplication da, IResourceDependencyList rdl, String image, IParameterInfo param) throws Exception {
//-- 1. Get the input as a theme-replaced resource
String svg = da.internalGetThemeManager().getThemeReplacedString(rdl, image);
//-- 2. Now generate the thingy using the Batik transcoder:
BufferedImageTranscoder bit = new BufferedImageTranscoder();
TranscoderInput in = new TranscoderInput(new StringReader(svg));
int w = PartUtil.getInt(param, "w", -1);
int h = PartUtil.getInt(param, "h", -1);
if(w != -1 && h != -1) {
bit.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, Float.valueOf(w));
bit.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, Float.valueOf(h));
}
bit.transcode(in, new TranscoderOutput());
return bit.getRendered();
}
示例2: generate
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
@Override
public void generate(@Nonnull PartResponse pr, @Nonnull DomApplication da, @Nonnull SvgKey k, @Nonnull IResourceDependencyList rdl) throws Exception {
//-- 1. Get the input as a theme-replaced resource
String svg = da.internalGetThemeManager().getThemeReplacedString(rdl, k.getRurl());
//-- 2. Now generate the thingy using the Batik transcoder:
PNGTranscoder coder = new PNGTranscoder();
// coder.addTranscodingHint(PNGTranscoder., null);
TranscoderInput in = new TranscoderInput(new StringReader(svg));
TranscoderOutput out = new TranscoderOutput(pr.getOutputStream());
if(k.getWidth() != -1 && k.getHeight() != -1) {
coder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, Float.valueOf(k.getWidth()));
coder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, Float.valueOf(k.getHeight()));
}
coder.transcode(in, out);
if(!da.inDevelopmentMode()) { // Not gotten from WebContent or not in DEBUG mode? Then we may cache!
pr.setCacheTime(da.getDefaultExpiryTime());
}
pr.setMime("image/png");
}
示例3: updateImage
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
private void updateImage() {
if (document == null) {
return;
}
try {
if (canvasWidth >= 0) {
addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, new Float(canvasWidth));
} else {
removeTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH);
}
if (canvasHeight >= 0) {
addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, new Float(canvasHeight));
} else {
removeTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT);
}
if (canvasAOI != null) {
addTranscodingHint(SVGAbstractTranscoder.KEY_AOI, canvasAOI);
} else {
removeTranscodingHint(SVGAbstractTranscoder.KEY_AOI);
}
transcode(new TranscoderInput(document), new TranscoderOutput());
} catch (TranscoderException e) {
TriqEditorPlugin.logError("Error transcoding SVG image", e);
}
}
示例4: exec
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
@Override
public void exec(String[] args, String rawArgs, MessageReceivedEvent e, GuildPreferences guildPreferences) {
// Quit and error out if none provided
if (args.length == 0) {
sendErrorEmbed(e.getChannel(), "Please provide a set name.");
return;
}
ScryfallSet set = Grimoire.getInstance().getCardProvider().getSetByNameOrCode(rawArgs);
if (set == null) {
sendErrorEmbedFormat(e.getChannel(), "I couldn't find any sets with **'%s'** as its name or code.", rawArgs);
return;
}
EmbedBuilder eb = new EmbedBuilder(set.getEmbed());
try {
// Attempt sending with set symbol
ByteArrayOutputStream resultByteStream = new ByteArrayOutputStream();
TranscoderInput transcoderInput = new TranscoderInput(set.getIconSvgUri());
TranscoderOutput transcoderOutput = new TranscoderOutput(resultByteStream);
PNGTranscoder pngTranscoder = new PNGTranscoder();
pngTranscoder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, 64f);
pngTranscoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, 64f);
pngTranscoder.transcode(transcoderInput, transcoderOutput);
resultByteStream.flush();
e.getChannel().sendFile(resultByteStream.toByteArray(), "set.png", new MessageBuilder().setEmbed(eb.build()).build()).submit();
} catch (Exception ex) {
// Fall back to no set symbol if needed
e.getChannel().sendMessage(eb.build());
}
}
示例5: createVector
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
public static byte[] createVector(WordCloudRenderer renderer, SVGAbstractTranscoder transcoder)
{
byte[] svg = createSVG(renderer);
// Set the transcoding hints
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, new Float(renderer.getActualWidth() + 20));
transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, new Float(renderer.getActualHeight() + 20));
// Create the transcoder input
InputStream is = new ByteArrayInputStream(svg);
TranscoderInput input = new TranscoderInput(is);
// Create the transcoder output
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
TranscoderOutput output = new TranscoderOutput(ostream);
try
{
// Save the image
transcoder.transcode(input, output);
// Flush and close the stream
ostream.flush();
ostream.close();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
return ostream.toByteArray();
}
示例6: setImageWidth
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
/**
* Sets the image width.
*
* @param width
* the new image width
*/
public void setImageWidth(float width) {
hints.put(SVGAbstractTranscoder.KEY_WIDTH, Float.valueOf(width));
}
示例7: setImageHeight
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
/**
* Sets the image height.
*
* @param height
* the new image height
*/
public void setImageHeight(float height) {
hints.put(SVGAbstractTranscoder.KEY_HEIGHT, Float.valueOf(height));
}
示例8: setLanguages
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
/**
* Sets the languages.
*
* @param language
* the new languages
*/
public void setLanguages(String language) {
hints.put(SVGAbstractTranscoder.KEY_LANGUAGE, language);
}
示例9: setPixelToMMFactor
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
/**
* Sets the pixel to mm factor.
*
* @param px2mm
* the new pixel to mm factor
*/
public void setPixelToMMFactor(float px2mm) {
hints.put(SVGAbstractTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, Float.valueOf(px2mm));
}
示例10: setUserStyleSheetURI
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
/**
* Sets the user style sheet uri.
*
* @param uri
* the new user style sheet uri
*/
public void setUserStyleSheetURI(String uri) {
hints.put(SVGAbstractTranscoder.KEY_USER_STYLESHEET_URI, uri);
}
示例11: setMedia
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
/**
* Sets the media.
*
* @param media
* the new media
*/
public void setMedia(String media) {
hints.put(SVGAbstractTranscoder.KEY_MEDIA, media);
}
示例12: setAlternateStylesheet
import org.apache.batik.transcoder.SVGAbstractTranscoder; //导入依赖的package包/类
/**
* Sets the alternate stylesheet.
*
* @param alternateStylesheet
* the new alternate stylesheet
*/
public void setAlternateStylesheet(String alternateStylesheet) {
hints.put(SVGAbstractTranscoder.KEY_ALTERNATE_STYLESHEET, alternateStylesheet);
}