/** Method to toggle the file chooser's visibilty. */ public void toggleFileChooser() { if (!windowShown) { // this.setVisible(true); // this.sendToFront(); window.setVisible(true); window.sendToFront(); } else // this.setVisible(false); window.setVisible(false); windowShown = !windowShown; }
/* (non-Javadoc) * @see org.mt4j.components.visibleComponents.shapes.MTPolygon#destroyComponent() */ @Override protected void destroyComponent() { super.destroyComponent(); // FIXME gets called twice if we destroy this component (because we listen to sceneTexture // destroy()) // -> but not tragic // Destroy the scene used for the window because we dont destroy it // in MTSceneTexture sceneTexture.getScene().destroy(); }
/** Method to show file chooser with the specified file filter applied. */ public void toggleFileChooser(String filter) { if (filter == "image") { setSelectedFileFilter(imagesFilter); setFileFilter(imagesFilter); refreshDirectory(); } if (filter == "movie") { setSelectedFileFilter(videosFilter); setFileFilter(videosFilter); refreshDirectory(); } if (filter == "xml") { setSelectedFileFilter(XMLFilter); setFileFilter(XMLFilter); refreshDirectory(); } if (filter == "pdf") { setSelectedFileFilter(PDFFilter); setFileFilter(PDFFilter); refreshDirectory(); } if (filter == "slideshow") { setSelectedFileFilter(allFilter); setFileFilter(allFilter); refreshDirectory(); } if (!windowShown) { this.setVisible(true); this.sendToFront(); window.setVisible(true); window.sendToFront(); } windowShown = true; }
public Scene6(MTApplication mtApplication, String name) { super(mtApplication, name, 6); this.mtApp = mtApplication; // Create a textfield MTTextArea textField = new MTTextArea( mtApplication, FontManager.getInstance() .createFont(mtApp, "arial.ttf", 50, new MTColor(251, 151, 29, 255))); textField.setNoFill(true); textField.setNoStroke(true); textField.setText("Ready?"); this.getCanvas().addChild(textField); textField.setPositionGlobal(new Vector3D(mtApp.width / 2f, mtApp.height / 4f)); textField.removeAllGestureEventListeners(DragProcessor.class); // To enable drag & drop textField.removeAllGestureEventListeners(RotateProcessor.class); startButton = new MTRoundRectangle(mtApp, 0, 0, 0, 200, 150, radius, radius); startButton.setPositionRelativeToParent(new Vector3D(mtApp.width / 2f, mtApp.height / 2f)); startButton.setStrokeWeight(5); startButton.setFillColor(new MTColor(254, 201, 71, 255)); startButton.setStrokeColor(new MTColor(251, 151, 29, 255)); startButton.removeAllGestureEventListeners(DragProcessor.class); // To enable drag & drop startButton.removeAllGestureEventListeners(RotateProcessor.class); MTTextArea startButtonTextField = new MTTextArea( mtApplication, FontManager.getInstance() .createFont(mtApp, "arial.ttf", 50, new MTColor(251, 151, 29, 255))); startButtonTextField.setNoFill(true); startButtonTextField.setNoStroke(true); startButtonTextField.setText("Start"); startButton.addChild(startButtonTextField); startButtonTextField.setPositionGlobal(new Vector3D(mtApp.width / 2f, mtApp.height / 2f)); startButtonTextField.removeAllGestureEventListeners( DragProcessor.class); // To enable drag & drop startButtonTextField.removeAllGestureEventListeners(RotateProcessor.class); this.getCanvas().addChild(startButton); startButtonTextField.registerInputProcessor(new TapProcessor(mtApplication)); startButtonTextField.addGestureListener( TapProcessor.class, new IGestureEventListener() { @Override public boolean processGestureEvent(MTGestureEvent ge) { TapEvent te = (TapEvent) ge; switch (te.getTapID()) { case TapEvent.TAPPED: setTransition(slideLeftTransition); if (workPlaceScene == null) { workPlaceScene = new WorkPlaceScene(mtApp, "WorkPlaceScene"); mtApp.addScene(workPlaceScene); } // Do the scene change mtApp.changeScene(workPlaceScene); break; default: break; } return false; } }); super.addButtons(6); // Set a scene transition - Flip transition only available using opengl supporting the FBO // extenstion if (MT4jSettings.getInstance().isOpenGlMode() && GLFBO.isSupported(mtApp)) { slideLeftTransition = new SlideTransition(mtApp, 700, true); slideRightTransition = new SlideTransition(mtApp, 700, false); } else { this.setTransition(new FadeTransition(mtApp)); } // Register flick gesture with the canvas to change the scene getCanvas().registerInputProcessor(new FlickProcessor()); getCanvas() .addGestureListener( FlickProcessor.class, new IGestureEventListener() { public boolean processGestureEvent(MTGestureEvent ge) { FlickEvent e = (FlickEvent) ge; if (e.getId() == MTGestureEvent.GESTURE_ENDED && e.isFlick()) { switch (e.getDirection()) { case WEST: case NORTH_WEST: case SOUTH_WEST: setTransition(slideLeftTransition); if (workPlaceScene == null) { workPlaceScene = new WorkPlaceScene(mtApp, "WorkPlaceScene"); mtApp.addScene(workPlaceScene); } // Do the scene change mtApp.changeScene(workPlaceScene); break; case EAST: case NORTH_EAST: case SOUTH_EAST: setTransition(slideRightTransition); if (mtApp.getScene("Scene 5") == null) { scenePrevious = new Scene5(mtApp, "Scene 5"); mtApp.addScene(scenePrevious); mtApp.changeScene(scenePrevious); } else { mtApp.changeScene(mtApp.getScene("Scene 5")); } break; default: break; } } return false; } }); }
public void Make(AbstractMTApplication mtApplication, String name) { /// Create map provider menu \\\ IFont font = FontManager.getInstance() .createFont(mtApplication, "SansSerif.Bold", 15, MTColor.WHITE, MTColor.WHITE); MTRoundRectangle mapMenu = new MTRoundRectangle(0, 0, 0, 220, 335, 20, 20, mtApplication); mapMenu.setFillColor(new MTColor(35, 35, 35, 180)); mapMenu.setStrokeColor(new MTColor(35, 35, 35, 180)); mapMenu.setPositionGlobal(new Vector3D(mtApplication.width / 2f, mtApplication.height / 2f)); mapMenu.translateGlobal(new Vector3D(-mtApplication.width / 2f - 80, 0)); MTRectangle drawing = new MTRectangle(0, 0, 200, 200, mtApplication); StartTiamat.general.addChild(mapMenu); System.out.println("added menu"); float cellWidth = 155; float cellHeight = 40; MTColor cellFillColor = new MTColor(new MTColor(0, 0, 0, 210)); MTColor cellPressedFillColor = new MTColor(new MTColor(20, 20, 20, 220)); MTList list = new MTList(0, 0, 152, 4 * cellHeight + 4 * 3, mtApplication); list.setChildClip(null); list.setNoFill(true); list.setNoStroke(true); list.unregisterAllInputProcessors(); list.setAnchor(PositionAnchor.CENTER); list.setPositionRelativeToParent(mapMenu.getCenterPointLocal()); mapMenu.addChild(list); for (int i = 0; i < StartTiamat.functions.size(); i++) { Tiamat.Templates template = StartTiamat.functions.get(i); list.addListElement( this.createListCell( mtApplication, template.getName(), template.getFunction(), font, cellWidth, cellHeight, cellFillColor, cellPressedFillColor)); } ; MultiPurposeInterpolator in = new MultiPurposeInterpolator(0, 170, 700, 0.1f, 0.7f, 1); final Animation slideOut = new Animation("slide out animation", in, mapMenu); slideOut.addAnimationListener( new IAnimationListener() { public void processAnimationEvent(AnimationEvent ae) { float delta = ae.getCurrentStepDelta(); ((IMTComponent3D) ae.getTargetObject()).translateGlobal(new Vector3D(delta, 0, 0)); switch (ae.getId()) { case AnimationEvent.ANIMATION_ENDED: doSlideIn = true; animationRunning = false; break; } } }); final Animation slideIn = new Animation("slide out animation", in, mapMenu); slideIn.addAnimationListener( new IAnimationListener() { public void processAnimationEvent(AnimationEvent ae) { float delta = -ae.getCurrentStepDelta(); ((IMTComponent3D) ae.getTargetObject()).translateGlobal(new Vector3D(delta, 0, 0)); switch (ae.getId()) { case AnimationEvent.ANIMATION_ENDED: doSlideIn = false; animationRunning = false; break; } } }); mapMenu.unregisterAllInputProcessors(); mapMenu.registerInputProcessor(new TapProcessor(mtApplication, 50)); mapMenu.addGestureListener( TapProcessor.class, new IGestureEventListener() { public boolean processGestureEvent(MTGestureEvent ge) { if (((TapEvent) ge).getTapID() == TapEvent.BUTTON_CLICKED) { if (!animationRunning) { animationRunning = true; if (doSlideIn) { slideIn.start(); } else { slideOut.start(); } } } return false; } }); }