本文整理汇总了Java中org.apache.batik.gvt.GraphicsNode类的典型用法代码示例。如果您正苦于以下问题:Java GraphicsNode类的具体用法?Java GraphicsNode怎么用?Java GraphicsNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsNode类属于org.apache.batik.gvt包,在下文中一共展示了GraphicsNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderSVG
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
private void renderSVG(String name, final double scale) throws IOException {
String uri = RenderSVGsTest.class.getResource(name).toString();
// create the document
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
Document document = f.createDocument(uri, RenderSVGsTest.class.getResourceAsStream(name));
// create the GVT
UserAgent userAgent = new UserAgentAdapter();
DocumentLoader loader = new DocumentLoader(userAgent);
BridgeContext bctx = new BridgeContext(userAgent, loader);
bctx.setDynamicState(BridgeContext.STATIC);
GVTBuilder builder = new GVTBuilder();
final GraphicsNode gvtRoot = builder.build(bctx, document);
this.exportGraphic("svg", name.replace(".svg", ""), new GraphicsExporter() {
@Override
public void draw(Graphics2D gfx) {
gfx.scale(scale, scale);
gvtRoot.paint(gfx);
}
});
}
示例2: GraphicsNodeMouseEvent
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Constructs a new graphics node mouse event.
* @param source the graphics node where the event originated
* @param id the id of this event
* @param when the time the event occurred
* @param modifiers the modifier keys down when event occurred
* @param lockState the lock keys active when the event occurred
* @param button the mouse button that changed state
* @param x the mouse x coordinate
* @param y the mouse y coordinate
* @param screenX the mouse x coordinate relative to the screen
* @param screenY the mouse y coordinate relative to the screen
* @param clickCount the number of clicks
* @param relatedNode the related node
* @see #getRelatedNode
*/
public GraphicsNodeMouseEvent(GraphicsNode source, int id,
long when, int modifiers, int lockState,
int button, float x, float y,
int clientX, int clientY,
int screenX, int screenY,
int clickCount,
GraphicsNode relatedNode) {
super(source, id, when, modifiers, lockState);
this.button = button;
this.x = x;
this.y = y;
this.clientX = clientX;
this.clientY = clientY;
this.screenX = screenX;
this.screenY = screenY;
this.clickCount = clickCount;
this.relatedNode = relatedNode;
}
示例3: report
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
private void report(GraphicsNodeEvent evt, String message) {
GraphicsNode source = evt.getGraphicsNode();
String label = "(non-text node)";
if (source instanceof TextNode) {
char[] cbuff;
java.text.CharacterIterator iter =
((TextNode) source).getAttributedCharacterIterator();
cbuff = new char[iter.getEndIndex()];
if (cbuff.length > 0) cbuff[0] = iter.first();
for (int i=1; i<cbuff.length;++i) {
cbuff[i] = iter.next();
}
label = new String(cbuff);
}
System.out.println("Mouse "+message+" in "+label);
}
示例4: isTextSensitive
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
public static boolean isTextSensitive(Element e) {
int ptrEvts = CSSUtilities.convertPointerEvents(e);
switch (ptrEvts) {
case GraphicsNode.VISIBLE_PAINTED: // fall-through is intended
case GraphicsNode.VISIBLE_FILL:
case GraphicsNode.VISIBLE_STROKE:
case GraphicsNode.VISIBLE:
return CSSUtilities.convertVisibility(e);
case GraphicsNode.PAINTED:
case GraphicsNode.FILL: // fall-through is intended
case GraphicsNode.STROKE:
case GraphicsNode.ALL:
return true;
case GraphicsNode.NONE:
default:
return false;
}
}
示例5: createGraphicsNode
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Creates a graphics node using the specified BridgeContext and
* for the specified element.
*
* @param ctx the bridge context to use
* @param e the element that describes the graphics node to build
* @return a graphics node that represents the specified element
*/
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
ShapeNode shapeNode = (ShapeNode)super.createGraphicsNode(ctx, e);
if (shapeNode == null) {
return null;
}
associateSVGContext(ctx, e, shapeNode);
// delegates to subclasses the shape construction
buildShape(ctx, e, shapeNode);
// 'shape-rendering' and 'color-rendering'
RenderingHints hints = null;
hints = CSSUtilities.convertColorRendering(e, hints);
hints = CSSUtilities.convertShapeRendering(e, hints);
if (hints != null)
shapeNode.setRenderingHints(hints);
return shapeNode;
}
示例6: getGraphicsNode
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
public GraphicsNode getGraphicsNode(int idx) {
if (srcs[idx] != null) {
Object o = srcs[idx].get();
if (o != null)
return (GraphicsNode)o;
}
try {
GVTBuilder builder = ctx.getGVTBuilder();
GraphicsNode gn;
gn = builder.build(ctx, srcElems[idx]);
srcs[idx] = new SoftReference(gn);
return gn;
} catch (Exception ex) { ex.printStackTrace(); }
return null;
}
示例7: getNext
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Returns the next GraphicsNode that matches the specified string or null
* if any.
*
* @param text the text to match
*/
protected GraphicsNode getNext(String text) {
if (walker == null && gvtRoot != null) {
walker = new GVTTreeWalker(gvtRoot);
}
GraphicsNode gn = walker.getCurrentGraphicsNode();
int index = match(gn, text, currentIndex+text.length());
if (index >= 0) {
currentIndex = index;
} else {
currentIndex = 0;
gn = walker.nextGraphicsNode();
while (gn != null &&
((currentIndex = match(gn, text, currentIndex)) < 0)) {
currentIndex = 0;
gn = walker.nextGraphicsNode();
}
}
return gn;
}
示例8: createEmptyFilter
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Creates a new returns a new filter that fills its output with
* transparent black. This is used when a <filter> element
* has no filter primitive children.
*/
protected static Filter createEmptyFilter(Element filterElement,
Rectangle2D filterRegion,
Element filteredElement,
GraphicsNode filteredNode,
BridgeContext ctx) {
Rectangle2D primitiveRegion
= SVGUtilities.convertFilterPrimitiveRegion(null,
filterElement,
filteredElement,
filteredNode,
filterRegion,
filterRegion,
ctx);
return new FloodRable8Bit(primitiveRegion, TRANSPARENT_BLACK);
}
示例9: actionPerformed
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
String text = search.getText();
if (text == null || text.length() == 0) {
return;
}
GraphicsNode gn = getNext(text);
if (gn != null) {
showSelectedGraphicsNode();
} else {
// end of document reached
walker = null;
JOptionPane.showMessageDialog(FindDialog.this,
resources.getString("End.text"),
resources.getString("End.title"),
JOptionPane.INFORMATION_MESSAGE);
}
}
示例10: convertStrokePaint
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Converts for the specified element, its stroke paint properties
* to a Paint object.
*
* @param strokedElement the element interested in a Paint
* @param strokedNode the graphics node to stroke
* @param ctx the bridge context
*/
public static Paint convertStrokePaint(Element strokedElement,
GraphicsNode strokedNode,
BridgeContext ctx) {
Value v = CSSUtilities.getComputedStyle
(strokedElement, SVGCSSEngine.STROKE_OPACITY_INDEX);
float opacity = convertOpacity(v);
v = CSSUtilities.getComputedStyle
(strokedElement, SVGCSSEngine.STROKE_INDEX);
return convertPaint(strokedElement,
strokedNode,
v,
opacity,
ctx);
}
示例11: buildGraphicsNode
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Builds using the specified BridgeContext and element, the
* specified graphics node.
*
* @param ctx the bridge context to use
* @param e the element that describes the graphics node to build
* @param node the graphics node to build
*/
public void buildGraphicsNode(BridgeContext ctx,
Element e,
GraphicsNode node) {
// 'opacity'
node.setComposite(CSSUtilities.convertOpacity(e));
// 'filter'
node.setFilter(CSSUtilities.convertFilter(e, node, ctx));
// 'mask'
node.setMask(CSSUtilities.convertMask(e, node, ctx));
// 'pointer-events'
node.setPointerEventType(CSSUtilities.convertPointerEvents(e));
initializeDynamicSupport(ctx, e, node);
ctx.closeViewport(e);
}
示例12: getViewBoxRect
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
protected Rectangle2D getViewBoxRect() {
SVGDocument doc = canvas.getSVGDocument();
if (doc == null) return null;
SVGSVGElement el = doc.getRootElement();
if (el == null) return null;
String viewBoxStr = el.getAttributeNS
(null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);
if (viewBoxStr.length() != 0) {
float[] rect = ViewBox.parseViewBoxAttribute(el, viewBoxStr, null);
return new Rectangle2D.Float(rect[0], rect[1],
rect[2], rect[3]);
}
GraphicsNode gn = canvas.getGraphicsNode();
if (gn == null) return null;
Rectangle2D bounds = gn.getBounds();
if (bounds == null) return null;
return (Rectangle2D) bounds.clone();
}
示例13: mouseExited
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
public void mouseExited(GraphicsNodeMouseEvent evt) {
Point clientXY = evt.getClientPoint();
// Get the 'new' node for the DOM event.
GraphicsNode node = evt.getRelatedNode();
Element targetElement = getEventTarget(node, evt.getPoint2D());
if (lastTargetElement != null) {
int n = 0;
if (targetElement != null) {
// moving from one element to another
n = DefaultXBLManager.computeBubbleLimit(lastTargetElement,
targetElement);
}
dispatchMouseEvent("mouseout",
lastTargetElement, // target
targetElement, // relatedTarget
clientXY,
evt,
true,
n);
lastTargetElement = null;
}
}
示例14: getIn2
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Returns the input source of the specified filter primitive
* element defined by its 'in2' attribute. The 'in2' attribute is assumed
* to be required if the subclasses ask for it.
*
* @param filterElement the filter primitive element
* @param filteredElement the element on which the filter is referenced
* @param filteredNode the graphics node on which the filter is applied
* @param inputFilter the default input filter
* @param filterMap the map that containes the named filter primitives
* @param ctx the bridge context
*/
protected static Filter getIn2(Element filterElement,
Element filteredElement,
GraphicsNode filteredNode,
Filter inputFilter,
Map filterMap,
BridgeContext ctx) {
String s = filterElement.getAttributeNS(null, SVG_IN2_ATTRIBUTE);
if (s.length() == 0) {
throw new BridgeException(ctx, filterElement, ERR_ATTRIBUTE_MISSING,
new Object [] {SVG_IN2_ATTRIBUTE});
}
return getFilterSource(filterElement,
s,
filteredElement,
filteredNode,
filterMap,
ctx);
}
示例15: createGraphicsNode
import org.apache.batik.gvt.GraphicsNode; //导入依赖的package包/类
/**
* Creates a <code>GraphicsNode</code> according to the specified parameters.
*
* @param ctx the bridge context to use
* @param e the element that describes the graphics node to build
* @return a graphics node that represents the specified element
*/
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
// 'requiredFeatures', 'requiredExtensions' and 'systemLanguage'
if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) {
return null;
}
GraphicsNode node = instantiateGraphicsNode();
// 'transform'
setTransform(node, e, ctx);
// 'visibility'
node.setVisible(CSSUtilities.convertVisibility(e));
associateSVGContext(ctx, e, node);
return node;
}