Package org.mt4j.input.inputProcessors.componentProcessors.scaleProcessor

Examples of org.mt4j.input.inputProcessors.componentProcessors.scaleProcessor.ScaleEvent


   
    meshGroup.registerInputProcessor(new ScaleProcessor(mtApplication));
    meshGroup.addGestureListener(ScaleProcessor.class, new IGestureEventListener(){
      //@Override
      public boolean processGestureEvent(MTGestureEvent ge) {
        ScaleEvent se = (ScaleEvent)ge;
        meshGroup.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorX(), biggestMesh.getCenterPointGlobal());
        return false;
      }
    });
   
    meshGroup.registerInputProcessor(new RotateProcessor(mtApplication));
View Full Code Here


    group.addGestureListener(RotateProcessor.class, new DefaultRotateAction());
    //Scale the earth from the center. Else it might get distorted
    group.registerInputProcessor(new ScaleProcessor(mtApplication));
    group.addGestureListener(ScaleProcessor.class, new IGestureEventListener() {
      public boolean processGestureEvent(MTGestureEvent ge) {
        ScaleEvent se = (ScaleEvent)ge;
        earth.scaleGlobal(se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorX(), earth.getCenterPointGlobal());
        return false;
      }
    });
    this.getCanvas().addChild(group);
        group.addChild(earth);
View Full Code Here

    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());
        Matrix m = Matrix.getScalingMatrix(newScalingPoint, se.getScaleFactorX(), se.getScaleFactorY(), se.getScaleFactorZ());
        Vertex.transFormArray(m, verts);
        target.setVertices(verts);

        //Scale vertices of the clip shape
        AbstractShape clip = (AbstractShape)target.getChildClip().getClipShape();
View Full Code Here

  private class MapScale implements IGestureEventListener{
//    private Vector3D scaleP =  new Vector3D(p.width/2, p.height/2, 0);
//    scaleP.setXYZ(p.width/2, p.height/2, 0);
    public boolean processGestureEvent(MTGestureEvent g) {
      if (g instanceof ScaleEvent){
        ScaleEvent se = (ScaleEvent)g;
        float scaleX = se.getScaleFactorX();
        //System.out.println("X:" + x + " Y:" +y);
        //Scale the map and the tags
        scaleMap(scaleX);
      }
      return false;
View Full Code Here

  /* (non-Javadoc)
   * @see com.jMT.input.gestureAction.IGestureAction#processGesture(com.jMT.input.inputAnalyzers.GestureEvent)
   */
  public boolean processGestureEvent(MTGestureEvent g) {
    if (g instanceof ScaleEvent){
      ScaleEvent scaleEvent = (ScaleEvent)g;
     
      if (target == null)
        target = scaleEvent.getTargetComponent();
     
      switch (scaleEvent.getId()) {
      case MTGestureEvent.GESTURE_DETECTED:
        if (target instanceof MTComponent){
          ((MTComponent)target).sendToFront();
          /*
          Animation[] animations = AnimationManager.getInstance().getAnimationsForTarget(target);
          for (int i = 0; i < animations.length; i++) {
            Animation animation = animations[i];
            animation.stop();
          }
          */
        }
        break;
      case MTGestureEvent.GESTURE_UPDATED:
       
        if (this.hasScaleLimit){
          if (target instanceof MTComponent) {
            MTComponent comp = (MTComponent) target;
           
            //FIXME actually we should use globalmatrix but performance is better for localMatrix..
            Vector3D currentScale = comp.getLocalMatrix().getScale();
           
//            if (currentScale.x != currentScale.y){
//              System.out.println("non uniform scale!");
//            }
           
            //We only check X because only uniform scales (x=y factor) should be used!
            if (currentScale.x * scaleEvent.getScaleFactorX() > this.maxScale){
//              System.out.println("Scale MAX Limit Hit!");
              //We should set to min scale, but we choose performance over accuracy
              //float factor = (1f/currentScale.x) * maxScale;
              //target.scaleGlobal(factor, factor, scaleEvent.getScaleFactorZ(), scaleEvent.getScalingPoint());
            }else if (currentScale.x * scaleEvent.getScaleFactorX() < this.minScale){
//              System.out.println("Scale MIN Limit Hit!");
              //We should set to min scale, but we choose performance over accuracy
              //float factor = (1f/currentScale.x) * minScale;
              //target.scaleGlobal(factor, factor, scaleEvent.getScaleFactorZ(), scaleEvent.getScalingPoint());
            }else{
              target.scaleGlobal(
                  scaleEvent.getScaleFactorX(),
                  scaleEvent.getScaleFactorY(),
                  scaleEvent.getScaleFactorZ(),
                  scaleEvent.getScalingPoint());
            }
           
          }
        }else{
          target.scaleGlobal(
              scaleEvent.getScaleFactorX(),
              scaleEvent.getScaleFactorY(),
              scaleEvent.getScaleFactorZ(),
              scaleEvent.getScalingPoint());
        }
        break;
      case MTGestureEvent.GESTURE_ENDED:
        break;
      default:
View Full Code Here

TOP

Related Classes of org.mt4j.input.inputProcessors.componentProcessors.scaleProcessor.ScaleEvent

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.