Source code: com/virtuosotechnologies/asaph/launch/TitlePane.java
1 /*
2 ================================================================================
3
4 FILE: TitlePane.java
5
6 PROJECT:
7
8 Asaph
9
10 CONTENTS:
11
12 JComponent that draws the title and logo
13
14 PROGRAMMERS:
15
16 Daniel Azuma (DA) <dazuma@kagi.com>
17
18 COPYRIGHT:
19
20 Copyright (C) 2003 Daniel Azuma (dazuma@kagi.com)
21
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public
33 License along with this program; if not, write to
34 Free Software Foundation, Inc.
35 59 Temple Place, Suite 330
36 Boston, MA 02111-1307 USA
37
38 ================================================================================
39 */
40
41
42 package com.virtuosotechnologies.asaph.launch;
43
44
45 import java.awt.Color;
46 import java.awt.Font;
47 import java.awt.Dimension;
48 import java.awt.Graphics;
49 import java.awt.Graphics2D;
50 import java.awt.RenderingHints;
51 import java.awt.font.FontRenderContext;
52 import java.awt.font.TextLayout;
53 import javax.swing.JPanel;
54
55
56 /**
57 * Title pane
58 */
59 /*package*/ class TitlePane
60 extends JPanel
61 {
62 private static final String STR_AsaphProgramName =
63 ResourceAccess.Strings.buildString("AsaphProgramName");
64 private static final String STR_Logo_Blurb1 =
65 ResourceAccess.Strings.buildString("Logo_Blurb1");
66 private static final String STR_Logo_Blurb2 =
67 ResourceAccess.Strings.buildString("Logo_Blurb2");
68
69 private static final Color textColor_ = new Color(128, 128, 160);
70 private static final Color shadowColor_ = new Color(64, 64, 64);
71 private static final Color blurbColor_ = new Color(64, 64, 64);
72 private static final Font titleFont_ = new Font("Serif", Font.BOLD, 64);
73 private static final Font blurbFont_ = new Font("SansSerif", Font.ITALIC, 12);
74 private static final float mainBaseline_ = 64;
75 private static final float blurbBaseline1_ = 96;
76 private static final float blurbBaseline2_ = 110;
77
78
79 /*package*/ TitlePane(
80 boolean large)
81 {
82 if (large)
83 {
84 setPreferredSize(new Dimension(500, 125));
85 }
86 else
87 {
88 setPreferredSize(new Dimension(300, 125));
89 }
90 }
91
92
93 public void paintComponent(
94 Graphics g)
95 {
96 Graphics2D gr = (Graphics2D)g;
97 RenderingHints hints = gr.getRenderingHints();
98 hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
99 hints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
100 gr.setRenderingHints(hints);
101 FontRenderContext frc = gr.getFontRenderContext();
102 float width = getWidth();
103 float height = getHeight();
104
105 gr.setColor(Color.white);
106 gr.fillRect(0, 0, getWidth(), getHeight());
107
108 TextLayout layout = new TextLayout(STR_AsaphProgramName, titleFont_, frc);
109 gr.setColor(shadowColor_);
110 layout.draw(gr, (width-layout.getAdvance())/2+1, mainBaseline_+1);
111 gr.setColor(textColor_);
112 layout.draw(gr, (width-layout.getAdvance())/2-1, mainBaseline_-1);
113
114 layout = new TextLayout(STR_Logo_Blurb1, blurbFont_, frc);
115 gr.setColor(blurbColor_);
116 layout.draw(gr, (width-layout.getAdvance())/2, blurbBaseline1_);
117
118 layout = new TextLayout(STR_Logo_Blurb2, blurbFont_, frc);
119 gr.setColor(blurbColor_);
120 layout.draw(gr, (width-layout.getAdvance())/2, blurbBaseline2_);
121 }
122 }