예제 #1
0
파일: MTMOVIE.java 프로젝트: hkaj/CoFITS
  private void addVolumeSlider(GSMovie m) {
    float widthToUse = m.width > GESTURE_AREA_MAX_WIDTH ? GESTURE_AREA_MAX_WIDTH : m.width;
    this.setAnchor(PositionAnchor.UPPER_LEFT);
    Vector3D gestureAreaPosition = gestureArea.getPosition(TransformSpace.LOCAL);
    volumeSlider =
        new MTSlider(
            getRenderer(),
            gestureAreaPosition.x,
            gestureAreaPosition.y,
            VOLUME_SLIDER_WIDTH,
            VOLUME_SLIDER_HEIGHT,
            0,
            1);

    volumeSlider.getOuterShape().setFillColor(new MTColor(0, 0, 0, 80));
    volumeSlider.getOuterShape().setStrokeColor(new MTColor(0, 0, 0, 80));
    volumeSlider.getKnob().setFillColor(new MTColor(100, 100, 100, 80));
    volumeSlider.getOuterShape().setStrokeColor(new MTColor(100, 100, 100, 80));
    volumeSlider.setVisible(true);
    volumeSlider.setValue(1);
    volumeSlider.addPropertyChangeListener(
        "value",
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            movieView.setVolume(((Float) e.getNewValue()).doubleValue());
          }
        });
    gestureArea.addChild(volumeSlider);
    volumeSlider.rotateZ(new Vector3D(gestureAreaPosition.x, gestureAreaPosition.y), -90f);

    volumeSlider.translate(
        new Vector3D(
            widthToUse - gestureAreaXPadding - VOLUME_SLIDER_HEIGHT,
            VOLUME_SLIDER_WIDTH + gestureAreaYPadding + VOLUME_SLIDER_HEIGHT));
  }
예제 #2
0
파일: SceneUtils.java 프로젝트: Ezea85/ypyi
  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;
            }
          }
        });
  }
예제 #3
0
파일: MTMOVIE.java 프로젝트: hkaj/CoFITS
  private void addTimeSlider(GSMovie m) {
    float widthToUse = m.width > GESTURE_AREA_MAX_WIDTH ? GESTURE_AREA_MAX_WIDTH : m.width;

    Vector3D gestureAreaPosition = gestureArea.getPosition(TransformSpace.LOCAL);
    timeSlider =
        new MTSlider(
            getRenderer(),
            gestureAreaPosition.x + gestureAreaXPadding,
            gestureAreaPosition.y + gestureAreaYPadding,
            widthToUse - gestureAreaXPadding * 2f,
            // slider width
            TIME_SLIDER_HEIGHT,
            0,
            10); // min max values
    timeSlider.getOuterShape().setFillColor(new MTColor(0, 0, 0, 80));
    timeSlider.getOuterShape().setStrokeColor(new MTColor(0, 0, 0, 80));
    timeSlider.getKnob().setFillColor(new MTColor(100, 100, 100, 80));
    timeSlider.getOuterShape().setStrokeColor(new MTColor(100, 100, 100, 80));
    timeSlider
        .getKnob()
        .addGestureListener(
            DragProcessor.class,
            new IGestureEventListener() {
              public boolean processGestureEvent(MTGestureEvent ge) {
                DragEvent de = (DragEvent) ge;
                switch (de.getId()) {
                  case MTGestureEvent.GESTURE_STARTED:
                    stopSliderAdvance = true;
                    break;
                  case MTGestureEvent.GESTURE_UPDATED:
                    break;
                  case MTGestureEvent.GESTURE_ENDED:
                    if (movieView != null && movieView.getMovie() != null) {
                      float currValue = timeSlider.getValue();
                      movieView.jump(currValue);
                    }
                    stopSliderAdvance = false;
                    break;
                  default:
                    break;
                }
                return false;
              }
            });
    timeSlider.setValueRange(0, m.duration());

    timeSlider
        .getOuterShape()
        .addGestureListener(
            TapProcessor.class,
            new IGestureEventListener() {
              @SuppressWarnings("deprecation")
              public boolean processGestureEvent(MTGestureEvent ge) {
                TapEvent te = (TapEvent) ge;
                switch (te.getTapID()) {
                  case TapEvent.BUTTON_DOWN:
                    stopSliderAdvance = true;
                    break;
                  case TapEvent.BUTTON_UP:
                    stopSliderAdvance = false;
                    break;
                  case TapEvent.BUTTON_CLICKED:
                    if (movieView != null && movieView.getMovie() != null) {
                      float currValue = timeSlider.getValue();
                      movieView.jump(currValue);
                    }
                    stopSliderAdvance = false;
                    break;
                  default:
                    break;
                }
                return false;
              }
            });
    timeSlider.setValue(0);
    gestureArea.addChild(timeSlider);
  }