// Java Document import java.awt.*; import java.io.*; import java.sql.*; import java.text.*; import java.util.*; import javax.servlet.*; import java.awt.image.*; import javax.servlet.http.*; import com.sun.image.codec.jpeg.*; public class grafic extends HttpServlet{ public void doGet(HttpServletRequest kysimus, HttpServletResponse vastus) throws IOException, ServletException{ try{ ResourceBundle rb = ResourceBundle.getBundle("LocalStrings",kysimus.getLocale()); vastus.setContentType("text/html"); int v = Integer.parseInt(kysimus.getParameter("v")); int n = Integer.parseInt(kysimus.getParameter("n")); int k = Integer.parseInt(kysimus.getParameter("k")); int ks = Integer.parseInt(kysimus.getParameter("ks")); int y = Integer.parseInt(kysimus.getParameter("y")); if((v < 50) || (n < 50) || (k < 50) || (ks < 50) || (y < 50)){ v = v * 10; n = n * 10; k = k * 10; ks = ks * 10; y = y * 10; } else if(((50 < v) && (v < 100)) || ((50 < n) && (n < 100)) || ((50 < k) && (k < 100)) || ((50 < ks) && (ks < 100)) || ((50 < y) && (y < 100))){ v = v * 5; n = n * 5; k = k * 5; ks = ks * 5; y = y * 5; } BufferedImage pilt =new BufferedImage(700, 300, BufferedImage.TYPE_INT_RGB); Graphics2D piltg=pilt.createGraphics(); // TAUST piltg.setColor(Color.white); piltg.fillRect(0, 0, 700, 300); // VIIED piltg.setColor(Color.black); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString("5", 0, 38); piltg.setColor(Color.blue); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString(kysimus.getParameter("v"), v + 12, 38); piltg.setColor(Color.red); piltg.fillRect(10, 30, v, 10); // NELJAD piltg.setColor(Color.black); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString("4", 0, 58); piltg.setColor(Color.blue); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString(kysimus.getParameter("n"), n + 12, 58); piltg.setColor(Color.red); piltg.fillRect(10, 50, n, 10); // KOLMED piltg.setColor(Color.black); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString("3", 0, 78); piltg.setColor(Color.blue); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString(kysimus.getParameter("k"), k + 12, 78); piltg.setColor(Color.red); piltg.fillRect(10, 70, k, 10); // KAHED piltg.setColor(Color.black); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString("2", 0, 98); piltg.setColor(Color.blue); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString(kysimus.getParameter("ks"), ks + 12, 98); piltg.setColor(Color.red); piltg.fillRect(10, 90, ks, 10); // ÜHED piltg.setColor(Color.black); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString("1", 0, 118); piltg.setColor(Color.blue); piltg.setFont(new Font("Times", Font.PLAIN, 10)); piltg.drawString(kysimus.getParameter("y"), y + 12, 118); piltg.setColor(Color.red); piltg.fillRect(10, 110, y, 10); vastus.setContentType("image/jpeg"); JPEGCodec.createJPEGEncoder(vastus.getOutputStream()).encode(pilt); }catch (Exception viga){viga.printStackTrace();} } }