1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head><body>
<!-- ======================================================== -->
<!-- = Java Sourcecode to HTML automatically converted code = -->
<!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div align="left" class="java">
<table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
<tr>
<!-- start source code -->
<td nowrap="nowrap" valign="top" align="left">
<code>
<font color="#7f0055"><b>package </b></font><font color="#000000">com.itmill.toolkit.demo.coverflow;</font><br />
<font color="#ffffff"></font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.BufferedReader;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.FileInputStream;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.FileReader;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.IOException;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.InputStream;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.InputStreamReader;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.Reader;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.io.StringReader;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.net.URL;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">java.nio.CharBuffer;</font><br />
<font color="#ffffff"></font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.data.Property;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.terminal.Resource;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.terminal.Sizeable;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.terminal.ThemeResource;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.ui.Button;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.ui.Embedded;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.ui.ExpandLayout;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.ui.Label;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.ui.Window;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.ui.Button.ClickEvent;</font><br />
<font color="#7f0055"><b>import </b></font><font color="#000000">com.itmill.toolkit.ui.Layout.AlignmentHandler;</font><br />
<font color="#ffffff"></font><br />
<font color="#7f0055"><b>public class </b></font><font color="#000000">CoverflowApplication </font><font color="#7f0055"><b>extends </b></font><font color="#000000">com.itmill.toolkit.Application </font><font color="#000000">{</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#000000">Coverflow covers = </font><font color="#7f0055"><b>new </b></font><font color="#000000">Coverflow</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>void </b></font><font color="#000000">init</font><font color="#000000">() {</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#000000">setMainWindow</font><font color="#000000">(</font><font color="#7f0055"><b>new </b></font><font color="#000000">Window</font><font color="#000000">(</font><font color="#2a00ff">"Coverflow"</font><font color="#000000">, createMainLayout</font><font color="#000000">()))</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#000000">setTheme</font><font color="#000000">(</font><font color="#2a00ff">"black"</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#000000">addSlidesToCoverflow</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>private </b></font><font color="#000000">ExpandLayout createMainLayout</font><font color="#000000">() {</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#3f7f5f">// Initialize coverflow component</font><br />
<font color="#ffffff"> </font><font color="#000000">covers.setHeight</font><font color="#000000">(</font><font color="#990000">150</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">covers.setWidth</font><font color="#000000">(</font><font color="#990000">100</font><font color="#000000">, Sizeable.UNITS_PERCENTAGE</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">covers.setBackgroundColor</font><font color="#000000">(</font><font color="#990000">0</font><font color="#000000">, </font><font color="#990000">0</font><font color="#000000">, </font><font color="#990000">0</font><font color="#000000">, </font><font color="#990000">100</font><font color="#000000">, </font><font color="#990000">100</font><font color="#000000">, </font><font color="#990000">100</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#3f7f5f">// Initialize visible slide viewer</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>final </b></font><font color="#000000">Embedded visibleSlide = </font><font color="#7f0055"><b>new </b></font><font color="#000000">Embedded</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">visibleSlide.setHeight</font><font color="#000000">(</font><font color="#990000">100</font><font color="#000000">, Sizeable.UNITS_PERCENTAGE</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#3f7f5f">// Listen to coverflow changes as change slides when needed</font><br />
<font color="#ffffff"> </font><font color="#000000">covers.addListener</font><font color="#000000">(</font><font color="#7f0055"><b>new </b></font><font color="#000000">Property.ValueChangeListener</font><font color="#000000">() {</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>void </b></font><font color="#000000">valueChange</font><font color="#000000">(</font><font color="#000000">Property.ValueChangeEvent event</font><font color="#000000">) {</font><br />
<font color="#ffffff"> </font><font color="#000000">visibleSlide.setSource</font><font color="#000000">((</font><font color="#000000">Resource</font><font color="#000000">) </font><font color="#000000">covers.getValue</font><font color="#000000">())</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"> </font><font color="#000000">})</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#3f7f5f">// Show sources button</font><br />
<font color="#ffffff"> </font><font color="#000000">Button showSrc = </font><font color="#7f0055"><b>new </b></font><font color="#000000">Button</font><font color="#000000">(</font><font color="#2a00ff">"src"</font><font color="#000000">, </font><font color="#7f0055"><b>new </b></font><font color="#000000">Button.ClickListener</font><font color="#000000">() {</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>public </b></font><font color="#7f0055"><b>void </b></font><font color="#000000">buttonClick</font><font color="#000000">(</font><font color="#000000">ClickEvent event</font><font color="#000000">) {</font><br />
<font color="#ffffff"> </font><font color="#000000">Window srcWindow = </font><font color="#7f0055"><b>new </b></font><font color="#000000">Window</font><font color="#000000">(</font><font color="#2a00ff">"Source code"</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">srcWindow.setWidth</font><font color="#000000">(</font><font color="#990000">700</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">srcWindow.setHeight</font><font color="#000000">(</font><font color="#990000">500</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">Label l = </font><font color="#7f0055"><b>new </b></font><font color="#000000">Label</font><font color="#000000">(</font><font color="#000000">getSourceCodeForThisClass</font><font color="#000000">()</font><font color="#000000">,</font><br />
<font color="#ffffff"> </font><font color="#000000">Label.CONTENT_XHTML</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">srcWindow.addComponent</font><font color="#000000">(</font><font color="#000000">l</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">getMainWindow</font><font color="#000000">()</font><font color="#000000">.addWindow</font><font color="#000000">(</font><font color="#000000">srcWindow</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"> </font><font color="#000000">})</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#3f7f5f">// Initialize main layout</font><br />
<font color="#ffffff"> </font><font color="#000000">ExpandLayout layout = </font><font color="#7f0055"><b>new </b></font><font color="#000000">ExpandLayout</font><font color="#000000">(</font><br />
<font color="#ffffff"> </font><font color="#000000">ExpandLayout.ORIENTATION_VERTICAL</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.addComponent</font><font color="#000000">(</font><font color="#000000">showSrc</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.setComponentAlignment</font><font color="#000000">(</font><font color="#000000">showSrc, AlignmentHandler.ALIGNMENT_RIGHT,</font><br />
<font color="#ffffff"> </font><font color="#000000">AlignmentHandler.ALIGNMENT_TOP</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.addComponent</font><font color="#000000">(</font><font color="#000000">visibleSlide</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.setComponentAlignment</font><font color="#000000">(</font><font color="#000000">visibleSlide,</font><br />
<font color="#ffffff"> </font><font color="#000000">AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER,</font><br />
<font color="#ffffff"> </font><font color="#000000">AlignmentHandler.ALIGNMENT_TOP</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.addComponent</font><font color="#000000">(</font><font color="#000000">covers</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.setComponentAlignment</font><font color="#000000">(</font><font color="#000000">covers,</font><br />
<font color="#ffffff"> </font><font color="#000000">AlignmentHandler.ALIGNMENT_HORIZONTAL_CENTER,</font><br />
<font color="#ffffff"> </font><font color="#000000">AlignmentHandler.ALIGNMENT_TOP</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.expand</font><font color="#000000">(</font><font color="#000000">visibleSlide</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">layout.setSizeFull</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">layout;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>private </b></font><font color="#000000">String getSourceCodeForThisClass</font><font color="#000000">() {</font><br />
<font color="#ffffff"> </font><font color="#000000">String code = </font><font color="#2a00ff">"Could not find source-file"</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>try </b></font><font color="#000000">{</font><br />
<font color="#ffffff"> </font><font color="#000000">InputStream is = </font><font color="#7f0055"><b>this</b></font><font color="#000000">.getClass</font><font color="#000000">()</font><font color="#000000">.getResource</font><font color="#000000">(</font><br />
<font color="#ffffff"> </font><font color="#2a00ff">"CoverflowApplication.html"</font><font color="#000000">)</font><font color="#000000">.openStream</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">BufferedReader r = </font><font color="#7f0055"><b>new </b></font><font color="#000000">BufferedReader</font><font color="#000000">(</font><font color="#7f0055"><b>new </b></font><font color="#000000">InputStreamReader</font><font color="#000000">(</font><font color="#000000">is</font><font color="#000000">))</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">StringBuffer buf = </font><font color="#7f0055"><b>new </b></font><font color="#000000">StringBuffer</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">String line;</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>while </b></font><font color="#000000">((</font><font color="#000000">line = r.readLine</font><font color="#000000">()) </font><font color="#000000">!= </font><font color="#7f0055"><b>null</b></font><font color="#000000">) {</font><br />
<font color="#ffffff"> </font><font color="#000000">buf.append</font><font color="#000000">(</font><font color="#000000">line</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"> </font><font color="#000000">code = buf.toString</font><font color="#000000">()</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">} </font><font color="#7f0055"><b>catch </b></font><font color="#000000">(</font><font color="#000000">IOException ignored</font><font color="#000000">) {</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>return </b></font><font color="#000000">code;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"></font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>private </b></font><font color="#7f0055"><b>void </b></font><font color="#000000">addSlidesToCoverflow</font><font color="#000000">() {</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>for </b></font><font color="#000000">(</font><font color="#7f0055"><b>int </b></font><font color="#000000">i = </font><font color="#990000">1</font><font color="#000000">; i <= </font><font color="#990000">22</font><font color="#000000">; i++</font><font color="#000000">) {</font><br />
<font color="#ffffff"> </font><font color="#000000">String head = </font><font color="#2a00ff">"../../../IMAGES/"</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">String tail = </font><font color="#2a00ff">"slideshow-example.0" </font><font color="#000000">+ </font><font color="#000000">((</font><font color="#000000">i < </font><font color="#990000">10</font><font color="#000000">) </font><font color="#000000">? </font><font color="#2a00ff">"0" </font><font color="#000000">: </font><font color="#2a00ff">""</font><font color="#000000">) </font><font color="#000000">+ i</font><br />
<font color="#ffffff"> </font><font color="#000000">+ </font><font color="#2a00ff">".jpg"</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">ThemeResource slide = </font><font color="#7f0055"><b>new </b></font><font color="#000000">ThemeResource</font><font color="#000000">(</font><font color="#000000">head + tail</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">covers.addItem</font><font color="#000000">(</font><font color="#000000">slide</font><font color="#000000">)</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">covers.setItemIcon</font><font color="#000000">(</font><font color="#000000">slide,</font><br />
<font color="#ffffff"> </font><font color="#7f0055"><b>new </b></font><font color="#000000">ThemeResource</font><font color="#000000">(</font><font color="#000000">head + </font><font color="#2a00ff">"thumbs/" </font><font color="#000000">+ tail</font><font color="#000000">))</font><font color="#000000">;</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#ffffff"> </font><font color="#000000">}</font><br />
<font color="#000000">}</font></code>
</td>
<!-- end source code -->
</tr>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== -->
</body></html>
|