Exemple #1
0
 public void setNextScene(Iscene nextScene, PImage arrow) {
   nextSceneInner = nextScene;
   // Button to get to the next scene
   MTImageButton nextSceneButton = new MTImageButton(arrow, mtApp);
   nextSceneButton.setNoStroke(true);
   if (MT4jSettings.getInstance().isOpenGlMode()) nextSceneButton.setUseDirectGL(true);
   nextSceneButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
           switch (ae.getID()) {
             case TapEvent.BUTTON_CLICKED:
             case TapEvent.BUTTON_UP:
               // Save the current scene on the scene stack before changing
               mtApp.pushScene();
               mtApp.changeScene(nextSceneInner);
               break;
             default:
               break;
           }
         }
       });
   getCanvas().addChild(nextSceneButton);
   nextSceneButton.setPositionGlobal(
       new Vector3D(
           mtApp.width - nextSceneButton.getWidthXY(TransformSpace.GLOBAL) - 5,
           mtApp.height - nextSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5,
           0));
 }
Exemple #2
0
  public SlideScene2(
      MTApplication mtApplication, String name, PImage pImage, boolean hasPrev, PImage arrow) {
    super(mtApplication, name);
    this.mtApp = mtApplication;

    // Set the background color
    this.setClearColor(new MTColor(0, 0, 0, 0));

    this.registerGlobalInputProcessor(new CursorTracer(mtApp, this));

    MTRectangle rect = new MTRectangle(pImage, mtApplication);
    this.getCanvas().addChild(rect);
    rect.setPositionGlobal(new Vector3D(mtApplication.width / 2f, mtApplication.height / 2f));

    if (hasPrev) {

      MTImageButton previousSceneButton = new MTImageButton(arrow, mtApplication);
      previousSceneButton.setNoStroke(true);
      if (MT4jSettings.getInstance().isOpenGlMode()) previousSceneButton.setUseDirectGL(true);
      previousSceneButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              switch (ae.getID()) {
                case TapEvent.BUTTON_CLICKED:
                case TapEvent.BUTTON_UP:
                  mtApp.popScene();
                  break;
                default:
                  break;
              }
            }
          });
      getCanvas().addChild(previousSceneButton);
      previousSceneButton.scale(
          -1, 1, 1, previousSceneButton.getCenterPointLocal(), TransformSpace.LOCAL);
      previousSceneButton.setPositionGlobal(
          new Vector3D(
              previousSceneButton.getWidthXY(TransformSpace.GLOBAL) + 5,
              mtApp.height - previousSceneButton.getHeightXY(TransformSpace.GLOBAL) - 5,
              0));
    }

    // Set a scene transition - Flip transition only available using opengl supporting the FBO
    // extenstion
    if (MT4jSettings.getInstance().isOpenGlMode() && GLFBO.isSupported(mtApp))
      this.setTransition(new FlipTransition(mtApp, 700));
    else {
      this.setTransition(new FadeTransition(mtApp));
    }
  }
  /**
   * Instantiates a new mT scene window.
   *
   * @param applet the applet
   * @param scene the scene
   * @param borderWidth the border width
   * @param borderHeight the border height
   * @param fboWidth the fbo width
   * @param fboHeight the fbo height
   */
  public MTSceneWindow(
      final AbstractMTApplication applet,
      final Iscene scene,
      float borderWidth,
      float borderHeight,
      int fboWidth,
      int fboHeight) {
    //		super(0-borderWidth, 0-borderHeight, applet.width+2*borderWidth,
    // applet.height+2*borderHeight, applet);
    super(
        applet,
        0 - borderWidth,
        0 - borderHeight,
        0,
        MT4jSettings.getInstance().getWindowWidth() + 2 * borderWidth,
        MT4jSettings.getInstance().getWindowHeight() + 2 * borderHeight,
        30,
        30);

    this.setStrokeColor(new MTColor(0, 0, 0));

    sceneTexture = new MTSceneTexture(applet, 0, 0, fboWidth, fboHeight, scene);
    sceneTexture.setStrokeColor(new MTColor(0, 0, 0));
    this.addChild(sceneTexture);

    // Add the scene to the scene list in the Application
    // FIXME add the scene later to the MTApplication because if we add the scene
    // before any other scene is added it becomes the active scene which we dont want
    if (applet.getSceneCount() == 0) {
      applet.invokeLater(
          new Runnable() {
            public void run() {
              applet.addScene(sceneTexture.getScene());
            }
          });
    } else {
      applet.addScene(sceneTexture.getScene());
    }

    sceneTexture.addStateChangeListener(
        StateChange.COMPONENT_DESTROYED,
        new StateChangeListener() {
          public void stateChanged(StateChangeEvent evt) {
            destroy();
          }
        });

    if (closeButtonImage == null) {
      closeButtonImage =
          applet.loadImage(
              MT4jSettings.getInstance().getDefaultImagesPath()
                  +
                  //			"close_32.png")
                  //			"126182-simple-black-square-icon-alphanumeric-circled-x3_cr.png"
                  //			"124241-matte-white-square-icon-alphanumeric-circled-x3_cr.png"
                  //			"124241-matte-white-square-icon-alphanumeric-circled-x3128.png"
                  "closeButton64.png");
    }
    MTImageButton closeButton = new MTImageButton(applet, closeButtonImage);
    closeButton.addGestureListener(
        TapProcessor.class,
        new IGestureEventListener() {
          public boolean processGestureEvent(MTGestureEvent ge) {
            TapEvent te = (TapEvent) ge;
            if (te.isTapped()) {
              close();
            }
            return true;
          }
        });
    this.addChild(closeButton);
    closeButton.setNoStroke(true);
    //		closeButton.setSizeXYRelativeToParent(borderWidth - borderWidth/20, borderWidth -
    // borderWidth/20);
    closeButton.setSizeXYRelativeToParent(
        borderWidth - borderWidth / 30, borderWidth - borderWidth / 30);
    //		closeButton.setSizeXYRelativeToParent(borderWidth -0.5f, borderWidth-0.5f);
    closeButton.setPositionRelativeToParent(
        new Vector3D((applet.width + (borderWidth / 2f)), borderHeight - 5));

    if (maximizeButtonImage == null) {
      maximizeButtonImage =
          applet.loadImage(
              MT4jSettings.getInstance().getDefaultImagesPath()
                  +
                  //			"window_app_blank_32.png")
                  //			"127941-simple-black-square-icon-symbols-shapes-maximize-button_cr.png"
                  "maximizeButton64.png");
    }
    MTImageButton maximizeButton = new MTImageButton(applet, maximizeButtonImage);
    maximizeButton.addGestureListener(
        TapProcessor.class,
        new IGestureEventListener() {
          public boolean processGestureEvent(MTGestureEvent ge) {
            TapEvent te = (TapEvent) ge;
            if (te.isTapped()) {
              maximize();
            }
            return true;
          }
        });
    this.addChild(maximizeButton);
    maximizeButton.setNoStroke(true);
    //		maximizeButton.setSizeXYRelativeToParent(borderWidth - borderWidth/10, borderWidth -
    // borderWidth/10);
    maximizeButton.setSizeXYRelativeToParent(
        borderWidth - borderWidth / 30, borderWidth - borderWidth / 30);
    //		maximizeButton.setPositionRelativeToParent(new Vector3D(
    // (applet.width+2*borderWidth)-maximizeButton.getWidthXY(TransformSpace.RELATIVE_TO_PARENT),
    // closeButton.getHeightXY(TransformSpace.RELATIVE_TO_PARENT) + 40));
    //		maximizeButton.setPositionRelativeToParent(new Vector3D( (applet.width+ (borderWidth /2f)),
    // borderHeight + closeButton.getHeightXY(TransformSpace.RELATIVE_TO_PARENT) + 15));
    maximizeButton.setPositionRelativeToParent(
        new Vector3D(
            (applet.width + (borderWidth / 2f)),
            applet.height - closeButton.getHeightXY(TransformSpace.RELATIVE_TO_PARENT) / 2f));
  }
