/**
   * Build the dot graph.
   *
   * @param plan the plan to visualize
   * @return {@code true} if the generation succeeds
   */
  @Override
  public boolean buildVisualization(TimedReconfigurationPlan plan) {
    buffer = new StringBuilder("digraph TimedExecutionGraph{\n");

    File parent = new File(getOutputFile()).getParentFile();
    if (parent != null && !parent.exists() && !parent.mkdirs()) {
      Plan.logger.error("Unable to create '" + parent.getName() + "'");
      return false;
    }

    buffer.append("rankdir=LR;\n");
    for (Action a : plan) {
      a.injectToVisualizer(this);
    }

    buffer.append("}");
    FileWriter out = null;
    try {
      out = new FileWriter(getOutputFile());
      out.write(buffer.toString());
    } catch (IOException e) {
      Plan.logger.error(e.getMessage(), e);
      return false;
    } finally {
      if (out != null) {
        try {
          out.close();
        } catch (IOException e) {
          Plan.logger.error(e.getMessage(), e);
        }
      }
    }

    return true;
  }
 private void setTimesLabel(Action a, StringBuilder b) {
   if (a.getStartMoment() >= 0) {
     b.append(", headlabel=\"").append(a.getStartMoment()).append("\",");
     b.append("taillabel=\" ").append(a.getFinishMoment()).append("\"");
   }
 }