public void mouseReleased(java.awt.event.MouseEvent ev) { if (isButton1(ev)) { // super.mouseReleased( ev ); if (hasBeenDragged) { // pass } else { edu.cmu.cs.stage3.alice.core.response.MoveAnimation moveAnimation = new edu.cmu.cs.stage3.alice.core.response.MoveAnimation(); moveAnimation.subject.set(pickedTransformable); moveAnimation.direction.set(edu.cmu.cs.stage3.alice.core.Direction.FORWARD); moveAnimation.amount.set(new Double(1)); moveAnimation.isScaledBySize.set(Boolean.TRUE); edu.cmu.cs.stage3.alice.core.response.MoveAnimation undoAnimation = new edu.cmu.cs.stage3.alice.core.response.MoveAnimation(); undoAnimation.subject.set(pickedTransformable); undoAnimation.direction.set(edu.cmu.cs.stage3.alice.core.Direction.FORWARD); undoAnimation.amount.set(new Double(-1)); undoAnimation.isScaledBySize.set(Boolean.TRUE); edu.cmu.cs.stage3.alice.core.Property[] affectedProperties = new edu.cmu.cs.stage3.alice.core.Property[] {pickedTransformable.localTransformation}; edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.getHack() .performOneShot(moveAnimation, undoAnimation, affectedProperties); } undoRedoStack.stopCompound(); } }
static { root = new Key(); root.name = "<root>"; root.subKeys = new java.util.HashMap(); java.io.File aliceHasNotExitedFile = new java.io.File( edu.cmu.cs.stage3.alice.authoringtool.JAlice.getAliceUserDirectory(), "aliceHasNotExited.txt"); if (aliceHasNotExitedFile.canRead()) { try { storeConfig(); } catch (java.io.IOException e2) { edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.showErrorDialog( java.util.ResourceBundle.getBundle( "edu/cmu/cs/stage3/alice/authoringtool/util/Configuration") .getString("UNABLE_TO_CREATE_NEW_PREFERENCES_FILE."), e2); } } else { try { loadConfig(configLocation); } catch (Exception e) { } } }
private void guiInit() { DefaultListModel listOfStuff = new DefaultListModel(); partsList.setModel(listOfStuff); listOfStuff.addElement(new ElementOrNullWrapper(null, "Build Model from skeleton file")); Sandbox[] possibilities = (Sandbox[]) AuthoringTool.getInstance().getWorld().sandboxes.getArrayValue(); for (int i = 0; i < possibilities.length; i++) { listOfStuff.addElement(new ElementOrNullWrapper(possibilities[i])); } partsList.setSelectedIndex(0); aliceFPSCombo.insertItemAt("15", 0); aliceFPSCombo.insertItemAt("30", 1); aliceFPSCombo.setSelectedIndex(1); nativeFPSCombo.insertItemAt("60", 0); nativeFPSCombo.insertItemAt("120", 1); nativeFPSCombo.setSelectedIndex(0); }
private static void storeConfig(java.io.OutputStream os) throws java.io.IOException { javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); try { javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder(); org.w3c.dom.Document document = builder.newDocument(); org.w3c.dom.Element rootElement = document.createElement("configuration"); document.appendChild(rootElement); if (root.subKeys != null) { for (java.util.Iterator iter = root.subKeys.values().iterator(); iter.hasNext(); ) { Key key = (Key) iter.next(); rootElement.appendChild(makeKeyElement(document, key)); } } document.getDocumentElement().normalize(); edu.cmu.cs.stage3.xml.Encoder.write(document, os); // try { // Class documentClass = document.getClass(); // java.lang.reflect.Method writeMethod = documentClass.getMethod( "write", new Class[] { // java.io.OutputStream.class } ); // writeMethod.invoke( document, new Object[] { os } ); // } catch( Exception e ) { // edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.showErrorDialog( "Unable to store // preferences. Cannot invoke 'write' method.", e ); // } // ((org.apache.crimson.tree.XmlDocument)document).write( os ); // ((com.sun.xml.tree.XmlDocument)document).write( os ); } catch (javax.xml.parsers.ParserConfigurationException pce) { edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.showErrorDialog( java.util.ResourceBundle.getBundle( "edu/cmu/cs/stage3/alice/authoringtool/util/Configuration") .getString("ERROR_PARSING_PREFERENCES_FILE."), pce); } }
public void dissolve() { if (m_element.getParent() instanceof edu.cmu.cs.stage3.alice.core.response.CompositeResponse) { authoringTool.getUndoRedoStack().startCompound(); edu.cmu.cs.stage3.alice.core.response.CompositeResponse parent = (edu.cmu.cs.stage3.alice.core.response.CompositeResponse) m_element.getParent(); int index = parent.componentResponses.indexOf(m_element); if (parent instanceof edu.cmu.cs.stage3.alice.core.response.IfElseInOrder) { if (!parent.componentResponses.contains(m_element)) { index = ((edu.cmu.cs.stage3.alice.core.response.IfElseInOrder) parent) .elseComponentResponses.indexOf(m_element); } } Object responses[] = m_components.getArrayValue(); for (int i = 0; i < responses.length; i++) { if (responses[i] instanceof edu.cmu.cs.stage3.alice.core.Response) { edu.cmu.cs.stage3.alice.core.Response currentResponse = (edu.cmu.cs.stage3.alice.core.Response) responses[i]; currentResponse.removeFromParent(); currentResponse.setParent(parent); parent.componentResponses.add(index + i, currentResponse); } } m_element.removeFromParent(); authoringTool.getUndoRedoStack().stopCompound(); } else if (m_element.getParent() instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.Composite) { authoringTool.getUndoRedoStack().startCompound(); edu.cmu.cs.stage3.alice.core.question.userdefined.Composite parent = (edu.cmu.cs.stage3.alice.core.question.userdefined.Composite) m_element.getParent(); int index = parent.getIndexOfChild(m_element); if (parent instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.IfElse) { if (!parent.components.contains(m_element)) { index = ((edu.cmu.cs.stage3.alice.core.question.userdefined.IfElse) parent) .elseComponents.indexOf(m_element); } } Object questions[] = m_components.getArrayValue(); for (int i = 0; i < questions.length; i++) { if (questions[i] instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.Component) { edu.cmu.cs.stage3.alice.core.question.userdefined.Component currentQuestion = (edu.cmu.cs.stage3.alice.core.question.userdefined.Component) questions[i]; currentQuestion.removeFromParent(); currentQuestion.setParent(parent); parent.components.add(index + i, currentQuestion); } } m_element.removeFromParent(); authoringTool.getUndoRedoStack().stopCompound(); } else if (m_element.getParent() instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.UserDefinedQuestion) { authoringTool.getUndoRedoStack().startCompound(); edu.cmu.cs.stage3.alice.core.question.userdefined.UserDefinedQuestion parent = (edu.cmu.cs.stage3.alice.core.question.userdefined.UserDefinedQuestion) m_element.getParent(); int index = parent.getIndexOfChild(m_element); Object questions[] = m_components.getArrayValue(); for (int i = 0; i < questions.length; i++) { if (questions[i] instanceof edu.cmu.cs.stage3.alice.core.question.userdefined.Component) { edu.cmu.cs.stage3.alice.core.question.userdefined.Component currentQuestion = (edu.cmu.cs.stage3.alice.core.question.userdefined.Component) questions[i]; currentQuestion.removeFromParent(); currentQuestion.setParent(parent); parent.components.add(index + i, currentQuestion); } } m_element.removeFromParent(); authoringTool.getUndoRedoStack().stopCompound(); } }
public Vector encodeFiles(double length, String exportDirectory) // get { Vector newDS = new Vector(); String orig_file = "", final_sound = "", sound_slice = "", sound_cut = "", track_file = "", silence = exportDirectory + "silence.wav"; int currentChunk = 0; int currentLength = 0; convertTimes(); convertCaptureTimes(); // print("size of length " + soundList.size()); for (int y = 0; y < soundList.size(); y++) { double blankLength = 0; SoundData sd = (SoundData) soundList.get(y); if ((sd.duration < sd.clippedDuration) || (sd.clippedDuration == 0.0)) sd.clippedDuration = sd.duration; sd.stopTime = sd.duration; while (sd.worldTime > ((Double) stopCaptureTimes.get(currentChunk)).doubleValue()) { currentLength += ((Double) stopCaptureTimes.get(currentChunk)).doubleValue(); currentChunk++; if (currentChunk >= stopCaptureTimes.size()) break; } // if no more capturing Chunks OR start+duration <startCapture if (currentChunk >= stopCaptureTimes.size()) break; if (((Double) startCaptureTimes.get(currentChunk)).doubleValue() > (sd.worldTime + sd.clippedDuration)) continue; // know that sound must intersect with capturing // print("Current Chunk Values: Start "+ startCaptureTimes.get(currentChunk) + " Stop: " + // stopCaptureTimes.get(currentChunk)); // print("Current Sound: Start " + sd.worldTime + " End: " + (sd.worldTime + // sd.clippedDuration)); if (sd.worldTime > ((Double) startCaptureTimes.get(currentChunk)).doubleValue()) { blankLength = sd.worldTime - ((Double) startCaptureTimes.get(currentChunk)).doubleValue() + currentLength; } else { blankLength = currentLength; } orig_file = exportDirectory + "sound" + y + "." + sd.data.getExtension(); sound_slice = exportDirectory + "sound" + y + ".wav"; sound_cut = exportDirectory + "soundCut" + y + ".wav"; track_file = exportDirectory + "track" + y + ".wav"; writeToFile(sd.data.getJMFDataSource(), createURL(orig_file)); if (sd.data.getExtension().equals("MP3")) { // print("About to try and Convert!" + sound_slice + " " + orig_file); SimpleSound.convert(orig_file, sound_slice); } // try to crop sound if necessary double beginning = 0.0; double ending = 0.0; beginning = cropBeginning(sd, length, currentChunk); ending = cropEnding(sd, length, currentChunk); // print("Trying to Cut"); if (beginning != 0 || ending != 0) { sound_slice = tryToCut(length, sd, sound_slice, sound_cut, beginning, ending, blankLength); } // if ( sound_slice.endsWith(".wav") ){ // String filename = "file:" + sound_slice.replace('/', '\\'); // SaveAsDialog dlgSaveAs = new SaveAsDialog (new Frame(), filename, null, null); // sound_slice = sound_slice.substring(0, sound_slice.length() - 4) + "a.wav"; // } // create sound try { SimpleSound s = new SimpleSound(); s.loadFromFile(sound_slice); // create silent sound of length blankLength, and type s SimpleSound blank = new SimpleSound(blankLength, s); blank.writeToFile(silence); } catch (SoundException e) { AuthoringTool.showErrorDialog("Error encoding sound file. ", e); return null; } if (blankLength > 0.0) { Vector v = new Vector(); v.add(createURL(silence)); v.add(createURL(sound_slice)); final_sound = createURL(track_file); if (concat(v, final_sound) == false) return null; } else { // print("No SILENCE"); final_sound = createURL(sound_slice); } // print("Sound " + y); newDS.add(final_sound); } // merging sounds!! // print(" Right before merging "); return newDS; }