List of usage examples for org.jfree.chart ChartUtilities writeChartAsJPEG
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height) throws IOException
From source file:net.commerce.zocalo.freechart.ChartTest.java
public void testOHLCChart() throws IOException { File jpgFile = newEmptyFile(".", "testChart.jpg"); File pngFile = newEmptyFile(".", "testChart.png"); assertFalse(jpgFile.exists());/*from w w w .j av a2 s. c o m*/ assertFalse(pngFile.exists()); OutputStream jpgStream = new FileOutputStream(jpgFile); OutputStream pngStream = new FileOutputStream(pngFile); OHLCDataset data2 = createOHLCDataSet(new Minute()); JFreeChart chart = ChartFactory.createHighLowChart("testChart", "date", "values", data2, false); ChartUtilities.writeChartAsJPEG(jpgStream, chart, 200, 500); ChartUtilities.writeChartAsPNG(pngStream, chart, 200, 500); assertTrue(jpgFile.exists()); assertTrue(pngFile.exists()); jpgFile.delete(); pngFile.delete(); }
From source file:org.hammurapi.inspectors.metrics.reporting.LocReporter.java
public void doIt(CodeMetric projectMetric) { //!! job: refactor to Visitor traversing // packages if (ncssReport.intValue() > 0) { LocCharts locClassCharts = new LocCharts("NCSS: Classes", classMaxLoc.intValue(), this.ncssClassList, chartDebugWindow);/*from www. j ava 2s .c om*/ locClassCharts.setGraphicDimX(350); locClassCharts.setGraphicDimY(250); this.jFreeChartClasses = locClassCharts.generateChart(); LocCharts locFunctionCharts = new LocCharts("NCSS: Functions", functionMaxLoc.intValue(), this.ncssFunctionList, chartDebugWindow); locFunctionCharts.setGraphicDimX(350); locFunctionCharts.setGraphicDimY(250); this.jFreeChartFunctions = locFunctionCharts.generateChart(); // writeToXml(projectMetric); try { jpgClassFileEntry = context.getNextFile("Class.jpg"); jpgFunctionFileEntry = context.getNextFile("Function.jpg"); FileOutputStream out = new FileOutputStream(jpgClassFileEntry.getFile()); ChartUtilities.writeChartAsJPEG((OutputStream) out, this.jFreeChartClasses, 500, 300); // outChartFile = new File(projectBaseDir, File.separatorChar + // "FunctionCodeMetric" + ".jpg"); out = new FileOutputStream(jpgFunctionFileEntry.getFile()); ChartUtilities.writeChartAsJPEG((OutputStream) out, this.jFreeChartFunctions, 500, 300); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.liferay.samplestrutsliferay.struts.action.ViewChartAction.java
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {/* ww w . j a v a 2 s .c om*/ if (_log.isInfoEnabled()) { _log.info("execute"); } String attrName = "chart_name"; // Application scoped session attributes can be fetched from the // servlet directly. Portlet scoped session attributes can be // fetched from Sun's PortletSessionUtil. HttpSession session = request.getSession(); String chartName = (String) session.getAttribute(attrName); //(String)_getAttribute(request, attrName); // Chart String chartType = request.getParameter("chart_type"); CategoryDataset dataset = _getDataset(); String xName = "Soda"; String yName = "Votes"; JFreeChart chart = null; if (chartType.equals("area")) { chart = ChartFactory.createAreaChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("horizontal_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.HORIZONTAL, true, false, false); } else if (chartType.equals("line")) { chart = ChartFactory.createLineChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("vertical_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else { PieDataset pieData = DatasetUtilities.createPieDatasetForRow(dataset, 0); chart = ChartFactory.createPieChart(chartName, pieData, true, false, false); } response.setContentType("image/jpeg"); OutputStream out = response.getOutputStream(); ChartUtilities.writeChartAsJPEG(out, chart, 400, 400); return mapping.findForward("/common/null.jsp"); } catch (Exception e) { request.setAttribute(PageContext.EXCEPTION, e); return mapping.findForward("/common/error.jsp"); } }
From source file:com.liferay.samplestruts.struts.action.ViewChartAction.java
@Override public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//from w w w .j a va 2 s . co m if (_log.isInfoEnabled()) { _log.info("execute"); } String attrName = "chart_name"; // Application scoped session attributes can be fetched from the // servlet directly. Portlet scoped session attributes can be // fetched from Sun's PortletSessionUtil. HttpSession session = request.getSession(); String chartName = (String) session.getAttribute(attrName); //(String)_getAttribute(request, attrName); // Chart String chartType = request.getParameter("chart_type"); CategoryDataset dataset = _getDataset(); String xName = "Soda"; String yName = "Votes"; JFreeChart chart = null; if (chartType.equals("area")) { chart = ChartFactory.createAreaChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("horizontal_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.HORIZONTAL, true, false, false); } else if (chartType.equals("line")) { chart = ChartFactory.createLineChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("vertical_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else { PieDataset pieData = DatasetUtilities.createPieDatasetForRow(dataset, 0); chart = ChartFactory.createPieChart(chartName, pieData, true, false, false); } response.setContentType("image/jpeg"); OutputStream out = response.getOutputStream(); ChartUtilities.writeChartAsJPEG(out, chart, 400, 400); return actionMapping.findForward("/common/null.jsp"); } catch (Exception e) { request.setAttribute(PageContext.EXCEPTION, e); return actionMapping.findForward("/common/error.jsp"); } }
From source file:net.sf.jsfcomp.chartcreator.ChartListener.java
private void writeChart(OutputStream stream, JFreeChart chart, ChartData chartData) throws IOException { if (chartData.getOutput().equalsIgnoreCase("png")) ChartUtilities.writeChartAsPNG(stream, chart, chartData.getWidth(), chartData.getHeight()); else if (chartData.getOutput().equalsIgnoreCase("jpeg")) ChartUtilities.writeChartAsJPEG(stream, chart, chartData.getWidth(), chartData.getHeight()); stream.flush();/*from www . ja v a 2 s . c o m*/ stream.close(); }
From source file:com.liferay.polls.web.internal.portlet.action.ViewChartMVCResourceCommand.java
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { try {//from www . j a va2 s .c o m ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); long questionId = ParamUtil.getLong(resourceRequest, "questionId"); String chartType = ParamUtil.getString(resourceRequest, "chartType", "pie"); String chartName = themeDisplay.translate("vote-results"); String xName = themeDisplay.translate("choice"); String yName = themeDisplay.translate("votes"); CategoryDataset categoryDataset = PollsUtil.getVotesDataset(questionId); JFreeChart jFreeChat = null; if (chartType.equals("area")) { jFreeChat = ChartFactory.createAreaChart(chartName, xName, yName, categoryDataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("horizontal_bar")) { jFreeChat = ChartFactory.createBarChart(chartName, xName, yName, categoryDataset, PlotOrientation.HORIZONTAL, true, false, false); } else if (chartType.equals("line")) { jFreeChat = ChartFactory.createLineChart(chartName, xName, yName, categoryDataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("vertical_bar")) { jFreeChat = ChartFactory.createBarChart(chartName, xName, yName, categoryDataset, PlotOrientation.VERTICAL, true, false, false); } else { PieDataset pieDataset = DatasetUtilities.createPieDatasetForRow(categoryDataset, 0); jFreeChat = ChartFactory.createPieChart(chartName, pieDataset, true, false, false); } resourceResponse.setContentType(ContentTypes.IMAGE_JPEG); OutputStream outputStream = resourceResponse.getPortletOutputStream(); ChartUtilities.writeChartAsJPEG(outputStream, jFreeChat, 400, 400); } catch (Exception e) { PortletSession portletSession = resourceRequest.getPortletSession(); PortletContext portletContext = portletSession.getPortletContext(); PortletRequestDispatcher requestDispatcher = portletContext.getRequestDispatcher("/polls/error.jsp"); requestDispatcher.forward(resourceRequest, resourceResponse); } }
From source file:org.openmrs.web.servlet.ShowGraphServlet.java
/** * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) *///from ww w .ja va 2 s. co m @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { JFreeChart chart = getChart(request); // get the height and width of the graph String widthString = request.getParameter("width"); String heightString = request.getParameter("height"); Integer width; Integer height; if (widthString != null && widthString.length() > 0) { width = Integer.parseInt(widthString); } else { width = 500; } if (heightString != null && heightString.length() > 0) { height = Integer.parseInt(heightString); } else { height = 300; } // get the requested mime type of the graph String mimeType = request.getParameter("mimeType"); if (mimeType == null) { mimeType = PNG_MIME_TYPE; } // Modify response to disable caching response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); // Write chart out to response as image try { if (JPG_MIME_TYPE.equalsIgnoreCase(mimeType)) { response.setContentType(JPG_MIME_TYPE); ChartUtilities.writeChartAsJPEG(response.getOutputStream(), chart, width, height); } else if (PNG_MIME_TYPE.equalsIgnoreCase(mimeType)) { response.setContentType(PNG_MIME_TYPE); ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, width, height); } else { throw new APIException("unsupported.mime.type", (Object[]) null); } } catch (IOException e) { // if its tomcat and the user simply navigated away from the page, don't throw an error if (e.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) { // do nothing } else { log.error("Error class name: " + e.getClass().getName()); log.error("Unable to write chart", e); } } } // Add error handling above and remove this try/catch catch (Exception e) { log.error("An unknown expected exception was thrown while rendering a graph", e); } }
From source file:org.geoserver.wms.ncwms.GetTimeSeriesResponse.java
@SuppressWarnings("rawtypes") private void writeChart(GetFeatureInfoRequest request, FeatureCollectionType results, OutputStream output, String mimeType) throws IOException { final TimeSeries series = new TimeSeries("time", Millisecond.class); String valueAxisLabel = "Value"; String title = "Time series"; final String timeaxisLabel = "Date / time"; final List collections = results.getFeature(); if (collections.size() > 0) { SimpleFeatureCollection fc = (SimpleFeatureCollection) collections.get(0); title += " of " + fc.getSchema().getName().getLocalPart(); valueAxisLabel = fc.getSchema().getDescription().toString(); try (SimpleFeatureIterator fi = fc.features()) { while (fi.hasNext()) { SimpleFeature f = fi.next(); Date date = (Date) f.getAttribute("date"); Double value = (Double) f.getAttribute("value"); series.add(new Millisecond(date), value); }/* www .ja v a 2s . com*/ } } XYDataset dataset = new TimeSeriesCollection(series); JFreeChart chart = ChartFactory.createTimeSeriesChart(title, timeaxisLabel, valueAxisLabel, dataset, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new XYLineAndShapeRenderer()); if (mimeType.startsWith("image/png")) { ChartUtilities.writeChartAsPNG(output, chart, IMAGE_WIDTH, IMAGE_HEIGHT); } else if (mimeType.equals("image/jpg") || mimeType.equals("image/jpeg")) { ChartUtilities.writeChartAsJPEG(output, chart, IMAGE_WIDTH, IMAGE_HEIGHT); } }
From source file:org.gaixie.micrite.struts2.jfreechart.ChartResult.java
/** * Executes the result. Writes the given chart as a PNG or JPG to the servlet output stream. * * @param invocation an encapsulation of the action execution state. * @throws Exception if an error occurs when creating or writing the chart to the servlet output stream. *///w w w .ja v a 2s.c o m public void execute(ActionInvocation invocation) throws Exception { if (!chartSet) // if our chart hasn't been set (by the testcase), we'll look it up in the value stack chart = (JFreeChart) invocation.getStack().findValue(value, JFreeChart.class); if (chart == null) // we need to have a chart object - if not, blow up throw new NullPointerException("No JFreeChart object found on the stack with name " + value); // make sure we have some value for the width and height if (height == null) throw new NullPointerException("No height parameter was given."); if (width == null) throw new NullPointerException("No width parameter was given."); // get a reference to the servlet output stream to write our chart image to OutputStream os = ServletActionContext.getResponse().getOutputStream(); try { // check the type to see what kind of output we have to produce if ("png".equalsIgnoreCase(type)) ChartUtilities.writeChartAsPNG(os, chart, width, height); else if ("jpg".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type)) ChartUtilities.writeChartAsJPEG(os, chart, width, height); else throw new IllegalArgumentException( type + " is not a supported render type (only JPG and PNG are)."); } finally { if (os != null) os.flush();//pw.close(); } }
From source file:projekt.CustomRenderer.java
public void raport_lokalny() throws IOException, ClassNotFoundException, SQLException { loginController login = new loginController(); String zapytanie = "select count(*) as Aktualne from projekty, (SELECT Nazwa, Opis, Status_zadania, idUzytkownika,projekt from zadania where Status_zadania = 'Aktualne' and idUzytkownika = '" + login.uzytkownikID + "') x where projekty.Nazwa = x.projekt"; String zapytanie1 = "select count(*) as FORTEST from projekty, (SELECT Nazwa, Opis, Status_zadania, idUzytkownika,projekt from zadania where Status_zadania = 'FORTEST' and idUzytkownika = '" + login.uzytkownikID + "') x where projekty.Nazwa = x.projekt"; String zapytanie2 = "select count(*) as Zakonczone from projekty, (SELECT Nazwa, Opis, Status_zadania, idUzytkownika,projekt from zadania where Status_zadania = 'Zakonczone' and idUzytkownika = '" + login.uzytkownikID + "') x where projekty.Nazwa = x.projekt"; Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pz?characterEncoding=utf8", "root", ""); PreparedStatement statment;/*from w ww . j av a 2 s. c o m*/ ResultSet result; double odp = 0, odp1 = 0, odp2 = 0; statment = con.prepareStatement(zapytanie); result = statment.executeQuery(); if (result.next()) { odp = result.getDouble("Aktualne"); } statment = con.prepareStatement(zapytanie1); result = statment.executeQuery(); if (result.next()) { odp1 = result.getDouble("FORTEST"); } statment = con.prepareStatement(zapytanie2); result = statment.executeQuery(); if (result.next()) { odp2 = result.getDouble("Zakonczone"); } //tu tez zmienic na id statment = con.prepareStatement( "SELECT CONCAT(imie, ' ', nazwisko) as osoba from uzytkownicy WHERE idUzytkownika = '" + login.uzytkownikID + "'"); result = statment.executeQuery(); String bbc = ""; if (result.next()) { bbc = result.getString(1); } DefaultCategoryDataset set2 = new DefaultCategoryDataset(); set2.setValue(odp, "", "Aktualne"); set2.setValue(odp1, "", "FORTEST"); set2.setValue(odp2, "", "Zakonczone"); JFreeChart chart = ChartFactory.createBarChart( "Wszystkie zadania z projektow za ktore odpowiada " + result.getString(1), "Zadania", "Ilosc", set2, PlotOrientation.VERTICAL, false, true, false); final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.blue, Color.pink, Color.cyan, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); final CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); renderer.setItemLabelsVisible(true); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0); renderer.setPositiveItemLabelPosition(p); plot.setRenderer(renderer); ByteArrayOutputStream out = new ByteArrayOutputStream(); ChartUtilities.writeChartAsJPEG(out, chart, 450, 600); DateFormat dataformat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); DateFormat dataformat1 = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss"); Date data = new Date(); String fileName = "Raport lokalny " + dataformat1.format(data) + ".pdf"; try { PDRectangle PAGE_SIZE = PDRectangle.A4; PDDocument doc = new PDDocument(); PDFont font = PDType0Font.load(doc, getClass().getResourceAsStream("/fonts/RobotoCondensed-Regular.ttf")); PDFont font1 = PDType0Font.load(doc, getClass().getResourceAsStream("/fonts/RobotoCondensed-Bold.ttf")); PDPage page = new PDPage(PAGE_SIZE); PDPage page1 = new PDPage(PAGE_SIZE); doc.addPage(page); PDPageContentStream content = new PDPageContentStream(doc, page); //naglowek strona 1 Naglowek1(content, dataformat, data); //stopka strona1 Stopka(content, doc); content.beginText(); content.setFont(font1, 48); content.moveTextPositionByAmount(135, 550); content.showText("Raport lokalny"); content.endText(); content.beginText(); content.setFont(font, 22); content.moveTextPositionByAmount(30, 250); content.showText("Wersja systemu : 1.0"); content.newLine(); content.moveTextPositionByAmount(0, 35); content.showText("Autor raportu : " + result.getString("osoba")); content.endText(); content.close(); PDPageContentStream content1 = new PDPageContentStream(doc, page1); PDPage page2 = new PDPage(PAGE_SIZE); doc.addPage(page2); PDPageContentStream content2 = new PDPageContentStream(doc, page2); Naglowek1(content2, dataformat, data); //stopka strona2 Stopka(content2, doc); content2.beginText(); content2.setFont(font, 14); content2.moveTextPositionByAmount(30, 775); content2.showText("Wszystkie projekty za ktre odpowiada: " + result.getString(1)); statment = con.prepareStatement( "Select Nazwa, Opis, Poczatek, Koniec, ludzie from projekty where idUzytkownika='" + login.uzytkownikID + "'"); result = statment.executeQuery(); content2.newLine(); int liczba = 615; content2.moveTextPositionByAmount(0, -15); while (result.next()) { content2.newLine(); content2.moveTextPositionByAmount(0, -22); liczba += 22; //content2.showText("Nazwa : "+result.getString("Nazwa")+" Opis: "+result.getString("Opis")+" Data rozpoczecia: "+result.getString("Poczatek")+" Data zakonczenia: "+result.getString("Koniec")); content2.showText("Nazwa : " + result.getString("Nazwa") + " Opis: " + result.getString(1)); content2.newLine(); content2.moveTextPositionByAmount(0, -17); liczba += 22; content2.showText("Data rozpoczecia: " + result.getString("Poczatek") + " Data zakonczenia: " + result.getString("Koniec")); } content2.endText(); // content2.setLineWidth(2); // content2.moveTo(10, liczba + 5); // content2.lineTo(10, liczba +5); // content2.closeAndStroke(); DateFormat dataformat2 = new SimpleDateFormat("yyyy-MM-dd"); statment = con.prepareStatement("Select count(*) as 'Aktualne' from projekty where Koniec > '" + dataformat2.format(data) + "' and idUzytkownika='" + login.uzytkownikID + "'"); result = statment.executeQuery(); int aktualne = 0, zakonczone = 0; if (result.next()) { aktualne = result.getInt("Aktualne"); } statment = con.prepareStatement("Select count(*) as 'Zakonczone' from projekty where Koniec < '" + dataformat2.format(data) + "' and idUzytkownika='" + login.uzytkownikID + "'"); result = statment.executeQuery(); if (result.next()) { zakonczone = result.getInt("Zakonczone"); } DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Aktualne", aktualne); pieDataset.setValue("Zakonczone", zakonczone); JFreeChart chart1 = ChartFactory.createPieChart("Zestawienia projekt za ktore odpowiada" + bbc, // Title pieDataset, // Dataset true, // Show legend true, // Use tooltips false // Configure chart to generate URLs? ); PiePlot plot1 = (PiePlot) chart1.getPlot(); plot1.setSectionPaint("Aktualne", Color.blue); plot1.setSectionPaint("Zakonczone", Color.yellow); plot1.setExplodePercent("Aktualne", 0.10); plot1.setSimpleLabels(true); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot1.setLabelGenerator(gen); ByteArrayOutputStream out1 = new ByteArrayOutputStream(); ChartUtilities.writeChartAsJPEG(out1, chart1, 450, 600); PDImageXObject img1 = JPEGFactory.createFromStream(doc, new ByteArrayInputStream(out1.toByteArray())); content2.close(); PDPage page3 = new PDPage(PAGE_SIZE); doc.addPage(page3); PDPageContentStream content3 = new PDPageContentStream(doc, page3); Naglowek1(content3, dataformat, data); //stopka strona2 Stopka(content3, doc); content3.drawImage(img1, 50, 50); content3.close(); PDPage page4 = new PDPage(PAGE_SIZE); doc.addPage(page4); PDPageContentStream content4 = new PDPageContentStream(doc, page4); Naglowek1(content4, dataformat, data); //stopka strona2 Stopka(content4, doc); content4.beginText(); content4.setFont(font, 14); content4.moveTextPositionByAmount(30, 780); content4.showText("Wszystkie zadania w projektach za ktore odpowiada:" + bbc); statment = con.prepareStatement( "SELECT zadania.Nazwa,zadania.Opis,zadania.Status_zadania,zadania.projekt, z.Imie, z.Nazwisko,CONCAT(y.imie, ' ' , y.nazwisko) as 'UZY' FROM zadania , (select Nazwa from projekty where idUzytkownika = '" + login.uzytkownikID + "') x, (SELECT imie, nazwisko, idUzytkownika from uzytkownicy) y,(SELECT imie, nazwisko, idUzytkownika from uzytkownicy where idUzytkownika = '" + login.uzytkownikID + "') z WHERE zadania.projekt = x.Nazwa LIMIT 12"); //poprawic result = statment.executeQuery(); content4.newLine(); int nw = 850; content4.moveTextPositionByAmount(0, -15); nw -= 15; while (result.next()) { content4.newLine(); nw -= 22; content4.moveTextPositionByAmount(0, -22); //content2.showText("Nazwa : "+result.getString("Nazwa")+" Opis: "+result.getString("Opis")+" Data rozpoczecia: "+result.getString("Poczatek")+" Data zakonczenia: "+result.getString("Koniec")); content4.showText("Nazwa : " + result.getString("zadania.Nazwa")); content4.newLine(); nw -= 17; content4.moveTextPositionByAmount(0, -17); content4.showText(" Opis: " + result.getString("zadania.Opis") + " Status zadania: " + result.getString("zadania.Status_zadania")); content4.newLine(); nw -= 17; content4.moveTextPositionByAmount(0, -17); content4.showText(" Projekt: " + result.getString("zadania.projekt") + " Przydzielona osoba do zadania: " + result.getString("UZY")); } content4.endText(); content4.close(); statment = con.prepareStatement( "SELECT count(*) as 'liczba' FROM `zadania` where idUzytkownika='" + login.uzytkownikID + "'"); //poprawic result = statment.executeQuery(); if (result.next()) { } statment = con.prepareStatement( "SELECT zadania.Nazwa,zadania.Opis,zadania.Status_zadania,zadania.projekt, z.Imie, z.Nazwisko,CONCAT(y.imie, \" \", y.nazwisko) as \"UZY\" FROM zadania , (select Nazwa from projekty where idUzytkownika = '" + login.uzytkownikID + "') x, (SELECT imie, nazwisko, idUzytkownika from uzytkownicy) y,(SELECT imie, nazwisko, idUzytkownika from uzytkownicy where idUzytkownika = '" + login.uzytkownikID + "') z WHERE zadania.projekt = x.Nazwa LIMIT 12," + result.getInt(1) + ""); result = statment.executeQuery(); PDPage page5 = new PDPage(PAGE_SIZE); doc.addPage(page5); PDPageContentStream content5 = new PDPageContentStream(doc, page5); Naglowek1(content5, dataformat, data); //stopka strona2 Stopka(content5, doc); content5.beginText(); content5.setFont(font, 14); content5.moveTextPositionByAmount(30, 700); while (result.next()) { content5.newLine(); nw -= 22; content5.moveTextPositionByAmount(0, -22); //content2.showText("Nazwa : "+result.getString("Nazwa")+" Opis: "+result.getString("Opis")+" Data rozpoczecia: "+result.getString("Poczatek")+" Data zakonczenia: "+result.getString("Koniec")); content5.showText("Nazwa : " + result.getString("zadania.Nazwa")); content5.newLine(); nw -= 17; content5.moveTextPositionByAmount(0, -17); content5.showText(" Opis: " + result.getString("zadania.Opis") + " Status zadania: " + result.getString("zadania.Status_zadania")); content5.newLine(); nw -= 17; content5.moveTextPositionByAmount(0, -17); content5.showText(" Projekt: " + result.getString("zadania.projekt") + " Przydzielona osoba do zadania: " + result.getString("UZY")); } content5.endText(); content5.close(); doc.addPage(page1); //naglowek strona 2 Naglowek1(content1, dataformat, data); //stopka strona2 Stopka(content1, doc); PDImageXObject img = JPEGFactory.createFromStream(doc, new ByteArrayInputStream(out.toByteArray())); content1.drawImage(img, 50, 50); content1.close(); doc.save(fileName); doc.close(); } catch (Exception e) { System.err.println(e.getMessage()); } }