Examples of MTPolygon


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

          new Vertex(app.width,   app.height/30,   0,0,0,255),
          new Vertex(app.width,   app.height/1.7f,0170,170,140,255),
          new Vertex(0,      app.height/1.7f,0170,170,140,255),
          new Vertex(0,       app.height/300,0,0,255),
      };
      MTPolygon p = new MTPolygon(vertices, getMTApplication());
      p.setName("upper gradient");
      p.setNoStroke(true);
      p.generateAndUseDisplayLists();
      p.setPickable(false);
      this.getCanvas().addChild(p);
     
      Vertex[] vertices2 = new Vertex[]{
          new Vertex(0,       app.height/1.7f0,   170,170,140,255),
          new Vertex(app.width,   app.height/1.7f0,   170,170,140,255),
          new Vertex(app.width,   app.height,      00,0,0,255),
          new Vertex(0,      app.height,      00,0,0,255),
          new Vertex(0,       app.height/1.7f0,   170,170,140,255),
      };
      MTPolygon p2 = new MTPolygon(vertices2, getMTApplication());
      p2.setNoStroke(true);
      p2.generateAndUseDisplayLists();
      p2.setPickable(false);
      this.getCanvas().addChild(p2);
    }
    //BACKGROUND
   
    preferredIconWidth = 256;
View Full Code Here

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

        new Vertex(realListCellWidth-topShift,          listCellHeight -border,  0, 1,0),
        new Vertex(realListCellWidth-topShift - icon.height, listCellHeight -border,  0, 1,1),
        new Vertex(realListCellWidth-topShift - icon.height,  border,          0, 0,1),
        new Vertex(realListCellWidth-topShift,         border,          0, 0,0),
    };
    MTPolygon p = new MTPolygon(vertices, getMTApplication());
    p.setTexture(icon);
//    p.setNoStroke(true);
//    p.setStrokeColor(new MTColor(150,150,150, 255));
    p.setStrokeColor(new MTColor(80,80,80, 255));
   
    Vertex[] verticesRef = new Vertex[]{
        new Vertex(listCellWidth - icon.height - reflectionDistanceFromImage,                    border,  0,   0,0),
        new Vertex(listCellWidth - icon.height - reflectionDistanceFromImage,            listCellHeight -border,  0,   1,0),
        new Vertex(listCellWidth - icon.height - reflection.height - reflectionDistanceFromImage,   listCellHeight -border,  0,   1,1),
        new Vertex(listCellWidth - icon.height - reflection.height - reflectionDistanceFromImage,        border,  0,   0,1),
        new Vertex(listCellWidth - icon.height - reflectionDistanceFromImage,                   border,  0,   0,0),
    };
    MTPolygon pRef = new MTPolygon(verticesRef, getMTApplication());
    pRef.setTexture(reflection);
    pRef.setNoStroke(true);
   
    cell.addChild(p);
    cell.addChild(pRef);
   
    list.addListElement(cell);
View Full Code Here

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

        verts = newVerts;
      }else{
        //ERROR
      }
    }
    MTPolygon poly = new MTPolygon2D(verts, app);
    return poly;
  }
