本文整理汇总了Java中org.apache.batik.dom.svg.SVGOMSVGElement类的典型用法代码示例。如果您正苦于以下问题:Java SVGOMSVGElement类的具体用法?Java SVGOMSVGElement怎么用?Java SVGOMSVGElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SVGOMSVGElement类属于org.apache.batik.dom.svg包,在下文中一共展示了SVGOMSVGElement类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CombineLetters2Words
import org.apache.batik.dom.svg.SVGOMSVGElement; //导入依赖的package包/类
public static void CombineLetters2Words(
JFrame jFrame,
SVGDocument doc,
SVGOMSVGElement myRootSVGElement,
BridgeContext ctx,
GraphicsNode gnElement,
GraphicsNode gntxtElem,
NodeList nlText,
String svgNS
) throws DOMException {
long memUsage = Runtime.getRuntime().totalMemory();
double interSectionRectSize = 1.0;
// combine letters to words
for (int i = 0; i < nlText.getLength(); i++) {
SVGOMTextElement nlElem = (SVGOMTextElement) nlText.item(i);
// Handle only single letters
if (nlElem.getTextContent().length() < 3) {
double angle = 0.0;
angle = getAngle(svgNS, nlElem);
if (angle != 0.0) {
blabla(ctx, nlText, interSectionRectSize, nlElem, angle);
} // if (nlText ..)
}
} // for i
}
示例2: setViewBoxPageSize
import org.apache.batik.dom.svg.SVGOMSVGElement; //导入依赖的package包/类
public static void setViewBoxPageSize(SVGOMSVGElement myRootSVGElement, GraphicsNode rootGN, SVGDocument doc)
throws DOMException {
// Calculate the viewport.
GraphicsNode gn;
Rectangle2D rd = null;
try{
Node ndbckgrd = myRootSVGElement.getElementById("canvas_background");
if ( ndbckgrd != null) ndbckgrd.getParentNode().removeChild(ndbckgrd);
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, "No Background - have you open / edited / saved the file in INKSPACE \r\n"
+ "and copy / pasted it in METHOD DRAW to 'normalize' the SVG-data?", "ERROR"
, JOptionPane.OK_CANCEL_OPTION);
}
rd = rootGN.getTransformedSensitiveBounds(rootGN.getTransform());
int minX = (int)rd.getX() - 1;
int minY = (int)rd.getY() - 1;
int width = (int)(2 + rd.getWidth());
int height = (int)(2 + rd.getHeight());
String strViewPort = "" + minX
+ " " + minY
+ " "+ width
+ " "+ height;
System.out.println("viewBox: \t" + strViewPort);
myRootSVGElement.setAttributeNS(null, "viewBox"
, strViewPort );
myRootSVGElement.setAttributeNS(null, "width"
, String.valueOf(rd.getWidth()).substring(0, 8) );
myRootSVGElement.setAttributeNS(null, "height"
, String.valueOf(rd.getHeight()).substring(0, 8) );
}
示例3: onAttach
import org.apache.batik.dom.svg.SVGOMSVGElement; //导入依赖的package包/类
@Override
protected void onAttach(MappingContext ctx) {
super.onAttach(ctx);
if (!getSource().isAttached()) {
throw new IllegalStateException("Element must be attached");
}
myPeer = new SvgAwtPeer();
getSource().container().setPeer(myPeer);
myRootMapper = new SvgElementMapper<>(getSource(), (SVGOMSVGElement) getTarget().getDocumentElement(), getTarget(), myPeer);
getTarget().getDocumentElement().setAttribute("shape-rendering", "geometricPrecision");
myRootMapper.attachRoot();
}
示例4: CombineLetters2Words
import org.apache.batik.dom.svg.SVGOMSVGElement; //导入依赖的package包/类
public static void CombineLetters2Words(
JFrame jFrame,
SVGDocument doc,
SVGOMSVGElement myRootSVGElement,
BridgeContext ctx,
GraphicsNode gnElement,
GraphicsNode gntxtElem,
NodeList nlText,
String svgNS
) throws DOMException {
long memUsage = Runtime.getRuntime().totalMemory();
System.err.println("Runtime.getRuntime().totalMemory(): "
+ memUsage );
if ( memUsage > 1253818880) return;
// Buchstaben zu Wörtern zusammenfassen
for (int i = nlText.getLength() - 1 ; i >=0; i--) {
if ( nlText.item(i) != null
&& !((SVGOMTextElement)nlText.item(i)).hasAttributeNS(null, "transform")) {
Node nextNeighbour = null;
Double distNextNeighbour = 5.0;
gnElement1
= ctx.getGraphicsNode(nlText.item(i));
double posXofI
= gnElement1.getBounds().getX()
+ gnElement1.getBounds().getWidth();
double posYofI
= gnElement1.getBounds().getY();
for ( int j = nlText.getLength() - 1; j >= 0; j--) {
if ( i != j && nlText.item(j) != null) {
gnElement2
= ctx.getGraphicsNode(nlText.item(j));
double posXofJ
= gnElement2.getBounds().getX();
double posYofJ
= gnElement2.getBounds().getY();
if ( Math.abs(posYofI - posYofJ) < 2
&& Math.abs(posXofI - posXofJ) < distNextNeighbour
&& posXofJ - posXofI > 0 ) {
distNextNeighbour = Math.abs(posXofI - posXofJ);
nextNeighbour = nlText.item(j);
System.err.print("DistanceX: \t" + (posXofI - posXofJ) );
System.err.println("\tDistanceY: \t" + (posYofI - posYofJ) );
}
} // if ( i != j && nlText.item(j) != null)
}// For j
gnElement1 = null;
if ( nextNeighbour != null) {
((SVGOMTextElement)nlText.item(i)).setTextContent(
((SVGOMTextElement)nlText.item(i)).getTextContent()
+ ((SVGOMTextElement)nextNeighbour).getTextContent());
System.out.println("..->"
+ ((SVGOMTextElement)nlText.item(i)).getTextContent() );
nextNeighbour.getParentNode().removeChild(nextNeighbour);
nextNeighbour = null;
distNextNeighbour = null;
nlText = myRootSVGElement.getElementsByTagName("text");
System.gc();
CombineLetters2Words(
jFrame,
doc,
myRootSVGElement,
ctx,
gnElement,
gntxtElem,
nlText,
svgNS
);
return;
} // if ( nextNeighbour != null)
} // if (nlText ..)
} // for i
}