/** Prints the given <code>JimpleBody</code> to the specified <code>PrintWriter</code>. */ private void printStatementsInBody( Body body, java.io.PrintWriter out, LabeledUnitPrinter up, UnitGraph unitGraph) { Chain units = body.getUnits(); Iterator unitIt = units.iterator(); Unit currentStmt = null, previousStmt; while (unitIt.hasNext()) { previousStmt = currentStmt; currentStmt = (Unit) unitIt.next(); // Print appropriate header. { // Put an empty line if the previous node was a branch node, the current node is a join node // or the previous statement does not have body statement as a successor, or if // body statement has a label on it if (currentStmt != units.getFirst()) { if (unitGraph.getSuccsOf(previousStmt).size() != 1 || unitGraph.getPredsOf(currentStmt).size() != 1 || up.labels().containsKey(currentStmt)) { up.newline(); } else { // Or if the previous node does not have body statement as a successor. List succs = unitGraph.getSuccsOf(previousStmt); if (succs.get(0) != currentStmt) { up.newline(); } } } if (up.labels().containsKey(currentStmt)) { up.unitRef(currentStmt, true); up.literal(":"); up.newline(); } if (up.references().containsKey(currentStmt)) { up.unitRef(currentStmt, false); } } up.startUnit(currentStmt); currentStmt.toString(up); up.endUnit(currentStmt); up.literal(";"); up.newline(); // only print them if not generating attributes files // because they mess up line number // if (!addJimpleLn()) { if (Options.v().print_tags_in_output()) { Iterator tagIterator = currentStmt.getTags().iterator(); while (tagIterator.hasNext()) { Tag t = (Tag) tagIterator.next(); up.noIndent(); up.literal("/*"); up.literal(t.toString()); up.literal("*/"); up.newline(); } /*Iterator udIt = currentStmt.getUseAndDefBoxes().iterator(); while (udIt.hasNext()) { ValueBox temp = (ValueBox)udIt.next(); Iterator vbtags = temp.getTags().iterator(); while (vbtags.hasNext()) { Tag t = (Tag) vbtags.next(); up.noIndent(); up.literal("VB Tag: "+t.toString()); up.newline(); } }*/ } } out.print(up.toString()); if (addJimpleLn()) { setJimpleLnNum(up.getPositionTagger().getEndLn()); } // Print out exceptions { Iterator trapIt = body.getTraps().iterator(); if (trapIt.hasNext()) { out.println(); incJimpleLnNum(); } while (trapIt.hasNext()) { Trap trap = (Trap) trapIt.next(); out.println( " catch " + Scene.v().quotedNameOf(trap.getException().getName()) + " from " + up.labels().get(trap.getBeginUnit()) + " to " + up.labels().get(trap.getEndUnit()) + " with " + up.labels().get(trap.getHandlerUnit()) + ";"); incJimpleLnNum(); } } }
public void generateHTML(java.io.PrintWriter p, int rowNo) throws Exception { processLocaleInfo(); String days[] = _displaySize == SIZE_LARGE ? _dayLongNames : _dayShortNames; String months[] = _displaySize == SIZE_LARGE ? _monthLongNames : _monthShortNames; int sz = _displaySize == SIZE_LARGE ? _largeFontSize : _smallFontSize; String size = ""; if (_fontSizeUnit == FONT_SIZE_IN_POINTS) size = sz + "pt"; else if (_fontSizeUnit == FONT_SIZE_IN_PIXELS) size = sz + "px"; else size = _fontSizes[sz]; // HiddenComponent & javascript p.println("<INPUT TYPE=\"HIDDEN\" NAME=\"" + getFullName() + "\">"); p.println("<SCRIPT>"); p.println(" function " + getFullName() + "_changeMonth(months) {"); p.println(getFormString() + getFullName() + ".value='changeMonth:' + months;"); p.println(getFormString() + "submit();"); p.println(" }"); p.println(" function " + getFullName() + "_selectDate(day,year) {"); p.println(getFormString() + getFullName() + ".value='selectDate:' + day + '-' + year;"); p.println(getFormString() + "submit();"); p.println(" }"); p.println("</SCRIPT>"); p.println("<A NAME=\"" + getFullName() + "CalStart\"></a>"); // Table Heading p.print("<TABLE BORDER=" + _border + " CELLSPACING=0 CELLPADDING=0 COLS=1 "); if (_width > -1) { p.print("WIDTH=\"" + _width); if (_sizeOption == SIZE_PERCENT) p.print("%"); p.print("\""); } p.println(">"); /* * String hFontStart = " <FONT"; if (_fontFace != null) hFontStart += " * FACE=\"" + _fontFace + "\""; hFontStart += " SIZE=\"" + size + "\""; * if (_headingForegroundColor != null) hFontStart += " COLOR=\"" + * _headingForegroundColor + "\""; hFontStart += "> <B>"; String * hFontEnd = " </B> </FONT>"; */ String hFontStart = "<SPAN style=\""; if (_fontFace != null) hFontStart += "font-family:" + _fontFace + ";text-decoration:none;font-size:" + size + ";"; if (_headingForegroundColor != null) hFontStart += "color:" + _headingForegroundColor + ";"; hFontStart += "\"><B>"; String hFontEnd = "</B></SPAN>"; p.print("<TR><TD>"); p.print("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 COLS=3 WIDTH=\"100%\""); if (_headingBackgroundColor != null) p.print(" BGCOLOR=\"" + _headingBackgroundColor + "\""); p.print("> <TR"); if (_headingStyleClass != null) p.print(" CLASS=\"" + _headingStyleClass + "\""); p.println(">"); p.println("<TD WIDTH=\"20%\" ALIGN=\"LEFT\">"); p.println("<A HREF=\"javascript:" + getFullName() + "_changeMonth(-12);\">"); p.print(hFontStart + "<<" + hFontEnd); p.println("</A>"); p.println("<A HREF=\"javascript:" + getFullName() + "_changeMonth(-1);\">"); p.print(hFontStart + "<" + hFontEnd); p.println("</A></TD>"); p.println("<TD ALIGN=\"CENTER\" WIDTH=\"00%\">" + hFontStart); p.print(months[_currentMonth] + " " + _currentYear + hFontEnd + "</TD>"); p.println("<TD ALIGN=\"RIGHT\" WIDTH=\"20%\" >"); p.println("<A HREF=\"javascript:" + getFullName() + "_changeMonth(1);\">"); p.print(hFontStart + ">" + hFontEnd); p.println("</A>"); p.println("<A HREF=\"javascript:" + getFullName() + "_changeMonth(12);\">"); p.print(hFontStart + ">>" + hFontEnd); p.println("</A>"); p.println("</TD>"); p.println("</TR></TABLE>"); // calendar // weeks p.print("<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1 COLS=7 WIDTH=\"100%\""); p.println(">"); p.print("<TR"); if (_weekStyleClass != null) p.print(" CLASS=\"" + _weekStyleClass + "\""); p.println(">"); int numDays = 0; int i = getFirstDayOfWeek(); while (numDays < 7) { p.print("<TD ALIGN=\"CENTER\""); if (_weekBackgroundColor != null) p.print(" BGCOLOR=\"" + _weekBackgroundColor + "\""); p.print("><SPAN style=\""); if (_fontFace != null) p.print("font-family:" + _fontFace + ";font-size:" + size + ";"); if (_weekForegroundColor != null) p.print("color:" + _headingForegroundColor + ";"); p.print("\">"); if (_displaySize == SIZE_SMALL) p.println("<B>"); p.print(days[i]); if (_displaySize == SIZE_SMALL) p.println("</B>"); p.println("</SPAN></TD>"); if (i < 6) i++; else i = 0; numDays++; } p.println("</TR>"); // days int subtract = getFirstDayOfWeek(); GregorianCalendar today = new GregorianCalendar(); GregorianCalendar date = getFirstDayOnCalendar(); date.add(Calendar.DATE, subtract); _nextDay = 0; for (i = 0; i < 6; i++) { p.println("<TR>"); for (int j = 0; j < 7; j++) { p.print("<TD ALIGN=\"CENTER\""); if (_dayBackgroundColor != null) p.print(" BGCOLOR=\"" + _dayBackgroundColor + "\""); p.print(">"); p.print( "<A HREF=\"javascript:" + getFullName() + "_selectDate(" + date.get(Calendar.DAY_OF_YEAR) + "," + date.get(Calendar.YEAR) + ");\">"); p.print("<SPAN "); String fontStyle = " style=\""; if (_fontFace != null) fontStyle += "text-decoration:none;font-family:" + _fontFace + ";font-size:" + size + ";"; if (date.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR) && date.get(Calendar.YEAR) == today.get(Calendar.YEAR) && _dayForegroundCurrent != null) fontStyle += "color:" + _dayForegroundCurrent + ";"; else if (date.get(Calendar.MONTH) != _currentMonth && _dayForegroundDeemphisis != null) fontStyle += "color:" + _dayForegroundDeemphisis + ";"; else if (_dayForegroundNormal != null) fontStyle += "color:" + _dayForegroundNormal + ";"; fontStyle += "\""; // p.print("<FONT"); // if (_fontFace != null) // p.print(" FACE=\"" + _fontFace + "\""); // p.print(" SIZE=\"" + size + "\""); // if (date.get(Calendar.DAY_OF_YEAR) == // today.get(Calendar.DAY_OF_YEAR) && date.get(Calendar.YEAR) == // today.get(Calendar.YEAR) && _dayForegroundCurrent != null) // p.print(" COLOR=\"" + _dayForegroundCurrent + "\""); // else if (date.get(Calendar.MONTH) != _currentMonth && // _dayForegroundDeemphisis != null) // p.print(" COLOR=\"" + _dayForegroundDeemphisis + "\""); // else if (_dayForegroundNormal != null) // p.print(" COLOR=\"" + _dayForegroundNormal + "\""); // p.print(">"); // String spanStart = ""; // if (date.get(Calendar.DAY_OF_YEAR) == // today.get(Calendar.DAY_OF_YEAR) && date.get(Calendar.YEAR) == // today.get(Calendar.YEAR) && _dayCurrentStyleClassName != // null) // spanStart = "<SPAN CLASS=\"" + _dayCurrentStyleClassName + // "\">"; // else if (date.get(Calendar.MONTH) != _currentMonth && // _dayDeemphisisClassName != null) // spanStart = "<SPAN CLASS=\"" + _dayDeemphisisClassName + // "\">"; // else if (_dayNormalStyleClassName != null) // spanStart = "<SPAN CLASS=\"" + _dayNormalStyleClassName + // "\">"; // String spanEnd = (spanStart.length() == 0 ? "" : "</SPAN>"); if (date.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR) && date.get(Calendar.YEAR) == today.get(Calendar.YEAR) && _dayCurrentStyleClassName != null) p.print("class=\"" + _dayCurrentStyleClassName + "\""); else if (date.get(Calendar.MONTH) != _currentMonth && _dayDeemphisisClassName != null) p.print("class=\"" + _dayDeemphisisClassName + "\""); else if (_dayNormalStyleClassName != null) p.print("class=\"" + _dayNormalStyleClassName + "\""); else p.print(fontStyle); p.print(">"); String boldStart = ""; String boldEnd = ""; if (dayHighlighted(date)) { boldStart = "<B>"; boldEnd = "</B>"; } p.print(boldStart + date.get(Calendar.DAY_OF_MONTH) + boldEnd); date.add(Calendar.DATE, 1); p.print("</SPAN></A></TD>"); } p.println("</TR>"); } // end of tables p.println("</TABLE>"); p.println("</TD></TR></TABLE>"); if (_scrollTo) { // getPage().scrollToItem(getFullName() + "CalStart"); _scrollTo = false; } }