Examples of BridgeContext


Examples of org.apache.batik.bridge.BridgeContext

    public TestReport runImpl() throws Exception {
        DefaultTestReport report = new DefaultTestReport(this);

        SVGDocument  svgDoc;
        GraphicsNode gvtRoot;
        BridgeContext  ctx;
        try {
            UserAgent      userAgent = new UserAgentAdapter();
            DocumentLoader loader    = new DocumentLoader(userAgent);
            GVTBuilder     builder   = new GVTBuilder();

            ctx     = new BridgeContext(userAgent, loader);
            ctx.setDynamic(true);
            svgDoc  = (SVGDocument)loader.loadDocument(svg.toString());
            gvtRoot = builder.build(ctx, svgDoc);
        } catch(Exception e) {
            StringWriter trace = new StringWriter();
            e.printStackTrace(new PrintWriter(trace));
            report.setErrorCode(ERROR_READING_SVG);
            report.setDescription(new TestReport.Entry[] {
                new TestReport.Entry
                    (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null),
                     Messages.formatMessage
                     (ERROR_READING_SVG,
                      new String[]{svg.toString(), trace.toString()}))
                    });
            report.setPassed(false);
            return report;
        }

        Shape highlight = null;
        try {
            Element e = svgDoc.getElementById(id);
            /// System.out.println("Element: " + e + " CTX: " + ctx );
            GraphicsNode gn = ctx.getGraphicsNode(e);
            if (gn == null) {
                report.setErrorCode(ERROR_BAD_ID);
                report.setDescription(new TestReport.Entry[] {
                    new TestReport.Entry
                        (Messages.formatMessage
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

     */
    protected BridgeContext createBridgeContext() {
        if (loader == null) {
            loader = new DocumentLoader(userAgent);
        }
        BridgeContext result = new BridgeContext(userAgent, loader);
        result.setDynamic(true);
        return result;
    }
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

        // Now that the SVG file has been loaded, build
        // a GVT Tree from it
        //
        UserAgent userAgent = buildUserAgent();
        GVTBuilder builder = new GVTBuilder();
        BridgeContext ctx = new BridgeContext(userAgent);
        ctx.setDynamic(true);

        try {
            builder.build(ctx, doc);
            BaseScriptingEnvironment scriptEnvironment
                = new BaseScriptingEnvironment(ctx);
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

        // Now that the SVG file has been loaded, build
        // a GVT Tree from it
        //
        UserAgent userAgent = buildUserAgent();
        GVTBuilder builder = new GVTBuilder();
        BridgeContext ctx = new BridgeContext(userAgent);
        ctx.setDynamic(true);

        try {
            builder.build(ctx, doc);
            BaseScriptingEnvironment scriptEnvironment
                = new BaseScriptingEnvironment(ctx);
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

    ImageRendererFactory rendererFactory;
    rendererFactory = new ConcreteImageRendererFactory();
    ImageRenderer renderer = rendererFactory.createStaticImageRenderer();

    GVTBuilder builder = new GVTBuilder();
    BridgeContext ctx = new BridgeContext(new UserAgentAdapter());
    ctx.setDynamicState(BridgeContext.STATIC);
    GraphicsNode rootNode = builder.build(ctx, document);

    renderer.setTree(rootNode);
   
    float docWidth  = (float) ctx.getDocumentSize().getWidth();
    float docHeight = (float) ctx.getDocumentSize().getHeight();
   
    float xscale = width/docWidth;
    float yscale = height/docHeight;
    if(!stretch){
      float scale = Math.min(xscale, yscale);
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

      {
        url = new File(".").toURI().toURL();
      }
      final SVGDocument document = (SVGDocument) loader.loadDocument
          (url.toURI().toASCIIString(), data.getResourceAsStream(caller));
      final BridgeContext ctx = new BridgeContext(userAgent, loader);
      final GVTBuilder builder = new GVTBuilder();
      final GraphicsNode node = builder.build(ctx, document);
      return new SimpleResource(data.getKey(), new SVGDrawable(node), DrawableWrapper.class, version);
    }
    catch (IOException e)
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

      {
        url = new File(".").toURI().toURL();
      }
      final SVGDocument document = (SVGDocument) loader.loadDocument
          (url.toURI().toASCIIString(), data.getResourceAsStream(caller));
      final BridgeContext ctx = new BridgeContext(userAgent, loader);
      final GVTBuilder builder = new GVTBuilder();
      final GraphicsNode node = builder.build(ctx, document);
      final Rectangle2D bounds = node.getBounds();

      final SVGDrawable drawable = new SVGDrawable(node);
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

      final SVGOMDocument doc = (SVGOMDocument) f.createDocument(uri);

      // Initialize the CSS Engine for the document
      final SVGDOMImplementation impl = (SVGDOMImplementation) SVGDOMImplementation.getDOMImplementation();
      final UserAgent userAgent = new UserAgentAdapter();
      final BridgeContext ctx = new BridgeContext(userAgent, new DocumentLoader(userAgent));
      doc.setCSSEngine(impl.createCSSEngine(doc, ctx));

      return Context.javaToJS(doc, scope);
    }
    catch (Exception e)
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

        private ImageInfo createImageInfo(String uri, ImageContext context, SVGDocument doc) {
            Element e = doc.getRootElement();
            float pxUnitToMillimeter = UnitConv.IN2MM / context.getSourceResolution();
            SVGUserAgent userAg = new SVGUserAgent(pxUnitToMillimeter,
                        new AffineTransform());
            BridgeContext ctx = new BridgeContext(userAg);
            UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e);

            String s;
            // 'width' attribute - default is 100%
            s = e.getAttributeNS(null, SVGOMDocument.SVG_WIDTH_ATTRIBUTE);
View Full Code Here

Examples of org.apache.batik.bridge.BridgeContext

        }
        SVGUserAgent ua = new SVGUserAgent(
                pxToMillimeter,
                new AffineTransform());
        GVTBuilder builder = new GVTBuilder();
        final BridgeContext ctx = new BridgeContext(ua);

        //Build the GVT tree
        final GraphicsNode root;
        try {
            root = builder.build(ctx, svg.getDocument());
        } catch (Exception e) {
            throw new ImageException("GVT tree could not be built for SVG graphic", e);
        }

        //Create the painter
        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public void paint(Graphics2D g2d, Rectangle2D area) {
                // If no viewbox is defined in the svg file, a viewbox of 100x100 is
                // assumed, as defined in SVGUserAgent.getViewportSize()
                float iw = (float) ctx.getDocumentSize().getWidth();
                float ih = (float) ctx.getDocumentSize().getHeight();
                float w = (float) area.getWidth();
                float h = (float) area.getHeight();
                g2d.translate(area.getX(), area.getY());
                g2d.scale(w / iw, h / ih);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.