View Full Code Here

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

  }
 
  private void initTiles(){
    SVGLoader l = new SVGLoader(app);
    MTComponent knob = l.loadSvg(svgPath + svgname);
    MTPolygon knobRight = (MTPolygon) knob.getChildByIndex(0).getChildByIndex(0);
    knobRight.setNoFill(false);
    knobRight.setUseDisplayList(false);
    float origHeight = knobRight.getHeightXY(TransformSpace.LOCAL);
   
    //Snap to upper left 0,0
    Vertex[] originalVerts = knobRight.getVerticesLocal();
    originalVerts = Vertex.translateArray(originalVerts, Vector3D.ZERO_VECTOR.getSubtracted(new Vector3D(originalVerts[0])));
   
    upDownOrderVerticalRightOut = Vertex.getDeepVertexArrayCopy(originalVerts);
    //Scale to desired height
    Vertex.scaleVectorArray(upDownOrderVerticalRightOut, Vector3D.ZERO_VECTOR, (1f/origHeight) * tileHeight, (1f/origHeight) * tileHeight, 1);
View Full Code Here

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

    Vertex[] shapeAndGradVerts = new Vertex[shapeVertsCopy.length + gradientRectVerts.length];
    System.arraycopy(shapeVertsCopy, 0, shapeAndGradVerts, 0, shapeVertsCopy.length);
    System.arraycopy(gradientRectVerts, 0, shapeAndGradVerts, shapeVertsCopy.length, gradientRectVerts.length);
   
    //Create a temporary polygon with the roated vertices to calc BBox
    MTPolygon inverseRotatedShape = new MTPolygon(shapeAndGradVerts, pa);
    //Calculate a bounding rectangle from the rotated shape
    BoundsZPlaneRectangle inverseRotatedBounds = new BoundsZPlaneRectangle(inverseRotatedShape);
    Vector3D[] invBoundsVecs = inverseRotatedBounds.getVectorsLocal();
   
    //logger.debug("Gradient Rectangle width: " + gradientRectWidth);
   
    //Get the positions where the offsets are on the gradient vector
//    float bBoxWidth  = invBoundsVecs[1].x - invBoundsVecs[0].x;
//    logger.debug("BBox width: " + bBoxWidth);
//    float w = bBoxWidth/*/100*/;
    List<Float> xStops = new ArrayList<Float>();
   
    //- Go through stops
    //- multiply stop offsets with bbox width to get the position on gradient vector
    //logger.debug("->Gradient Vector stop positions:");
    for(Stop stop : stops){
      float offsetStopPosition = gradientRectWidth * stop.offset; //position auf gradient vector, stop(0) = vP1.x + offest
      xStops.add(offsetStopPosition);
      //logger.debug(" Offset-Stop-Position: " + offsetStopPosition);
    }
   
    //Calc new gradient polygon vertices with vertices at the stop locations
    Vertex[] newBounds = new Vertex[(xStops.size()-1) * 4];
    for (int i = 0; i < xStops.size()-1; i++) {
      float offset = xStops.get(i);
      Color stopColor = stops.get(i).color;
     
      float nextOffset = xStops.get(i+1);
      Color nextStopColor = stops.get(i+1).color;
     
      newBounds[i*4]     = new Vertex(vP1.x + offset,     invBoundsVecs[0].y,0,   stopColor.getRed(), stopColor.getGreen(), stopColor.getBlue(), stopColor.getAlpha());
      newBounds[i*4+1= new Vertex(vP1.x + nextOffset, invBoundsVecs[0].y,0,   nextStopColor.getRed(), nextStopColor.getGreen(), nextStopColor.getBlue(), nextStopColor.getAlpha());
      newBounds[i*4+2]   = new Vertex(vP1.x + nextOffset, invBoundsVecs[2].y,0,   nextStopColor.getRed(), nextStopColor.getGreen(), nextStopColor.getBlue(), nextStopColor.getAlpha());
      newBounds[i*4+3= new Vertex(vP1.x + offset,    invBoundsVecs[2].y,0,   stopColor.getRed(), stopColor.getGreen(), stopColor.getBlue(), stopColor.getAlpha());
    }
   
    //Put gradient rectangle quads into a list
    List<Vertex> gradientRectQuads = new ArrayList<Vertex>();
    for (int i = 0; i < newBounds.length; i++) {
      Vertex vertex = newBounds[i];
      gradientRectQuads.add(vertex);
    }
   
    /* Bounding shape with gradient rectangle inside (can also overlap outlines)
     invBoundsVecs[0]       invBoundsVecs[1]
            | _______________ |
           |   |_____|    |
           |   |  G  |     |
           | vp1|____>|vp2 |
           |____|_____|____|
     */
    //Calc rectangle bands (quads) to fill the gradient shape with the gradVect end colors if the gradient vector is smaller than the shape to draw
    List<Vertex> leftQuad = new ArrayList<Vertex>();
    if (vP1.x > invBoundsVecs[0].x){
      //upper left of bounding rect
      Vertex v1 = new Vertex(invBoundsVecs[0].x, invBoundsVecs[0].y, 0, newBounds[0].getR(), newBounds[0].getG(), newBounds[0].getB(), newBounds[0].getA());
      //first stop on gradient vector upper
      Vertex v2 = new Vertex(newBounds[0].x, newBounds[0].y, 0, newBounds[0].getR(), newBounds[0].getG(), newBounds[0].getB(), newBounds[0].getA());
      //first stop on gradient vector lower
      Vertex v3 = new Vertex(newBounds[3].x, newBounds[3].y, 0, newBounds[3].getR(), newBounds[3].getG(), newBounds[3].getB(), newBounds[3].getA());
      //down left of bounding rect
      Vertex v4 = new Vertex(invBoundsVecs[3].x, invBoundsVecs[3].y, 0, newBounds[0].getR(), newBounds[0].getG(), newBounds[0].getB(), newBounds[0].getA());
     
      leftQuad.add(v1);
      leftQuad.add(v2);
      leftQuad.add(v3);
      leftQuad.add(v4);
    }
   
    //Add Right quad if gradient rectangle is smaler than overall bounds
    List<Vertex> rightQuad = new ArrayList<Vertex>();
    if (vP2.x < invBoundsVecs[1].x){
      Vertex gradientRectUpperRight = newBounds[newBounds.length-3];
      Vertex gradientRectLowerRight = newBounds[newBounds.length-2];
     
      Vertex v1 = new Vertex(gradientRectUpperRight.x, gradientRectUpperRight.y, 0, gradientRectUpperRight.getR(), gradientRectUpperRight.getG(), gradientRectUpperRight.getB(), gradientRectUpperRight.getA());
      Vertex v2 = new Vertex(invBoundsVecs[1].x, invBoundsVecs[1].y, 0, gradientRectUpperRight.getR(), gradientRectUpperRight.getG(), gradientRectUpperRight.getB(), gradientRectUpperRight.getA());
      Vertex v3 = new Vertex(invBoundsVecs[2].x, invBoundsVecs[2].y, 0, gradientRectUpperRight.getR(), gradientRectUpperRight.getG(), gradientRectUpperRight.getB(), gradientRectUpperRight.getA());
      Vertex v4 = new Vertex(gradientRectLowerRight.x, gradientRectLowerRight.y, 0, gradientRectUpperRight.getR(), gradientRectUpperRight.getG(), gradientRectUpperRight.getB(), gradientRectUpperRight.getA());
     
      rightQuad.add(v1);
      rightQuad.add(v2);
      rightQuad.add(v3);
      rightQuad.add(v4);
    }
   
    //Create new array for gradient shape with all quads inside
    List<Vertex> allGradientShapeVerts = new ArrayList<Vertex>();
    allGradientShapeVerts.addAll(leftQuad);
    allGradientShapeVerts.addAll(gradientRectQuads);
    allGradientShapeVerts.addAll(rightQuad);
    newBounds = allGradientShapeVerts.toArray(new Vertex[allGradientShapeVerts.size()]);
   
    //Rotate the vectors of the calculated bounding rect back to the original angle
    newBounds = (Vertex[]) Vector3D.rotateZVectorArray(newBounds, testShape.getCenterPointLocal(), gradAngle);
   
    //Create gradient shape to paint over the real shape
    MTPolygon p = new MTPolygon(newBounds,pa);
        p.setNoStroke(true);
        p.setPickable(false);
        p.setStrokeWeight(testShape.getStrokeWeight());
        p.setFillDrawMode(GL.GL_QUADS);
        //Use displaylist by default for gradientshape
        p.generateAndUseDisplayLists();
       
        FillPaint gradStencil = new FillPaint(gl, p);
    return gradStencil;
  }
View Full Code Here

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

      Vertex[] shapeVertsCopy = Vertex.getDeepVertexArrayCopy(testShape.getGeometryInfo().getVertices());
      //Rotate the vertices in the inverse direction of the gradients vector angle
      shapeVertsCopy = (Vertex[]) Vertex.rotateZVectorArray(shapeVertsCopy, testShape.getCenterPointLocal(), -gradAngle);
     
      //Create a temporary polygon with the roated vertices to calc BBox
      MTPolygon inverseRotatedShape = new MTPolygon(shapeVertsCopy, pa);
      //Calculate a bounding rectangle from the rotated shape
      BoundsZPlaneRectangle inverseRotatedBounds = new BoundsZPlaneRectangle(inverseRotatedShape);
      Vector3D[] invBoundsVecs = inverseRotatedBounds.getVectorsLocal();
     
      //Get the positions where the offsets are on the gradient vector
      float bBoxWidth  = invBoundsVecs[1].x - invBoundsVecs[0].x;
      logger.debug("BBox width: " + bBoxWidth);
      float w = bBoxWidth/*/100*/;
      List<Float> xStops = new ArrayList<Float>();
      //Go through stops and multiply stop offset with bbox width to get the position
      for(Stop stop : stops){
        float offsetStopPosition = w * stop.offset;
        xStops.add(offsetStopPosition);
        logger.debug("OffsetStopPosition: " + offsetStopPosition);
      }
     
      //Calc new gradient polygon vertices with vertices at the stop locations
      Vertex[] newBounds = new Vertex[(xStops.size()-1) * 4];
      for (int i = 0; i < xStops.size()-1; i++) {
        float offset = xStops.get(i);
        Color stopColor = stops.get(i).color;
        float nextOffset = xStops.get(i+1);
        Color nextStopColor = stops.get(i+1).color;
        newBounds[i*4]     = new Vertex(invBoundsVecs[0].x + offset,     invBoundsVecs[0].y,0,   stopColor.getRed(), stopColor.getGreen(), stopColor.getBlue(), stopColor.getAlpha());
        newBounds[i*4+1= new Vertex(invBoundsVecs[0].x + nextOffset, invBoundsVecs[0].y,0,   nextStopColor.getRed(), nextStopColor.getGreen(), nextStopColor.getBlue(), nextStopColor.getAlpha());
        newBounds[i*4+2]   = new Vertex(invBoundsVecs[0].x + nextOffset, invBoundsVecs[2].y,0,   nextStopColor.getRed(), nextStopColor.getGreen(), nextStopColor.getBlue(), nextStopColor.getAlpha());
        newBounds[i*4+3= new Vertex(invBoundsVecs[0].x + offset,     invBoundsVecs[2].y,0,   stopColor.getRed(), stopColor.getGreen(), stopColor.getBlue(), stopColor.getAlpha());
      }
     
      /*
      logger.debug("->New bounds:");
      for (int i = 0; i < newBounds.length; i++) {
        Vertex vertex = newBounds[i];
        logger.debug(vertex);
      }
      */
     
      //Rotate the vectors of the calculated bounding rect back to the original angle
      newBounds = (Vertex[]) Vector3D.rotateZVectorArray(newBounds, testShape.getCenterPointLocal(), gradAngle);
     
      //Create gradient shape to paint over the real shape
      MTPolygon p = new MTPolygon(newBounds,pa);
          p.setNoStroke(true);
          p.setPickable(false);
          p.setFillDrawMode(GL.GL_QUADS);
          p.setStrokeWeight(testShape.getStrokeWeight());
          //Use displaylist by default for gradientshape
          p.generateAndUseDisplayLists();
     
          FillPaint gradStencil = new FillPaint(gl, p);
          return gradStencil;
    }
View Full Code Here

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

      }
    }
   
    //For lines or polygons do this
//    MTPolygon poly = new MTPolygon(verts , pa);
    MTPolygon poly = new SvgPolygon(verts,pa);
    return poly;
  }
