private void addControls() { int right = _application.getWidth(); int bottom = _application.getHeight(); addTextArea(); SceneUtilities.addButton( this, "images/backButton.png", new Vector3D(60, bottom - 35), new TapAction() { @Override public void onTap() { _application.popScene(); } }); _okButton = SceneUtilities.addButton( this, "images/okButton.png", new Vector3D(right / 2, bottom - bottom / 3), new TapAction() { @Override public void onTap() { acceptPayment(); } }); _okButton.setEnabled(false); }
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)); }
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)); }
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; } } }); }
/** * Method that opens the currently selected file -- triggered by tapping the "Open" button or * finishing the tap+hold gesture */ public void openSelected() { File file = currFile.getFile(); if (!file.exists() && !FileSystemView.getFileSystemView().isDrive(currFile.getFile())) { scene .getGuiOverlay() .addChild(new WBErrorMessage(scene.getMTApplication(), "File does not exist!")); } else if (file.isDirectory()) { // Set whether the up button will disable when it reaches desktop if (currFile.isBelowComp()) stopAtDesktop = false; if (currFile == top || currFile.isDesktopLookIn()) stopAtDesktop = true; // Up should always be disabled when the back button stack is empty // and obviously if we are at the top if (prevDirs.size() == 0 && currFile == top) { currFile.setStrokeColor(new MTColor(0, 0, 0, 0)); currFile.setNoFill(true); if (lookInDropDown.isVisible()) lookInDropDown.setVisible(false); } else { prevDirs.push(currDir); changeDirectory(currFile); if (lookInDropDown.isVisible()) lookInDropDown.setVisible(false); currFile.setStrokeColor(new MTColor(0, 0, 0, 0)); currFile.setNoFill(true); // Disable up button if at top if (currFile == top) { upButton.setEnabled(false); upButton.setTexture( scene .getMTApplication() .loadImage( System.getProperty("user.dir") + File.separator + "ktsi" + File.separator + "ch" + File.separator + "mitoco" + File.separator + "data" + File.separator + "filechooser" + File.separator + "noUpFolder.png")); } else { upButton.setEnabled(true); upButton.setTexture( scene .getMTApplication() .loadImage( System.getProperty("user.dir") + File.separator + "ktsi" + File.separator + "ch" + File.separator + "mitoco" + File.separator + "data" + File.separator + "filechooser" + File.separator + "upFolder.png")); } } } else { // Add video if (videos.accept(file) && !file.isDirectory()) { MTMovieClip clip = new MTMovieClip(file.getPath(), new Vertex(20, 20, 0), scene); clip.setName(file.getName()); clip.setUseDirectGL(true); clip.setHeightXYGlobal(300); clip.addGestureListener(DragProcessor.class, new InertiaDragAction()); // scene.getLassoProcessor().addClusterable(clip); //make clip lasso-able scene.getCanvas().addChild(clip); System.out.println("Opening: " + file.getName() + "."); // Update settings // scene.updateSettings(clip); toggleFileChooser(); } // Add image else if (images.accept(file) && !file.isDirectory()) { System.out.println("FileChooser: ImageLoad: " + MitocoScene.getImageload()); if (MitocoScene.getImageload()) { PImage texture = scene.getMTApplication().loadImage(file.getPath()); WBImage photo = new WBImage(texture, scene); photo.setName(file.getName()); photo.setNoFill(true); photo.setNoStroke(true); photo.setDisplayCloseButton(true); photo.setHeightXYGlobal(300); photo.addGestureListener(DragProcessor.class, new InertiaDragAction()); // scene.getLassoProcessor().addClusterable(photo); //make photo lasso-able scene.getCanvas().addChild(photo); MitocoScene.setImageload(false); } else { selectionPath = file.getPath(); } toggleFileChooser(); System.out.println("Opening: " + file.getName() + "."); // Update settings // scene.updateSettings(photo); } // Add xml else if (xml.accept(file) && !file.isDirectory()) { selectionPath = file.getPath(); scene.drawXMLload(getSelectionPath()); MitocoScene.setImageload(false); toggleFileChooser(); } else if (pdf.accept(file) && !file.isDirectory()) { selectionPath = file.getPath(); PDFViewer testpdf = new PDFViewer((MTApplication) (scene.getMTApplication()), "Test", selectionPath); scene.getCanvas().addChild(testpdf); testpdf.setVisible(true); testpdf.sendToFront(); MitocoScene.setImageload(false); // scene.drawXMLload(getSelectionPath()); toggleFileChooser(); } else if (powerpoints.accept(file) && !file.isDirectory()) { /* // Run powerpoint to image conversion thread. int numberOfSlides = 0; try{ numberOfSlides = PowerpointToImageConverter.powerPointToImageConversion(file.getCanonicalPath()); }catch(Exception e){} // Add powerpoint images to scene. ArrayList<File> slides = new ArrayList<File>(); for(int i = 0; i < numberOfSlides; i++) { slides.add(new File("slide-" + (i+1) + ".png")); } WBSlideShow photo = new WBSlideShow(scene, slides); photo.setName(file.getName()); photo.setNoFill(true); photo.setNoStroke(true); photo.setDisplayCloseButton(true); photo.setHeightXYGlobal(300); photo.addGestureListener(DragProcessor.class, new InertiaDragAction()); scene.getLassoProcessor().addClusterable(photo); //make photo lasso-able scene.addToMediaLayer(photo); */ selectionPath = file.getPath(); // scene.drawXMLload(getSelectionPath()); toggleFileChooser(); } // FIXME see WBSlideShow and WBImage for needed changes // Add slideshow /*else if(file.length == 1 && file[0].isDirectory()){ //Remove all non-image files File[] holder = file[0].listFiles(); ArrayList<File> dir = createArrayList(holder); for(int index=0; index<dir.size(); index++) { System.out.println("List contains: "+dir.get(index).getName()); if(!dir.get(index).canExecute() || !images.accept(dir.get(index)) || dir.get(index).isDirectory()){ System.out.println("removing "+dir.get(index).getName()); dir.remove(index); } } if(dir.size() > 0) { WBSlideShow show = new WBSlideShow(scene.getApp(),dir); scene.getMediaLayer().addChild(show); show.setName(file[i].getName()); show.setNoFill(true); show.setDisplayCloseButton(true); show.setHeightXYGlobal(300); show.addGestureListener(DragProcessor.class, new InertiaDragAction()); scene.getLassoProcessor().addClusterable(show); //make show lasso-able System.out.println("Opening: " + file[i].getName() + "."); //Update settings scene.updateSettings(show); } else { scene.getCanvas().addChild(new WBErrorMessage(scene, "There weren't any images in that folder!")); } } */ else { // Unreadable drive if (FileSystemView.getFileSystemView().isDrive(currFile.getFile())) { scene .getGuiOverlay() .addChild(new WBErrorMessage(scene.getMTApplication(), "Drive cannot be read from!")); currFile.setStrokeColor(new MTColor(0, 0, 0, 0)); currFile.setNoFill(true); if (lookInDropDown.isVisible()) lookInDropDown.setVisible(false); } // Unsupported file type else { scene .getGuiOverlay() .addChild( new WBErrorMessage(scene.getMTApplication(), "Can't open file of that type!")); } } } }
/** * Method to remove all currently displayed files and show the specified directory's contents * * @param dir */ public void changeDirectory(WBFile dir) { for (WBFile target : currDispFiles) { fileSelector.removeListElement(target); } if (dir.isComputer()) { dispDrives(); currDir = dir; currLookInIcon.setTexture( scene .getMTApplication() .loadImage( System.getProperty("user.dir") + File.separator + "ktsi" + File.separator + "ch" + File.separator + "mitoco" + File.separator + "data" + File.separator + "filechooser" + File.separator + "computer.png")); } else { // Fill window with directory contents if (dir.getFile().getPath() != null) { if (dir.getFile().isDirectory()) { boolean allFiles = false; if (currFilter.getFilter() == null) allFiles = true; ArrayList<File> list = new ArrayList<File>(Arrays.asList(dir.getFile().listFiles())); int target = 0; int size = list.size(); // First add directories for (int i = 0; i < size; i++) { if (list.get(target).isDirectory()) { WBFile tmpDir = new WBFile(scene, list.get(target)); fileSelector.addListElement(tmpDir); tmpDir.setIcon("directory"); currDispFiles.add(tmpDir); list.remove(list.get(target)); } else target++; } target = 0; size = list.size(); // Then add images if (allFiles || currFilter.getFilter() == images) { for (int i = 0; i < size; i++) { if (images.accept(list.get(target))) { WBFile tmpImage = new WBFile(scene, list.get(target)); fileSelector.addListElement(tmpImage); tmpImage.setIcon("image"); currDispFiles.add(tmpImage); list.remove(list.get(target)); } else target++; } } target = 0; size = list.size(); // Then add videos if (allFiles || currFilter.getFilter() == videos) { for (int i = 0; i < size; i++) { if (videos.accept(list.get(target))) { WBFile tmpMovie = new WBFile(scene, list.get(target)); fileSelector.addListElement(tmpMovie); tmpMovie.setIcon("video"); currDispFiles.add(tmpMovie); list.remove(list.get(target)); } else target++; } } target = 0; size = list.size(); if (allFiles || currFilter.getFilter() == xml) { for (int i = 0; i < size; i++) { if (xml.accept(list.get(target))) { WBFile tmpXml = new WBFile(scene, list.get(target)); fileSelector.addListElement(tmpXml); tmpXml.setIcon("xml"); currDispFiles.add(tmpXml); list.remove(list.get(target)); } else target++; } } target = 0; size = list.size(); if (allFiles || currFilter.getFilter() == pdf) { for (int i = 0; i < size; i++) { if (pdf.accept(list.get(target))) { WBFile tmpPdf = new WBFile(scene, list.get(target)); fileSelector.addListElement(tmpPdf); tmpPdf.setIcon("pdf"); currDispFiles.add(tmpPdf); list.remove(list.get(target)); } else target++; } } if (allFiles) { for (File file : list) { WBFile tmpFile = new WBFile(scene, file); fileSelector.addListElement(tmpFile); tmpFile.setIcon(""); currDispFiles.add(tmpFile); } } } currDir = dir; // File system root if (currDir.getFile().getParent() == null) { lookInText.setText(" " + currDir.getFile().getAbsolutePath()); currLookInIcon.setTexture( scene .getMTApplication() .loadImage( System.getProperty("user.dir") + File.separator + "ktsi" + File.separator + "ch" + File.separator + "mitoco" + File.separator + "data" + File.separator + "filechooser" + File.separator + "drive.png")); } // Top desktop else if (stopAtDesktop && currDir.getFile().getPath().toString().compareTo(top.getFile().getPath().toString()) == 0) { lookInText.setText(" " + currDir.getName()); currLookInIcon.setTexture( scene .getMTApplication() .loadImage( System.getProperty("user.dir") + File.separator + "ktsi" + File.separator + "ch" + File.separator + "mitoco" + File.separator + "data" + File.separator + "filechooser" + File.separator + "desktop.png")); } // Normal desktop else { lookInText.setText(" " + currDir.getName()); currLookInIcon.setTexture( scene .getMTApplication() .loadImage( System.getProperty("user.dir") + File.separator + "ktsi" + File.separator + "ch" + File.separator + "mitoco" + File.separator + "data" + File.separator + "filechooser" + File.separator + "folder.png")); } } } // Enable back button if (prevDirs.size() == 1) { // Minimize the times the image is loaded backButton.setEnabled(true); backButton.setTexture( scene .getMTApplication() .loadImage( System.getProperty("user.dir") + File.separator + "ktsi" + File.separator + "ch" + File.separator + "mitoco" + File.separator + "data" + File.separator + "filechooser" + File.separator + "back.png")); } }
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); }