Package org.mt4j.components.visibleComponents.widgets

Examples of org.mt4j.components.visibleComponents.widgets.MTSlider


        }
      }
        });
       
        //Add a slider to set the brush width
        MTSlider slider = new MTSlider(0, 0, 200, 38, 0.05f, 2.0f, pa);
        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),
        }, 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


       
        //Create movie seek Slider
        float sliderXPadding = 10;
        float sliderYPadding = 3;
        float sliderHeight = bottomBarHeight - 2*sliderYPadding;
        slider = new MTSlider(lowerLeft.x + sliderXPadding, lowerLeft.y - sliderHeight - sliderYPadding, MTMovieClip.this.getWidthXY(TransformSpace.LOCAL) - sliderXPadding*2, sliderHeight, 0, 10, app);
        slider.getOuterShape().setFillColor(new MTColor(0, 0, 0, 80));
        slider.getOuterShape().setStrokeColor(new MTColor(0, 0, 0, 80));
        slider.getKnob().setFillColor(new MTColor(100, 100, 100, 80));
        slider.getOuterShape().setStrokeColor(new MTColor(100, 100, 100, 80));
        slider.getKnob().addGestureListener(DragProcessor.class, new IGestureEventListener() {
          public boolean processGestureEvent(MTGestureEvent ge) {
            DragEvent de = (DragEvent)ge;
            switch (de.getId()) {
            case MTGestureEvent.GESTURE_DETECTED:
              stopSliderAdvance = true;
              break;
            case MTGestureEvent.GESTURE_UPDATED:
              break;
            case MTGestureEvent.GESTURE_ENDED:
              if (movieClip != null && movieClip.getMovie() != null /*&& movieClip.getMovie().isPlaying()*/){
                float currValue = slider.getValue();
                movieClip.jump(currValue);
              }
              stopSliderAdvance = false;
              break;
            default:
              break;
            }
            return false;
          }
        });
        //Dont do every frame! Duration is only valid if playing..
        slider.setValueRange(0, m.duration());
       
        slider.getOuterShape().addGestureListener(TapProcessor.class, new IGestureEventListener() {
          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 (movieClip != null && movieClip.getMovie() != null /*&& movieClip.getMovie().isPlaying()*/){
                float currValue = slider.getValue();
                movieClip.jump(currValue);
              }
              stopSliderAdvance = false;
              break;
            default:
              break;
            }
            return false;
          }
        });
        if (app instanceof MTApplication) {
          MTApplication mtApp = (MTApplication) app;
          mtApp.invokeLater(new Runnable() {
            public void run() {
              MTMovieClip.this.addChild(slider);
            }
          });
        }else{
          this.addChild(slider);
        }
        slider.setVisible(true);
       
        //Create volume slider
        float volSliderWidth = this.getWidthXY(TransformSpace.LOCAL)/7f;
        float volSliderHeight = topBarHeight - 2*sliderYPadding;
        this.setAnchor(PositionAnchor.UPPER_LEFT);
        Vector3D movieUpperLeft = this.getPosition(TransformSpace.RELATIVE_TO_PARENT);
        volumeSlider = new MTSlider(movieUpperLeft.x + 1.5f, movieUpperLeft.y - volSliderHeight - 1.5f, volSliderWidth, volSliderHeight, 0, 1, app);
        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));
        if (app instanceof MTApplication) {
View Full Code Here

TOP

Related Classes of org.mt4j.components.visibleComponents.widgets.MTSlider

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.