Mercurial > hg > Applications > TreeVNC
annotate src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java @ 400:845698fd6fb6
Remove synchronized
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Oct 2015 17:45:16 +0900 |
parents | 28d67bbfa9f1 |
children | 94c520535ef1 |
rev | line source |
---|---|
34 | 1 package com.glavsoft.viewer; |
2 | |
206 | 3 import jp.ac.u_ryukyu.treevnc.VncProxyService; |
34 | 4 |
260 | 5 import java.io.FileNotFoundException; |
6 import java.io.PrintStream; | |
293 | 7 import java.net.SocketException; |
8 import java.net.UnknownHostException; | |
260 | 9 |
34 | 10 public class TreeViewer { |
240 | 11 private boolean treeProxy; |
12 private boolean viewer; | |
13 private boolean cui = false; | |
14 private int width; | |
15 private int height; | |
257 | 16 private int fixingSizeWidth; |
17 private int fixingSizeHeight; | |
240 | 18 private String hostName = null; |
261 | 19 private String logFileName = null; |
240 | 20 private boolean noConnection = false; |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
89
diff
changeset
|
21 private boolean permitChangeScreen = true; |
163 | 22 private boolean showTree = false; |
240 | 23 private boolean checkDelay = false; |
241 | 24 private boolean addSerialNum = false; |
257 | 25 private boolean fixingSizeDisplay = false; |
267 | 26 private boolean logFile = false; |
27 private boolean filterSingleDisplay = false; | |
377 | 28 private boolean direct = false; |
257 | 29 |
34 | 30 |
293 | 31 public static void main(String[] args) throws SocketException, UnknownHostException { |
223 | 32 new TreeViewer().vncStart(args); |
33 } | |
34 | 34 |
293 | 35 private void vncStart(String[] args) throws SocketException, UnknownHostException { |
223 | 36 modeSelect(args); |
261 | 37 if(logFile) { |
38 PrintStream out = null; | |
39 try { | |
40 out = new PrintStream(logFileName + ".txt"); | |
41 } catch (FileNotFoundException e) { | |
42 e.printStackTrace(); | |
43 } | |
44 System.setOut(out); | |
45 } | |
223 | 46 if (treeProxy && !viewer) { |
47 // start treeManager only ( -p flag ) | |
48 VncProxyService vps = new VncProxyService(); | |
266 | 49 if(fixingSizeDisplay) |
50 setFixingSizeDisplay(vps); | |
223 | 51 rootStart(args,vps); |
52 return; | |
53 } | |
54 if (viewer) { | |
55 ViewerInterface v = cui ? new CuiViewer() : new Viewer(); | |
225 | 56 setWidthAndHeight(v); |
301 | 57 // if(filterSingleDisplay) |
266 | 58 if(fixingSizeDisplay) |
257 | 59 setFixingSizeDisplay(v); |
223 | 60 if (treeProxy) { |
343 | 61 if (hostName != null) { |
377 | 62 if (direct) { |
63 rootStart(args, new VncProxyService()); | |
64 } else { | |
65 // send whereToConnect | |
379 | 66 v.startTreeViewer(hostName, cui, addSerialNum); |
377 | 67 } |
343 | 68 } |
223 | 69 // this viewer also works as tree root ( display mode -d flag ) |
70 // start with no connection waiting server change request | |
71 rootStart(args, v); | |
72 } else { | |
379 | 73 v.startTreeViewer(hostName,cui, addSerialNum); |
399
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
74 |
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
379
diff
changeset
|
75 // selected "Start as TreeVNC Root" for start selection panel |
400
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
76 if (v.getRfb().getConnectionParam().isRootMode()) { |
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
77 noConnection = true; |
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
78 rootStart(args, v); |
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
79 } |
223 | 80 } |
81 } | |
82 } | |
34 | 83 |
293 | 84 public void rootStart(String[] args, ViewerInterface v) throws SocketException, UnknownHostException { |
219 | 85 v.setNoConnection(noConnection); // should we accept host name here? |
377 | 86 v.proxyStart(args, hostName, width, height, showTree, checkDelay, addSerialNum, fixingSizeDisplay, filterSingleDisplay); |
219 | 87 v.getRfb().setHasViewer(viewer); |
343 | 88 if (!permitChangeScreen) v.getRfb().setPermitChangeScreen(false); |
219 | 89 v.getRfb().getAcceptThread().waitForShutdown(); |
90 } | |
91 | |
240 | 92 private void modeSelect(String[] args) { |
93 viewer = true; // default | |
94 for (int i = 0; i < args.length; i++) { | |
95 if ("-p".equals(args[i]) || "-r".equals(args[i])) { | |
96 // no display. behave as root. | |
97 // relay rfb update to clients. | |
98 treeProxy = true; | |
99 viewer = false; | |
79 | 100 } else if ("-d".equals(args[i])) { |
101 // behave as root with display. | |
102 // use this on main display such as large tv. | |
240 | 103 noConnection = true; |
79 | 104 treeProxy = true; |
105 viewer = true; | |
106 } else if ("--cui".equals(args[i])) { | |
107 // use cui viewer | |
108 cui = true; | |
240 | 109 } else if ("-v".equals(args[i]) || "-c".equals(args[i])) { |
110 // behave as client. | |
111 // open display and connect to some tree node. | |
112 viewer = true; | |
113 } else if ("--version".equals(args[i])) { | |
114 System.out.println("version :" + Viewer.ver()); | |
115 System.exit(0); | |
122
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
89
diff
changeset
|
116 } else if ("-ns".equals(args[i])) { |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
89
diff
changeset
|
117 permitChangeScreen = false; |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
89
diff
changeset
|
118 } else if ("--noScreenChange".equals(args[i])) { |
e2416a246c95
noScreenChange flag on command line ( should be on panel also )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
89
diff
changeset
|
119 permitChangeScreen = false; |
273
5bab82abcc4f
fix --fixSize option name and input option arguments at console.
oc
parents:
271
diff
changeset
|
120 } else if ("--fixSize".equals(args[i])) { |
240 | 121 // retina display too large for TreeVNC. |
122 // restrict display size. | |
273
5bab82abcc4f
fix --fixSize option name and input option arguments at console.
oc
parents:
271
diff
changeset
|
123 fixingSizeWidth = Integer.parseInt(args[++i]); |
5bab82abcc4f
fix --fixSize option name and input option arguments at console.
oc
parents:
271
diff
changeset
|
124 fixingSizeHeight = Integer.parseInt(args[++i]); |
257 | 125 fixingSizeDisplay = true; |
267 | 126 } else if ("--filterSingleDisplay".equals(args[i])) { |
266 | 127 // retina display too large for TreeVNC. |
128 // restrict display size. | |
267 | 129 filterSingleDisplay = true; |
240 | 130 } else if ("--width".equals(args[i])) { |
131 width = Integer.parseInt(args[i+1]); | |
132 i++; | |
133 } else if ("--height".equals(args[i])) { | |
134 height = Integer.parseInt(args[i+1]); | |
135 i++; | |
136 } else if ("--host".equals(args[i])) { | |
137 hostName = args[++i]; | |
339
4713559f5838
if have a parent, send serverChangeRequest and whereToConnect
oc
parents:
301
diff
changeset
|
138 treeProxy = true; |
377 | 139 } else if ("--direct".equals(args[i])) { |
140 // direct connect without whereToConnect message | |
141 // use is --host | |
142 direct = true; | |
240 | 143 } else if ("--showTree".equals(args[i])) { |
144 // show Tree node. | |
145 showTree = true; | |
146 } else if ("--checkDelay".equals(args[i])) { | |
241 | 147 // check flow of data delay. |
240 | 148 checkDelay = true; |
241 | 149 } else if ("--addSerialNum".equals(args[i])) { |
150 // add data serial number. | |
151 addSerialNum = true; | |
261 | 152 } else if ("--logFile".equals(args[i])) { |
153 // add log file. | |
154 logFile = true; | |
155 try { | |
156 this.logFileName = args[++i]; | |
157 } catch (ArrayIndexOutOfBoundsException e) { | |
271 | 158 // not input file name. |
261 | 159 System.out.println("Please put the log file name. If you do not put file name, set file name logFile.txt"); |
160 } | |
161 if (logFileName == null) { | |
162 logFileName = "logFile"; | |
163 } else if ("-".equals(logFileName.substring(0,1))) { | |
271 | 164 // not input file name. |
165 // to continue to add option. | |
261 | 166 System.out.println("Please put the log file name. If you do not put file name, set file name logFile.txt"); |
167 logFileName = "logFile"; | |
168 i++; | |
169 } else { | |
170 i++; | |
171 } | |
240 | 172 } else { |
173 System.out.println("(default) TreeVNCClient\n" | |
271 | 174 + "-v or -c: View shared screen.\n" |
175 + "-p: (proxy) Share my screen and behave as tree root.\n" | |
176 + "-ns --noScreenChange: Viewers cannot change screen to thiers (default permite screen change)\n" | |
177 + "-d: Show shared screen and behave as tree root.\n" | |
178 + "-r: Connect to fix to specified host and port.\n" | |
179 + "--host hostname: Set host name.\n" | |
180 + "--retina: Limit screen size for very large display.\n" | |
181 + "--width w: Set display width.\n" | |
182 + "--height h: Set display height.\n" | |
183 + "--showTree: Show connected tree node.\n" | |
184 + "--checkDelay: Check speed flow of data each node.\n" | |
185 + "--logFile logFileName: Set log file name.\n" | |
186 + "--filterSingleDisplay: Share single display (case of use multi display).\n" | |
187 + "--fixingSize w h: Fix share screen size.\n" | |
188 + "--addSerialNum: Check lost data.\n"); | |
376 | 189 System.exit(0); |
240 | 190 } |
191 } | |
192 } | |
71
36e116795e0c
option -d mode is behave as root with display. use this on main display such as large tv.
one
parents:
65
diff
changeset
|
193 |
225 | 194 public void setWidthAndHeight(ViewerInterface v) { |
195 if(width != 0 || height != 0) { | |
196 v.setWidth(width); | |
197 v.setHeight(height); | |
198 } | |
257 | 199 } |
200 | |
201 public void setFixingSizeDisplay(ViewerInterface v) { | |
202 v.setFixingSize(fixingSizeWidth, fixingSizeHeight); | |
203 } | |
71
36e116795e0c
option -d mode is behave as root with display. use this on main display such as large tv.
one
parents:
65
diff
changeset
|
204 |
240 | 205 private boolean isInteger(String num) { |
206 try { | |
207 Integer.parseInt(num); | |
208 return true; | |
209 } catch (NumberFormatException e) { | |
210 return false; | |
211 } | |
212 } | |
34 | 213 } |