📄 servletconsole.java
字号:
out.println("</BODY></HTML>\n"); } private void writeDebuggingReportSphericalHarmonics( ServletSessionInformation currentSession, GeometryMetadata data, PrintWriter out) { out.write("Current reported model was retrieved from a 3D comparison commit against a similar selected model. Spherical Harmonics shape descriptor defined in [FUNK2003] was used.<P>"); } private void writeDebuggingReportSketch( ServletSessionInformation currentSession, GeometryMetadata data, PrintWriter out) { int i; IndexedColorImage img; //----------------------------------------------------------------- out.println("Current reported model was retrieved from a 2D SKETCH commit. The following table sumarize drawings given by end user:<P>"); out.println("<CENTER><TABLE BORDER=2>\n"); out.println("<TR><TH>Image number</TH>\n"); out.println("<TH>2D Sketch recieved from applet</TH>\n"); out.println("<TH>Normalized 2D Sketch to 64x64 pixels</TH>\n"); out.println("<TH>Distance field (gamma corrected at factor 2 and border highlighted)</TH></TR>\n"); for ( i = 0; (workingImages != null) && i < 3; i++ ) { img = workingImages.get(i); if ( img != null && img.getXSize() > 0 && img.getYSize() > 0 ) { out.println("<TR><TD><CENTER><B>" + (i+1) + "</B></CENTER></TD>\n"); out.println("<TD><CENTER><IMG SRC=\"ServletConsole?session=" + currentSession.getId() + "&input=retrieve_sketch&image_source=source" + i + "\"></IMG></CENTER></TD>\n"); out.println("<TD><CENTER><IMG SRC=\"ServletConsole?session=" + currentSession.getId() + "&input=retrieve_sketch&image_source=outline" + i + "\"></IMG></CENTER></TD>\n"); out.println("<TD><CENTER><IMG SRC=\"ServletConsole?session=" + currentSession.getId() + "&input=retrieve_sketch&image_source=distance_field" + i + "\"></IMG></CENTER></TD>\n"); out.println("</TR>\n"); } } out.println("</TABLE></CENTER>\n"); //----------------------------------------------------------------- DecimalFormat f1 = new DecimalFormat("0000000"); DecimalFormat f2 = new DecimalFormat("00"); String imgname, basename, name; FourierShapeDescriptor fourierShapeDescriptor1 = null; int j; ShapeDescriptor2DGenerator component = new ShapeDescriptor2DGenerator(); out.println("<P>From such skethes, current model resulted in a match, due to CUBE13 projected view ([FUNK2003]) matching in the views shown in the following table:<P>"); out.println("<CENTER><TABLE BORDER=2>\n"); out.println("<TR>\n"); out.println("<TH>DATA</TH>\n"); for ( i = 0; i < 13; i++ ) { out.println("<TH><CENTER>VIEW" + (i+1) + "</CENTER></TH>\n"); } out.println("</TR>\n"); out.println("<TR>\n"); out.println("<TH>VIEW </TH>\n"); for ( i = 0; i < 13; i++ ) { basename = serverUrl + "/images/previews/" + f1.format(data.getId(), new StringBuffer(""), new FieldPosition(0)).toString() + "/"; imgname = f2.format(i, new StringBuffer(""), new FieldPosition(0)).toString(); out.println("<TD><CENTER><IMG SRC=\"" + (basename + "df" + imgname + ".jpg") + "\"></IMG></CENTER></TD>\n"); } out.println("</TR>\n"); //- Search result for which debugging report is being generated --- Result r; Result currentModel = null; ArrayList<Result> results = currentSession.getSimilarModels(); for ( i = 0; i < results.size(); i++ ) { r = results.get(i); if ( r.getId() == data.getId() ) { currentModel = r; break; } } //----------------------------------------------------------------- int k; Image test; ArrayList<ResultSource> parts; ResultSource part; for ( i = 0; currentModel != null && i < 3; i++ ) { test = workingImages.get(i); if ( test == null || test.getXSize() <= 0 || test.getYSize() <= 0 ) { continue; } out.println("<TR>\n"); out.println("<TH>Matches with sketch " + (i+1) + "</TH>\n"); for ( j = 0; j < 13; j++ ) { name = "PROJECTED_VIEW_CUBE_" + j; int source; int sketch; boolean match = false; double d; out.println("<TD><CENTER>\n"); parts = currentModel.getParts(); for ( k = 0; k < parts.size(); k++ ) { part = parts.get(k); source = part.getSource() - 1 - ResultSource.CUBE13VIEW; sketch = part.getSketchId(); d = parts.get(k).getSource() - 1 - ResultSource.CUBE13VIEW; if ( source == j && i == sketch ) { out.println("<IMG SRC=\"ServletConsole?session=" + currentSession.getId() + "&input=retrieve_sketch&image_source=distance_field" + i + "\"></IMG>\n"); out.println("<BR>Distance: " + VSDK.formatDouble(d)); match = true; break; } } if ( !match ) { out.println("No match\n"); } out.println("</CENTER></TD>\n"); } out.println("</TR>\n"); } //----------------------------------------------------------------- out.println("</TABLE></CENTER>\n"); } private void writeDebuggingReport(ServletSessionInformation currentSession, GeometryMetadata data, PrintWriter out) { out.println("<P><HR><P><H2>QUERY INFORMATION</H2>\n"); switch ( currentSession.getMethod() ) { case ServletSessionInformation.METHOD_2D_SKETCH_CUBE13: writeDebuggingReportSketch(currentSession, data, out); break; case ServletSessionInformation.METHOD_3D_SPHERICAL_HARMONICS: writeDebuggingReportSphericalHarmonics(currentSession, data, out); break; default: out.println("Unknown search method used to obtain this model. No further information available."); break; } } private void process2DSketchQuery(ServletSessionInformation currentSession, PrintWriter out) { //----------------------------------------------------------------- currentSession.setSimilarModels(execute2DSketchQuery(currentSession, out)); int similarSize = currentSession.getSimilarModels().size(); int minSize = 16; if ( similarSize < minSize ) { minSize = similarSize; } currentSession.setMethod(currentSession.METHOD_2D_SKETCH_CUBE13); searchEngine.writeResultsAsHtml(out, currentSession.getSimilarModels(), shapeDatabase, serverUrl + "/images", currentSession.getId(), 0, minSize); } private void process3DSphericalHarmonicsQuery( ServletSessionInformation currentSession, HttpServletRequest request, PrintWriter out) { ArrayList<Result> similarModels = new ArrayList<Result>(); //----------------------------------------------------------------- String cad; GeometryMetadata m; cad = request.getParameter("id"); if ( cad != null && cad.length() > 0 ) { m = shapeDatabase.searchEntryById(Long.parseLong(cad)); similarModels = searchEngine.matchModelSphericalHarmonics(m, shapeDatabase, 4); } Collections.sort(similarModels); //----------------------------------------------------------------- currentSession.setSimilarModels(similarModels); int similarSize = currentSession.getSimilarModels().size(); int minSize = 16; if ( similarSize < minSize ) { minSize = similarSize; } currentSession.setMethod(currentSession.METHOD_3D_SPHERICAL_HARMONICS); searchEngine.writeResultsAsHtml(out, currentSession.getSimilarModels(), shapeDatabase, serverUrl + "/images", currentSession.getId(), 0, minSize); } private void retrieveSketch(ServletSessionInformation currentSession, HttpServletRequest request, HttpServletResponse response, OutputStream os) { response.setContentType("image/jpeg"); response.setHeader( "Cache-control", "max-age=0" ); response.setDateHeader( "Expires", new Date().getTime()-1 ); response.setDateHeader( "Last-Modified", new Date().getTime()+1 ); String source; try { Image img = null; source = request.getParameter("image_source"); if ( source != null && source.startsWith("source") ) { img = currentSession.getSourceImage(Integer.parseInt(source.substring(6))); } else if ( source != null && source.startsWith("outline") ) { img = currentSession.getOutline(Integer.parseInt(source.substring(7))); } else if ( source != null && source.startsWith("distance_field") ) { img = currentSession.getDistanceField(Integer.parseInt(source.substring(14))); } else { img = new RGBImage(); img.init(640, 480); img.createTestPattern(); } ImagePersistence.exportJPG(os, img); } catch ( Exception e ) { System.out.println("Error sending image."); e.printStackTrace(); } } private void processGeneric( HttpServletRequest request, HttpServletResponse response, String id) throws IOException, ServletException { response.setContentType("text/html"); OutputStream os = response.getOutputStream(); PrintWriter out = new PrintWriter(os); //PrintWriter out = response.getWriter(); //----------------------------------------------------------------- String cad; //----------------------------------------------------------------- Enumeration parametersList; parametersList = request.getParameterNames(); String operation; ServletSessionInformation currentSession = null; cad = request.getParameter("session"); if ( cad != null ) { currentSession = currentSession = searchSessionById(Long.parseLong(cad)); } operation = request.getParameter("input"); System.out.print("Log message: (ServletConsole::" + id + ")->"); if ( currentSession == null ) { // JOB out.println("No session ID specified!<P>Parameters given where:<BR><UL>"); while ( parametersList.hasMoreElements() ) { cad = "" + parametersList.nextElement(); out.println( "<LI>" + cad + " = " + request.getParameter(cad) ); } out.println("</UL>"); // LOG System.out.println("No session ID specified!\nParameters given where:"); parametersList = request.getParameterNames(); System.out.println(" - Parameters:"); while ( parametersList.hasMoreElements() ) { cad = "" + parametersList.nextElement(); System.out.println(" . " + cad + " = " + request.getParameter(cad)); } } else if ( operation == null || operation.length() < 1 ) { // JOB out.println("No input parameter specifying operation found on request parameters!<P>Parameters given where:<BR><UL>"); while ( parametersList.hasMoreElements() ) { cad = "" + parametersList.nextElement(); out.println( "<LI>" + cad + " = " + request.getParameter(cad) ); } out.println("</UL>"); // LOG System.out.println("No input parameter specifying operation found on request parameters!\nParameters given where:"); parametersList = request.getParameterNames(); System.out.println(" - Parameters:"); while ( parametersList.hasMoreElements() ) { cad = "" + parametersList.nextElement(); System.out.println(" . " + cad + " = " + request.getParameter(cad)); } } else if ( operation.equals("text_2d") ) { // JOB process2DSketchQuery(currentSession, out); // LOG System.out.println("request for sketch search."); } else if ( operation.equals("model_detail") ) { // JOB processInformation(request, out, currentSession); // LOG System.out.println("request for model detail."); } else if ( operation.equals("retrieve_sketch") ) { // JOB retrieveSketch(currentSession, request, response, os); // LOG System.out.println("request for image sketch retrieval."); } else if ( operation.equals("retrieve_sh") ) { // JOB process3DSphericalHarmonicsQuery(currentSession, request, out); // LOG System.out.println("request for spherical harmonics 3D model retrieval."); } else if ( operation.equals("show_cached_results") ) { // JOB cad = request.getParameter("start"); if ( cad == null ) { out.printf("Showing cached results for session " + currentSession.getId() + "."); out.printf("Error: no start range specified."); } else { searchEngine.writeResultsAsHtml(out, currentSession.getSimilarModels(), shapeDatabase, serverUrl + "/images", currentSession.getId(), Integer.parseInt(cad), 16); } // LOG System.out.println("showing cached results."); } else { // JOB out.println("Unknown operation <B>" + operation + "</B>!<P>Parameters given where:<BR><UL>"); while ( parametersList.hasMoreElements() ) { cad = "" + parametersList.nextElement(); out.println( "<LI>" + cad + " = " + request.getParameter(cad) ); } out.println("</UL>"); // LOG System.out.println("Unknown operation " + operation + "!\nParameters given where:"); parametersList = request.getParameterNames(); System.out.println(" - Parameters:"); while ( parametersList.hasMoreElements() ) { cad = "" + parametersList.nextElement(); System.out.println(" . " + cad + " = " + request.getParameter(cad)); } } out.flush(); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { processGeneric(request, response, "doGet"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { receiveImages(request, response, "doPost"); }}//===========================================================================//= EOF =//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -