Package org.mt4j.components.visibleComponents.shapes

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


                  //System.out.println("-> Creating tag at: " + vecOnScreen);
                  if pointOnScreen.x >= 0 && pointOnScreen.x <= p.width
                    &&  pointOnScreen.y >= 0 && pointOnScreen.y <= p.height
                  ){
                    final MTEllipse tagCircle = new MTEllipse(p, vecOnScreen, 15, 15, 30);
                    tagCircle.setPickable(true);
                    tagCircle.setFillColor(new MTColor(90, 205, 230, 200));
                    tagCircle.setDrawSmooth(true);
                    tagCircle.setStrokeWeight(2);
                    tagCircle.setStrokeColor(new MTColor(40, 130, 220, 255));
                    tagCircle.translate(new Vector3D(pointOnScreen.x, pointOnScreen.y , 0.0f));
                    tagCircle.transform(tagContainer.getGlobalInverseMatrix());
                    tagCircle.setName(id);
                   
                    tagToPhoto.put(tagCircle, foto);
                   
                    tagContainer.addChild(tagCircle);
                   
                    tagCircle.unregisterAllInputProcessors();
                    tagCircle.registerInputProcessor(new TapProcessor(p));
                    tagCircle.addGestureListener(TapProcessor.class, new IGestureEventListener(){
                      //@Override
                      public boolean processGestureEvent(MTGestureEvent g) {
                        if (g instanceof TapEvent) {
                          TapEvent ce = (TapEvent) g;
                          switch (ce.getTapID()) {
                          case TapEvent.BUTTON_DOWN:
                            IMTComponent3D e = ce.getTargetComponent();
                            Photo foto = tagToPhoto.get(e);
                            if (foto != null){
                              SinglePhotoLoader fotoLoader = new SinglePhotoLoader(foto, 50);
                              fotoLoader.start();
                             
                              //Disable and remove the fototag
                              tagCircle.setGestureAllowance(TapProcessor.class, false);
                             
                              p.getCurrentScene().registerPreDrawAction(new IPreDrawAction(){
                                public boolean isLoop() {
                                  return false;
                                }
                                public void processAction() {
//                                  fotoTagContainer.removeChild(tagCircle);
                                  tagToPhoto.remove(tagCircle);
                                  tagCircle.destroy();
                                }

                              });
                            }
                            break;
View Full Code Here


    return false;
  }


  private AbstractShape createComponent(int id, Vector3D pos){
    MTEllipse comp = new MTEllipse(app, new Vector3D(pos), 50,50, 50);
    comp.setNoFill(false);
    float r = ToolsMath.getRandom(20, 255);
    float g = ToolsMath.getRandom(20, 255);
    float b = ToolsMath.getRandom(20, 255);
    comp.setFillColor(new MTColor(r, g, b, 200));
    comp.setNoStroke(false);
    comp.setStrokeWeight(1);
    comp.setStrokeColor(new MTColor(r, g, b, 200));
    comp.unregisterAllInputProcessors(); //Dont process input/gestures on this component
   
    MTTextArea text = new MTTextArea(app, font);
    text.appendText(new Integer(id).toString());
    text.setFillColor(new MTColor(0, 0, 0, 0));
    text.setStrokeColor(new MTColor(0, 0, 0, 0));
    text.unregisterAllInputProcessors();
    comp.addChild(text);
    text.setPositionRelativeToParent(comp.getCenterPointLocal());
    return comp;
  }
View Full Code Here

          //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() {
              MTEllipse e = new MTEllipse(instance, new Vector3D(0,0), ToolsMath.getRandom(50, 150),ToolsMath.getRandom(50, 150));
              e.setFillColor(new MTColor(ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255),ToolsMath.getRandom(50,255)));
              e.addGestureListener(DragProcessor.class, new InertiaDragAction());
              instance.getCurrentScene().getCanvas().addChild(e);
              e.setPositionGlobal(new Vector3D(ToolsMath.getRandom(0, instance.width), ToolsMath.getRandom(0, instance.height)));
            }
          });
         
        }
      }
View Full Code Here

       
        //somehow the circle radii need to be doubled
        //or else theyre too small => processing bug?
