Java 类org.apache.commons.lang3.tuple.MutableTriple 实例源码

项目:tuio-mouse-driver    文件:MouseDriver.java   
/**
 * Update Cursor Event.
 *
 * @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;
        }
    }
}
项目:tuio-mouse-driver    文件:MouseDriver.java   
/**
 * Remove Cursor Event.
 *
 * @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());
    }
}
项目:information-retrieval    文件:SearchEngine.java   
/**
 * Given a key, it loads one docMap into memory
 *
 * @param key
 */
@SuppressWarnings("unchecked")
private void loadDMap(int key) {
    String path = dmap_cache.get(key).getMiddle();

    dmap_cache.put(key, new MutableTriple<>(System.currentTimeMillis(), path, (ConcurrentHashMap<Integer, Pair<String, Integer>>) dm.read(path)));
}
项目:information-retrieval    文件:SearchEngine.java   
/**
 * Builds the docMap cache map
 */
private void buildDmap_cache() {
    dm.getRFiles()
            .parallelStream()
            .filter(file -> file.getName().contains("docMap"))
            .forEach(file -> dmap_cache.put(Integer.valueOf(file.getName().split("\\.")[0]), new MutableTriple<>(System.currentTimeMillis(), file.getPath(), null)));
}
项目:tuio-mouse-driver    文件:MouseDriver.java   
/**
 * Add Cursor Event.
 *
 * @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);
        }
    }
}
项目:mlib    文件:PerformanceInspector.java   
public Object inspect(final ProceedingJoinPoint pjp) throws Throwable {
    MethodSignature signature = (MethodSignature) pjp.getSignature();

    InvokeInfo invokeInfo = invokeInfoThreadLocal.get();
    boolean isRoot = false;
    if (invokeInfo == null) {
        invokeInfo = new InvokeInfo();
        invokeInfoThreadLocal.set(invokeInfo);
        isRoot = true;
    }

    MutableTriple<Integer, MethodSignature, Long> currInvokeInfo =
            MutableTriple.of(invokeInfo.currentLevel++, signature, 0L);
    invokeInfo.infos.add(currInvokeInfo);

    try {
        Tick tick = Tick.tick();
        Object result = pjp.proceed();
        currInvokeInfo.setRight(tick.nip());
        return result;
    } finally {
        invokeInfo.currentLevel--;

        if (isRoot) {
            for (MutableTriple<Integer, MethodSignature, Long> info : invokeInfo.infos) {
                System.out.println(genInfoStr(info));
            }
            invokeInfoThreadLocal.set(null);
        }
    }
}
项目:MrglgaghCore    文件:OBJModel.java   
public void load(Reader data) throws IOException {
    vertices.clear();
    uvs.clear();
    normals.clear();
    faces.clear();
    BufferedReader reader = new BufferedReader(data);
    String line;
    int lineNumber = 1;
    while ((line = reader.readLine()) != null){
        StringTokenizer tokenizer = new StringTokenizer(line);
        if (tokenizer.hasMoreTokens()){
            switch (tokenizer.nextToken()){
                case "v":
                    if (tokenizer.countTokens() != 3){
                        MrglgaghCore.logger.error("Malformed vertex on line "+lineNumber);
                        break;
                    }
                    vertices.add(new Point3f(Float.parseFloat(tokenizer.nextToken()),
                            Float.parseFloat(tokenizer.nextToken()),
                            Float.parseFloat(tokenizer.nextToken())));
                    break;
                case "vt":
                    if (tokenizer.countTokens() != 2){
                        MrglgaghCore.logger.error("Malformed uv on line "+lineNumber);
                        break;
                    }
                    uvs.add(new Point2f(Float.parseFloat(tokenizer.nextToken()),
                            Float.parseFloat(tokenizer.nextToken())));
                    break;
                case "vn":
                    if (tokenizer.countTokens() != 3){
                        MrglgaghCore.logger.error("Malformed vertex normal on line "+lineNumber);
                        break;
                    }
                    normals.add(new Point3f(Float.parseFloat(tokenizer.nextToken()),
                            Float.parseFloat(tokenizer.nextToken()),
                            Float.parseFloat(tokenizer.nextToken())));
                    break;
                case "f":
                    if (tokenizer.countTokens() < 3){
                        MrglgaghCore.logger.error("Malformed face on line "+lineNumber);
                        break;
                    }
                    MutableTriple<Point3i, Point3i, Point3i> face = new MutableTriple<>();
                    String[] p1 = tokenizer.nextToken().split("/");
                    face.setLeft(new Point3i(Integer.parseInt(p1[0])-1, Integer.parseInt(p1[1])-1, Integer.parseInt(p1[2])-1));
                    String[] p2 = tokenizer.nextToken().split("/");
                    face.setMiddle(new Point3i(Integer.parseInt(p2[0])-1, Integer.parseInt(p2[1])-1, Integer.parseInt(p2[2])-1));
                    String[] p3 = tokenizer.nextToken().split("/");
                    face.setRight(new Point3i(Integer.parseInt(p3[0])-1, Integer.parseInt(p3[1])-1, Integer.parseInt(p3[2])-1));
                    faces.add(face);
                    break;
            }
        }
        lineNumber++;
    }
}
项目:AwesomeJavaLibraryExamples    文件:ExampleTriple.java   
private static void buildATriple(MutableTriple<String, String, String> triple)
{
   triple.setMiddle("New Middle");
}
项目:LIMES    文件:SoundexMapper.java   
/**
 * Computes a mapping between a source and a target.
 *
 * @param source
 *            Source cache
 * @param target
 *            Target cache
 * @param sourceVar
 *            Variable for the source dataset
 * @param targetVar
 *            Variable for the target dataset
 * @param expression
 *            Expression to process.
 * @param threshold
 *            Similarity threshold
 * @return A mapping which contains links between the source instances and
 *         the target instances
 */
