Examples of MTRectangle


Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

   * @param y the y
   * @param width the width
   * @param height the height
   */
  public Clip(PApplet pApplet, float x, float y, float width, float height) {
    MTRectangle clipRect = new MTRectangle(x, y, width, height, pApplet);
    clipRect.setNoStroke(true);
    if (clipRect.getBounds() == null ){
      clipRect.setBounds(new BoundsZPlaneRectangle(clipRect));
    }else{
      if (!(clipRect.getBounds() instanceof BoundsZPlaneRectangle)){
        clipRect.setBounds(new BoundsZPlaneRectangle(clipRect));
      }
    }
    clipRect.setBoundsBehaviour(AbstractShape.BOUNDS_ONLY_CHECK)
    this.clipShape = clipRect;
   
    if (MT4jSettings.getInstance().isOpenGlMode()){
      this.gl = Tools3D.getGL(pApplet)
    }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

          //If we want to modify the MT4j applet from the swing thread
          //we should wrap the actions into an invokeLater runnable which
          //will be executed the next time the mt4j thread runs.
          instance.invokeLater(new Runnable() {
            public void run() {
              MTRectangle r = new MTRectangle(0,0,ToolsMath.getRandom(50, 250),ToolsMath.getRandom(50, 250), instance);
              r.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
              r.addGestureListener(DragProcessor.class, new InertiaDragAction());
              instance.getCurrentScene().getCanvas().addChild(r);
              r.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, instance.width), ToolsMath.getRandom(0, instance.height)));
            }
          });
         
        }
      }
    });
        menu.add(addRectItem);
       
        JMenuItem addRoundRectItem = new JMenuItem("MTRoundRectangle", KeyEvent.VK_E);
        addRoundRectItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        if (instance.getCurrentScene() != null){
          //If we want to modify the MT4j applet from the swing thread
          //we should wrap the actions into an invokeLater runnable which
          //will be executed the next time the mt4j thread runs.
          instance.invokeLater(new Runnable() {
            public void run() {
              float arc = ToolsMath.getRandom(8, 25);
              MTRoundRectangle r = new MTRoundRectangle(0,0,0, ToolsMath.getRandom(50, 250),ToolsMath.getRandom(50, 250), arc, arc, instance);
              r.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
              r.addGestureListener(DragProcessor.class, new InertiaDragAction());
              instance.getCurrentScene().getCanvas().addChild(r);
              r.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, instance.width), ToolsMath.getRandom(0, instance.height)));
            }
          });
         
        }
      }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

    super(mtApplication, name);
    CursorTracer c = new CursorTracer(mtApplication, this);
    registerGlobalInputProcessor(c);
    int count = 2;
    for (int i = 0; i < count; i++) {
      MTRectangle r = new MTRectangle(0,0,ToolsMath.getRandom(50, 250),ToolsMath.getRandom(50, 250),mtApplication);
      r.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
      r.addGestureListener(DragProcessor.class, new InertiaDragAction());
      getCanvas().addChild(r);
      r.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, mtApplication.width), ToolsMath.getRandom(0, mtApplication.height)));
    }
  }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

    else
      this.setDrawActionText(true);
   
    b =  new Vector3D(this.getWidthXY(TransformSpace.RELATIVE_TO_PARENT)/2, this.getHeightXY(TransformSpace.RELATIVE_TO_PARENT)/2, 0);
   
    outerBar = new MTRectangle(0, 0, 0, 200, 30, pa);
    outerBar.setStrokeWeight(1);
//    outerBar.setNoStroke(true);
    outerBar.setStrokeColor(new MTColor(0, 0, 0, 255));
    outerBar.setFillColor(new MTColor(100, 100, 100, 200));
   
    outerBar.setGestureAllowance(DragProcessor.class, false);
    outerBar.setGestureAllowance(RotateProcessor.class, false);
    outerBar.setGestureAllowance(ScaleProcessor.class, false);
    outerBar.setGestureAllowance(TapProcessor.class, false);
   
    c = new Vector3D(b.x -  outerBar.getWidthXY(TransformSpace.RELATIVE_TO_PARENT)/2, b.y - outerBar.getHeightXY(TransformSpace.RELATIVE_TO_PARENT)/2, 0);
    outerBar.translate(c);
    outerBar.setName("MTProgressbar outer bar");
    this.addChild(outerBar);
   
    innerBar = new MTRectangle(0, 0, 0, 199, 29, pa);
    innerBar.setStrokeWeight(1);
    innerBar.setNoStroke(true);
    innerBar.setStrokeColor(new MTColor(255, 255, 255, 200));
    innerBar.setFillColor(new MTColor(250, 150, 150, 200));
   
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

   
    //Create inner children clip shape
    float border = 10;
    GL gl = ((PGraphicsOpenGL)applet.g).gl;
