Examples of GraphicContext


Examples of org.apache.batik.ext.awt.g2d.GraphicContext

        // b. Modify the value of each of the context attributes
        // c. Dump new list of SVG attributes
        // d. Dump list of defs
        //

        GraphicContext gc = new GraphicContext(new AffineTransform());
        SVGGraphicContextConverter converter =
            new SVGGraphicContextConverter(getContext(domFactory));
        SVGGraphicContext defaultSVGGC = converter.toSVG(gc);
        traceSVGGC(defaultSVGGC, converter);

        // Transform
        gc.translate(40, 40);

        // Paint
        gc.setPaint(new GradientPaint(0, 0, Color.yellow, 200, 200, Color.red));

        // Stroke
        gc.setStroke(new BasicStroke(4, BasicStroke.CAP_ROUND,
                                     BasicStroke.JOIN_BEVEL, 40, new float[]{ 4, 5, 6, 7 }, 3));

        // Composite
        gc.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN, .25f));

        // Clip
        gc.setClip(new Ellipse2D.Double(20, 30, 40, 50));

        // Hints
        gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        // Font
        gc.setFont(new Font("French Script MT", Font.BOLD, 45));

        SVGGraphicContext modifiedSVGGC = converter.toSVG(gc);

        traceSVGGC(modifiedSVGGC, converter);
View Full Code Here

Examples of org.apache.batik.ext.awt.g2d.GraphicContext

        trace(group, System.out);
    }

    public void testSVGTransform() throws Exception {
        GraphicContext gc = new GraphicContext();
        gc.translate(20, 20);
        gc.rotate(Math.PI/4);
        gc.shear(.5, .5);
        gc.scale(20, 20);

        AffineTransform txf = new AffineTransform();
        txf.translate(60, 60);
        gc.transform(txf);

        String svgTransform = SVGTransform.toSVGTransform(gc);
        System.out.println("SVG Transform: " + svgTransform);

        gc.setTransform(new AffineTransform());
        gc.translate(45, 45);

        svgTransform = SVGTransform.toSVGTransform(gc);
        System.out.println("SVG Transform: " + svgTransform);

        gc.setTransform(new AffineTransform());
        gc.translate(10, 10);
        gc.translate(30, 30);
        gc.scale(2, 3);
        gc.scale(3, 2);
        gc.rotate(Math.PI/2);
        gc.rotate(Math.PI/2);
        gc.translate(100, 100);
        gc.translate(-100, -100);
        gc.scale(2, 2);
        gc.scale(.5, .5);
        gc.rotate(Math.PI/2);
        gc.rotate(-Math.PI/2);

        svgTransform = SVGTransform.toSVGTransform(gc);
        System.out.println("SVG Transform: " + svgTransform);
    }
View Full Code Here

Examples of org.apache.batik.ext.awt.g2d.GraphicContext

            // not error handler here as we don't have the ctx...
            throw new SVGGraphics2DRuntimeException(ERR_CONTEXT_NULL);

        this.generatorCtx = generatorCtx;

        this.gc = new GraphicContext(new AffineTransform());
        this.shapeConverter = new SVGShape(generatorCtx);
        this.domTreeManager = new DOMTreeManager(gc,
                                                 generatorCtx,
                                                 DEFAULT_MAX_GC_OVERRIDES);
        this.domGroupManager = new DOMGroupManager(gc, domTreeManager);
View Full Code Here