View Full Code Here

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

        case TapEvent.BUTTON_CLICKED:
          //Get the first polygon type out of the array
          for (int i = 0; i < comps.length; i++) { //TODO this is stupid.. redo this whole thing
            MTComponent comp = comps[i];
            if (comp instanceof MTPolygon) {
              MTPolygon poly = (MTPolygon) comp;
              if (referencePoly == null){//nur 1. occur zuweisen
                referencePoly = poly;
              }
            }
          }
View Full Code Here

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

  public void packClusterPolygon(){
    ArrayList<Vector3D> allClusteredVerts = new ArrayList<Vector3D>();
    int shapes = 0;
   
    //Remove the old clusterpoly
    MTPolygon clusterPoly = getClusterPolygon();
    this.removeChild(clusterPoly);
   
    MTComponent[] children = this.getChildren();
    for (int i = 0; i < children.length; i++) {
      MTComponent component = children[i];
     
      //Get vertices for convex hull of all selected components
      if (component instanceof AbstractShape){
        shapes++;
        AbstractShape shape = (AbstractShape)component;
//        Vertex[] verts = shape.getVerticesPickingWorld();
        Vector3D[] verts = null;
       
//        if (shape.isBoundingShapeSet()){
//           verts = shape.getBoundingShape().getVectorsGlobal();
//        }else{
//           verts = shape.getVerticesGlobal();
//        }
       
        if (shape.hasBounds()){
          if (shape.getBounds() instanceof BoundsZPlaneRectangle || shape.getBounds() instanceof BoundsArbitraryPlanarPolygon){
            verts = shape.getBounds().getVectorsGlobal();
          }else{
            BoundsZPlaneRectangle b = new BoundsZPlaneRectangle(shape);
            verts = b.getVectorsGlobal();
          }
        }else{
          BoundsZPlaneRectangle b = new BoundsZPlaneRectangle(shape);
          verts = b.getVectorsGlobal();
//           verts = shape.getVerticesGlobal();
        }
       
        for (Vector3D v : verts){
          allClusteredVerts.add(v);
        }
      }
    }
   
    if (shapes != 0 && shapes == children.length){ //If all children are of type abstractShape
     
      ArrayList<Vector3D> hull = ConvexQuickHull2D.getConvexHull2D(allClusteredVerts);
      if (hull.size() > 0){
        //Correctly close polygon with 1.st vertex again
        hull.add(hull.get(0).getCopy());
       
        Vertex[] newVerts = new Vertex[hull.size()];
        for (int i = 0; i < hull.size(); i++) {
          Vector3D vec = hull.get(i);
          newVerts[i] = new Vertex(vec);
        }
       
//        Vertex[] newVerts = (Vertex[])hull.toArray(new Vertex[hull.size()]);
//        System.out.println("Hull vertices: ");
        for (Vertex v : newVerts){
          v.setRGBA(100,150,250, 50);
        }
       
        clusterPoly.setVertices(newVerts);
       
        clusterPoly.setBoundsBehaviour(AbstractShape.BOUNDS_DONT_USE);
//        clusterPoly.setBoundingShape(new BoundsArbitraryPlanarPolygon(clusterPoly, clusterPoly.getVerticesLocal()));
       
        //Reset matrix of the clusterpoly because the new vertices are set at the global location
        clusterPoly.setLocalMatrix(new Matrix());
       
        //FIXME center are is negative if verts are in counterclockwise order?
//        Vector3D clusterCenter = clusterPoly.getCenterPointGlobal();
//        clusterPoly.scaleGlobal(1.1f, 1.1f, 1, new Vector3D(-1* clusterCenter.x, -1 * clusterCenter.y, clusterCenter.z));
        clusterPoly.scale(1.1f, 1.1f, 1, clusterPoly.getCenterPointLocal(), TransformSpace.LOCAL);
        this.addChild(clusterPoly);
      }else{
        System.err.println("Couldnt pack polygon.");
      }
    }
View Full Code Here

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

      public void propertyChange(PropertyChangeEvent p) {
        drawingScene.setBrushScale((Float)p.getNewValue());
      }
    });
        //Add triangle in slider to indicate brush width
        MTPolygon p = new MTPolygon(new Vertex[]{
            new Vertex(2 + slider.getKnob().getWidthXY(TransformSpace.LOCAL), slider.getHeightXY(TransformSpace.LOCAL)/2f, 0),
            new Vertex(slider.getWidthXY(TransformSpace.LOCAL)-3, slider.getHeightXY(TransformSpace.LOCAL)/4f +2, 0),
            new Vertex(slider.getWidthXY(TransformSpace.LOCAL)-1, slider.getHeightXY(TransformSpace.LOCAL)/2f, 0),
            new Vertex(slider.getWidthXY(TransformSpace.LOCAL)-3, -slider.getHeightXY(TransformSpace.LOCAL)/4f -2 + slider.getHeightXY(TransformSpace.LOCAL), 0),
            new Vertex(2, slider.getHeightXY(TransformSpace.LOCAL)/2f, 0),
        }, pa);
        p.setFillColor(new MTColor(150,150,150, 150));
        p.setStrokeColor(new MTColor(160,160,160, 190));
        p.unregisterAllInputProcessors();
        p.setPickable(false);
        slider.getOuterShape().addChild(p);
        slider.getKnob().sendToFront();
       
  }
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.