List of usage examples for org.apache.commons.lang3.tuple MutableTriple getLeft
@Override
public L getLeft()
From source file:com.artistech.tuio.mouse.MouseDriver.java
/** * Update Cursor Event./*from ww w. j a v a2 s . c om*/ * * @param tcur */ @Override public void updateTuioCursor(TuioCursor tcur) { logger.trace(MessageFormat.format("update tuio cursor id: {0}", tcur.getCursorID())); int width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); int height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); if (!curs.isEmpty() && curs.get(0).getLeft() == tcur.getSessionID()) { logger.debug(MessageFormat.format("update mouse move: ({0}, {1})", new Object[] { tcur.getScreenX(width), tcur.getScreenY(height) })); robot.mouseMove(tcur.getScreenX(width), tcur.getScreenY(height)); } for (MutableTriple<Long, Integer, Integer> trip : curs) { if (trip.getLeft() == tcur.getSessionID()) { trip.setMiddle(tcur.getScreenX(width)); trip.setRight(tcur.getScreenY(height)); break; } } }
From source file:com.artistech.tuio.mouse.MouseDriver.java
/** * Remove Cursor Event./*ww w . j a v a 2s . c o m*/ * * @param tcur */ @Override public void removeTuioCursor(TuioCursor tcur) { logger.trace(MessageFormat.format("remove tuio cursor id: {0}", tcur.getCursorID())); if (!curs.isEmpty() && curs.get(0).getLeft() == tcur.getSessionID()) { robot.mouseRelease(InputEvent.BUTTON1_MASK); } else if (curs.size() == 2) { logger.debug(MessageFormat.format("remove mouse release: {0}", tcur.getCursorID())); robot.mouseRelease(InputEvent.BUTTON1_MASK); } MutableTriple t = null; for (MutableTriple<Long, Integer, Integer> trip : curs) { if (trip.getLeft() == tcur.getSessionID()) { t = trip; break; } } if (t != null) { curs.remove(t); } if (!curs.isEmpty()) { robot.mouseMove(curs.get(0).getMiddle(), curs.get(0).getRight()); } }
From source file:com.artistech.tuio.mouse.MouseDriver.java
/** * Add Cursor Event.//from w w w. j av a2 s.co m * * @param tcur */ @Override public void addTuioCursor(TuioCursor tcur) { logger.trace(MessageFormat.format("add tuio cursor id: {0}", tcur.getCursorID())); int width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); int height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); boolean found = false; for (MutableTriple<Long, Integer, Integer> trip : curs) { if (trip.getLeft() == tcur.getSessionID()) { found = true; break; } } if (!found) { curs.add(new MutableTriple<>(tcur.getSessionID(), tcur.getScreenX(width), tcur.getScreenY(height))); } if (curs.size() == 1) { logger.debug(MessageFormat.format("add mouse move: ({0}, {1})", new Object[] { tcur.getScreenX(width), tcur.getScreenY(height) })); robot.mouseMove(tcur.getScreenX(width), tcur.getScreenY(height)); } else { logger.debug(MessageFormat.format("add mouse press: {0}", tcur.getCursorID())); if (curs.size() == 2) { robot.mousePress(InputEvent.BUTTON1_MASK); } else { robot.mousePress(InputEvent.BUTTON3_MASK); robot.mouseRelease(InputEvent.BUTTON3_MASK); } } }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeSyncValidator.java
@Override public void run() { isFinished_ = false;// w w w .ja v a 2 s.c o m AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_); for (Volume vol : VolumeSyncValidate_) { try { JSONParser parser = new JSONParser(); String inttagvalue = getIntTagValue(vol); if (inttagvalue == null) { continue; } JSONObject eideticParameters; try { Object obj = parser.parse(inttagvalue); eideticParameters = (JSONObject) obj; } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } if (eideticParameters == null) { continue; } //Same Integer keep = getKeep(eideticParameters, vol); if (keep == null) { continue; } JSONObject syncSnapshot = null; if (eideticParameters.containsKey("SyncSnapshot")) { syncSnapshot = (JSONObject) eideticParameters.get("SyncSnapshot"); } if (syncSnapshot == null) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); continue; } JSONObject validateParameters; try { validateParameters = (JSONObject) syncSnapshot.get("Validate"); } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); continue; } Integer createAfter = getCreateAfter(validateParameters, vol); String cluster = getCluster(validateParameters, vol); if (validateCluster_.containsKey(cluster)) { validateCluster_.get(cluster).add(new MutableTriple(vol, createAfter, keep)); } else { validateCluster_.put(cluster, new ArrayList<MutableTriple<Volume, Integer, Integer>>()); validateCluster_.get(cluster).add(new MutableTriple(vol, createAfter, keep)); } } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } for (String cluster : validateCluster_.keySet()) { try { ArrayList<MutableTriple<Volume, Integer, Integer>> myList = validateCluster_.get(cluster); Boolean snapshotCluster = false; Integer min = Integer.MAX_VALUE; for (MutableTriple trip : myList) { if (((Integer) trip.getMiddle()) < min) { min = (Integer) trip.getMiddle(); } } for (MutableTriple trip : myList) { if (snapshotDecision(ec2Client, (Volume) trip.getLeft(), min)) { snapshotCluster = true; } } if (snapshotCluster) { ArrayList<Volume> vols = new ArrayList<>(); for (MutableTriple trip : myList) { vols.add((Volume) trip.getLeft()); } SnapshotVolumeSync thread = new SnapshotVolumeSync(awsAccessKeyId_, awsSecretKey_, uniqueAwsAccountIdentifier_, maxApiRequestsPerSecond_, ApplicationConfiguration.getAwsCallRetryAttempts(), region_, vols, true); try { thread.run(); } catch (Exception e) { String responseMessage = "Error running cluster validator thread for cluster " + cluster; logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Error=\"" + responseMessage + "\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } Integer wait = 0; while (!(thread.isFinished()) && (wait <= 200)) { Threads.sleepMilliseconds(250); //break after 50 seconds wait = wait + 1; } } } catch (Exception e) { logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); } } ec2Client.shutdown(); isFinished_ = true; }