Graphics with jsp
Hi. How can i show data with graphics like de follow or similar: 100| . 80| . 60| . 40| 20| 0| 1 2 3 4 I need access to database, take the data and show with one graphic. There are any web where i will find information about this?.
Re: Graphics with jsp
Hi! Hmm, this is a bit off topic, but nevertheless: You could use KavaChart (www.ve.com), which you can use in Servlets and JSPs, but unfortunately it is not free. Best regards, Kovi At 14:00 22.8.01 +0200, you wrote: Hi. How can i show data with graphics like de follow or similar: 100| . 80| . 60| . 40| 20| 0| 1 2 3 4 I need access to database, take the data and show with one graphic. There are any web where i will find information about this?.
Re: Graphics with jsp
Gregor Kovah wrote: Hi! Hmm, this is a bit off topic, but nevertheless: You could use KavaChart (www.ve.com), which you can use in Servlets and JSPs, but unfortunately it is not free. Why not the good old Fly? It is a C compiled CGI program that takes a command file and draws a GIF following those commands. All the JSP/servlet needs to do is create a command file. Is there something equivalent in Java? Nix.
RE: Graphics with jsp
You could use awt to draw the graph to a Graphics context and GifEncoder from Acme Laboratories (www.acme.com) to convert the image to a gif which you can simply return to the browser by setting the content type to image/gif. GifEncoder is free. Attached is a servlet which shows how to do this. This sample shows how to send the image back to the browser directly. You could also create the image as file and use an img tag to include it in the HTML sent back to the browser. Jim Urban Product Manager Netsteps Inc. Suite 505E 1 Pierce Pl. Itasca, IL 60143 Voice: (630) 250-3045 x2164 Fax: (630) 250-3046 -Original Message- From: Nikola Milutinovic [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 7:27 AM To: [EMAIL PROTECTED] Subject: Re: Graphics with jsp Gregor Kovah wrote: Hi! Hmm, this is a bit off topic, but nevertheless: You could use KavaChart (www.ve.com), which you can use in Servlets and JSPs, but unfortunately it is not free. Why not the good old Fly? It is a C compiled CGI program that takes a command file and draws a GIF following those commands. All the JSP/servlet needs to do is create a command file. Is there something equivalent in Java? Nix. GifTest.java
RE: Graphics with jsp
unfortunately this doesn't work on linux unless you have an running X server or Xvfb, a virtual X server. you have to set the display variable to access the X server in this way: DISPLAY=localhost:0 export DISPLAY i've heared that this problem will be removed in jdk1.4 michael -Original Message- From: Jim Urban [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 2:46 PM To: [EMAIL PROTECTED] Subject: RE: Graphics with jsp You could use awt to draw the graph to a Graphics context and GifEncoder from Acme Laboratories (www.acme.com) to convert the image to a gif which you can simply return to the browser by setting the content type to image/gif. GifEncoder is free. Attached is a servlet which shows how to do this. This sample shows how to send the image back to the browser directly. You could also create the image as file and use an img tag to include it in the HTML sent back to the browser. Jim Urban Product Manager Netsteps Inc. Suite 505E 1 Pierce Pl. Itasca, IL 60143 Voice: (630) 250-3045 x2164 Fax: (630) 250-3046 -Original Message- From: Nikola Milutinovic [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 7:27 AM To: [EMAIL PROTECTED] Subject: Re: Graphics with jsp Gregor Kovah wrote: Hi! Hmm, this is a bit off topic, but nevertheless: You could use KavaChart (www.ve.com), which you can use in Servlets and JSPs, but unfortunately it is not free. Why not the good old Fly? It is a C compiled CGI program that takes a command file and draws a GIF following those commands. All the JSP/servlet needs to do is create a command file. Is there something equivalent in Java? Nix.
Re: Graphics with jsp
Hi, One of the solutions (though not very elegant) is to create the graph dynamically by dynamically generating html in a jsp/servlet after fetching the data from the database. You create the requisite no. of html tags (td and tr)and fill then up with colour. Of course this wouldnt help in case of complex graphs, and if you feel that your or the programmers time can be utilized doing something else more productive. The advantage is that it is useful for simple graphs and is free. Regards Nitin Goyal Webrizon eSolutions Pvt. Ltd., India [EMAIL PROTECTED] There is no failure except in no longer trying. - Original Message - From: Ruben Domene [EMAIL PROTECTED] To: tomcat [EMAIL PROTECTED] Sent: Wednesday, August 22, 2001 5:30 PM Subject: Graphics with jsp Hi. How can i show data with graphics like de follow or similar: 100| . 80| . 60| . 40| 20| 0| 1 2 3 4 I need access to database, take the data and show with one graphic. There are any web where i will find information about this?.
RE: Graphics with jsp
You can look at JFreeChart at: http://www.jrefinery.com/jfreechart/index.html Best regards Joacim Järkeborn At 14:00 22.8.01 +0200, you wrote: Hi. How can i show data with graphics like de follow or similar: 100| . 80| . 60| . 40| 20| 0| 1 2 3 4 I need access to database, take the data and show with one graphic. There are any web where i will find information about this?.
Re: Graphics with jsp
At 02:54 PM 22/08/01, you wrote: Hi, One of the solutions (though not very elegant) is to create the graph dynamically by dynamically generating html in a jsp/servlet after fetching the data from the database. You create the requisite no. of html tags (td and tr)and fill then up with colour. Of course this wouldnt help in case of complex graphs, and if you feel that your or the programmers time can be utilized doing something else more productive. The advantage is that it is useful for simple graphs and is free. Which interestingly was in the JDC Tech Tips I received yesterday... the relevant bit is cut 'n pasted below. I've included the archive links in case you're interested: DELIVERING DYNAMIC IMAGES FROM JAVASERVER PAGES (JSP) TECHNOLOGY Have you ever wanted to deliver dynamically-generated images from your JSP pages (or servlets)? This tip shows you how. To run the code in this tip, you need Tomcat or another JSP 1.1-enabled web server. You can download Tomcat from the Jakarta Project page at http://jakarta.apache.org/tomcat. When a web page is delivered with a MIME type of image/jpeg (or one of the other image formats), your browser treats the response as an image. The browser then displays the image, either as part of a larger web page or on its own. To set up the MIME type for your JSP pages, you need to set the contentType attribute of the page directive in the .jsp file for the specific page: %@ page contentType=image/jpeg ... % Then you need to create a BufferedImage to draw on for your dynamic image: BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); After you create the BufferedImage, you need to get a graphics context to draw with, either a Graphics or Graphics2D object will do: Graphics g = image.getGraphics(); // or Graphics2d g2d = image.createGraphics(); From here, you can draw the image content. Drawing to the graphics context draws to the BufferedImage. Initially, the entire image is black, so it's a good idea to fill the image with the desired background color. Then, when you are finished drawing, you need to dispose of the context: g.dispose(); // or g2d.dispose(); Once the image is completely drawn, you send the image back in the response. You can use the JPEGImageEncoder class of the non-standard com.sun.image.codec.jpeg package to encode the image. Or, if you use the Java 2 SDK, Standard Edition, v 1.4 Beta, you can use the standard ImageIO class. There is one tricky part of using the JPEGImageEncoder. You must fetch the ServletOutputStream from the ServletResponse (response object), and not use the implicit JSP output variable out. ServletOutputStream sos = response.getOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos); encoder.encode(image); // or ImageIO.write(image, JPEG, out); Here's a complete example that picks one option from all the choices (for example, g.dispose(); versus g2d.dispose();). The example uses the Graphics object to draw a random polygon. The image is drawn back through the JPEGImageEncoder. Feel free to play with the number of points in the polygon to get more complex shapes, in other words, shapes with more points and edges. To run this example, place the JSP code from %@ to the last % in a file named image.jsp. Place the image.jsp file in a directory that your web server can find. In the case of Tomcat, this is the ROOT directory, under the webapps directory, beneath the Tomcat installation directory. To start Tomcat, you need to run the startup script (startup.bat or startup.sh depending upon your platform) in the bin directory under the Tomcat installation directory. Make sure you have the JAVA_HOME environment variable set to the root level of your Java 2 SDK installation, for example, C:\jdk1.2.2. Once the file is in the appropriate directory and Tomcat is running, you can load the dynamic image generating JSP file with http://localhost:8080/image.jsp. %@ page contentType=image/jpeg import=java.awt.*,java.awt.image.*, com.sun.image.codec.jpeg.*,java.util.* % % // Create image int width=200, height=200; BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // Get drawing context Graphics g = image.getGraphics(); // Fill background g.setColor(Color.white); g.fillRect(0, 0, width, height); // Create random polygon Polygon poly = new Polygon(); Random random = new Random(); for (int i=0; i 5; i++) { poly.addPoint(random.nextInt(width), random.nextInt(height)); } // Fill polygon g.setColor(Color.cyan); g.fillPolygon(poly); // Dispose context g.dispose(); // Send back image ServletOutputStream sos = response.getOutputStream(); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos); encoder.encode(image); % . . . . . . . . . . . . . . . . . . . . . . . - NOTE Sun respects your online time and privacy. The Java Developer Connection mailing lists are used for internal Sun Microsystems(tm) purposes only. You have received this email because you elected
RE: Graphics with jsp
I've heard about something called vml (Virtual modelling language) which allows you to draw vector graphics in xml and display them on the browser. not sure what browsers support it but I recall that NASA use it on some of there sites! -Original Message- From: Nikola Milutinovic [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 1:27 PM To: [EMAIL PROTECTED] Subject: Re: Graphics with jsp Gregor Kovah wrote: Hi! Hmm, this is a bit off topic, but nevertheless: You could use KavaChart (www.ve.com), which you can use in Servlets and JSPs, but unfortunately it is not free. Why not the good old Fly? It is a C compiled CGI program that takes a command file and draws a GIF following those commands. All the JSP/servlet needs to do is create a command file. Is there something equivalent in Java? Nix. ___ Email Disclaimer This communication is for the attention of the named recipient only and should not be passed on to any other person. Information relating to any company or security, is for information purposes only and should not be interpreted as a solicitation or offer to buy or sell any security. The information on which this communication is based has been obtained from sources we believe to be reliable, but we do not guarantee its accuracy or completeness. All expressions of opinion are subject to change without notice. All e-mail messages, and associated attachments, are subject to interception and monitoring for lawful business purposes. ___
Re: Graphics with jsp
That's a good idea. Try using the batik project for delivering your files as svg(scalable vector graphics) files. These are xml-based files which you can generate with your relevant database data and view with a java applet or the freely available adobe svg plug-in. Also another try would be the cocoon framework. I would recomment the svg approach though. - viru - Original Message - From: James, Stuart [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 22, 2001 6:24 AM Subject: RE: Graphics with jsp I've heard about something called vml (Virtual modelling language) which allows you to draw vector graphics in xml and display them on the browser. not sure what browsers support it but I recall that NASA use it on some of there sites! -Original Message- From: Nikola Milutinovic [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 22, 2001 1:27 PM To: [EMAIL PROTECTED] Subject: Re: Graphics with jsp Gregor Kovah wrote: Hi! Hmm, this is a bit off topic, but nevertheless: You could use KavaChart (www.ve.com), which you can use in Servlets and JSPs, but unfortunately it is not free. Why not the good old Fly? It is a C compiled CGI program that takes a command file and draws a GIF following those commands. All the JSP/servlet needs to do is create a command file. Is there something equivalent in Java? Nix. ___ Email Disclaimer This communication is for the attention of the named recipient only and should not be passed on to any other person. Information relating to any company or security, is for information purposes only and should not be interpreted as a solicitation or offer to buy or sell any security. The information on which this communication is based has been obtained from sources we believe to be reliable, but we do not guarantee its accuracy or completeness. All expressions of opinion are subject to change without notice. All e-mail messages, and associated attachments, are subject to interception and monitoring for lawful business purposes. ___