@Override
public AMapping getMapping(ACache source, ACache target, String sourceVar, String targetVar, String expression,
        double threshold) {
    if (threshold <= 0) {
        throw new InvalidThresholdException(threshold);
    }
    List<String> listA, listB;
    Map<String, List<Integer>> invListA, invListB;
    List<String> properties = PropertyFetcher.getProperties(expression, threshold);
    Map<String, Set<String>> sourceMap = getValueToUriMap(source, properties.get(0));
    Map<String, Set<String>> targetMap = getValueToUriMap(target, properties.get(1));
    listA = new ArrayList<>(sourceMap.keySet());
    listB = new ArrayList<>(targetMap.keySet());
    // create inverted lists (code=>index of original list)
    invListA = getInvertedList(listA);
    invListB = getInvertedList(listB);
    Deque<Triple<Integer, List<Integer>, List<Integer>>> similarityBook = new ArrayDeque<>();
    // construct trie from smaller list
    TrieNode trie = TrieNode.recursiveAddAll(invListB);
    int maxDistance = getMaxDistance(threshold);
    // iterate over other list
    for (Map.Entry<String, List<Integer>> entry : invListA.entrySet()) {
        // for each entry do trie search
        Deque<TrieSearchState> queue = new ArrayDeque<>();
        queue.add(new TrieSearchState(0, 0, trie));
        while (!queue.isEmpty()) {
            TrieSearchState current = queue.pop();
            Set<Map.Entry<Character, TrieNode>> childs = current.getNode().getChildren();
            if (childs.isEmpty() && !current.getNode().getReferences().isEmpty()) {
                similarityBook.push(new MutableTriple<>(current.getDistance(), entry.getValue(),
                        current.getNode().getReferences()));
            }
            for (Map.Entry<Character, TrieNode> nodeEntry : childs) {
                if (nodeEntry.getKey().equals(entry.getKey().charAt(current.getPosition()))) {
                    queue.push(new TrieSearchState(current.getDistance(), current.getPosition() + 1,
                            nodeEntry.getValue()));
                } else if (current.getDistance() < maxDistance) {
                    queue.push(new TrieSearchState(current.getDistance() + 1, current.getPosition() + 1,
                            nodeEntry.getValue()));
                }
            }
        }
    }
    AMapping result = MappingFactory.createDefaultMapping();
    while (!similarityBook.isEmpty()) {
        Triple<Integer, List<Integer>, List<Integer>> t = similarityBook.pop();
        for (Integer i : t.getMiddle()) {
            String a = listA.get(i);
            for (Integer j : t.getRight()) {
                String b = listB.get(j);
                for (String sourceUri : sourceMap.get(a)) {
                    for (String targetUri : targetMap.get(b)) {
                        result.add(sourceUri, targetUri,
                                (1.0d - (t.getLeft().doubleValue() / (double) SoundexMeasure.codeLength)));
                    }
                }
            }
        }
    }

    return result;
}
项目:mlib    文件:PerformanceInspector.java   
private String genInfoStr(MutableTriple<Integer, MethodSignature, Long> info) {
    return Strings.repeat("\t", info.getLeft())
            + info.getMiddle().getDeclaringType().getSimpleName() + "." + info.getMiddle().getName()
            + " :" + info.getRight() + "ms";
}
项目:AwesomeJavaLibraryExamples    文件:ExampleTriple.java   
public static void main(String[] args)
{
   MutableTriple<String, String, String> mutableTriple = new MutableTriple<>("Left", "Middle", "Right");

   System.out.println("Our first Triple: " + buildATriple());

   System.out.println("Before changing: " + mutableTriple);

   buildATriple(mutableTriple);

   System.out.println("After changing: " + mutableTriple);
}