if(log.isDebugEnabled()) { log.error("CSMARTGraph: Could not write to file:" + e);
if(log.isErrorEnabled()) { log.error("CSMARTGraph: Could not write to file:", e);
  private void saveGraph(File outputFile) {    if (outputFile == null)      return;    StringBuffer colorTable = new StringBuffer(500);    // first, save colors as real colors    Attribute ct = getAttribute(COLOR_TABLE);    // if there's no color table, then give the COLOR_DETERMINER attributes    // unique ids before storing them in a color table    String graphUID = null;    if (ct == null) {      InetAddress localHost = null;      try {	localHost = InetAddress.getLocalHost();      } catch (Exception e) {        if(log.isDebugEnabled()) {          log.error("CSMARTGraph: Can't get local host: " + e);        }      }      graphUID = localHost.toString() + "/" + (new UID()).toString();    }    Hashtable colorsWritten = new Hashtable();    GraphEnumeration ge = elements(GrappaConstants.NODE);    while (ge.hasMoreElements()) {      Node node = (Node)ge.nextGraphElement();      // save mapping of COLOR_DETERMINER to Color from ui.properties      Attribute a = node.getAttribute(COLOR_DETERMINER);      if (a == null)	continue;      String colorName = a.getStringValue();      Color c = properties.getClusterColor(colorName);      if(log.isDebugEnabled()) {        log.debug("CSMARTGraph: color for: " + colorName + " is: " + c);      }      if (graphUID != null) {	colorName = graphUID + "=" + colorName;	node.setAttribute(COLOR_DETERMINER, colorName);      }      if (colorsWritten.get(colorName) != null)	continue; // write each mapping only once      colorsWritten.put(colorName, c);      colorTable.append(colorName);      colorTable.append("+");      colorTable.append(Integer.toString(c.getRed()));      colorTable.append(",");      colorTable.append(Integer.toString(c.getGreen()));      colorTable.append(",");      colorTable.append(Integer.toString(c.getBlue()));      colorTable.append(";");    }    // save color table    setAttribute(COLOR_TABLE, colorTable.toString());    // next, save all edges as black    ge = elements(GrappaConstants.EDGE);    while (ge.hasMoreElements()) {      Element e = ge.nextGraphElement();      e.setAttribute(GrappaConstants.COLOR_ATTR, "black");    }    String pathname = outputFile.getPath();    String extension = "";    int i = pathname.lastIndexOf('.');    if (i > 0 && i < pathname.length()-1)      extension = pathname.substring(i+1).toLowerCase();    if (extension.length() == 0 || !(extension.equals("dot"))) {      pathname = pathname + ".dot";      outputFile = new File(pathname);      extension = "dot";    }    FileOutputStream fos = null;    Grappa.usePrintList = false;    try {      fos = new FileOutputStream(outputFile);      PrintWriter pw = new PrintWriter(fos);      printGraph(pw);      fos.flush();      fos.close();    } catch (Exception e) {      if(log.isDebugEnabled()) {        log.error("CSMARTGraph: Could not write to file:" + e);      }    }    Grappa.usePrintList = true;  }