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); }
public static DefaultCategoryDataset createDataSetForStudent( ObservableList<EvaluationHelper> allEvaluationHelper) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); for (EvaluationHelper eh : allEvaluationHelper) { ArrayList<Double> values = CalculationHelper.getAverageDataPerStudent(allEvaluationHelper); defaultcategorydataset.addValue( values.get(allEvaluationHelper.indexOf(eh)), SeCatResourceBundle.getInstance().getString("scene.chart.studentincrease"), eh.getRawId() + " " + SeCatResourceBundle.getInstance().getString("scene.chart.all.value.lable") + ": " + doubleFormat.format(values.get(allEvaluationHelper.indexOf(eh)))); } return defaultcategorydataset; }
/** * Toogles the view between navigation view and playback mode. * * @param show */ private void showPlayerMode(final boolean show) { UIStateController.getInstance().setLockInput(true); getPager().toggleMode(); if (show) { getPager().setModels(new ArrayList<IServiceModel>(album.getSongs()), album.getSongs().get(0)); } else { IGoogleMusicService service = ServiceRegistry.getGoogleService(); List<Album> albums = service.getAlbums(); getPager().setModels(new ArrayList<IServiceModel>(albums), album); } Pane centerRegion = UIStateController.getInstance().getGoogleNaviController().getCenterRegion(); final ObservableList<Node> children = ((Pane) centerRegion.getChildren().get(0)).getChildren(); List<Node> nodes = new ArrayList<Node>(); int count = children.indexOf(albumNode) + 1; for (int i = count; i < count + 4; i++) { if (children.size() > i) { nodes.add(children.get(i)); } } if (!show) { final FadeTransition outFader = TransitionUtil.createOutFader(songScroller); outFader.setOnFinished( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { albumNode.getChildren().remove(songScroller); } }); outFader.play(); } int scrollPos = (int) UIStateController.getInstance().getGoogleNaviController().getScrollPos(); for (Node node : nodes) { TransitionUtil.moveNodeX( node, 0, children.indexOf(albumNode) * GoogleUINaviController.COVER_SIZE + 490, !show, SCROLL_DELAY); } final EventHandler<ActionEvent> eventHandler = new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { if (show) { display(); final FadeTransition inFader = TransitionUtil.createInFader(songScroller); inFader.setOnFinished( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { UIStateController.getInstance().setLockInput(false); } }); inFader.play(); } else { if (UIStateController.getInstance().getActiveController() != GoogleUIPlayerController.this) { albumNode.setStyle(GoogleUINaviController.STYLE_ACTIVE); } UIStateController.getInstance().setLockInput(false); } } }; TransitionUtil.moveNode( centerRegion, scrollPos, (scrollPos - 245), !show, SCROLL_DELAY, eventHandler, true); }