/** Removes the from scene. */ public void removeFromScene() { MTComponent cursorTraceContainer = null; MTCanvas canvas = scene.getCanvas(); /* //Re-use cursor trace group which is always on top for this menu MTComponent[] children = canvas.getChildren(); for (int i = 0; i < children.length; i++) { MTComponent component = children[i]; if (component instanceof MTOverlayContainer && component.getName().equalsIgnoreCase("Cursor Trace group")){ cursorTraceContainer = component; if (cursorTraceContainer.containsChild(this)){ cursorTraceContainer.removeChild(this); } } } */ // /* // cursor tracer group NOT found in the scene -> add overlay container to canvas if (cursorTraceContainer == null) { if (canvas.containsChild(overlayGroup)) { canvas.removeChild(overlayGroup); } } // */ }
/** Private method, handle a new fiducial */ private void started() { AbstractShape roundingcircle = new MTEllipse(app, new Vector3D(event.getPosition()), 180, 180, 100); roundingcircle.setNoFill(false); float r = ToolsMath.getRandom(20, 255); float g = ToolsMath.getRandom(20, 255); float b = ToolsMath.getRandom(20, 255); roundingcircle.setFillColor(new MTColor(r, g, b, 200)); roundingcircle.setNoStroke(false); roundingcircle.setStrokeWeight(1); roundingcircle.setStrokeColor(new MTColor(r, g, b, 200)); roundingcircle.unregisterAllInputProcessors(); AbstractShape component = new MTEllipse(app, new Vector3D(event.getPosition()), 20, 20, 20); component.setNoFill(false); float r1 = ToolsMath.getRandom(20, 255); float g1 = ToolsMath.getRandom(20, 255); float b1 = ToolsMath.getRandom(20, 255); component.setFillColor(new MTColor(r1, g1, b1, 200)); component.setNoStroke(false); component.setStrokeWeight(1); component.setStrokeColor(new MTColor(r1, g1, b1, 200)); component.unregisterAllInputProcessors(); // Dont process input/gestures on this component roundingcircle.addChild(component); MTColor white = new MTColor(255, 255, 255); IFont fontArial = FontManager.getInstance().createFont(app, "arial.ttf", 50, white); MTTextArea text = new MTTextArea(app, fontArial); text.setFillColor(new MTColor(0, 0, 0, 0)); text.setStrokeColor(new MTColor(0, 0, 0, 0)); text.unregisterAllInputProcessors(); roundingcircle.addChild(text); text.setPositionRelativeToParent( new Vector3D(event.getPosition().x, event.getPosition().y - 120)); roundingcircle.setUserData("angle", event.getAngle()); MTKeyboard keys = KeyboardPool.getInstance(app).getKeyboard(); roundingcircle.addChild(keys); keys.setPositionRelativeToParent( new Vector3D(event.getPosition().x, event.getPosition().y + 150)); keys.setUserData("fiducialID", EventID); text.setExpandDirection(ExpandDirection.UP); text.unregisterAllInputProcessors(); /* * Need to find a way to keep the text centred at all times. */ // text.setEnableCaret(true); keys.addTextInputListener(text); keys.addInputListener(text); FiducialRegistry.getInstance().putFiducialCompoent(EventID, roundingcircle); String searchTerm = "Doctor Who"; TwitterSearch twsearch = new TwitterSearch(); twsearch.search(searchTerm); canvas.addChild(roundingcircle); }