//    MTRoundRectangle clipRect =  new MTRoundRectangle(x+border, y+border, z, width-(2*border), height-(2*border), arcWidth, arcHeight, applet);
    MTRectangle clipRect =  new MTRectangle(x+border, y+border, z, width-(2*border), height-(2*border), applet);
    clipRect.setDrawSmooth(true);
    clipRect.setNoStroke(true);
    clipRect.setBoundsBehaviour(MTRectangle.BOUNDS_ONLY_CHECK);
    this.clip = new Clip(gl, clipRect);
    this.setChildClip(this.clip);
    this.drawInnerBorder = true;
   
    //Add window background
    final MTRectangle windowBackGround = new MTRectangle(x, y, z, 100, 200, applet);
    windowBackGround.setFillColor(new MTColor(200,200,200,255));
    windowBackGround.setNoStroke(true);
    windowBackGround.setPickable(false);
    this.addChild(windowBackGround);
   
    this.removeAllGestureEventListeners(ScaleProcessor.class);
//    cr.removeAllGestureEventListeners(RotationDetector.class);
    this.addGestureListener(ScaleProcessor.class, new IGestureEventListener(){
      //@Override
      public boolean processGestureEvent(MTGestureEvent ge) {
        ScaleEvent se = (ScaleEvent)ge;
       
        //Scale window background normally
        windowBackGround.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorZ(), se.getScalingPoint());
       
        //Scale vertices of the window
        AbstractShape target = (AbstractShape)ge.getTargetComponent();
        Vertex[] verts = target.getGeometryInfo().getVertices();
        Vector3D newScalingPoint = target.globalToLocal(se.getScalingPoint());
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

            rx = width/2;
          if (ry > height/2 )
            ry = height/2;
          comp = new MTRoundRectangle(x,y,0, width,height,rx, ry, pa);
        }else{
          comp = new MTRectangle(x,y, width,height, pa);
        }
       
        try{
          comp.setLocalMatrix(currentLocalTransformMatrix);
        }catch(Exception e){
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

          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);

//          /*//
            if (MT4jSettings.getInstance().isOpenGlMode()){
              app.invokeLater(new InvokeLaterAction(rectangle));
            }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

   * @param pApplet the applet
   */
  public MTImage(PImage texture, PApplet pApplet) {
    super(-7, -7, texture.width + 14, texture.height + 14, pApplet);
   
    image = new MTRectangle(texture, pApplet);
    image.setStrokeColor(new MTColor(255,255,255,255));
    image.setPickable(false);
    this.addChild(image);
   
    //Draw this component and its children above
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

        drawingScene = new DrawSurfaceScene(pa, "DrawSurface Scene");
        drawingScene.setClear(false);
      
        //Create texture brush
        PImage brushImage = getMTApplication().loadImage(imagesPath + "brush1.png");
    textureBrush = new MTRectangle(brushImage, getMTApplication());
    textureBrush.setPickable(false);
    textureBrush.setNoFill(false);
    textureBrush.setNoStroke(true);
    textureBrush.setDrawSmooth(true);
    textureBrush.setFillColor(new MTColor(0,0,0));
View Full Code Here

Examples of org.mt4j.components.visibleComponents.shapes.MTRectangle

     
      break;
    case MODE_WRAP:
      //if in MODE_WRAP also reset the size of the CLIP SHAPE!
      if (MT4jSettings.getInstance().isOpenGlMode() && this.getClip() != null && this.getClip().getClipShape() instanceof MTRectangle){
        MTRectangle clipRect = (MTRectangle)this.getClip().getClipShape();
        //        clipRect.setWidthLocal(this.getWidthXY(TransformSpace.LOCAL));
        //Clip the text to the area
        //        this.setClip(new Clip(pApplet, this.getVerticesLocal()[0].x, this.getVerticesLocal()[0].y, this.getWidthXY(TransformSpace.LOCAL), this.getHeightXY(TransformSpace.LOCAL)));
        //        clipRect.setVertices(Vertex.getDeepVertexArrayCopy(this.getVerticesLocal()));
        clipRect.setVertices(this.getVerticesLocal());
      }
      this.updateLayout();
      break;
    default:
      break;
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.