private void cleanUpRepeatingFramesAndValues() { ObservableList<KeyFrame> timelineKeyFrames = timeline.getKeyFrames().sorted(new KeyFrameComparator()); // Timeline timeline; int kfTotal = timelineKeyFrames.size(), kfRemoved = 0; int kvTotal = 0, kvRemoved = 0; Map<Duration, KeyFrame> kfUnique = new HashMap<>(); Map<WritableValue, KeyValue> kvUnique = new HashMap<>(); MapOfLists<KeyFrame, KeyFrame> duplicates = new MapOfLists<>(); Iterator<KeyFrame> iterator = timelineKeyFrames.iterator(); while (iterator.hasNext()) { KeyFrame duplicate = iterator.next(); KeyFrame original = kfUnique.put(duplicate.getTime(), duplicate); if (original != null) { kfRemoved++; iterator.remove(); // removing duplicate keyFrame duplicates.add(original, duplicate); kfUnique.put(duplicate.getTime(), original); } kvUnique.clear(); for (KeyValue kvDup : duplicate.getValues()) { kvTotal++; KeyValue kvOrig = kvUnique.put(kvDup.getTarget(), kvDup); if (kvOrig != null) { kvRemoved++; if (!kvOrig.getEndValue().equals(kvDup.getEndValue()) && kvOrig.getTarget() == kvDup.getTarget()) { System.err.println( "KeyValues set different values for KeyFrame " + duplicate.getTime() + ":" + "\n kvOrig = " + kvOrig + ", \nkvDup = " + kvDup); } } } } for (KeyFrame orig : duplicates.keySet()) { List<KeyValue> keyValues = new ArrayList<>(); for (KeyFrame dup : duplicates.get(orig)) { keyValues.addAll(dup.getValues()); } timelineKeyFrames.set( timelineKeyFrames.indexOf(orig), new KeyFrame(orig.getTime(), keyValues.toArray(new KeyValue[keyValues.size()]))); } System.out.printf( "Removed %d (%.2f%%) duplicate KeyFrames out of total %d.\n", kfRemoved, 100d * kfRemoved / kfTotal, kfTotal); System.out.printf( "Identified %d (%.2f%%) duplicate KeyValues out of total %d.\n", kvRemoved, 100d * kvRemoved / kvTotal, kvTotal); }
/** * * Método a ser usado no update region para decrementar o timer de todas as evidencias na região * e remove-las caso o timer zere. */ private void decrementEvidenceTimer() { for (Iterator<Evidence> it = evidences.iterator(); it.hasNext(); ) { Evidence e = it.next(); if (!e.decrementTimer()) { e.setReg(null); it.remove(); System.out.println("Timer zerado, removendo evidencia"); } } }
private void optimize(Node node) { ObservableList<Transform> transforms = node.getTransforms(); Iterator<Transform> iterator = transforms.iterator(); boolean prevIsStatic = false; while (iterator.hasNext()) { Transform transform = iterator.next(); trTotal++; if (transform.isIdentity()) { if (timeline == null || !bound.contains(transform)) { iterator.remove(); trRemoved++; } } else { if (timeline == null || !bound.contains(transform)) { if (prevIsStatic) { trCandidate++; } prevIsStatic = true; } else { prevIsStatic = false; } } } if (node instanceof Parent) { groupsTotal++; Parent p = (Parent) node; for (Node n : p.getChildrenUnmodifiable()) { optimize(n); } if (transforms.isEmpty()) { Parent parent = p.getParent(); if (parent instanceof Group) { trEmpty++; // System.out.println("Empty group = " + node.getId()); emptyParents.add(p); } else { // System.err.println("parent is not group = " + parent); } } } if (node instanceof MeshView) { meshViews.add((MeshView) node); } }
/** Writes the data to file. */ private void writeIt() { try { // FileWriter writer = new FileWriter("build/resource/mydata.txt"); BufferedWriter writer = new BufferedWriter(new FileWriter("build/resource/mydata.txt")); Iterator<PersonBean> it = personData.iterator(); while (it.hasNext()) { String x; PersonBean p = it.next(); writer.write( p.getFirstAndLastName() + "," + p.getEmail() + "," + p.getGender() + "," + p.getAge()); if (it.hasNext()) { writer.newLine(); } System.out.println("First and last: " + p.getFirstAndLastName()); } writer.close(); } catch (Exception e) { System.out.println("There was a problem saving the file:" + e.getMessage()); } }