コード例 #1
0
ファイル: RTree.java プロジェクト: kirevey/Tarea1Algoritmos
 private void visualize(RNode n, java.io.PrintWriter pw, int x0, int y0, int w, int h) {
   pw.printf(
       "<div style=\"position:absolute; left: %d; top: %d; width: %d; height: %d; border: 1px dashed\">\n",
       x0, y0, w, h);
   pw.println("<pre>");
   pw.println("Node: " + n.toString() + " \n(root==" + (n == root) + ") \n");
   pw.println("Coords start: " + Arrays.toString(n.getMbr().getP_start()) + "\n");
   pw.println("coords end: " + Arrays.toString(n.getMbr().getP_end()) + "\n");
   pw.println("# Children: " + ((n.children() == null) ? 0 : n.children().size()) + "\n");
   if (n instanceof REntry) {
     REntry n1 = (REntry) n;
     pw.println("Content: " + n1.getContent());
   }
   pw.println("isLeaf: " + n.isLeaf() + "\n");
   pw.println("</pre>");
   int numChildren = (n.children() == null) ? 0 : n.children().size();
   for (int i = 0; i < numChildren; i++) {
     visualize(
         n.children().get(i),
         pw,
         (int) (x0 + (i * w / (float) numChildren)),
         y0 + elemHeight,
         (int) (w / (float) numChildren),
         h - elemHeight);
   }
   pw.println("</div>");
 }
コード例 #2
0
ファイル: RTree.java プロジェクト: kirevey/Tarea1Algoritmos
 String visualize() {
   int ubDepth = (int) Math.ceil(Math.log(size) / Math.log(m_order)) * elemHeight;
   int ubWidth = size * elemWidth;
   java.io.StringWriter sw = new java.io.StringWriter();
   java.io.PrintWriter pw = new java.io.PrintWriter(sw);
   pw.println("<html><head></head><body>");
   visualize(root, pw, 0, 0, ubWidth, ubDepth);
   pw.println("</body></html>");
   pw.flush();
   return sw.toString();
 }
コード例 #3
0
ファイル: Upload2.java プロジェクト: fgxbzns/crossover
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
    // Check that we have a file upload request
    isMultipart = ServletFileUpload.isMultipartContent(request);
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    if (!isMultipart) {
      out.println("<html>");
      out.println("<head>");
      out.println("<title>Servlet upload</title>");
      out.println("</head>");
      out.println("<body>");
      out.println("<p>No file uploaded</p>");
      out.println("</body>");
      out.println("</html>");
      return;
    }
    DiskFileItemFactory factory = new DiskFileItemFactory();
    // maximum size that will be stored in memory
    factory.setSizeThreshold(maxMemSize);
    // Location to save data that is larger than maxMemSize.
    factory.setRepository(new File("c:\\temp"));

    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);
    // maximum file size to be uploaded.
    upload.setSizeMax(maxFileSize);

    try {
      // Parse the request to get file items.
      List fileItems = upload.parseRequest(request);

      // Process the uploaded file items
      Iterator i = fileItems.iterator();

      out.println("<html>");
      out.println("<head>");
      out.println("<title>Servlet upload</title>");
      out.println("</head>");
      out.println("<body>");
      while (i.hasNext()) {
        FileItem fi = (FileItem) i.next();
        if (!fi.isFormField()) {
          // Get the uploaded file parameters
          String fieldName = fi.getFieldName();
          String fileName = fi.getName();
          String contentType = fi.getContentType();
          boolean isInMemory = fi.isInMemory();
          long sizeInBytes = fi.getSize();
          // Write the file
          if (fileName.lastIndexOf("\\") >= 0) {
            file = new File(filePath + fileName.substring(fileName.lastIndexOf("\\")));
          } else {
            file = new File(filePath + fileName.substring(fileName.lastIndexOf("\\") + 1));
          }
          fi.write(file);
          out.println("Uploaded Filename: " + fileName + "<br>");
        }
      }
      out.println("</body>");
      out.println("</html>");
    } catch (Exception ex) {
      System.out.println(ex);
    }
  }
コード例 #4
0
ファイル: Printer.java プロジェクト: safdariqbal/soot
  /** 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();
      }
    }
  }
コード例 #5
0
ファイル: HtmlCalendar.java プロジェクト: juanmadryn/web-db
  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 + "&lt;&lt;" + hFontEnd);
    p.println("</A>");
    p.println("<A HREF=\"javascript:" + getFullName() + "_changeMonth(-1);\">");
    p.print(hFontStart + "&lt;" + 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 + "&gt;" + hFontEnd);
    p.println("</A>");
    p.println("<A HREF=\"javascript:" + getFullName() + "_changeMonth(12);\">");
    p.print(hFontStart + "&gt;&gt;" + 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;
    }
  }