Examples of org.apache.batik.ext.awt.g2d.GraphicContext

     * Sets an non null <code>SVGGeneratorContext</code>.
     */
    private void setGeneratorContext(SVGGeneratorContext generatorCtx) {
        this.generatorCtx = generatorCtx;

        this.gc = new GraphicContext(new AffineTransform());

        SVGGeneratorContext.GraphicContextDefaults gcDefaults =
            generatorCtx.getGraphicContextDefaults();

        if(gcDefaults != null){
View Full Code Here

Examples of org.apache.batik.ext.awt.g2d.GraphicContext

     * Sets an non null <code>SVGGeneratorContext</code>.
     */
    private void setGeneratorContext(SVGGeneratorContext generatorCtx) {
        this.generatorCtx = generatorCtx;

        this.gc = new GraphicContext(new AffineTransform());

        SVGGeneratorContext.GraphicContextDefaults gcDefaults =
            generatorCtx.getGraphicContextDefaults();

        if(gcDefaults != null){
View Full Code Here

Examples of org.apache.batik.ext.awt.g2d.GraphicContext

     * Sets an non null <code>SVGGeneratorContext</code>.
     */
    private void setGeneratorContext(SVGGeneratorContext generatorCtx) {
        this.generatorCtx = generatorCtx;

        this.gc = new GraphicContext(new AffineTransform());

        SVGGeneratorContext.GraphicContextDefaults gcDefaults =
            generatorCtx.getGraphicContextDefaults();

        if(gcDefaults != null){
View Full Code Here

Examples of org.apache.flex.compiler.internal.fxg.dom.GraphicContext

    }
   

    private PlaceObject3Tag bitmapWithClip(DefineImage defImage, BitmapGraphicNode node)
    {
        GraphicContext context = node.createGraphicContext();

        //process the filters later to avoid masking
        List<IFilterNode> filters = null;
        if (context.filters != null)      
        {  
            filters = context.filters;
            context.filters = null;
            DefineSpriteTag filterSprite = createDefineSpriteTag("MaskFilter");
            spriteStack.push(filterSprite);
        }
       
        DefineSpriteTag imageSprite = createDefineSpriteTag("BitmapGraphic");
        spriteStack.push(imageSprite);
       
        // First, generate the clipping mask
        DefineSpriteTag clipSprite = createDefineSpriteTag("BitmapGraphic_Clip");
        spriteStack.push(clipSprite);
       
        double width = (defImage.getWidth() < node.width) ? defImage.getWidth() : node.width;
        double height = (defImage.getHeight() < node.height) ? defImage.getHeight() : node.height;
        List<ShapeRecord> shapeRecords = ShapeHelper.rectangle(0.0, 0.0, width, height);
        DefineShapeTag clipShape = createDefineShapeTag(null, shapeRecords, new SolidColorFillNode(), null, context.getTransform());
        PlaceObject3Tag(clipShape, new GraphicContext());
        spriteStack.pop();
       
        //place the clipping mask in the imageSprite
        PlaceObject3Tag po3clip = PlaceObject3Tag(clipSprite, context);
        po3clip.setClipDepth(po3clip.getDepth()+1);
        po3clip.setHasClipDepth(true);
        // Then, process the image
        DefineShapeTag imageShape = ImageHelper.createShapeForImage(defImage, node);
        PlaceObject3Tag(imageShape, context);       
        spriteStack.pop();
       
        PlaceObject3Tag po3 = PlaceObject3Tag(imageSprite, new GraphicContext());
       
        // If filters were not processed, place the topmost sprite in display list and apply filters
        // This is done to force processing of masks before filters
        if (filters != null)
        {
            DefineSpriteTag sprite = spriteStack.pop();
            GraphicContext gc = new GraphicContext();
            gc.filters = filters;
            PlaceObject3Tag poFilter = PlaceObject3Tag(sprite, gc);
            return poFilter;           
        }
        return po3;
View Full Code Here

Examples of org.apache.flex.compiler.internal.fxg.dom.GraphicContext

    // Graphic Content Nodes
    //
    // --------------------------------------------------------------------------
    protected PlaceObject3Tag bitmap(BitmapGraphicNode node)
    {
        GraphicContext context = node.createGraphicContext();
        String source = parseSource(node.source);

        if (source == null)
        {
            // Missing source attribute in <BitmapGraphic> or <BitmapFill>.
            problems.add(new FXGMissingAttributeProblem(node.getDocumentPath(), node.getStartLine(),
                    node.getStartColumn(), FXGConstants.FXG_SOURCE_ATTRIBUTE, node.getNodeName()));
            return null;
       }
       
        DefineImage imageTag = createDefineBitsTag(node, source);
        if(imageTag == null)
            return null;
       
        if ((node.visible) && (!node.isPartofClipMask))
        {
      
            DefineShapeTag imageShape;
            ScalingGrid scalingGrid = context.scalingGrid;
            if (scalingGrid != null)
            {
                Rect grid = TypeHelper.rect(scalingGrid.scaleGridLeft, scalingGrid.scaleGridTop, scalingGrid.scaleGridRight, scalingGrid.scaleGridBottom);
                imageShape = ImageHelper.create9SlicedShape(imageTag, grid, Double.NaN, Double.NaN);
                PlaceObject3Tag po3 = PlaceObject3Tag(imageShape, context);
                return po3;
            }
            else
            {
              if (ImageHelper.bitmapImageNeedsClipping(imageTag, node))
              {
                PlaceObject3Tag p03 = bitmapWithClip(imageTag, node);
                return p03;
              }
              else
              {
                imageShape = ImageHelper.createShapeForImage(imageTag, node);
                PlaceObject3Tag po3 = PlaceObject3Tag(imageShape, context);
                return po3;
              }
            }           
        }
        else
        {
          if (!ImageHelper.bitmapImageNeedsClipping(imageTag, node))
          {          
               double width = (Double.isNaN(node.width)) ? imageTag.getWidth() : node.width;
                 double height = (Double.isNaN(node.height)) ? imageTag.getHeight() : node.height;
             List<ShapeRecord>  shapeRecords = ShapeHelper.rectangle(0.0, 0.0, width, height);       
               DefineShapeTag shape = createDefineShapeTag(null, shapeRecords, new SolidColorFillNode(), null, context.getTransform());
             PlaceObject3Tag po3 = PlaceObject3Tag(shape, context);
             return po3;
          }
          else
          {
                double width = ((imageTag.getWidth() < node.width) || Double.isNaN(node.width)) ? imageTag.getWidth() : node.width;
                double height = ((imageTag.getHeight() < node.height) || (Double.isNaN(node.height))) ? imageTag.getHeight() : node.height;
              List<ShapeRecord>  shapeRecords = ShapeHelper.rectangle(0.0, 0.0, width, height);       
                 DefineShapeTag shape = createDefineShapeTag(null, shapeRecords, new SolidColorFillNode(), null, context.getTransform());
              PlaceObject3Tag po3 = PlaceObject3Tag(shape, context);
              return po3;
          }
        }
    }
View Full Code Here

Examples of org.apache.flex.compiler.internal.fxg.dom.GraphicContext

            // If filters were not processed, place the topmost sprite in display list and apply filters
            // This is done to force processing of masks before filters
            if (filters != null)
            {
                DefineSpriteTag sprite = spriteStack.pop();
                GraphicContext gc = new GraphicContext();
                gc.filters = filters;
                PlaceObject3Tag poFilter = PlaceObject3Tag(sprite, gc);
                return poFilter;           
            }
        }
View Full Code Here

Examples of org.apache.flex.compiler.internal.fxg.dom.GraphicContext

          else
            node.blendMode = BlendMode.LAYER;
        }
       
        DefineSpriteTag groupSprite = createDefineSpriteTag("Group");
        GraphicContext context = node.createGraphicContext();
       
        // Handle 'scale 9' grid definition
        if (node.definesScaleGrid())
        {
            DefineScalingGridTag grid = createDefineScalingGridTag(context.scalingGrid);
            grid.setCharacter(groupSprite);
            extraTags.put(groupSprite,grid);
            //groupSprite.scalingGrid = grid;
        }

        PlaceObject3Tag po3 = PlaceObject3Tag(groupSprite, context);
        spriteStack.push(groupSprite);
       
        // First, process mask (if present)
        List <IFilterNode> filters = null;
        if (node.mask != null)
        {   
            // Remove the filters from context and process them later to force Flash Player to process the masks first
            filters = node.filters;
            if (filters == null)
            {
                List<GraphicContentNode> children = node.children;
                if (children != null)
                {
                    GraphicContentNode gcNode0 = (GraphicContentNode) children.get(0);
                    filters = gcNode0.filters;
                    if (filters != null)
                    {
                        //check if all the nodes share the same filter
                        for (int i = 1; ((i < children.size()) && filters!= null); i++)
                        {
                            GraphicContentNode gcNodeI = (GraphicContentNode) children.get(i);
                            if (gcNodeI.filters != filters)
                                filters = null;
                        }
                    }

                    if (filters != null)
                    {
                        for (int i = 0; (i < children.size()) ; i++)
                        {
                            GraphicContentNode gcNodeI = (GraphicContentNode) children.get(i);
                            gcNodeI.filters = null;
                        }                       
                    }
                   
                }
            }
            else
            {
                node.filters = null;
            }
            if (filters != null)      
            {   
                DefineSpriteTag filterSprite = createDefineSpriteTag("MaskFilter");
                spriteStack.push(filterSprite);
            }
            DefineSpriteTag sprite = spriteStack.peek();
            mask(node, sprite);
        }

        // Then process child nodes.
        if (node.children != null)
            graphicContentNodes(node.children);
       
        // If filters were not processed, place the topmost sprite in display list and apply filters
        // This is done to force processing of masks before filters
        if (filters != null)
        {
            DefineSpriteTag sprite = spriteStack.pop();
            GraphicContext gc = new GraphicContext();
            gc.filters = filters;
            PlaceObject3Tag poFilter = PlaceObject3Tag(sprite, gc);
            return poFilter;           
        }
        spriteStack.pop();
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.