//        r*=2;
//        r2*=2;
        MTEllipse comp = new MTEllipse(pa, middlePoint, r, r2);
        returnComp = comp;
      }else if (gfxElem instanceof SVGOMCircleElement){
        SVGOMCircleElement circleElem = (SVGOMCircleElement)gfxElem;
        float cx = circleElem.getCx().getBaseVal().getValue();
        float cy = circleElem.getCy().getBaseVal().getValue();
        float r = circleElem.getR().getBaseVal().getValue();
        float r2 = circleElem.getR().getBaseVal().getValue();
       
        Vertex middlePoint = new Vertex(cx,cy,0);
        //Apply transformation, transform centerpoint and the radii
        try{
          middlePoint.transform(currentLocalTransformMatrix);
        }catch(Exception e){
          logger.error(e.getMessage());
        }
       
        //somehow the circle radii need to be doubled
        //or else theyre too small => processing bug?
//        r*=2;
//        r2*=2;
        MTEllipse comp = new MTEllipse(pa, middlePoint, r, r2);
        returnComp = comp;
      }else if (gfxElem instanceof SVGOMLineElement){
        SVGOMLineElement line = (SVGOMLineElement)gfxElem;
        float x1 = line.getX1().getBaseVal().getValue();
        float y1 = line.getY1().getBaseVal().getValue();
        float x2 = line.getX2().getBaseVal().getValue();
        float y2 = line.getY2().getBaseVal().getValue();
        //logger.debug("Line x1: " + x1 + ",y1:" + y1 + ",x2:" + x2 + ",y2:" + y2);
       
        MTLine comp = new MTLine(pa, x1,y1 ,x2,y2);
      
        try{
          comp.setLocalMatrix(currentLocalTransformMatrix);
        }catch(Exception e){
          logger.error(e.getMessage());
        }
        returnComp = comp;
      }else if (gfxElem instanceof SVGOMClipPathElement){
      }else if (gfxElem instanceof SVGOMDefsElement){
      }else if (gfxElem instanceof SVGOMMaskElement){
      }else if (gfxElem instanceof SVGOMSwitchElement){
      }else if (gfxElem instanceof SVGOMFlowRootElement){
      }else if (gfxElem instanceof SVGURIReferenceGraphicsElement){
      }else if (gfxElem instanceof BindableElement){
      }else if (gfxElem instanceof SVGOMForeignObjectElement){
      }else if (gfxElem instanceof SVGOMToBeImplementedElement){
      }
     
      //Do the finishing touch of the svg graphics element
      if (returnComp != null){
        returnComp.setName(gfxElem.getTagName());
       
        //Set style infos
        if (returnComp instanceof AbstractVisibleComponent){
          AbstractVisibleComponent comp = (AbstractVisibleComponent)returnComp;
          //Set Fill
          comp.setFillColor(new MTColor(fillR, fillG, fillB, fillOpacity));
          comp.setNoFill(noFill);
          //Set Stroke
          comp.setStrokeColor(new MTColor(strokeR, strokeG, strokeB, strokeOpacity));
          //Opengl cant handle big lines well
          //So cap at width 3
          if (strokeWidth > 2.0f)
            strokeWidth = 2.0f;
          comp.setStrokeWeight(strokeWidth);
          comp.setNoStroke(noStroke);
          //Other
          comp.setDrawSmooth(true);
          comp.setPickable(false);
         
          //Hack for smoothing non stroked components with a stroke same as fillcolor
          if (comp.isNoStroke()
           && linearGradient == null
          ){ 
            comp.setStrokeColor(new MTColor(fillR, fillG, fillB, fillOpacity)); //fillOpacity
            comp.setStrokeWeight(0.6f);
            //Ellipse doesent smooth right with 0.1f strokeweight
            if (comp instanceof MTEllipse){
              comp.setStrokeWeight(1.0f);
            }
            comp.setNoStroke(false);
          }

          //Some settings for Geometric shapes (actually should all be)
          if (comp instanceof AbstractShape ){
            AbstractShape shape = (AbstractShape)comp;
View Full Code Here

        return false;
      }
    });
   
