本文整理汇总了Java中org.apache.batik.dom.svg.SVGDOMImplementation.SVG_NAMESPACE_URI属性的典型用法代码示例。如果您正苦于以下问题:Java SVGDOMImplementation.SVG_NAMESPACE_URI属性的具体用法?Java SVGDOMImplementation.SVG_NAMESPACE_URI怎么用?Java SVGDOMImplementation.SVG_NAMESPACE_URI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.batik.dom.svg.SVGDOMImplementation
的用法示例。
在下文中一共展示了SVGDOMImplementation.SVG_NAMESPACE_URI属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullExportToStream
@Override
public void fullExportToStream(ERDesignerGraph aGraph, OutputStream aStream) throws IOException {
Object[] cells = aGraph.getRoots();
Rectangle2D bounds = aGraph.toScreen(aGraph.getCellBounds(cells));
if (bounds != null) {
DOMImplementation theDomImpl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document theDocument = theDomImpl.createDocument(svgNS, "svg", null);
SVGGraphics2D theSvgGenerator = new SVGGraphics2D(theDocument);
theSvgGenerator.translate(-bounds.getX() + 10, -bounds.getY() + 0);
RepaintManager theRepaintManager = RepaintManager.currentManager(aGraph);
theRepaintManager.setDoubleBufferingEnabled(false);
boolean theDoubleBuffered = aGraph.isDoubleBuffered();
// Disable double buffering to allow Batik to render svg elements
// instead of images
aGraph.setDoubleBuffered(false);
aGraph.paint(theSvgGenerator);
aGraph.setDoubleBuffered(theDoubleBuffered);
Writer theWriter = new OutputStreamWriter(aStream, PlatformConfig.getXMLEncoding());
theSvgGenerator.stream(theWriter, false);
theRepaintManager.setDoubleBufferingEnabled(true);
theWriter.flush();
theWriter.close();
}
}
示例2: createTestImage
/**
* Creates a splash image with the message "No item selected"
*
* @return
*/
protected SVGDocument createTestImage() {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
SVGDocument doc = (SVGDocument) impl.createDocument(svgNS, "svg", null);
Element root = doc.getDocumentElement();
root.setAttributeNS(null, "width", "500px");
root.setAttributeNS(null, "height", "500px");
Element text = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "text");
text.setAttributeNS(null, "x", "10");
text.setAttributeNS(null, "y", "20");
text.setAttributeNS(null, "font-size", DEFAULT_FONT_SIZE);
text.setAttributeNS(null, "font-family", DEFAULT_FONT_FAMILY);
text.setAttributeNS(null, "font-weight", "bold");
text.setAttributeNS(null, "fill", "red");
text.setAttributeNS(null, "stroke", "none");
text.setTextContent("No item selected");
root.appendChild(text);
return doc;
}
示例3: createNoSyntaxImage
/**
* Creates a splash image with the message "No syntax defined"
*
* @return
*/
protected SVGDocument createNoSyntaxImage() {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
SVGDocument doc = (SVGDocument) impl.createDocument(svgNS, "svg", null);
Element root = doc.getDocumentElement();
root.setAttributeNS(null, "width", "500px");
root.setAttributeNS(null, "height", "500px");
Element text = doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "text");
text.setAttributeNS(null, "x", "10");
text.setAttributeNS(null, "y", "20");
text.setAttributeNS(null, "font-size", DEFAULT_FONT_SIZE);
text.setAttributeNS(null, "font-family", DEFAULT_FONT_FAMILY);
text.setAttributeNS(null, "font-weight", "bold");
text.setAttributeNS(null, "fill", "red");
text.setAttributeNS(null, "stroke", "none");
text.setTextContent("No syntax defined");
root.appendChild(text);
return doc;
}
示例4: setupFactory
/**
* Create the SVGDocument and the SVGGraphics2D objects of this SvgFactory.
* This method is called by the constructors.
*/
private void setupFactory() {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
this.setSvgDoc((SVGDocument) impl.createDocument(svgNS, "svg", null));
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(this.getSvgDoc());
ctx.setComment("Generated by MonosaccharideDB (www.monosaccharidedb.org) with Batik SVG Generator");
this.setSVGGraph2D(new SVGGraphics2D(ctx, false));
}
示例5: makeSequenceDiagram
public Document makeSequenceDiagram(String[] strings) {
// Create an SVG document.
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
// Create a converter for this document.
SVGGraphics2D g = new SVGGraphics2D(doc);
int startx = 10;
int starty = (int)fontsize;//10;
//int scalefactor = 10000;
for (String objectEntity : strings) {
Font old = g.getFont();
Font neu = old.deriveFont(fontsize);
g.setFont(neu);
g.drawString(objectEntity, startx, starty);
g.setFont(old);
startx = paintSequenceDiagram(
dStruct.getObjectEntity(objectEntity), g, startx,
starty + 20, scalefactor) + 100;
}
// paintSequenceDiagramWithErrors(objectEntity, g);
g.setSVGCanvasSize(new Dimension(startx, scalefactor + 100));
// Populate the document root with the generated SVG content.
Element root = doc.getDocumentElement();
g.getRoot(root);
return doc;
}
示例6: buildSVG
/**
* Builds the SVG for the corresponding notationElement. The representation is for
* the abstract syntax element.
*
* @param notationElement
* @return
*/
public SVGDocument buildSVG(NotationElement notationElement) {
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
SVGDocument doc = (SVGDocument) impl.createDocument(svgNS, "svg", null);
buildSVG(notationElement, doc, START_X, START_Y);
return doc;
}
示例7: SvgGraphics2DHelper
public SvgGraphics2DHelper(int width, int height) {
this.width = width;
this.height = height;
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
g2 = new SVGGraphics2D(doc, new DefaultImageHandler(), new DefaultExtensionHandler(), true);
}
示例8: exportSVG
public static void exportSVG(File file,
VisualizationPainter visualizationPainter, int width, int height)
throws TransformerException, IOException
{
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
Element svgRoot = doc.getDocumentElement();
svgRoot.setAttributeNS(null, "width", Integer.toString(width));
svgRoot.setAttributeNS(null, "height", Integer.toString(height));
SvgPainter painter = new SvgPainter(doc, svgRoot);
visualizationPainter.setPainter(painter);
visualizationPainter.setWidth(width);
visualizationPainter.setHeight(height);
visualizationPainter.paint();
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
FileOutputStream fos = new FileOutputStream(file);
StreamResult result = new StreamResult(fos);
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(source, result);
fos.close();
}
示例9: main
public static void main(String[] args) throws TransformerException,
IOException
{
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
Element svgRoot = doc.getDocumentElement();
Element element = doc.createElementNS(svgNS, "image");
svgRoot.appendChild(element);
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(System.out);
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(source, result);
}
示例10: main
public static void main(String[] args) throws IOException,
ParserConfigurationException, SAXException, TransformerException
{
File file = new File("/tmp/polygon.svg");
String path = "res/presets/polygons/Hole.geom";
Content content = ContentResources.load(path);
List<Polygon> polygons = content.getPolygons();
Polygon polygon = polygons.get(0);
int width = 600, height = 600;
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
Element svgRoot = doc.getDocumentElement();
svgRoot.setAttributeNS(null, "width", Integer.toString(width));
svgRoot.setAttributeNS(null, "height", Integer.toString(height));
SvgPainter painter = new SvgPainter(doc, svgRoot);
paint(painter, polygon);
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
FileOutputStream fos = new FileOutputStream(file);
StreamResult result = new StreamResult(fos);
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty(
"{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(source, result);
fos.close();
}
示例11: main
public static void main(String[] args) throws TransformerException,
IOException
{
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
Element svgRoot = doc.getDocumentElement();
svgRoot.setAttributeNS(null, "width", "400");
svgRoot.setAttributeNS(null, "height", "450");
Element rectangle = doc.createElementNS(svgNS, "rect");
rectangle.setAttributeNS(null, "x", "10");
rectangle.setAttributeNS(null, "y", "20");
rectangle.setAttributeNS(null, "width", "100");
rectangle.setAttributeNS(null, "height", "50");
rectangle.setAttributeNS(null, "fill", "red");
svgRoot.appendChild(rectangle);
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
File file = new File("/tmp/foo.svg");
FileOutputStream fos = new FileOutputStream(file);
StreamResult result = new StreamResult(fos);
transformer.transform(source, result);
fos.close();
}
示例12: main
public static void main(String[] args) throws TransformerException,
IOException
{
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
Element svgRoot = doc.getDocumentElement();
svgRoot.setAttributeNS(null, "width", "400");
svgRoot.setAttributeNS(null, "height", "450");
Element rectangle = doc.createElementNS(svgNS, "rect");
rectangle.setAttributeNS(null, "x", "10");
rectangle.setAttributeNS(null, "y", "20");
rectangle.setAttributeNS(null, "width", "100");
rectangle.setAttributeNS(null, "height", "50");
rectangle.setAttributeNS(null, "fill", "none");
rectangle.setAttributeNS(null, "stroke", "red");
rectangle.setAttributeNS(null, "stroke-width", "4px");
rectangle.setAttributeNS(null, "stroke-linecap", "round");
rectangle.setAttributeNS(null, "stroke-dasharray", "8,12");
rectangle.setAttributeNS(null, "stroke-dashoffset", "4");
svgRoot.appendChild(rectangle);
TransformerFactory transformerFactory = TransformerFactory
.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
File file = new File("/tmp/foo.svg");
FileOutputStream fos = new FileOutputStream(file);
StreamResult result = new StreamResult(fos);
transformer.transform(source, result);
fos.close();
}
示例13: getSymbolGraphic
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;
}
}
示例14: getSupportedNamespaces
/** {@inheritDoc} */
public String[] getSupportedNamespaces() {
return new String[] {SVGDOMImplementation.SVG_NAMESPACE_URI};
}
示例15: getNamespace
/** {@inheritDoc} */
public String getNamespace() {
return SVGDOMImplementation.SVG_NAMESPACE_URI;
}