private void initAnimator() {
    HashMap<String, HashMap<Integer, SimulationElement>> networkStateForAnimation = new HashMap<>();
    networkStateForAnimation.putAll(currentNetwork.getNetworkElements());
    networkStateForAnimation.putAll(currentTransit.getTransits());

    animator.initAnimator(networkStateForAnimation);
  }
  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();
  }
 private void deleteTransportNeed() {
   int transportNeedID = simulationBox.getSelectedTransportNeedID();
   if (transportNeedID != -1) {
     currentTransit.removeTransportNeed(transportNeedID);
   }
   for (Integer transitID : simulationBox.getConcernedBySelectionTransitID()) {
     if (currentTransit.getTransits().get(Circuit.class.getSimpleName()).containsKey(transitID)) {
       currentTransit.removeCircuit(transitID);
     }
     if (currentTransit
         .getTransits()
         .get(TransportNeed.class.getSimpleName())
         .containsKey(transitID)) {
       currentTransit.removeTransportNeed(transitID);
     }
   }
 }
 /**
  * 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 saveNetworkElementChangement() {
    simulationBox.endEdition();
    if (simulationBox.isElementModified()) {
      if (simulationBox.isAnimationModified()) {

      } else {
        SimulationElement modifiedElement = simulationBox.getModifiedElement();
        if (isTransit(modifiedElement)) {
          Transit modifiedTransit = (Transit) modifiedElement;
          currentTransit.modifyTransit(modifiedTransit.getIdentifier(), modifiedTransit);
        } else {
          currentNetwork.modifyNetworkElement(modifiedElement.getIdentifier(), modifiedElement);
          if (simulationBox.isThereASecondSegment()) {
            Segment secondSegment = simulationBox.getModifiedSecondWay();
            currentNetwork.modifyNetworkElement(secondSegment.getIdentifier(), secondSegment);
          }
        }
        updateNetworkData();
        simulationBox.refreshElementsAfterModification();
      }
    }
  }