/** * Formats a timespan in milliseconds * @param millisec number of milliseconds * @return a string of hours:minutes:seconds:milliseconds */ public static String timeString(long millisec){ return timeString(millisec, 0); } /**
@Override public B adapt(A a) { return polymorphicAdapt(a); }
private void myStopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_myStopButtonActionPerformed if(myPlayable == null){ return; } myPlayable.stop(TimeUtils.now()); }//GEN-LAST:event_myStopButtonActionPerformed
TimeUtils.sleep(10000);
@Override public void actionPerformed(ActionEvent e) { SourceImpl<AnimationEditor> cS = new SourceImpl<AnimationEditor>(); new FileAction.Open(cS, new UndoRedoFactory(), null).actionPerformed(null); if(cS.getValue() == null){ return; } AnimationTimelineEditor editor = new AnimationTimelineEditor(); editor.open(); editor.requestActive(); CoordinateScalar scaler = new DefaultCoordinateScalar(0.02, 400, true); ScalingManager sm = new ScalingManager(scaler); editor.init(sm); editor.setController(cS.getValue()); } }
/** * Reads a list of floats from the Configuration at the given key * @param config Configuration to read * @param key Configuration key for the floats * @return list of floats from the Configuration at the given key */ public static float[] readFloats(Configuration config, String key){ try{ String[] strs = config.getStringArray(key); return ListUtils.parseFloats(strs); }catch(Throwable t){ theLogger.log(Level.WARNING, "There was an error readign key:" + key, t); return null; } }
private <C extends A> B polymorphicAdapt(C a) { String type = myKeyMap.getKey(a); if(type == null){ theLogger.warning("Unable to adapt, KeyMap returned null key."); return null; } Adapter<? extends A,B> adapter = myAdapterMap.get(type); if(adapter != null){ B b = null; try{ b = ((Adapter<C,? extends B>)adapter).adapt(a); if(b != null){ return b; } }catch(ClassCastException ex){ theLogger.log(Level.WARNING, "Found incompatible adapter for given class. Class: " + a.getClass() + ", Adapter: " + adapter, ex); return null; } theLogger.info( "Unable to adapt with specific adapter, returned null."); }else{ theLogger.info("No specifc adapter, using default adapter."); } return null; }
protected void updateConfig(BoneJointConfig bjc, boolean flag_hardResetGoalPosToDefault) { double defPosVal = Utils.bound(bjc.myNormalDefaultPos, 0.0, 1.0); myDefaultPosNorm = new NormalizedDouble(defPosVal); myBoneProjectionRanges = bjc.myProjectionRanges; List<BoneProjectionRange> projRanges = getBoneRotationRanges(); if(projRanges == null || projRanges.isEmpty()){ myNormalizableRange = NormalizableRange.NORMALIZED_RANGE; } else { BoneProjectionRange range = projRanges.get(0); double min = range.getMinPosAngRad(); double max = range.getMaxPosAngRad(); myNormalizableRange = new DoubleRange(min, max); } if (flag_hardResetGoalPosToDefault) { hardResetGoalPosToDefault(); } } private void hardResetGoalPosToDefault() {
private void myPlayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_myPlayButtonActionPerformed if(myPlayable == null){ return; } PlayState state = myPlayable.getPlayState(); switch(state){ case PENDING: case COMPLETED: case STOPPED: myPlayable.start(TimeUtils.now()); break; case RUNNING: myPlayable.pause(TimeUtils.now()); break; case PAUSED: myPlayable.resume(TimeUtils.now()); break; } }//GEN-LAST:event_myPlayButtonActionPerformed
TimeUtils.sleep(1000);
return Color.decode(colStr); }else if(len == 4){ int r = Utils.readHex(colStr.charAt(1))*17; int g = Utils.readHex(colStr.charAt(1))*17; int b = Utils.readHex(colStr.charAt(1))*17; int a = Utils.readHex(colStr.charAt(1))*17; return new Color(r, g, b, a); }else{ int r = Utils.readHex(colStr.substring(1, 3)); int g = Utils.readHex(colStr.substring(3, 5)); int b = Utils.readHex(colStr.substring(5, 7)); int a = Utils.readHex(colStr.substring(7, 9)); return new Color(r, g, b, a);
@Override public void actionPerformed(ActionEvent e) { SourceImpl<AnimationEditor> cS = new SourceImpl<AnimationEditor>(); new FileAction.New(cS, new UndoRedoFactory()).actionPerformed(e); CoordinateScalar scalar = new DefaultCoordinateScalar(0.2, 400, true); ScalingManager scalingManager = new ScalingManager(scalar); AnimationTimelineEditor editor = new AnimationTimelineEditor(); editor.init(scalingManager); editor.open(); editor.requestActive(); editor.setController(cS.getValue()); } }
@Override public SpeechRequest adapt(String a) { SpeechRequestRecord rec = new SpeechRequestRecord(); rec.setRequestSourceId(mySourceId); rec.setSpeechServiceId(myDestId); rec.setTimestampMillisecUTC(TimeUtils.now()); rec.setPhrase(a); return rec; }
@Override public ConvoResponse adapt(String a) { if(a == null){ return null; } long start = TimeUtils.now(); if(myCogbotComm == null){ return null; } GenRespWithConf resp = myCogbotComm.getResponse(a); if(STOP_SCHED_PROMPT.equals(resp.getResponse())){ mySchedule.shutdownNow(); mySchedule = new ScheduledThreadPoolExecutor(1); resp.setResponse("INTERRUPT_OUTPUT"); } resp.setResponse(trySchedule(resp.getResponse())); return new ConvoResponse( a, resp.getResponse(), 0, start, TimeUtils.now()); }
public void test(String text){ SpeechRecEventRecord e = new SpeechRecEventRecord(); e.setRecognizerId("rec"); e.setRecognizedText(text); e.setConfidence(1.0); e.setTimestampMillisecUTC(TimeUtils.now()); List<SpeechRecEventRecord> list = new ArrayList<SpeechRecEventRecord>(); list.add(e); SpeechRecEventListRecord l = new SpeechRecEventListRecord(); l.setSpeechRecServiceId("source"); l.setEventDestinationId("dest"); l.setSpeechRecEvents(list); l.setTimestampMillisecUTC(TimeUtils.now()); notifyListeners(l); }
AnimationJob jobToCheck = getOutJobOrNull(perf); if (jobToCheck != null) { long remainingTime = jobToCheck.getRemainingTime(TimeUtils.now());