//    knob = new MTRectangle(x+innerOffset, y+innerOffset,   knobWidth, knobHeight, applet);
    knob = new MTEllipse(applet,  new Vector3D(0,0,0), knobWidth*0.5f, knobHeight*0.5f);
    knob.setFillColor(new MTColor(140, 140, 140, 255));
    AbstractComponentProcessor[] inputPs = knob.getInputProcessors();
    for (int i = 0; i < inputPs.length; i++) {
      AbstractComponentProcessor p = inputPs[i];
      if (!(p instanceof DragProcessor)){
View Full Code Here

   * @param position the position
   *
   * @return the abstract shape
   */
  protected AbstractShape createDisplayComponent(PApplet applet, Vector3D position){
    MTEllipse displayShape = new CursorEllipse(applet, position, 15, 15);
    displayShape.setPickable(false);
    displayShape.setNoFill(true);
    displayShape.setDrawSmooth(true);
    displayShape.setStrokeWeight(2);
    displayShape.setStrokeColor(new MTColor(100, 130, 220, 255));
    return displayShape;
  }
View Full Code Here

    textureBrush.setFillColor(new MTColor(0,0,0));
    //Set texture brush as default
    drawingScene.setBrush(textureBrush);
   
    //Create pencil brush
    pencilBrush = new MTEllipse(pa, new Vector3D(brushImage.width/2f,brushImage.height/2f,0), brushImage.width/2f, brushImage.width/2f, 60);
    pencilBrush.setPickable(false);
    pencilBrush.setNoFill(false);
    pencilBrush.setNoStroke(false);
    pencilBrush.setDrawSmooth(true);
    pencilBrush.setStrokeColor(new MTColor(0, 0, 0, 255));
View Full Code Here

      }else{
       
      }
//      mouseInfo.ellipse.setWidthXYGlobal(newEllipseWidth);
     
      MTEllipse fingerCircle = new MTEllipse(mtApp, new Vector3D(mouseInfo.x, mouseInfo.y), currentEllipseWidth, currentEllipseWidth, 10);
      fingerCircle.setPickable(false);
     
//      fingerCircle.setCustomAndGlobalCam(currentScene.getSceneCam(), defaultCenterCam);
      fingerCircle.attachCamera(defaultCenterCam);
     
      //fingerCircle.setFillColor(50, 225, 230, 200);
//      fingerCircle.setNoFill(true);
      fingerCircle.setFillColor(new MTColor(255,50,50, 190));
//      fingerCircle.setFillColor(Tools3D.getRandom(140, 255),Tools3D.getRandom(110, 255),Tools3D.getRandom(135, 255), 150);
      fingerCircle.setDrawSmooth(true);
//      fingerCircle.setStrokeWeight(2);
//      fingerCircle.setStrokeColor(100,100,100, 150);
      fingerCircle.setNoStroke(true);
      fingerCircle.setDepthBufferDisabled(true);
     
      //Add to mouseinfo
      mouseInfo.ellipse = fingerCircle;
      //Add to canvas
//      currentCanvas.addChild(fingerCircle);
View Full Code Here

//    line.setStrokeColor(new MTColor(0,0,0));
    line.setStrokeColor(new MTColor(150,150,150));
    line.setStrokeWeight(0.5f);
    physicsContainer.addChild(line);
   
    MTEllipse centerCircle = new MTEllipse(mtApplication, new Vector3D(mtApplication.width/2f/scale, mtApplication.height/2f/scale), 80/scale, 80/scale);
    centerCircle.setPickable(false);
    centerCircle.setNoFill(true);
//    centerCircle.setStrokeColor(new MTColor(0,0,0));
    centerCircle.setStrokeColor(new MTColor(150,150,150));
    centerCircle.setStrokeWeight(0.5f);
    physicsContainer.addChild(centerCircle);
   
    MTEllipse centerCircleInner = new MTEllipse(mtApplication, new Vector3D(mtApplication.width/2f/scale, mtApplication.height/2f/scale), 10/scale, 10/scale);
    centerCircleInner.setPickable(false);
    centerCircleInner.setFillColor(new MTColor(160,160,160));
//    centerCircleInner.setStrokeColor(new MTColor(150,150,150));
//    centerCircleInner.setStrokeColor(new MTColor(0,0,0));
    centerCircleInner.setStrokeColor(new MTColor(150,150,150));
    centerCircleInner.setStrokeWeight(0.5f);
    physicsContainer.addChild(centerCircleInner);
   
    //Create the paddles
    PImage paddleTex = mtApplication.loadImage(imagesPath + "paddle.png");
    redCircle = new Paddle(app, new Vector3D(mtApplication.width - 60, mtApplication.height/2f), 50, world, 1.0f, 0.3f, 0.4f, scale);
View Full Code Here

        assertEquals(getCanvas().getChildren()[3], r1);
       
        MTRoundRectangle roundRect = new MTRoundRectangle(0,0,0, 160, 110, 30,30, getMTApplication());
            getCanvas().addChild(roundRect);
           
        MTEllipse ellipse = new MTEllipse(getMTApplication(), new Vector3D(100,100,0), 160, 80);
        getCanvas().addChild(ellipse);
       
        MTCube cube = new MTCube(getMTApplication(), 150);
        getCanvas().addChild(cube);
       
View Full Code Here

TOP

Related Classes of org.mt4j.components.visibleComponents.shapes.MTEllipse

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.