当前位置: 首页>>代码示例>>Java>>正文


Java GraphicsNode.getGeometryBounds方法代码示例

本文整理汇总了Java中org.apache.batik.gvt.GraphicsNode.getGeometryBounds方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsNode.getGeometryBounds方法的具体用法?Java GraphicsNode.getGeometryBounds怎么用?Java GraphicsNode.getGeometryBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.batik.gvt.GraphicsNode的用法示例。


在下文中一共展示了GraphicsNode.getGeometryBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toObjectBBox

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
/**
 * Returns an AffineTransform to move to the objectBoundingBox
 * coordinate system.
 *
 * @param Tx the original transformation
 * @param node the graphics node that defines the coordinate
 *             system to move into
 */
public static AffineTransform toObjectBBox(AffineTransform Tx,
                                           GraphicsNode node) {

    AffineTransform Mx = new AffineTransform();
    Rectangle2D bounds = node.getGeometryBounds();
    if (bounds != null) {
        Mx.translate(bounds.getX(), bounds.getY());
        Mx.scale(bounds.getWidth(), bounds.getHeight());
    }
    Mx.concatenate(Tx);
    return Mx;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:21,代码来源:SVGUtilities.java

示例2: extendRegion

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
/**
* Returns a rectangle that represents the region extended by the
* specified differential coordinates.
*
* @param dxStr the differential x coordinate of the region
* @param dyStr the differential y coordinate of the region
* @param dwStr the differential width of the region
* @param dhStr the differential height of the region
* @param unitsType specifies whether the values are in userSpaceOnUse
*        or objectBoundingBox space
* @param region the region to extend
* @param uctx the unit processor context (needed for userSpaceOnUse)
*/
protected static Rectangle2D extendRegion(String dxStr,
                                          String dyStr,
                                          String dwStr,
                                          String dhStr,
                                          short unitsType,
                                          GraphicsNode filteredNode,
                                          Rectangle2D region,
                                          UnitProcessor.Context uctx) {

    float dx,dy,dw,dh;
    switch (unitsType) {
    case USER_SPACE_ON_USE:
        dx = UnitProcessor.svgHorizontalCoordinateToUserSpace
            (dxStr, SVG12Constants.SVG_MX_ATRIBUTE, uctx);
        dy = UnitProcessor.svgVerticalCoordinateToUserSpace
            (dyStr, SVG12Constants.SVG_MY_ATRIBUTE, uctx);
        dw = UnitProcessor.svgHorizontalCoordinateToUserSpace
            (dwStr, SVG12Constants.SVG_MW_ATRIBUTE, uctx);
        dh = UnitProcessor.svgVerticalCoordinateToUserSpace
            (dhStr, SVG12Constants.SVG_MH_ATRIBUTE, uctx);
        break;
    case OBJECT_BOUNDING_BOX:
        Rectangle2D bounds = filteredNode.getGeometryBounds();
        if (bounds == null) {
            dx = dy = dw = dh = 0;
        } else {
            dx = UnitProcessor.svgHorizontalCoordinateToObjectBoundingBox
                (dxStr, SVG12Constants.SVG_MX_ATRIBUTE, uctx);
            dx *= bounds.getWidth();

            dy = UnitProcessor.svgVerticalCoordinateToObjectBoundingBox
                (dyStr, SVG12Constants.SVG_MY_ATRIBUTE, uctx);
            dy *= bounds.getHeight();

            dw = UnitProcessor.svgHorizontalCoordinateToObjectBoundingBox
                (dwStr, SVG12Constants.SVG_MW_ATRIBUTE, uctx);
            dw *= bounds.getWidth();

            dh = UnitProcessor.svgVerticalCoordinateToObjectBoundingBox
                (dhStr, SVG12Constants.SVG_MH_ATRIBUTE, uctx);
            dh *= bounds.getHeight();
        }
        break;
    default:
        throw new IllegalArgumentException("Invalid unit type");
    }

    region.setRect(region.getX() + dx,
                   region.getY() + dy,
                   region.getWidth() + dw,
                   region.getHeight() + dh);

    return region;
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:68,代码来源:SVGUtilities.java

示例3: convertRegion

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
/**
 * Returns a rectangle that represents the region defined by the
 * specified coordinates.
 *
 * @param xStr the x coordinate of the region
 * @param yStr the y coordinate of the region
 * @param wStr the width of the region
 * @param hStr the height of the region
 * @param targetNode the graphics node (needed for objectBoundingBox)
 * @param uctx the unit processor context (needed for userSpaceOnUse)
 */
protected static Rectangle2D convertRegion(String xStr,
                                           String yStr,
                                           String wStr,
                                           String hStr,
                                           short unitsType,
                                           GraphicsNode targetNode,
                                           UnitProcessor.Context uctx) {

    // construct the mask region in the appropriate coordinate system
    double x, y, w, h;
    switch (unitsType) {
    case OBJECT_BOUNDING_BOX:
        x = UnitProcessor.svgHorizontalCoordinateToObjectBoundingBox
            (xStr, SVG_X_ATTRIBUTE, uctx);
        y = UnitProcessor.svgVerticalCoordinateToObjectBoundingBox
            (yStr, SVG_Y_ATTRIBUTE, uctx);
        w = UnitProcessor.svgHorizontalLengthToObjectBoundingBox
            (wStr, SVG_WIDTH_ATTRIBUTE, uctx);
        h = UnitProcessor.svgVerticalLengthToObjectBoundingBox
            (hStr, SVG_HEIGHT_ATTRIBUTE, uctx);

        Rectangle2D bounds = targetNode.getGeometryBounds();
        if (bounds != null ) {
            x = bounds.getX() + x*bounds.getWidth();
            y = bounds.getY() + y*bounds.getHeight();
            w *= bounds.getWidth();
            h *= bounds.getHeight();
        } else {
            x = y = w = h = 0;
        }
        break;
    case USER_SPACE_ON_USE:
        x = UnitProcessor.svgHorizontalCoordinateToUserSpace
            (xStr, SVG_X_ATTRIBUTE, uctx);
        y = UnitProcessor.svgVerticalCoordinateToUserSpace
            (yStr, SVG_Y_ATTRIBUTE, uctx);
        w = UnitProcessor.svgHorizontalLengthToUserSpace
            (wStr, SVG_WIDTH_ATTRIBUTE, uctx);
        h = UnitProcessor.svgVerticalLengthToUserSpace
            (hStr, SVG_HEIGHT_ATTRIBUTE, uctx);
        break;
    default:
        throw new Error("invalid unitsType:" + unitsType ); // can't be reached
    }
    return new Rectangle2D.Double(x, y, w, h);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:58,代码来源:SVGUtilities.java

示例4: createSVGFeImage

import org.apache.batik.gvt.GraphicsNode; //导入方法依赖的package包/类
/**
 * Returns a Filter that represents a svg document or element as an image.
 *
 * @param ctx the bridge context
 * @param primitiveRegion the primitive region
 * @param refElement the referenced element
 * @param toBBoxNeeded true if there is a need to transform to ObjectBoundingBox
 *        space
 * @param filterElement parent filter element
 * @param filteredNode node to which the filter applies
 */
protected static Filter createSVGFeImage(BridgeContext ctx,
                                         Rectangle2D primitiveRegion,
                                         Element refElement,
                                         boolean toBBoxNeeded,
                                         Element filterElement,
                                         GraphicsNode filteredNode) {

    //
    // <!> FIX ME
    // Unresolved issue on the feImage behavior when referencing an
    // image (PNG, JPEG or SVG image).
    // VH & TK, 03/08/2002
    // Furthermore, for feImage referencing doc fragment, should act
    // like a <use>, i.e., CSS cascading and the whole zing bang.
    //
    GraphicsNode node = ctx.getGVTBuilder().build(ctx, refElement);
    Filter filter = node.getGraphicsNodeRable(true);

    AffineTransform at = new AffineTransform();

    if (toBBoxNeeded){
        // 'primitiveUnits' attribute - default is userSpaceOnUse
        short coordSystemType;
        Element filterDefElement = (Element)(filterElement.getParentNode());
        String s = SVGUtilities.getChainableAttributeNS
            (filterDefElement, null, SVG_PRIMITIVE_UNITS_ATTRIBUTE, ctx);
        if (s.length() == 0) {
            coordSystemType = SVGUtilities.USER_SPACE_ON_USE;
        } else {
            coordSystemType = SVGUtilities.parseCoordinateSystem
                (filterDefElement, SVG_PRIMITIVE_UNITS_ATTRIBUTE, s, ctx);
        }

        if (coordSystemType == SVGUtilities.OBJECT_BOUNDING_BOX) {
            at = SVGUtilities.toObjectBBox(at, filteredNode);
        }

        Rectangle2D bounds = filteredNode.getGeometryBounds();
        at.preConcatenate(AffineTransform.getTranslateInstance
                          (primitiveRegion.getX() - bounds.getX(),
                           primitiveRegion.getY() - bounds.getY()));

    } else {

        // Need to translate the image to the x, y coordinate to
        // have the same behavior as the <use> element
        at.translate(primitiveRegion.getX(), primitiveRegion.getY());
    }

    return new AffineRable8Bit(filter, at);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:63,代码来源:SVGFeImageElementBridge.java


注:本文中的org.apache.batik.gvt.GraphicsNode.getGeometryBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。