本文整理汇总了Java中com.kitfox.svg.SVGUniverse类的典型用法代码示例。如果您正苦于以下问题:Java SVGUniverse类的具体用法?Java SVGUniverse怎么用?Java SVGUniverse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SVGUniverse类属于com.kitfox.svg包,在下文中一共展示了SVGUniverse类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSVGImage
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
public static BufferedImage createSVGImage(String filename, int width, int height) throws Exception
{
File file = new File(filename);
FileInputStream fis = new FileInputStream(file);
SVGUniverse universe = new SVGUniverse();
universe.loadSVG(fis, file.toURI().toString());
SVGDiagram diagram = universe.getDiagram(file.toURI());
diagram.setIgnoringClipHeuristic(true);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.transform(getAffineTransform((int)diagram.getWidth(), (int)diagram.getHeight(), width, height));
diagram.render(g);
g.dispose();
return image;
}
示例2: getPanel
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
/**
* Retrieve a JPanel whith the provided SVG drawn on it.
*
* @return The JPanel with the SVG drawing
* @throws java.lang.ClassNotFoundException If the SVGSalamander library
* could not be found, or if any other error occurred.
*/
public JPanel getPanel() throws ClassNotFoundException {
/*
* Use reflection API to create the representation in SVG format
*/
if (output == null || output.equals(""))
throw new NullPointerException("SVG output is empty; probably SVG terminal is not used or plot() not executed yet.");
try {
SVGUniverse universe = new SVGUniverse();
universe.loadSVG(new StringReader(output), "plot");
SVGDiagram diagram = universe.getDiagram(universe.getStreamBuiltURI("plot"));
SVGDisplayPanel svgDisplayPanel = new SVGDisplayPanel();
svgDisplayPanel.setDiagram(diagram);
return svgDisplayPanel;
} catch (Exception e) {
throw new ClassNotFoundException(e.getMessage());
}
}
示例3: fillBuffer
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
@Override
protected void fillBuffer(final IScope scope) throws GamaRuntimeException {
try (BufferedReader in = new BufferedReader(new FileReader(getFile(scope)))) {
final SVGUniverse svg = SVGCache.getSVGUniverse();
final URI uri = svg.loadSVG(in, getPath(scope));
final SVGDiagram diagram = svg.getDiagram(uri);
final Shape shape = diagram.getRoot().getShape();
final Geometry geom = ShapeReader.read(shape, 1.0, GeometryUtils.GEOMETRY_FACTORY); // flatness
// =
// ??
// We center and scale the shape in the same operation
// final Envelope env = geom.getEnvelopeInternal();
// GamaPoint translation = new GamaPoint(-env.getWidth() / 2,
// -env.getHeight() / 2);
final IShape gs = new GamaShape(null, geom, null, new GamaPoint(0, 0), size, true);
// gs.setLocation(new GamaPoint(0, 0));
// gs.setLocation(translation);
// if ( size != null ) {
// gs = Spatial.Transformations.scaled_to(scope, gs, size);
// }
setBuffer(GamaListFactory.createWithoutCasting(Types.GEOMETRY, gs));
} catch (final IOException e) {
throw GamaRuntimeException.create(e, scope);
// e.printStackTrace();
}
}
示例4: loadMapFromFile
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
synchronized private void loadMapFromFile(File file) throws MalformedURLException {
log.info("loading map file " + file);
doClearMap();
SVGUniverse svgUniverse = new SVGUniverse();
SVGDiagram svgDiagram = null;
svgUniverse.setVerbose(false); // set true to see parsing debug info
URI svgURI = svgUniverse.loadSVG(file.toURI().toURL());
svgDiagram = svgUniverse.getDiagram(svgURI);
SVGRoot root = svgDiagram.getRoot();
loadChildren(root.getChildren(null));
String s = String.format("map has %d holes, %d lines, %d paths, ball path has %d vertices", holesSVG.size(), linesSVG.size(), pathsSVG.size(), ballPathSVG != null ? ballPathSVG.size() : 0);
log.info(s);
computeTransformsToRetinaCoordinates();
}
示例5: setSVG
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
public final void setSVG(Element svg) {
this.svg = svg;
this.coef = Double.parseDouble(svg.attr("height"))/Double.parseDouble(svg.attr("width"));//le coef a pu changer
SVGUniverse uni = new SVGUniverse();
StringReader r = new StringReader(getSVGString());
uni.loadSVG(r,id+".svg");
super.setSvgUniverse(uni);
super.setSvgURI(uni.getStreamBuiltURI(id+".svg"));
super.setScaleToFit(true);
super.setAntiAlias(true);
setSize(largeurInitiale);
repaint();
}
示例6: loadURL
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
private void loadURL(URL url)
{
boolean verbose = cmCheck_verbose.isSelected();
// SVGUniverse universe = new SVGUniverse();
SVGUniverse universe = SVGCache.getSVGUniverse();
SVGDiagram diagram = null;
URI uri;
if (!CheckBoxMenuItem_anonInputStream.isSelected())
{
//Load from a disk with a valid URL
uri = universe.loadSVG(url);
if (verbose) System.err.println("Loading document " + uri.toString());
diagram = universe.getDiagram(uri);
}
else
{
//Load from a stream with no particular valid URL
try
{
InputStream is = url.openStream();
uri = universe.loadSVG(is, "defaultName");
if (verbose) System.err.println("Loading document " + uri.toString());
}
catch (Exception e)
{
Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e);
return;
}
}
/*
ByteArrayOutputStream bs = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(bs);
os.writeObject(universe);
os.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bs.toByteArray());
ObjectInputStream is = new ObjectInputStream(bin);
universe = (SVGUniverse)is.readObject();
is.close();
*/
diagram = universe.getDiagram(uri);
svgDisplayPanel.setDiagram(diagram);
repaint();
}
示例7: getSvgUniverse
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
/**
* @return the universe this icon draws it's SVGDiagrams from
*/
public SVGUniverse getSvgUniverse()
{
return svgUniverse;
}
示例8: setSvgUniverse
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
public void setSvgUniverse(SVGUniverse svgUniverse)
{
SVGUniverse old = this.svgUniverse;
this.svgUniverse = svgUniverse;
changes.firePropertyChange("svgUniverse", old, svgUniverse);
}
示例9: draw
import com.kitfox.svg.SVGUniverse; //导入依赖的package包/类
void draw(Graphics2D g2d, int mode) throws SVGException {
double h1, h2, w1, w2, ratio, newwidth;
ratio = ((double) panel.getHeight()) / 297;
newwidth = ratio * 210;
h2 = panel.getHeight() - 10;
w1 = ((panel.getWidth() - newwidth) / 2) + 10;
w2 = ((panel.getWidth() + newwidth) / 2) - 10;
h1 = 10;
if (mode == 1) {
h2 = 860;
w1 = 0;
w2 = 585;
h1 = 0;
}
String txt1 = "", txt2 = "", txtbuffer = "";
for (int t = 0; t < panel.txt.length(); t++) {
if ((panel.txt.charAt(t) == (' '))) {
if (t <= 27) {
txt1 = txt1 + txtbuffer + ' ';
txtbuffer = "";
}
if ((t > 28) && (t <= 55)) {
txt2 = txt2 + txtbuffer + ' ';
txtbuffer = "";
}
} else if ((t == panel.txt.length() - 1) || (t == 27)) {
if (t <= 27) {
txt1 = txt1 + txtbuffer + panel.txt.charAt(t);
txtbuffer = "";
}
if ((t > 27) && (t <= 55)) {
txt2 = txt2 + txtbuffer + panel.txt.charAt(t);
}
} else {
txtbuffer = txtbuffer + panel.txt.charAt(t);
}
}
if (mode == 0) {
//Boundary
g2d.draw(new Rectangle2D.Double(w1, h1, w2 - w1, h2 - h1));
}
//Top Right Corner Circle
g2d.fill(new Ellipse2D.Double(w1 + 20, h1 + 20, 25, 25));
// Text box
g2d.setFont(new Font("Braille", Font.PLAIN, panel.fontsize));
g2d.drawString(txt1, (float) w1 + 60, (float) h1 + 40);
g2d.drawString(txt2, (float) w1 + 60, (float) h1 + 75);
if (panel.f != null) {
try {
SVGUniverse svgUniverse = new SVGUniverse();
SVGDiagram diagram = svgUniverse.getDiagram(svgUniverse.loadSVG(panel.f.toURI().toURL()));
SVGElement root = diagram.getRoot();
panel.converted.clear();
converter(root, panel.converted);
scaling(panel.converted, panel, mode);
aslipaint(g2d, panel.converted, panel.textures);
} catch (MalformedURLException ex) {
Logger.getLogger(IconPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
}