Exemple #4
0
  public static void addEditableImage(
      final MTApplication mtApplication,
      AbstractScene slideScene,
      ImagenVO imagenVO,
      int xOffset,
      int yOffset) {

    System.out.println("******************** Entré al addEditableImage ********************");

    final MTRectangle textureBrush;
    final MTEllipse pencilBrush;
    final DrawSurfaceScene drawingScene;

    String path = StartYPYIShell.getPathToIconsYPYI();

    PImage pImage = mtApplication.loadImage(imagenVO.getDireccionFisicaImagen());
    float x = new Float(imagenVO.getImagen().getAnchor().getCenterX()).floatValue();
    float y = new Float(imagenVO.getImagen().getAnchor().getCenterY()).floatValue();
    float w = new Float(imagenVO.getImagen().getAnchor().getWidth()).floatValue();
    float h = new Float(imagenVO.getImagen().getAnchor().getHeight()).floatValue();

    final MTRectangle frame =
        new MTRectangle(
            -50, -50, 0, mtApplication.width + 100, mtApplication.height + 100, mtApplication);
    frame.setSizeXYGlobal(w, h);
    frame.setPositionGlobal(new Vector3D(x + xOffset, y + yOffset));
    frame.setTexture(pImage);
    //		frame.setPickable(imagenVO.isPickable());
    frame.setNoStroke(true);
    slideScene.getCanvas().addChild(frame);

    // Create the scene in which we actually draw
    drawingScene = new DrawSurfaceScene(mtApplication, "DrawSurface Scene");
    drawingScene.setClear(false);

    // Create texture brush
    PImage brushImage = mtApplication.loadImage(path + "brush1.png");
    textureBrush = new MTRectangle(brushImage, mtApplication);
    textureBrush.setPickable(false);
    textureBrush.setNoFill(false);
    textureBrush.setNoStroke(true);
    textureBrush.setDrawSmooth(true);
    textureBrush.setFillColor(new MTColor(0, 0, 0));
    // Set texture brush as default
    drawingScene.setBrush(textureBrush);

    // Create pencil brush
    pencilBrush =
        new MTEllipse(
            mtApplication,
            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));
    pencilBrush.setFillColor(new MTColor(0, 0, 0, 255));

    // Create the frame/window that displays the drawing scene through a FBO
    //      final MTSceneTexture sceneWindow = new MTSceneTexture(0,0, pa, drawingScene);
    // We have to create a fullscreen fbo in order to save the image uncompressed
    int wi = new Float(frame.getWidthXY(TransformSpace.GLOBAL)).intValue();
    int hi = new Float(frame.getHeightXY(TransformSpace.GLOBAL)).intValue();

    final MTSceneTexture sceneTexture =
        new MTSceneTexture(mtApplication, 0, 0, wi, hi, drawingScene);
    sceneTexture.getFbo().clear(true, 255, 255, 255, 0, true);
    sceneTexture.setStrokeColor(new MTColor(155, 155, 155));
    frame.addChild(sceneTexture);

    // Eraser button
    PImage eraser = mtApplication.loadImage(path + "Kde_crystalsvg_eraser.png");
    final MTImageButton eraserButton = new MTImageButton(eraser, mtApplication);
    eraserButton.setNoStroke(true);
    eraserButton.translate(new Vector3D(-50, 70, 0));
    eraserButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            switch (ae.getID()) {
              case TapEvent.BUTTON_CLICKED:
              case TapEvent.BUTTON_UP:
                {
                  //					//As we are messing with opengl here, we make sure it happens in the
                  // rendering thread
                  mtApplication.invokeLater(
                      new Runnable() {
                        public void run() {
                          sceneTexture.getFbo().clear(true, 255, 255, 255, 0, true);
                        }
                      });
                }
                break;
              default:
                break;
            }
          }
        });
    frame.addChild(eraserButton);

    // Pen brush selector button
    PImage penIcon = mtApplication.loadImage(path + "pen.png");
    final MTImageButton penButton = new MTImageButton(penIcon, mtApplication);
    frame.addChild(penButton);
    penButton.translate(new Vector3D(-50f, 120, 0));
    penButton.setNoStroke(true);
    penButton.setStrokeColor(new MTColor(0, 0, 0));

    // Texture brush selector button
    PImage brushIcon = mtApplication.loadImage(path + "paintbrush.png");
    final MTImageButton brushButton = new MTImageButton(brushIcon, mtApplication);
    frame.addChild(brushButton);
    brushButton.translate(new Vector3D(-50f, 170, 0));
    brushButton.setStrokeColor(new MTColor(0, 0, 0));
    brushButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            switch (ae.getID()) {
              case TapEvent.BUTTON_CLICKED:
              case TapEvent.BUTTON_UP:
                {
                  drawingScene.setBrush(textureBrush);
                  brushButton.setNoStroke(false);
                  penButton.setNoStroke(true);
                }
                break;
              default:
                break;
            }
          }
        });

    penButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            switch (ae.getID()) {
              case TapEvent.BUTTON_CLICKED:
              case TapEvent.BUTTON_UP:
                {
                  drawingScene.setBrush(pencilBrush);
                  penButton.setNoStroke(false);
                  brushButton.setNoStroke(true);
                }
                break;
              default:
                break;
            }
          }
        });

    /////////////////////////
    // ColorPicker and colorpicker button
    PImage colPick = mtApplication.loadImage(path + "colorcircle.png");
    //      final MTColorPicker colorWidget = new MTColorPicker(0, pa.height-colPick.height,
    // colPick, pa);
    final MTColorPicker colorWidget = new MTColorPicker(0, 0, colPick, mtApplication);
    colorWidget.translate(new Vector3D(0f, 175, 0));
    colorWidget.setStrokeColor(new MTColor(0, 0, 0));
    colorWidget.addGestureListener(
        DragProcessor.class,
        new IGestureEventListener() {
          public boolean processGestureEvent(MTGestureEvent ge) {
            if (ge.getId() == MTGestureEvent.GESTURE_ENDED) {
              if (colorWidget.isVisible()) {
                colorWidget.setVisible(false);
              }
            } else {
              drawingScene.setBrushColor(colorWidget.getSelectedColor());
            }
            return false;
          }
        });
    frame.addChild(colorWidget);
    colorWidget.setVisible(false);

    PImage colPickIcon = mtApplication.loadImage(path + "ColorPickerIcon.png");
    final MTImageButton colPickButton = new MTImageButton(colPickIcon, mtApplication);
    frame.addChild(colPickButton);
    colPickButton.translate(new Vector3D(-50f, 235, 0));
    colPickButton.setNoStroke(true);
    colPickButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            switch (ae.getID()) {
              case TapEvent.BUTTON_CLICKED:
              case TapEvent.BUTTON_UP:
                {
                  if (colorWidget.isVisible()) {
                    colorWidget.setVisible(false);
                  } else {
                    colorWidget.setVisible(true);
                    colorWidget.sendToFront();
                  }
                }
                break;
              default:
                break;
            }
          }
        });

    // Add a slider to set the brush width
    final MTSlider slider = new MTSlider(0, 0, 200, 38, 0.05f, 2.0f, mtApplication);
    slider.setValue(1.0f);
    frame.addChild(slider);
    slider.rotateZ(new Vector3D(), 90, TransformSpace.LOCAL);
    slider.translate(new Vector3D(-7, 325));
    slider.setStrokeColor(new MTColor(0, 0, 0));
    slider.setFillColor(new MTColor(220, 220, 220));
    slider.getKnob().setFillColor(new MTColor(70, 70, 70));
    slider.getKnob().setStrokeColor(new MTColor(70, 70, 70));
    slider.addPropertyChangeListener(
        "value",
        new PropertyChangeListener() {
          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),
            },
            mtApplication);
    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();

    PImage editIcon = mtApplication.loadImage(path + "edit_icon.jpg");
    final MTImageButton editButton = new MTImageButton(editIcon, mtApplication);
    frame.addChild(editButton);
    editButton.translate(new Vector3D(-50f, 20, 0));
    editButton.setNoStroke(true);
    editButton.setStrokeColor(new MTColor(0, 0, 0));

    PImage handIcon = mtApplication.loadImage(path + "hand2.png");
    final MTImageButton handButton = new MTImageButton(handIcon, mtApplication);
    frame.addChild(handButton);
    handButton.translate(new Vector3D(-50f, -40, 0));
    handButton.setNoStroke(true);
    handButton.setStrokeColor(new MTColor(0, 0, 0));

    penButton.setVisible(false);
    brushButton.setVisible(false);
    slider.setVisible(false);
    colPickButton.setVisible(false);
    eraserButton.setVisible(false);
    sceneTexture.setVisible(false);

    handButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            switch (ae.getID()) {
              case TapEvent.BUTTON_CLICKED:
              case TapEvent.BUTTON_UP:
                {
                  handButton.setNoStroke(false);
                  penButton.setVisible(false);
                  brushButton.setVisible(false);
                  slider.setVisible(false);
                  colPickButton.setVisible(false);
                  eraserButton.setVisible(false);

                  sceneTexture.setVisible(false);
                }
                break;
              default:
                break;
            }
          }
        });

    editButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            switch (ae.getID()) {
              case TapEvent.BUTTON_CLICKED:
              case TapEvent.BUTTON_UP:
                {
                  editButton.setNoStroke(false);
                  penButton.setVisible(true);
                  brushButton.setVisible(true);
                  slider.setVisible(true);
                  colPickButton.setVisible(true);
                  eraserButton.setVisible(true);

                  sceneTexture.setVisible(true);
                  //					sceneTexture.sendToFront();
                  //						frame.sendToFront();
                }
                break;
              default:
                break;
            }
          }
        });
  }
  public FlickrScene(MTApplication mtAppl, String name) {
    super(mtAppl, name);
    this.app = mtAppl;
    piler = new PileManager(this.app, this.getCanvas());

    // Set a zoom limit
    final MTCamera camManager = new MTCamera(mtAppl);
    this.setSceneCam(camManager);
    this.getSceneCam().setZoomMinDistance(80);

    //		this.setClearColor(new MTColor(135, 206, 250, 255));
    this.setClearColor(new MTColor(70, 70, 72, 255));

    // Show touches
    this.registerGlobalInputProcessor(new CursorTracer(mtAppl, this));

    // Add multitouch gestures to the canvas background
    lassoProcessor = new LassoProcessor(app, this.getCanvas(), this.getSceneCam());
    this.getCanvas().registerInputProcessor(lassoProcessor);
    this.getCanvas()
        .addGestureListener(
            LassoProcessor.class,
            new DefaultLassoAction(app, this.getCanvas().getPileManager(), this.getCanvas()));

    this.getCanvas().registerInputProcessor(new PanProcessorTwoFingers(app));
    this.getCanvas().addGestureListener(PanProcessorTwoFingers.class, new DefaultPanAction());

    this.getCanvas().registerInputProcessor(new ZoomProcessor(app));
    this.getCanvas().addGestureListener(ZoomProcessor.class, new DefaultZoomAction());

    makePileProcessor = new MakePileProcessor(app, this.getCanvas());
    this.getCanvas().registerInputProcessor(makePileProcessor);
    this.getCanvas()
        .addGestureListener(
            MakePileProcessor.class,
            new DefaultMakePileAction(app, this.getCanvas().getPileManager(), this.getCanvas()));

    this.getCanvas().registerInputProcessor(new TapAndHoldProcessor(app, 2000));
    this.getCanvas()
        .addGestureListener(TapAndHoldProcessor.class, new TapAndHoldVisualizer(app, getCanvas()));
    this.getCanvas()
        .addGestureListener(
            TapAndHoldProcessor.class,
            new IGestureEventListener() {
              public boolean processGestureEvent(MTGestureEvent ge) {
                TapAndHoldEvent th = (TapAndHoldEvent) ge;
                switch (th.getId()) {
                  case TapAndHoldEvent.GESTURE_DETECTED:
                    break;
                  case TapAndHoldEvent.GESTURE_UPDATED:
                    break;
                  case TapAndHoldEvent.GESTURE_ENDED:
                    break;
                  default:
                    break;
                }
                return false;
              }
            });

    piler = new PileManager(app, getCanvas());

    pictureLayer = new MTComponent(app);

    MTComponent topLayer = new MTComponent(app, "top layer group", new MTCamera(app));

    PImage keyboardImg =
        app.loadImage(
            System.getProperty("user.dir")
                + File.separator
                + "examples"
                + File.separator
                + "advanced"
                + File.separator
                + File.separator
                + "flickrMT"
                + File.separator
                + File.separator
                + "data"
                + File.separator
                //		+ "keyb2.png");
                + "keyb128.png");

    final MTImageButton keyboardButton = new MTImageButton(keyboardImg, app);
    keyboardButton.setFillColor(new MTColor(255, 255, 255, 200));
    keyboardButton.setName("KeyboardButton");
    keyboardButton.setNoStroke(true);
    //		keyboardButton.translateGlobal(new Vector3D(5,5,0));
    keyboardButton.translateGlobal(
        new Vector3D(-2, app.height - keyboardButton.getWidthXY(TransformSpace.GLOBAL) + 2, 0));
    topLayer.addChild(keyboardButton);

    progressBar =
        new MTProgressBar(
            app, app.loadFont(MT4jSettings.getInstance().getDefaultFontPath() + "Ziggurat.vlw"));
    progressBar.setDepthBufferDisabled(true);
    progressBar.setVisible(false);
    topLayer.addChild(progressBar);

    keyboardButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            switch (ae.getID()) {
              case TapEvent.BUTTON_CLICKED:
                // Flickr Keyboard
                MTKeyboard keyb = new MTKeyboard(app);
                keyb.setFillColor(new MTColor(30, 30, 30, 210));
                keyb.setStrokeColor(new MTColor(0, 0, 0, 255));

                final MTTextArea t =
                    new MTTextArea(
                        app,
                        FontManager.getInstance()
                            .createFont(
                                app,
                                "arial.ttf",
                                50,
                                new MTColor(0, 0, 0, 255), // Fill color
                                new MTColor(0, 0, 0, 255))); // Stroke color
                t.setStrokeColor(new MTColor(0, 0, 0, 255));
                t.setFillColor(new MTColor(205, 200, 177, 255));
                t.unregisterAllInputProcessors();
                t.setEnableCaret(true);
                t.snapToKeyboard(keyb);
                keyb.addTextInputListener(t);

                // Flickr Button for the keyboard
                MTSvgButton flickrButton =
                    new MTSvgButton(
                        System.getProperty("user.dir")
                            + File.separator
                            + "examples"
                            + File.separator
                            + "advanced"
                            + File.separator
                            + File.separator
                            + "flickrMT"
                            + File.separator
                            + "data"
                            + File.separator
                            + "Flickr_Logo.svg",
                        app);
                flickrButton.scale(0.4f, 0.4f, 1, new Vector3D(0, 0, 0), TransformSpace.LOCAL);
                flickrButton.translate(new Vector3D(0, 15, 0));
                flickrButton.setBoundsPickingBehaviour(AbstractShape.BOUNDS_ONLY_CHECK);

                // Add actionlistener to flickr button
                flickrButton.addActionListener(
                    new ActionListener() {
                      public void actionPerformed(ActionEvent arg0) {
                        if (arg0.getSource() instanceof MTComponent) {
                          // MTBaseComponent clickedComp = (MTBaseComponent)arg0.getSource();
                          switch (arg0.getID()) {
                            case TapEvent.BUTTON_CLICKED:
                              // Get current search parameters
                              SearchParameters sp = new SearchParameters();
                              // sp.setSafeSearch("213on");
                              /*
                              DateFormat dateFormat = new SimpleDateFormat ("yyyy/MM/dd HH:mm:ss");
                              java.util.Date date = new java.util.Date ();
                              String dateStr = dateFormat.format (date);
                              System.out.println("Date: " + dateStr);
                              try{
                              	Date date2 = dateFormat.parse (dateStr);
                              	sp.setInterestingnessDate(date2);
                              }catch(ParseException pe){
                              	pe.printStackTrace();
                              }
                              */

                              // sp.setMachineTags(new String[]{"geo:locality=\"san francisco\""});
                              sp.setText(t.getText());
                              // sp.setTags(new String[]{t.getText()});
                              sp.setSort(SearchParameters.RELEVANCE);

                              System.out.println("Flickr search for: \"" + t.getText() + "\"");

                              // Load flickr api key from file
                              String flickrApiKey = "";
                              String flickrSecret = "";
                              Properties properties = new Properties();
                              try {
                                properties.load(
                                    new FileInputStream(
                                        System.getProperty("user.dir")
                                            + File.separator
                                            + "examples"
                                            + File.separator
                                            + "advanced"
                                            + File.separator
                                            + File.separator
                                            + "flickrMT"
                                            + File.separator
                                            + "data"
                                            + File.separator
                                            + "FlickrApiKey.txt"));
                                flickrApiKey = properties.getProperty("FlickrApiKey", " ");
                                flickrSecret = properties.getProperty("FlickrSecret", " ");
                              } catch (Exception e) {
                                System.err.println(
                                    "Error while loading Settings.txt file. Using defaults.");
                              }

                              // Create flickr loader thread
                              final FlickrMTFotoLoader flickrLoader =
                                  new FlickrMTFotoLoader(app, flickrApiKey, flickrSecret, sp, 300);
                              flickrLoader.setFotoLoadCount(15);
                              // Define action when loader thread finished
                              flickrLoader.addProgressFinishedListener(
                                  new IMTEventListener() {
                                    public void processMTEvent(MTEvent mtEvent) {
                                      // Add the loaded fotos in the main drawing thread to
                                      // avoid threading problems
                                      registerPreDrawAction(
                                          new IPreDrawAction() {
                                            public void processAction() {
                                              MTImage[] fotos = flickrLoader.getMtFotos();
                                              for (int i = 0; i < fotos.length; i++) {
                                                MTImage card = fotos[i];
                                                card.setUseDirectGL(true);
                                                card.setDisplayCloseButton(true);
                                                card.setPositionGlobal(
                                                    new Vector3D(
                                                        Tools3D.getRandom(
                                                            10,
                                                            MT4jSettings.getInstance()
                                                                    .getScreenWidth()
                                                                - 100),
                                                        Tools3D.getRandom(
                                                            10,
                                                            MT4jSettings.getInstance()
                                                                    .getScreenHeight()
                                                                - 50),
                                                        0));
                                                card.toSize(200, 200);
                                                card.addGestureListener(
                                                    DragProcessor.class, new InertiaDragAction());
                                                lassoProcessor.addClusterable(
                                                    card); // make fotos lasso-able
                                                makePileProcessor.addClusterable(
                                                    card); // make elements pileable by this
                                                           // processor
                                                piler.addPileable(
                                                    card); // makes the photos pile-able
                                                pictureLayer.addChild(card);
                                              }
                                              progressBar.setVisible(false);
                                            }

                                            public boolean isLoop() {
                                              return false;
                                            }
                                          });
                                    }
                                  });
                              progressBar.setProgressInfoProvider(flickrLoader);
                              progressBar.setVisible(true);
                              // Run the thread
                              flickrLoader.start();
                              // Clear textarea
                              t.clear();
                              break;
                            default:
                              break;
                          }
                        }
                      }
                    });
                keyb.addChild(flickrButton);
                //			        getCanvas().addChild(0, keyb);
                getCanvas().addChild(keyb);
                keyb.setPositionGlobal(new Vector3D(app.width / 2f, app.height / 2f, 0));
                break;
              default:
                break;
            }
          }
        });

    this.getCanvas().addChild(pictureLayer);
    this.getCanvas().addChild(topLayer);
  }