public void actionPerformed(ActionEvent ae) { // 响应用户点击 if (ae.getActionCommand().equals("new_game")) { // 如果选择 “开始新游戏” 则跳转到游戏开始 ae_panel = new GamePanel(false); Thread ae_thread = new Thread(ae_panel); ae_thread.start(); // 先删除旧面板 -- 开始界面 this.remove(start_panel); this.add(ae_panel); this.addKeyListener(ae_panel); this.setVisible(true); // 如果没有这句点击后不会出现新的游戏面板 } else if (ae.getActionCommand().equals("qs_game")) { // 退出时保存游戏进度 Recorder.set_enemies(ae_panel.enemies); Recorder.save_game_data(); // 0 表示正常退出 System.exit(0); } else if (ae.getActionCommand().equals("restart_old_game")) { // 恢复游戏数据 -- 如果曾经保存 Recorder.recovery_position(); ae_panel = new GamePanel(true); Thread ae_thread = new Thread(ae_panel); ae_thread.start(); // 先删除旧面板 -- 开始界面 this.remove(start_panel); this.add(ae_panel); this.addKeyListener(ae_panel); this.setVisible(true); } else if (ae.getActionCommand().equals("save_now")) { Recorder.set_enemies(ae_panel.enemies); Recorder.recovery_position(); } }
public void run(String local, String remote, InputStream pin, OutputStream pout) { try { microphone = SoundMixerEnumerator.getInputLine(pcmformat, DefaultPhonePCMBlockSize); } catch (LineUnavailableException lue) { System.out.println( "\3b" + getClass().getName() + ".<init>:\n\tCould not create microphone input stream.\n\t" + lue); } try { speaker = SoundMixerEnumerator.getOutputLine(pcmformat, DefaultPhonePCMBlockSize); } catch (LineUnavailableException lue) { microphone.close(); System.out.println( "\3b" + getClass().getName() + ".<init>:\n\tCould not create speaker output stream.\n\t" + lue); } if ((speaker == null) || (microphone == null)) { super.run(local, remote, pin, pout); return; } try { recorder = new Recorder(pout); recorder.start(); gui = openMonitorGUI("Remote " + remote + " Local " + local); pin.skip(pin.available()); // waste whatever we couldn't process in time super.run(local, remote, new PhoneCallMonitorInputStream(pin), pout); recorder.interrupt(); gui.dispose(); } catch (Exception e) { System.out.println("3\b" + getClass().getName() + ".run:\n\t" + e); e.printStackTrace(); } finally { deactivate(); microphone.close(); speaker.close(); if (gui != null) { gui.dispose(); } } }
private void assertReportWrongNumberOfMatchers(TestInterface testObject) { Recorder<TestInterface> recorder = TestObject.createRecorder(testObject); recorder .record(testObject.methodWithArguments((String) recorder.matchObject(Any.ANY), 10)) .andReturn("value"); }
private void assertUseCustomMatcher(TestInterface testObject) { String returnedValue = "returnedValue"; String stringArg = "stringarg"; int intArg = -1; Recorder<TestInterface> recorder = new Recorder<TestInterface>(testObject); recorder .record( testObject.methodWithArguments( (String) recorder.matchObject( new Matcher() { @Override public boolean matches(Object aActual) { return ((String) aActual).startsWith("s"); } }), recorder.matchInt( new Matcher() { @Override public boolean matches(Object aActual) { return ((Integer) aActual).intValue() < 0; } }))) .andReturn(returnedValue); String actual = testObject.methodWithArguments(stringArg, intArg); assertEquals(actual, returnedValue); }
// 每个DNS服务器都必须实现解析任务 protected Recorder echo(String domain) { Recorder recorder = new Recorder(); // 获得IP地址 recorder.setIp(genIpAddress()); recorder.setDomain(domain); return recorder; }
/** Starts/stops the recording of the call when this button is pressed. */ @Override public void buttonPressed() { if (call != null) { // start recording if (isSelected()) { boolean startedRecording = false; try { startedRecording = startRecording(); } finally { if (!startedRecording && (recorder != null)) { try { recorder.stop(); } finally { recorder = null; } } setSelected(startedRecording); } } // stop recording else if (recorder != null) { try { recorder.stop(); } finally { recorder = null; setSelected(false); } } } }
private void assertThrowOnVoidMethod(TestInterface testObject) { Recorder<TestInterface> recorder = TestObject.createRecorder(testObject); testObject.returnNothing(); recorder.recordForLastCall().andThrow(new RuntimeException()); testObject.returnNothing(); }
private void assertVoidMethodWithParamMatching(TestInterface testObject) { Recorder<TestInterface> recorder = new Recorder<TestInterface>(testObject); String arg = "arg"; testObject.methodWithArguments(arg); recorder.recordForLastCall().andThrow(new RuntimeException()); testObject.methodWithArguments("otherstring"); testObject.methodWithArguments(arg); }
private void assertRecordingUseArgumentMatching(TestInterface testObject) { String stringArg = "arg"; int intArg = 11; String returnedValue = "returnedValue"; Recorder<TestInterface> recorder = TestObject.createRecorder(testObject); recorder.record(testObject.methodWithArguments(stringArg, intArg)).andReturn(returnedValue); String actual = testObject.methodWithArguments("otherArg", -1); assertNull(actual); actual = testObject.methodWithArguments(stringArg, intArg); assertEquals(actual, returnedValue); }
private void assertUseLooseArgumentMatching(TestInterface testObject) { String returnedValue = "returnedValue"; Recorder<TestInterface> recorder = TestObject.createRecorder(testObject); recorder .record( testObject.methodWithArguments( (String) recorder.matchObject(Any.ANY), recorder.matchInt(Any.ANY))) .andReturn(returnedValue); String actual = testObject.methodWithArguments("otherArg", -1); ; assertEquals(actual, returnedValue); }
private void assertNullParametersMatched(TestInterface testObject) { String stringArg = null; int intArg = 11; String returnedValue = "returnedValue"; Recorder<TestInterface> recorder = new Recorder<TestInterface>(testObject); recorder.record(testObject.methodWithArguments(stringArg, intArg)).andReturn(returnedValue); String actual = testObject.methodWithArguments("string", -1); assertNull(actual); actual = testObject.methodWithArguments(stringArg, intArg); assertEquals(actual, returnedValue); }
public void record2(DataOutputStream dos) { try { mRecorder = new Recorder(); mRecorder.StartRecord(dos); while (isRecording) { if (Thread.interrupted()) Log.e("YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY", "" + Thread.interrupted()); } mRecorder.StopRecord(); } catch (Exception t) { Log.e("AudioRecord", "Recording Failed - " + t); } return; }
@Override public void actionPerformed(ActionEvent e) { // 对用户不同的选择做出不同的处理 if (e.getActionCommand().equals("new game")) { // 创建游戏界面面板 mp = new MyPanel("newGame"); // 启动MyPanel线程 Thread t = new Thread(mp); t.start(); // 先删除旧Panel this.remove(msp); this.add(mp); // 注册监听 this.addKeyListener(mp); // 显示(刷新JFrame) this.setVisible(true); } else if (e.getActionCommand().equals("exit")) { // 用户点击了退出系统菜单 // 保存击毁敌人数量. Recorder.SaveRecord(); System.exit(0); } // 对存盘退出做处理 else if (e.getActionCommand().equals("saveExit")) { Recorder rd = new Recorder(); rd.setEts(mp.enemyTanks); // 保存击毁敌人的数量和敌人的坐标 rd.SaveRecAndEnemy(); // 退出(0代表正常退出,1代表异常退出) System.exit(0); } else if (e.getActionCommand().equals("continue")) { // // 创建游戏界面面板 mp = new MyPanel("con"); // mp.flag="con"; // 启动MyPanel线程 Thread t = new Thread(mp); t.start(); // 先删除旧Panel this.remove(msp); this.add(mp); // 注册监听 this.addKeyListener(mp); // 显示(刷新JFrame) this.setVisible(true); } }
private void assertReturnRecordedValue(TestInterface testObject) { String returnValue = "returnValue"; Integer returnInteger = 10; Recorder<TestInterface> recorder = TestObject.createRecorder(testObject); recorder .record(testObject.returnObject()) .andReturn(returnValue) .record(testObject.returnInteger()) .andReturn(returnInteger); assertEquals(returnValue, testObject.returnObject()); assertEquals(returnInteger, testObject.returnInteger()); }
void finishPolygon() { if (xpf != null) { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; bounds = poly.getFloatBounds(); float xbase = (float) bounds.getX(); float ybase = (float) bounds.getY(); for (int i = 0; i < nPoints; i++) { xpf[i] -= xbase; ypf[i] -= ybase; } } else { Polygon poly = new Polygon(xp, yp, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; for (int i = 0; i < nPoints; i++) { xp[i] = xp[i] - x; yp[i] = yp[i] - y; } bounds = null; } if (nPoints < 2 || (!(type == FREELINE || type == POLYLINE || type == ANGLE) && (nPoints < 3 || width == 0 || height == 0))) { if (imp != null) imp.deleteRoi(); if (type != POINT) return; } state = NORMAL; if (imp != null && !(type == TRACED_ROI)) imp.draw(x - 5, y - 5, width + 10, height + 10); oldX = x; oldY = y; oldWidth = width; oldHeight = height; if (Recorder.record && userCreated && (type == POLYGON || type == POLYLINE || type == ANGLE || (type == POINT && Recorder.scriptMode() && nPoints == 3))) Recorder.recordRoi(getPolygon(), type); if (type != POINT) modifyRoi(); LineWidthAdjuster.update(); }
/** * Determines whether a specific format is supported by the <tt>Recorder</tt> represented by this * <tt>RecordButton</tt>. * * @param format the format which is to be checked whether it is supported by the * <tt>Recorder</tt> represented by this <tt>RecordButton</tt> * @return <tt>true</tt> if the specified <tt>format</tt> is supported by the <tt>Recorder</tt> * represented by this <tt>RecordButton</tt>; otherwise, <tt>false</tt> */ private boolean isSupportedFormat(String format) { Recorder recorder; try { recorder = getRecorder(); } catch (OperationFailedException ofex) { logger.error("Failed to get Recorder", ofex); return false; } List<String> supportedFormats = recorder.getSupportedFormats(); return (supportedFormats != null) && supportedFormats.contains(format); }
private void assertEqMatcher(TestInterface testObject) { String returnedValue = "returnedValue"; String stringArg = "stringarg"; int intArg = -1; Recorder<TestInterface> recorder = TestObject.createRecorder(testObject); recorder .record( testObject.methodWithArguments( (String) recorder.matchObject(new Eq(stringArg)), recorder.matchInt(new Eq(intArg)))) .andReturn(returnedValue); String actual = testObject.methodWithArguments(stringArg, intArg); assertEquals(actual, returnedValue); }
public void stop() { if (!sIsRecording) { return; } super.stop(); sIsRecording = false; }
public void start() { super.start(); steps.clear(); MessageFormat mf = new MessageFormat(Strings.get("RecordingX")); setStatus(mf.format(new Object[] {toString()})); lastStepTime = getLastEventTime(); }
@Override protected void finalize() throws Throwable { super.finalize(); writer.flush(); writer.close(); }
@Override protected void configureFrom(Properties properties) { super.configureFrom(properties); proxyPort = getInteger(properties, "betamax.proxyPort", DEFAULT_PROXY_PORT); proxyTimeoutSeconds = getInteger(properties, "betamax.proxyTimeout", DEFAULT_PROXY_TIMEOUT); sslSupport = getBoolean(properties, "betamax.sslSupport"); }
@Override protected void configureWithDefaults() { super.configureWithDefaults(); proxyPort = DEFAULT_PROXY_PORT; proxyTimeoutSeconds = DEFAULT_PROXY_TIMEOUT; sslSupport = false; sslSocketFactory = DEFAULT_SSL_SOCKET_FACTORY; }
@Before public void setUp() throws Exception { driver = new FirefoxDriver(); recorder = new Recorder(); baseUrl = "http://10.0.0.107:8080/"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.manage().window().maximize(); recorder.startRecording(this.getClass().getName()); }
@After public void tearDown() throws Exception { recorder.stopRecording(); driver.quit(); String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } }
public void stopRecording() { recorder.stopRecording(); if (PreferenceManager.getInstance().getPreference(PreferenceManager.PLAY_PLAYBACK_KEY) == 1) { SoundMixer.getInstance().stopAllSoundInSoundMixerAndRewind(); } else if (PreferenceManager.getInstance() .getPreference(PreferenceManager.METRONOM_VISUALIZATION_KEY) > 0) { SoundMixer.getInstance().stopMetronom(); } }
public boolean startRecording() { Log.i("AudioHandler", "StartRecording"); File check = new File(path + '/' + filename); if (check.exists()) { showDialog(); } else { checkAndStartPlaybackAndMetronom(); recorder.record(); } return true; }
@Override public void prepare(@SuppressWarnings("rawtypes") Map stormConf, TopologyContext context) { this.thisTaskId = context.getThisTaskId(); this.recorder = Recorder.getInstance(stormConf); this.recordMessages = true; // // only record messages that are not from a "source" component // this.recordMessages = !context.getThisComponentId().toLowerCase().contains("source"); }
// 画出提示信息的函数 public void showInfo(Graphics g) { // 画出提示信息坦克(该坦克只是提示) this.drawTank(80, 330, g, 0, 1); g.setColor(Color.blue); g.drawString(Recorder.getEnNum() + "", 110, 350); this.drawTank(130, 330, g, 0, 0); g.setColor(Color.blue); g.drawString(Recorder.getMyLife() + "", 165, 350); // 画出玩家的总成绩 g.setColor(Color.BLACK); Font f = new Font("娃娃體-繁", Font.BOLD, 20); g.setFont(f); g.drawString("您的總成績", 420, 30); this.drawTank(420, 60, g, 0, 1); g.setColor(Color.BLACK); g.drawString(Recorder.getAllEnNum() + "", 460, 80); }
public static void onAllocation() { try { long timestamp = System.currentTimeMillis(); StackTrace stackTrace = new StackTrace(Thread.currentThread().getStackTrace()); Record record = new Record(timestamp, stackTrace); synchronized (recorder) { recorder.record(record); } } catch (Exception e) { } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); final float minAngle = (float) Math.PI / 8; final float maxAngle = (float) Math.PI * 7 / 8; float angle = minAngle; if (mRecorder != null) angle += (float) (maxAngle - minAngle) * mRecorder.getMaxAmplitude() / 32768; if (angle > mCurrentAngle) mCurrentAngle = angle; else mCurrentAngle = Math.max(angle, mCurrentAngle - DROPOFF_STEP); mCurrentAngle = Math.min(maxAngle, mCurrentAngle); float w = getWidth(); float h = getHeight(); float pivotX = w / 2; float pivotY = h - PIVOT_RADIUS - PIVOT_Y_OFFSET; float l = h * 4 / 5; float sin = (float) Math.sin(mCurrentAngle); float cos = (float) Math.cos(mCurrentAngle); float x0 = pivotX - l * cos; float y0 = pivotY - l * sin; canvas.drawLine( x0 + SHADOW_OFFSET, y0 + SHADOW_OFFSET, pivotX + SHADOW_OFFSET, pivotY + SHADOW_OFFSET, mShadow); canvas.drawCircle(pivotX + SHADOW_OFFSET, pivotY + SHADOW_OFFSET, PIVOT_RADIUS, mShadow); canvas.drawLine(x0, y0, pivotX, pivotY, mPaint); canvas.drawCircle(pivotX, pivotY, PIVOT_RADIUS, mPaint); if (mRecorder != null && mRecorder.state() == Recorder.RECORDING_STATE) postInvalidateDelayed(ANIMATION_INTERVAL); }