1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.curre.prefcount.gui;
16
17 import java.awt.Graphics;
18 import java.awt.Graphics2D;
19 import java.awt.RenderingHints;
20 import java.awt.print.PageFormat;
21 import java.awt.print.Printable;
22 import java.awt.print.PrinterException;
23
24 import net.curre.prefcount.PrefCountRegistry;
25 import net.curre.prefcount.gui.theme.skin.PrefSkin;
26 import net.curre.prefcount.gui.theme.skin.PrintSkin;
27
28
29
30
31
32
33
34
35 public class Template implements Printable {
36
37
38 private final int numberOfPlayers;
39
40
41
42
43
44
45 public Template(int numberOfPlayers) {
46 this.numberOfPlayers = numberOfPlayers;
47 }
48
49
50
51 public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
52 if (pageIndex > 0) {
53 return (NO_SUCH_PAGE);
54
55 } else {
56 Graphics2D g2 = (Graphics2D) g;
57 g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
58
59 final int height = (int) pageFormat.getImageableHeight();
60 final int width = (int) pageFormat.getImageableWidth();
61
62
63 MainWindow mainWindow = PrefCountRegistry.getInstance().getMainWindow();
64 final PrefSkin skin = new PrintSkin();
65
66 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
67 RenderingHints.VALUE_ANTIALIAS_ON);
68 mainWindow.scoreBoardPanel.drawScoreBoard(g2, width, height - 20, 0, 20,
69 numberOfPlayers, skin);
70 return (PAGE_EXISTS);
71 }
72 }
73
74
75 }