Last change
on this file since 1315 was
193,
checked in by Maciej Komosinski, 11 years ago
|
Set svn:eol-style native for all textual files
|
-
Property svn:eol-style set to
native
|
File size:
1.2 KB
|
Line | |
---|
1 | package games.league; |
---|
2 | |
---|
3 | import java.awt.Color; |
---|
4 | import java.io.FileOutputStream; |
---|
5 | import java.util.Scanner; |
---|
6 | |
---|
7 | import com.lowagie.text.Document; |
---|
8 | import com.lowagie.text.PageSize; |
---|
9 | import com.lowagie.text.Paragraph; |
---|
10 | import com.lowagie.text.Rectangle; |
---|
11 | import com.lowagie.text.pdf.PdfPCell; |
---|
12 | import com.lowagie.text.pdf.PdfPTable; |
---|
13 | import com.lowagie.text.pdf.PdfWriter; |
---|
14 | |
---|
15 | public class WPCVisualizerPDF { |
---|
16 | |
---|
17 | public static void main(String[] args) { |
---|
18 | Document document = new Document(PageSize.A4); |
---|
19 | |
---|
20 | try { |
---|
21 | PdfWriter.getInstance(document, new FileOutputStream("WPC.pdf")); |
---|
22 | document.open(); |
---|
23 | |
---|
24 | PdfPTable table = new PdfPTable(8); |
---|
25 | Scanner sc = new Scanner(System.in); |
---|
26 | double sum = 0; |
---|
27 | for (int i = 0; i < 64; i++) { |
---|
28 | float w = (float)sc.nextDouble(); |
---|
29 | sum += w; |
---|
30 | System.out.println(w); |
---|
31 | PdfPCell cell = new PdfPCell(new Paragraph(" ")); |
---|
32 | cell.setPadding(20.0f); |
---|
33 | cell.setBorder(Rectangle.NO_BORDER); |
---|
34 | if (w >= 0) { |
---|
35 | cell.setBackgroundColor(new Color(0, Math.min(1, w), 0)); |
---|
36 | } else { |
---|
37 | cell.setBackgroundColor(new Color(Math.min(1, Math.abs(w)), 0, 0)); |
---|
38 | } |
---|
39 | |
---|
40 | table.addCell(cell); |
---|
41 | } |
---|
42 | |
---|
43 | System.err.println(sum / 64); |
---|
44 | document.add(table); |
---|
45 | } catch (Exception de) { |
---|
46 | de.printStackTrace(); |
---|
47 | } |
---|
48 | document.close(); |
---|
49 | } |
---|
50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.