/**
   * this method maintains the dyanmic coloring, makes sure that entities are added and removed to
   * their current edges, and from a certain threshold, added to the dynamic coloring group.
   *
   * @param from
   * @param to
   * @param startPrecent
   * @param who
   * @param boundingQuery
   * @param endPrecent
   */
  private void maintainDynamicColoring(
      String from,
      String to,
      double startPrecent,
      Integer who,
      GroupBoundingQuery boundingQuery,
      double endPrecent) {
    String edge = from + " " + to;
    if (!graphData.getEdgeSet().contains(edge)) {
      String[] split = edge.split(" ");
      edge = split[1] + " " + split[0];
    }
    AZVisVertex sV = (AZVisVertex) graphData.getData(edge.split(" ")[0]);
    AZVisVertex tV = (AZVisVertex) graphData.getData(edge.split(" ")[1]);

    Edge temp = (Edge) boundingQuery.getById(edge + " dynamic");
    if (temp == null) {
      temp = new Edge(edge + " dynamic");
    }

    // what happens if start=0 and end=100 at the same time???
    if (startPrecent == 0) {
      String oldEdge = graphData.removeEdgeEntity(who.toString());
      Edge oldTemp = null;
      if (oldEdge != null) {
        //                String[] split = oldEdge.split(" ");
        //                oldEdge = split[0] + " " + split[1];
        oldTemp = (Edge) boundingQuery.getById(oldEdge + " dynamic");
      }

      if (oldTemp != null) {
        int numEdges = graphData.getEdgeEntities(oldEdge).size();
        if (numEdges <= THRESHOLD) {
          Object removed =
              boundingQuery.remove("DYNAMIC_COLORED", "EDGES", sV.getX(), sV.getY(), oldTemp);
        }
      }

      graphData.addEntityToEdge(edge, who.toString());
      int numEdges = graphData.getEdgeEntities(edge).size();
      if (numEdges == THRESHOLD + 1) {
        boundingQuery.addToGroup(
            "DYNAMIC_COLORED",
            "EDGES",
            sV.getX(),
            sV.getY(),
            Math.abs(sV.getX() - tV.getX()),
            Math.abs(sV.getY() - tV.getY()),
            temp);
      }
    }
  }
  private Location translateToLocation(String src, String target, Double precentage) {
    //        String src = graphData.getEdgeSource(edgeName);
    //        String target = graphData.getEdgeTarget(edgeName);
    AZVisVertex sV = (AZVisVertex) graphData.getData(src);
    AZVisVertex tV = (AZVisVertex) graphData.getData(target);

    return new Location(
        sV.getX() + (tV.getX() - sV.getX()) * precentage / 100.0,
        sV.getY() + (tV.getY() - sV.getY()) * precentage / 100.0);
  }
 private double getAngle(String src, String target) {
   AZVisVertex sV = (AZVisVertex) graphData.getData(src);
   AZVisVertex tV = (AZVisVertex) graphData.getData(target);
   return (180 * Math.atan2(tV.getY() - sV.getY(), tV.getX() - sV.getX()) / Math.PI);
 }