public void updateNetworkData() { HashMap<String, HashMap<Integer, SimulationElement>> originalNetwork = new HashMap<>(); HashMap<String, HashMap<Integer, SimulationElement>> originalTransit = new HashMap<>(); HashMap<String, HashMap<Integer, SimulationElement>> networkCopy = new HashMap<>(); HashMap<String, HashMap<Integer, SimulationElement>> transitCopy = new HashMap<>(); HashMap<String, HashMap<Integer, SimulationElement>> totalCopy = new HashMap<>(); historyIndex++; removeRedo(); originalNetwork.putAll(currentNetwork.getNetworkElements()); originalTransit.putAll(currentTransit.getTransits()); for (Entry<String, HashMap<Integer, SimulationElement>> entry : originalNetwork.entrySet()) { networkCopy.put(entry.getKey(), new HashMap<>(entry.getValue())); } networkHistory.add(historyIndex, networkCopy); for (Entry<String, HashMap<Integer, SimulationElement>> entry : originalTransit.entrySet()) { transitCopy.put(entry.getKey(), new HashMap<>(entry.getValue())); } transitHistory.add(historyIndex, transitCopy); totalCopy.putAll(networkCopy); totalCopy.putAll(transitCopy); dataReceiver.updateSimulationElements(totalCopy); simulationBox.updateRendering(); }
/** * Use for undo and redo update. * * @param history The index of the required version of the network to reload */ public void updateHistoryData(int history) { HashMap<String, HashMap<Integer, SimulationElement>> original = new HashMap<>(); original.putAll(networkHistory.get(history)); original.putAll(transitHistory.get(history)); currentNetwork.setNetworkElements(networkHistory.get(history)); currentTransit.setTransits(transitHistory.get(history)); dataReceiver.updateSimulationElements(original); simulationBox.updateRendering(); }
private void startAnimation() { initAnimator(); parametriseAnimator(); animator.computeAnimation(); dataReceiver.updateAnimations(animator.getAnimations(), animator.getReport()); }