diff -u -d -b -w -r1.1.1.1 IItemAttribute.java Index: core/java12/com/vladium/emma/report/html/ReportGenerator.java =================================================================== RCS file: /cvsroot/emma/emma/core/java12/com/vladium/emma/report/html/ReportGenerator.java,v retrieving revision 1.2 diff -u -d -b -w -r1.2 ReportGenerator.java --- core/java12/com/vladium/emma/report/html/ReportGenerator.java 20 May 2004 02:28:07 -0000 1.2 +++ core/java12/com/vladium/emma/report/html/ReportGenerator.java 18 Jul 2004 01:12:19 -0000 @@ -933,15 +933,56 @@ } else { + final boolean fail = (m_metrics [attrID] > 0) && ! attr.passes (item, m_metrics [attrID]); + // There must be a better way to do this, but I don't see it currently, so we grab the percentage and reparse it. YUCK. + + StringBuffer sb = new StringBuffer(); + attr.format (item, sb); + String s = sb.toString(); + int count; + for(count = 0; count < s.length(); count++) { + if (!Character.isDigit(s.charAt(count))) { + break; + } + } + int percent = Integer.parseInt(sb.toString().substring(0, count)); + buf.setLength (0); + HTMLTable graph = new HTMLTable("100%", null, null, null); + HTMLTable.IRow graphRow = graph.newRow(); + + // Don't create a 0 length cell. + if (percent != 0) { + HTMLTable.ICell green = graphRow.newCell(); + green.setColspan(percent); + if (odd) + green.setClass (CSS_ODDROW_PERCENT_COVERED); + else + green.setClass (CSS_PERCENT_COVERED); + green.setText("", false); + } + + // Don't create a 0 length cell. + if (percent != 100) { + HTMLTable.ICell red = graphRow.newCell(); + red.setColspan(100 - percent); + if (odd) + red.setClass (CSS_ODDROW_PERCENT_UNCOVERED); + else + red.setClass (CSS_PERCENT_UNCOVERED); + red.setText("", false); + } + + graphRow = graph.newRow(); attr.format (item, buf); trimForDisplay (buf); - - cell.setText (buf.toString (), true); + graphRow.setText (buf.toString (), true); if (fail) cell.setClass (CSS_DATA_HIGHLIGHT); + + cell.add(graph); } } else @@ -1527,6 +1568,13 @@ private static final String CSS_HEADER = ""; private static final String CSS_HEADER_FIRST = CSS_HEADER + "f"; + private static final String CSS_ODDROW_PERCENT_COVERED = "og"; + private static final String CSS_ODDROW_PERCENT_UNCOVERED = "or"; + private static final String CSS_PERCENT_COVERED = "g"; + private static final String CSS_PERCENT_UNCOVERED = "r"; + private static final String GREEN = "#00FF00"; + private static final String RED = "#FF0000"; + private static final String CSS_CLS_NOLEFT = "cn"; // TODO: optimize this @@ -1597,7 +1645,10 @@ "TABLE." + CSS_INVISIBLE_TABLE + " {border-style:none;}" + "TABLE." + CSS_INVISIBLE_TABLE + " TD,TABLE." + CSS_INVISIBLE_TABLE + " TH {border-style:none;}" + - + " TR." + CSS_ODDROW + " TD." + CSS_ODDROW_PERCENT_COVERED + " {border-style:none;height:10px;background:" + GREEN + ";}" + + " TR." + CSS_ODDROW + " TD." + CSS_ODDROW_PERCENT_UNCOVERED + " {border-style:none;height:10px;background:" + RED + ";}" + + " TR TD." + CSS_PERCENT_COVERED + " {border-style:none;height:10px;background:" + GREEN + ";}" + + " TR TD." + CSS_PERCENT_UNCOVERED + " {border-style:none;height:10px;background:" + RED + ";}" + ""; private static final String NESTED_ITEMS_PARENT_DIRNAME = "_files";