Package org.mt4j.util

Examples of org.mt4j.util.SwingTextureRenderer


          BoundsZPlaneRectangle boundsZ = new BoundsZPlaneRectangle(shape, shape.getVerticesLocal());
          Vector3D[] boundsVecs = boundsZ.getVectorsLocal();
          float bBoxWidth  = boundsZ.getWidthXY(TransformSpace.LOCAL);//boundsVecs[1].x - boundsVecs[0].x;
          float bBoxHeight = boundsZ.getHeightXY(TransformSpace.LOCAL);//boundsVecs[2].y - boundsVecs[1].y;

          SwingTextureRenderer swingTex;
          final MTRectangle rectangle;

          //Trial to make the texture as big as the bigger side of the bounding rectangle of the shape
          //to allow for automatic texture stretching to fit when texture is applied
          int size = -1;
          if (coordSystemType == SVGUtilities.OBJECT_BOUNDING_BOX){
            if (bBoxWidth >= bBoxHeight){
              size = Math.round(bBoxWidth);
              r *= bBoxWidth;
            }else{
              size = Math.round(bBoxHeight);
              r *= bBoxHeight;
            }

            AffineTransform Mx = new AffineTransform();
            Rectangle2D bounds = new Rectangle(Math.round(boundsVecs[0].x), Math.round(boundsVecs[0].y), size, size);
            if (bounds != null) {
              //we dont translate the center and focal point
              //instead we create the gradient mask shape at that position
//            Mx.translate(bounds.getX(), bounds.getY());
              Mx.scale(bounds.getWidth(), bounds.getHeight());
            }
            Mx.concatenate(transform);
            transform = Mx;

            //Transform gradient vector points with gradientTransform
            transform.transform(c, c);
            transform.transform(f, f);

            GradientPanel gradPanel = new GradientPanel(size, size, r, offsets, colors, (float)c.getX(), (float)c.getY(), (float)f.getX(), (float)f.getY(), awtCycleMethod);
//          GradientPanel gradPanel = new GradientPanel(bBoxWidth, bBoxHeight, r, offsets, colors, (float)c.getX(), (float)c.getY(), (float)f.getX(), (float)f.getY());
            swingTex = new SwingTextureRenderer(app, gradPanel);
            swingTex.scheduleRefresh();
            rectangle = new MTRectangle(new Vertex(boundsVecs[0]), bBoxWidth, bBoxHeight, pa);
            rectangle.setName("Swing texture rendering");
            rectangle.setTexture(swingTex.getTextureToRenderTo());
            rectangle.setNoStroke(true);
            rectangle.setPickable(false);
            rectangle.setFillDrawMode(GL.GL_QUADS);

            //Use displaylist by default for gradientshape
            if (MT4jSettings.getInstance().isOpenGlMode()){
              app.invokeLater(new InvokeLaterAction(rectangle));
            }

            //FIXME REMOVE TEST
            /*//Draw the shape we draw in swing
          MTRectangle rectanglePaintedComp = new MTRectangle(new Vertex(boundsVecs[0]), size, size, pa);
          rectanglePaintedComp.setName("rectanglePaintedComp");
          rectanglePaintedComp.setTexture(swingTex.getTextureToRenderTo());
          rectanglePaintedComp.setFillColor(255, 255, 255, 150);
          shape.addChild(rectanglePaintedComp);
             */
          }else{
            //coordsystemtype = userSpaceOnUse!

            //FIXME Problem at userOnSpace with proportional length (%)
            //seems we have to take the width/height from the viewbox then!? and use bounding box code above? but we have to recalculate absoulte values then..

            //Since we draw the gradient at 0,0 we have to transform the gradient points to there
            AffineTransform Mx = new AffineTransform();
            Mx.translate(-boundsVecs[0].x, -boundsVecs[0].y);
            Mx.concatenate(transform);
            transform = Mx;

            //Transform gradient points with gradientTransform
            transform.transform(c, c);
            transform.transform(f, f);

//          GradientPanel gradPanel = new GradientPanel(size, size, r, offsets, colors, (float)c.getX(), (float)c.getY(), (float)f.getX(), (float)f.getY());
            GradientPanel gradPanel = new GradientPanel(bBoxWidth, bBoxHeight, r, offsets, colors, (float)c.getX(), (float)c.getY(), (float)f.getX(), (float)f.getY(), awtCycleMethod);
            swingTex = new SwingTextureRenderer(app, gradPanel);
            swingTex.scheduleRefresh();
            rectangle = new MTRectangle(new Vertex(boundsVecs[0]), bBoxWidth, bBoxHeight, pa);
            final GLTexture tex = swingTex.getTextureToRenderTo();
            rectangle.setName("Swing texture rendering");
            rectangle.setTexture(tex);
            rectangle.setNoStroke(true);
            rectangle.setPickable(false);

View Full Code Here

TOP

Related Classes of org.mt4j.util.SwingTextureRenderer

Copyright © 2018 www.massapicom. 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.