Mercurial > hg > octave-lyh
comparison scripts/java/dlgtest.m @ 15625:acf0addfc610
include Octave Forge java package in core Octave
* scripts/java: New directory tree.
* scripts/Makefile.am: Include java/module.mk.
(JAR_FILES): New variable.
(nobase_fcnfile_DATA): Include $(JAR_FILES) in the list.
(all-local): Depend on $(JAR_FILES).
(java/PKG_ADD, java_GEN_FCN_FILES, java/$(octave_dirstamp)):
New rules.
* libinterp/link-deps (LIBOCTINTERP_LINK_DEP): Include $(JAVA_LIBS) in
the list.
* dldfcn/__java__.h, dldfcn/__java__.cc: New files.
* dldfcn/module-files (__java__.cc): New file description.
* doc/interpreter/java.txi: New file.
* doc/interpreter/octave.texi: Include java.texi.
* doc/interpreter/java-images: New directory.
* doc/interpreter/Makefile.am (JAVA_IMAGES): New variable.
(IMAGES): Include $(JAVA_IMAGSES) in the list.
(MUNGED_TEXI_SRC): Include java.texi in the list.
* configure.ac: Check for Java libraries and tools.
Include Java info in the summary message.
* build-aux/common.mk (JAVA_CPPFLAGS, JAVA_LIBS): New variables.
* NEWS: Update.
* contributors.in: Include Martin Hepperle in the list.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 23 Nov 2012 15:29:13 -0500 |
parents | |
children | 9fee0b741de6 |
comparison
equal
deleted
inserted
replaced
15624:550147454137 | 15625:acf0addfc610 |
---|---|
1 % | |
2 % Install the java package. | |
3 % Test the dlg... functions of the java package. | |
4 % | |
5 % Author: Martin Hepperle | |
6 % Version August 2010 | |
7 % | |
8 function dlgtest ( reinstall ) | |
9 | |
10 % Windows example paths | |
11 if ispc() | |
12 % NOTE: do NOT use backslashes as separator, only forward slashes! | |
13 pkgpath = 'z:/java-1.2.8.tar.gz'; | |
14 java_home = getenv ("JAVA_HOME"); | |
15 elseif isunix() | |
16 % Linux example paths | |
17 pkgpath = '~/java-1.2.8.tar.gz'; | |
18 java_home = getenv ("JAVA_HOME"); | |
19 else | |
20 pkgpath = 'unknown'; | |
21 java_home = 'unknown'; | |
22 end | |
23 | |
24 if nargin<1 | |
25 disp('usage: dlgtest ( reinstall )'); | |
26 disp( 'where: reinstall = 0 : do not reinstall java package'); | |
27 disp([' reinstall = 1 : reinstall java package from ', pkgpath, ... | |
28 ', using Java JDK from ', java_home]); | |
29 return | |
30 end | |
31 | |
32 if ! exist (java_home, "dir") | |
33 disp(['Java JDK home directory ', java_home,' does not exist.']); | |
34 disp('Please adapt java_home in dlgtest.m.'); | |
35 return; | |
36 end | |
37 | |
38 if reinstall == 1 | |
39 if ! exist (pkgpath, "file") | |
40 disp(['Package file ', pkgpath, ' does not exist.']); | |
41 disp('Please adapt pkgpath in dlgtest.m.'); | |
42 return; | |
43 end | |
44 end | |
45 | |
46 page_screen_output(0); | |
47 | |
48 if reinstall == 1 | |
49 disp('- uninstalling package java'); | |
50 pkg uninstall java | |
51 | |
52 disp(['- installing package java from ',pkgpath]); | |
53 disp([' using JDK from ',java_home]); | |
54 setenv('JAVA_HOME',java_home) | |
55 %% pkg does not understand variables as arguments? | |
56 eval(['pkg install ', pkgpath]) | |
57 disp('Done.'); | |
58 end | |
59 | |
60 page_screen_output(1); | |
61 | |
62 answer = 1; | |
63 while (answer > 0 ) | |
64 | |
65 disp(''); | |
66 disp('0 ... STOP'); | |
67 disp('1 ... listdlg tests'); | |
68 disp('2 ... errordlg tests'); | |
69 disp('3 ... warndlg tests'); | |
70 disp('4 ... helpdlg tests'); | |
71 disp('5 ... inputdlg tests'); | |
72 disp('6 ... TeX code tests'); | |
73 | |
74 answer = str2num(input ('Run which test? [0] > ','s')); | |
75 | |
76 disp(''); | |
77 | |
78 switch answer | |
79 case 1 | |
80 test_listdlg(); | |
81 case 2 | |
82 test_errordlg(); | |
83 case 3 | |
84 test_warndlg(); | |
85 case 4 | |
86 test_helpdlg(); | |
87 case 5 | |
88 test_inputdlg(); | |
89 case 6 | |
90 test_TeXCodes(); | |
91 end | |
92 end | |
93 | |
94 % d = javaObject('javax.swing.JDialog'); | |
95 % cp = d.getContentPane; | |
96 % b = javaObject('javax.swing.JButton','OK'); | |
97 % cp.add(b); | |
98 % d.pack; | |
99 % d.setVisible(true); | |
100 | |
101 | |
102 page_screen_output(1); | |
103 | |
104 end | |
105 | |
106 function test_listdlg | |
107 | |
108 %----------------------------------------------- | |
109 disp('- test listdlg with selectionmode single. No caption, no prompt.'); | |
110 itemlist = {'An item \\alpha', 'another', 'yet another'}; | |
111 s = listdlg ( 'ListString',itemlist, 'SelectionMode','Single' ); | |
112 imax = length(s); | |
113 for i=1:1:imax | |
114 disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]); | |
115 end | |
116 | |
117 %----------------------------------------------- | |
118 disp('- test listdlg with selectionmode and preselection. Has caption and two lines prompt.'); | |
119 s = listdlg ( 'ListString',itemlist, ... | |
120 'SelectionMode','Multiple', ... | |
121 'Name','Selection Dialog', ... | |
122 'InitialValue',[1,2,3,4], | |
123 'PromptString',{'Select an item...', '...or multiple items'} ); | |
124 imax = length(s); | |
125 for i=1:1:imax | |
126 disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]); | |
127 end | |
128 | |
129 end | |
130 | |
131 function test_errordlg | |
132 %----------------------------------------------- | |
133 disp('- test errordlg with prompt only.'); | |
134 errordlg('Oops, an expected error occured'); | |
135 %----------------------------------------------- | |
136 disp('- test errordlg with prompt and caption.'); | |
137 errordlg('Oops another error','This is a very long and informative caption'); | |
138 end | |
139 | |
140 function test_warndlg | |
141 %----------------------------------------------- | |
142 disp('- test warndlg with prompt only.'); | |
143 warndlg('Oh, a warning occured'); | |
144 %----------------------------------------------- | |
145 disp('- test warndlg with prompt and caption.'); | |
146 warndlg('Oh, No...','This is the last Warning'); | |
147 end | |
148 | |
149 function test_helpdlg | |
150 %----------------------------------------------- | |
151 disp('- test helpdlg with a help message only.'); | |
152 helpdlg("Below, you should see 3 lines:\nline #1\nline #2, and\nline #3."); | |
153 %----------------------------------------------- | |
154 disp('- test helpdlg with help message and caption.'); | |
155 helpdlg('You should see a single line.','A help dialog'); | |
156 end | |
157 | |
158 function test_inputdlg | |
159 %----------------------------------------------- | |
160 disp('- test inputdlg with prompt and caption only.'); | |
161 prompt = {'Width','Height','Depth'}; | |
162 dims = inputdlg ( prompt, 'Enter Box Dimensions' ); | |
163 if isempty(dims) | |
164 helpdlg('Canceled by user', 'Information'); | |
165 else | |
166 volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); | |
167 surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... | |
168 str2num(dims{2}) * str2num(dims{3}) + ... | |
169 str2num(dims{1}) * str2num(dims{3})); | |
170 helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); | |
171 end | |
172 | |
173 %----------------------------------------------- | |
174 disp('- test inputdlg with prescribed scalar (2 lines per text field) and defaults.'); | |
175 prompt = {'Width','Height','Depth'}; | |
176 default = {'1.1','2.2','3.3'}; | |
177 rc = 2; | |
178 dims = inputdlg ( prompt, 'Enter Box Dimensions',rc,default ); | |
179 if isempty(dims) | |
180 helpdlg('Canceled by user', 'Information'); | |
181 else | |
182 volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); | |
183 surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... | |
184 str2num(dims{2}) * str2num(dims{3}) + ... | |
185 str2num(dims{1}) * str2num(dims{3})); | |
186 helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); | |
187 end | |
188 %----------------------------------------------- | |
189 disp('- test inputdlg with prescribed vector [1,2,3] for # of lines per text field and defaults.'); | |
190 prompt = {'Width','Height','Depth'}; | |
191 default = {'1.10', '2.10', '3.10'}; | |
192 rc = [1,2,3]; % NOTE: must be an array | |
193 dims = inputdlg ( prompt, 'Enter Box Dimensions',rc,default ); | |
194 if isempty(dims) | |
195 helpdlg('Canceled by user', 'Information'); | |
196 else | |
197 volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); | |
198 surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... | |
199 str2num(dims{2}) * str2num(dims{3}) + ... | |
200 str2num(dims{1}) * str2num(dims{3})); | |
201 helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); | |
202 end | |
203 %----------------------------------------------- | |
204 disp('- test inputdlg with prescribed row by column sizes and defaults.'); | |
205 prompt = {'Width','Height','Depth'}; | |
206 default = {'1.10', '2.20', '3.30'}; | |
207 rc = [1,10; 2,20; 3,30]; % NOTE: must be an array | |
208 dims = inputdlg ( prompt, 'Enter Box Dimensions',rc,default ); | |
209 if isempty(dims) | |
210 helpdlg('Canceled by user', 'Information'); | |
211 else | |
212 volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); | |
213 surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... | |
214 str2num(dims{2}) * str2num(dims{3}) + ... | |
215 str2num(dims{1}) * str2num(dims{3})); | |
216 helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); | |
217 end | |
218 end | |
219 | |
220 %% show a table of TeX symbol codes and the resulting Unicode character | |
221 function test_TeXCodes | |
222 %----------------------------------------------- | |
223 disp('- test TeX code to Unicode translation.'); | |
224 | |
225 msgbox ( ['\\alpha = ''\alpha '' \\beta = ''\beta '' \\gamma = ''\gamma ''', 10, ... | |
226 '\\delta = ''\delta '' \\epsilon = ''\epsilon '' \\zeta = ''\zeta ''', 10, ... | |
227 '\\eta = ''\eta '' \\theta = ''\theta '' \\vartheta = ''\vartheta ''', 10, ... | |
228 '\\iota = ''\iota '' \\kappa = ''\kappa '' \\lambda = ''\lambda ''', 10, ... | |
229 '\\mu = ''\mu '' \\nu = ''\nu '' \\xi = ''\xi ''', 10, ... | |
230 '\\pi = ''\pi '' \\rho = ''\rho '' \\sigma = ''\sigma ''', 10, ... | |
231 '\\varsigma = ''\varsigma '' \\tau = ''\tau '' \\phi = ''\phi ''', 10, ... | |
232 '\\chi = ''\chi '' \\psi = ''\psi '' \\omega = ''\omega ''', 10, ... | |
233 '\\upsilon = ''\upsilon '' \\Gamma = ''\Gamma '' \\Delta = ''\Delta ''', 10, ... | |
234 '\\Theta = ''\Theta '' \\Lambda = ''\Lambda '' \\Pi = ''\Pi ''', 10, ... | |
235 '\\Xi = ''\Xi '' \\Sigma = ''\Sigma '' \\Upsilon = ''\Upsilon ''', 10, ... | |
236 '\\Phi = ''\Phi '' \\Psi = ''\Psi '' \\Omega = ''\Omega ''', 10, ... | |
237 '\\Im = ''\Im '' \\Re = ''\Re '' \\leq = ''\leq ''', 10, ... | |
238 '\\geq = ''\geq '' \\neq = ''\neq '' \\pm = ''\pm ''', 10, ... | |
239 '\\infty = ''\infty '' \\partial = ''\partial '' \\approx = ''\approx ''', 10, ... | |
240 '\\circ = ''\circ '' \\bullet = ''\bullet '' \\times = ''\times ''', 10, ... | |
241 '\\sim = ''\sim '' \\nabla = ''\nabla '' \\ldots = ''\ldots ''', 10, ... | |
242 '\\exists = ''\exists '' \\neg = ''\neg '' \\aleph = ''\aleph ''', 10, ... | |
243 '\\forall = ''\forall '' \\cong = ''\cong '' \\wp = ''\wp ''', 10, ... | |
244 '\\propto = ''\propto '' \\otimes = ''\otimes '' \\oplus = ''\oplus ''', 10, ... | |
245 '\\oslash = ''\oslash '' \\cap = ''\cap '' \\cup = ''\cup ''', 10, ... | |
246 '\\ni = ''\ni '' \\in = ''\in '' \\div = ''\div ''', 10, ... | |
247 '\\equiv = ''\equiv '' \\int = ''\int '' \\perp = ''\perp ''', 10, ... | |
248 '\\wedge = ''\wedge '' \\vee = ''\vee '' \\supseteq = ''\supseteq ''', 10, ... | |
249 '\\supset = ''\supset '' \\subseteq = ''\subseteq '' \\subset = ''\subset ''', 10, ... | |
250 '\\clubsuit = ''\clubsuit '' \\spadesuit = ''\spadesuit '' \\heartsuit = ''\heartsuit ''', 10, ... | |
251 '\\diamondsuit = ''\diamondsuit '' \\copyright = ''\copyright '' \\leftarrow = ''\leftarrow ''', 10, ... | |
252 '\\uparrow = ''\uparrow '' \\rightarrow = ''\rightarrow '' \\downarrow = ''\downarrow ''', 10, ... | |
253 '\\leftrightarrow = ''\leftrightarrow '' \\updownarrow = ''\updownarrow '''], ... | |
254 'TeX symbol code table Test'); | |
255 end |