Mercurial > hg > Applications > TreeVNC
annotate src/viewer_swing/java/com/glavsoft/viewer/Viewer.java @ 457:effba48b76f3
Fix position
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 22 Jun 2016 19:52:32 +0900 |
parents | 34277b436cac |
children | 4ea47640942a |
rev | line source |
---|---|
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC. |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 // All rights reserved. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is part of the TightVNC software. Please visit our Web site: |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 // http://www.tightvnc.com/ |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 // This program is free software; you can redistribute it and/or modify |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // it under the terms of the GNU General Public License as published by |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // the Free Software Foundation; either version 2 of the License, or |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 // (at your option) any later version. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 // This program is distributed in the hope that it will be useful, |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 // GNU General Public License for more details. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 // You should have received a copy of the GNU General Public License along |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 // with this program; if not, write to the Free Software Foundation, Inc., |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 package com.glavsoft.viewer; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 import com.glavsoft.rfb.protocol.ProtocolSettings; |
383 | 28 import com.glavsoft.transport.Reader; |
29 import com.glavsoft.transport.Writer; | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 import com.glavsoft.viewer.cli.Parser; |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
31 import com.glavsoft.viewer.swing.ConnectionParams; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
32 import com.glavsoft.viewer.swing.ParametersHandler; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
33 import com.glavsoft.viewer.swing.SwingViewerWindow; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
34 import jp.ac.u_ryukyu.treevnc.CreateConnectionParam; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
35 import jp.ac.u_ryukyu.treevnc.TreeRFBProto; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 import javax.swing.*; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 import java.awt.*; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
39 import java.awt.event.WindowEvent; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
40 import java.awt.event.WindowListener; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 import java.io.IOException; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 import java.io.InputStream; |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
43 import java.lang.reflect.Field; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 import java.net.Socket; |
301 | 45 import java.util.ArrayList; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 import java.util.jar.Attributes; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 import java.util.jar.Manifest; |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
48 import java.util.logging.ConsoleHandler; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
49 import java.util.logging.Handler; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
50 import java.util.logging.Level; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
51 import java.util.logging.Logger; |
32 | 52 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 @SuppressWarnings("serial") |
179 | 54 public class Viewer extends JApplet implements Runnable, WindowListener , ViewerInterface { |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55 |
224 | 56 private Logger logger; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
57 public int paramsMask; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
58 public boolean allowAppletInteractiveConnections; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 |
60 | 60 public final ConnectionParams connectionParams; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
61 public String passwordFromParams; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
62 public boolean isSeparateFrame = true; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
63 public boolean isApplet = true; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
64 public final ProtocolSettings settings; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
65 public UiSettings uiSettings; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
66 private volatile boolean isAppletStopped = false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
67 private ConnectionPresenter connectionPresenter; |
65 | 68 boolean isTreeVNC = false; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
69 public TreeRFBProto myRfb; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
70 public boolean noConnection; |
175 | 71 public int vncport = ConnectionParams.DEFAULT_RFB_PORT; |
72 private int fbWidth; | |
224 | 73 private boolean showTree = false; |
225 | 74 public int width; |
75 public int height; | |
257 | 76 public int fixingSizeWidth; |
77 public int fixingSizeHeight; | |
139 | 78 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
79 public static void main(String[] args) { |
224 | 80 Parser parser = new Parser(); |
81 ParametersHandler.completeParserOptions(parser); | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 |
224 | 83 parser.parse(args); |
84 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
85 printUsage(parser.optionsUsage()); | |
86 System.exit(0); | |
87 } | |
88 Viewer viewer = new Viewer(parser); | |
89 SwingUtilities.invokeLater(viewer); | |
90 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
91 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
92 public static void printUsage(String additional) { |
224 | 93 System.out.println("Usage: java -jar (progfilename) [hostname [port_number]] [Options]Â¥n" + |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
94 " or¥n" + |
224 | 95 " java -jar (progfilename) [Options]Â¥n" + |
96 " or¥n java -jar (progfilename) -help¥n to view this help¥n¥n" + | |
97 "Where Options are:Â¥n" + additional + | |
98 "¥nOptions format: -optionName=optionValue. Ex. -host=localhost -port=5900 -viewonly=yes¥n" + | |
99 "Both option name and option value are case insensitive."); | |
100 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
101 |
224 | 102 public Viewer() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
103 logger = Logger.getLogger(getClass().getName()); |
224 | 104 connectionParams = new ConnectionParams(); |
105 settings = ProtocolSettings.getDefaultSettings(); | |
106 uiSettings = new UiSettings(); | |
107 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 |
224 | 109 private Viewer(Parser parser) { |
110 this(); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
111 setLoggingLevel(parser.isSet(ParametersHandler.ARG_VERBOSE) ? Level.FINE : |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
112 parser.isSet(ParametersHandler.ARG_VERBOSE_MORE) ? Level.FINER : |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
113 Level.INFO); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
114 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
115 paramsMask = ParametersHandler.completeSettingsFromCLI(parser, connectionParams, settings, uiSettings); |
224 | 116 passwordFromParams = parser.getValueFor(ParametersHandler.ARG_PASSWORD); |
117 logger.info("TightVNC Viewer version " + ver()); | |
118 isApplet = false; | |
119 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
121 private void setLoggingLevel(Level levelToSet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
122 final Logger appLogger = Logger.getLogger("com.glavsoft"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
123 appLogger.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
124 ConsoleHandler ch = null; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
125 for (Handler h : appLogger.getHandlers()) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
126 if (h instanceof ConsoleHandler) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
127 ch = (ConsoleHandler) h; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
128 break; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
129 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
130 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
131 if (null == ch) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
132 ch = new ConsoleHandler(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
133 appLogger.addHandler(ch); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
134 } |
224 | 135 // ch.setFormatter(new SimpleFormatter()); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
136 ch.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
137 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
140 @Override |
224 | 141 public void windowClosing(WindowEvent e) { |
142 if (e != null && e.getComponent() != null) { | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
143 final Window w = e.getWindow(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
144 if (w != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
145 w.setVisible(false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
146 w.dispose(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
147 } |
224 | 148 } |
149 closeApp(); | |
150 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 |
224 | 152 /** |
153 * Closes App(lication) or stops App(let). | |
154 */ | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
155 public void closeApp() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
156 if (connectionPresenter != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
157 connectionPresenter.cancelConnection(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
158 logger.info("Connections cancelled."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
159 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
160 if (isApplet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
161 if ( ! isAppletStopped) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
162 logger.severe("Applet is stopped."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
163 isAppletStopped = true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
164 repaint(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
165 stop(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
166 } |
224 | 167 } else { |
168 System.exit(0); | |
169 } | |
170 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 |
224 | 172 @Override |
173 public void paint(Graphics g) { | |
174 if ( ! isAppletStopped) { | |
175 super.paint(g); | |
176 } else { | |
177 getContentPane().removeAll(); | |
178 g.clearRect(0, 0, getWidth(), getHeight()); | |
179 g.drawString("Disconnected", 10, 20); | |
180 } | |
181 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 |
224 | 183 @Override |
184 public void destroy() { | |
185 closeApp(); | |
186 super.destroy(); | |
187 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 |
224 | 189 @Override |
190 public void init() { | |
191 paramsMask = ParametersHandler.completeSettingsFromApplet(this, connectionParams, settings, uiSettings); | |
192 isSeparateFrame = ParametersHandler.isSeparateFrame; | |
193 passwordFromParams = getParameter(ParametersHandler.ARG_PASSWORD); | |
194 isApplet = true; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
195 allowAppletInteractiveConnections = ParametersHandler.allowAppletInteractiveConnections; |
224 | 196 repaint(); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
197 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
198 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
199 SwingUtilities.invokeAndWait(this); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
200 } catch (Exception e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
201 logger.severe(e.getMessage()); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
202 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
203 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 |
224 | 205 @Override |
206 public void start() { | |
207 super.start(); | |
208 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
210 public boolean checkJsch() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
211 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
212 Class.forName("com.jcraft.jsch.JSch"); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
213 return true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
214 } catch (ClassNotFoundException e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
215 return false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
216 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
217 } |
224 | 218 |
85 | 219 public void setNoConnection(boolean c){ |
224 | 220 noConnection = c; |
85 | 221 } |
224 | 222 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
223 @Override |
224 | 224 public void run() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
225 final boolean hasJsch = checkJsch(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
226 final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
227 connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); |
85 | 228 connectionPresenter.setNoConnection(noConnection); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
229 connectionPresenter.addModel("ConnectionParamsModel", connectionParams); |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
230 connectionPresenter.startVNCConnection(this, false, null, null); |
224 | 231 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
232 |
224 | 233 @Override |
370 | 234 public ConnectionPresenter getConnectionPresenter() { |
235 return connectionPresenter; | |
363 | 236 } |
237 | |
238 @Override | |
370 | 239 public void setConnectionPresenter(ConnectionPresenter connectionPresenter) { |
240 this.connectionPresenter = connectionPresenter; | |
369 | 241 } |
242 | |
243 @Override | |
224 | 244 public void windowOpened(WindowEvent e) { /* nop */ } |
245 @Override | |
246 public void windowClosed(WindowEvent e) { /* nop */ } | |
247 @Override | |
248 public void windowIconified(WindowEvent e) { /* nop */ } | |
249 @Override | |
250 public void windowDeiconified(WindowEvent e) { /* nop */ } | |
251 @Override | |
252 public void windowActivated(WindowEvent e) { /* nop */ } | |
253 @Override | |
254 public void windowDeactivated(WindowEvent e) { /* nop */ } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
255 |
224 | 256 public static String ver() { |
257 final InputStream mfStream = Viewer.class.getClassLoader().getResourceAsStream( | |
258 "META-INF/MANIFEST.MF"); | |
259 if (null == mfStream) { | |
260 System.out.println("No Manifest file found."); | |
261 return "-1"; | |
262 } | |
263 try { | |
264 Manifest mf = new Manifest(); | |
265 mf.read(mfStream); | |
266 Attributes atts = mf.getMainAttributes(); | |
267 return atts.getValue(Attributes.Name.IMPLEMENTATION_VERSION); | |
268 } catch (IOException e) { | |
269 return "-2"; | |
270 } | |
271 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
272 |
59 | 273 |
224 | 274 public void setSocket(Socket soc) { |
275 connectionParams.setConnectionParam(soc.getInetAddress().getHostAddress(),soc.getPort()); | |
276 } | |
59 | 277 |
224 | 278 public void setOpenPort(int parseInt) { |
279 } | |
59 | 280 |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
281 public void setTerminationType(boolean b) { |
224 | 282 myRfb.setTerminationType(b); |
283 } | |
284 | |
285 /** | |
174 | 286 * Start client with new parent (including reconnection) |
287 * @param port | |
288 * @param hostname | |
289 * @throws IOException | |
290 */ | |
224 | 291 @Override |
334 | 292 public void connectToParenet(int port, String hostname) throws IOException { |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
293 setTerminationType(false); |
174 | 294 closeApp(); |
179 | 295 connectionParams.setConnectionParam(hostname, port); |
174 | 296 run(); |
297 } | |
224 | 298 |
299 public void setIsTreeVNC(boolean flag) { | |
300 isTreeVNC = flag; | |
301 } | |
65 | 302 |
224 | 303 public TreeRFBProto getRfb() { |
304 return myRfb; | |
305 } | |
306 | |
307 public boolean getCuiVersion() { | |
308 return myRfb.getCuiVersion(); | |
309 } | |
310 public void setCuiVersion(boolean flag) { | |
311 myRfb.setCuiVersion(flag); | |
312 } | |
313 | |
377 | 314 public void setVncport(int vncport) { |
315 this.vncport = vncport; | |
316 } | |
317 | |
175 | 318 /** |
319 * start new VNC server receiver with | |
320 * inherited clients | |
321 * @param hostName | |
369 | 322 * @param newVNCServerId |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
323 * @param x |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
324 * @param y |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
325 * @param width |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
326 * @param height |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
327 * @param scale |
175 | 328 */ |
176 | 329 @Override |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
330 public void inhelitClients(String hostName, short newVNCServerId, int x, int y, int width, int height, int scale) { |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
331 final ConnectionPresenter connectionPresenter = createNewConnectionPresenter(hostName, newVNCServerId, x, y, width, height, scale); |
383 | 332 isApplet = true; |
333 this.setNoConnection(false); | |
334 final Viewer v = this; | |
335 new Thread(new Runnable() { | |
336 @Override | |
337 public void run() { | |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
338 connectionPresenter.startVNCConnection(v, false, null, null); |
383 | 339 } |
340 }, "ServerChangeThread").start(); | |
341 } | |
342 | |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
343 public void changeToDirectConnectedServer(String hostName, Reader is, Writer os, int x, int y, int width, int height, int scale) { |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
344 final ConnectionPresenter connectionPresenter = createNewConnectionPresenter(hostName, (short) -1, x, y, width, height, scale); |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
345 connectionPresenter.startVNCConnection(this, true, is, os); |
441 | 346 } |
383 | 347 |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
348 private ConnectionPresenter createNewConnectionPresenter(String hostName, short newVNCServerId, int x, int y, int width, int height, int scale) { |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
349 final boolean hasJsch = checkJsch(); |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
350 final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
351 final ConnectionPresenter connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
352 connectionPresenter.setNoConnection(noConnection); |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
353 ConnectionParams connectionParams = new ConnectionParams(); |
179 | 354 connectionParams.setConnectionParam(hostName, vncport); |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
355 connectionPresenter.addModel("ConnectionParamsModel", connectionParams); |
369 | 356 connectionPresenter.setConnectionParams(connectionParams); |
357 connectionPresenter.setReconnectingId(newVNCServerId); | |
370 | 358 connectionPresenter.setIsTreeVNC(true); |
359 connectionPresenter.setNoConnection(false); | |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
360 connectionPresenter.setX(x); |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
361 connectionPresenter.setY(y); |
454
432e2967eaab
All screen sharing request information is now in ConnectionPresenter only
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
451
diff
changeset
|
362 connectionPresenter.setSingleWidth(width); |
432e2967eaab
All screen sharing request information is now in ConnectionPresenter only
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
451
diff
changeset
|
363 connectionPresenter.setSingleHeight(height); |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
364 connectionPresenter.setRetinaScale(scale); |
383 | 365 return connectionPresenter; |
174 | 366 } |
367 | |
343 | 368 /** |
369 * start TreeVNC viewer | |
370 */ | |
379 | 371 public void startTreeViewer(String hostName, boolean cui, boolean addSerialNum) { |
343 | 372 TreeRFBProto rfb = new TreeRFBProto(false, this); |
373 rfb.setCuiVersion(cui); | |
379 | 374 rfb.setAddSerialNum(addSerialNum); |
343 | 375 rfb.setHasViewer(true); |
376 rfb.createConnectionAndStart(this); | |
377 CreateConnectionParam cp = new CreateConnectionParam(rfb); | |
378 if (hostName!=null) { | |
379 cp.setHostName(hostName); | |
380 } else { | |
381 cp.findTreeVncRoot(); | |
400
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
382 |
401
94c520535ef1
Fix selection panel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
383 // selected "Start Display Mode" or "Start as TreeVNC Root" for start selection panel |
94c520535ef1
Fix selection panel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
384 if (cp.isDisplayMode() || cp.isRootMode()) { |
400
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
385 myRfb = rfb; |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
386 myRfb.setIsTreeManager(true); |
399
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
387 return; |
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
388 } |
343 | 389 } |
390 cp.sendWhereToConnect(this); | |
391 isTreeVNC = true; | |
392 myRfb = rfb; | |
393 settings.setViewOnly(true); // too avoid unnecessary upward traffic | |
394 rfb.getAcceptThread().waitForShutdown(); | |
395 } | |
396 | |
455
6f3d3da40940
fix cui and hasViewer flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
454
diff
changeset
|
397 public void proxyStart(String[] argv, String hostName, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize, boolean filterSingleDisplay, boolean hasViewer) { |
224 | 398 fbWidth = width; |
399 this.showTree = showTree; | |
175 | 400 Parser parser = new Parser(); |
401 ParametersHandler.completeParserOptions(parser); | |
402 if (fbWidth == 0) | |
403 parser.parse(argv); | |
404 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
405 printUsage(parser.optionsUsage()); | |
406 System.exit(0); | |
407 } | |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
408 |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
409 // myRfb is null if use command line option "-d" "-p" |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
410 // myRfb not null if use start panel |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
411 if (myRfb == null) { |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
412 myRfb = new TreeRFBProto(true, this); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
413 } |
455
6f3d3da40940
fix cui and hasViewer flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
454
diff
changeset
|
414 myRfb.setCuiVersion(!hasViewer); |
6f3d3da40940
fix cui and hasViewer flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
454
diff
changeset
|
415 myRfb.setHasViewer(hasViewer); |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
416 myRfb.setShowTree(showTree); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
417 myRfb.setCheckDelay(checkDelay); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
418 myRfb.setAddSerialNum(addSerialNum); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
419 myRfb.setFixingSize(fixingSize); |
266 | 420 if(fixingSize) { |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
421 myRfb.fixingSizeWidth = fixingSizeWidth; |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
422 myRfb.fixingSizeHeight = fixingSizeHeight; |
266 | 423 } |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
424 if (myRfb.getAcceptThread() == null) { |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
425 myRfb.createConnectionAndStart(this); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
426 } else { |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
427 myRfb.startTreeRootFindThread(); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
428 } |
179 | 429 setIsTreeVNC(true); |
377 | 430 if (hostName == null) { |
431 hostName = "localhost"; | |
432 } | |
433 connectionParams.setConnectionParam(hostName, vncport); | |
179 | 434 isApplet = true; |
449
d5bcae14c2cd
reuse FrameUpdateRequest for all code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
448
diff
changeset
|
435 settings.setViewOnly(true); // to avoid unnecessary upward traffic |
179 | 436 run(); |
437 } | |
438 | |
207 | 439 public void initRoot(TreeRFBProto myRfbProto, String hostName) { |
179 | 440 setIsTreeVNC(true); |
441 connectionParams.setConnectionParam(hostName, vncport); | |
442 isApplet = true; | |
443 myRfbProto.createConnectionAndStart(this); | |
444 run(); | |
175 | 445 } |
224 | 446 |
192 | 447 @Override |
448 public void setVisible(boolean b) { | |
366 | 449 if(connectionPresenter == null) return; |
224 | 450 SwingViewerWindow v = connectionPresenter.getViewer(); |
451 if (v != null) | |
452 v.setVisible(b); | |
192 | 453 } |
188 | 454 |
224 | 455 @Override |
456 public Socket getVNCSocket() { | |
457 return connectionPresenter.getSocket(); | |
458 } | |
202 | 459 |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
460 @Override |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
461 public boolean getShowTree() { |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
462 return showTree; |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
463 } |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
464 |
225 | 465 @Override |
466 public void setWidth(int w) { | |
467 width = w; | |
468 } | |
469 | |
470 @Override | |
471 public void setHeight(int h) { | |
472 height = h; | |
473 } | |
474 | |
257 | 475 @Override |
476 public void setFixingSize(int width, int height) { | |
477 this.fixingSizeWidth = width; | |
478 this.fixingSizeHeight = height; | |
479 } | |
301 | 480 |
481 @Override | |
482 public ArrayList<Rectangle> getScreenRectangles() { | |
314 | 483 // New screen server has one or more screens. |
484 // Screens are numbered in the order from left. | |
485 // put screens in an ArrayList. | |
301 | 486 ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>(); |
487 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
488 GraphicsDevice[] gs = ge.getScreenDevices(); | |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
489 |
314 | 490 for (GraphicsDevice gd : gs) { |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
491 int screenNumber = 0; |
314 | 492 for (GraphicsConfiguration r : gd.getConfigurations()) { |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
493 Rectangle rect = r.getBounds(); |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
494 //System.out.println("screen "+ screenNumber +":"+rect); |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
495 rectangles.add(rect); |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
496 screenNumber++; |
301 | 497 } |
498 } | |
499 return rectangles; | |
500 } | |
501 | |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
502 public Point getScreenOffset(ArrayList<Rectangle> rectangles) { |
451
65ffb64cfb51
try to fix scroll y in fitScreen
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
449
diff
changeset
|
503 // position of screen may negative, but RFBscreen position is always positive |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
504 // compute offset to make them positive |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
505 int offsetx = 0; |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
506 int offsety = 0; |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
507 int screenNumber = 0; |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
508 for (Rectangle rect : rectangles) { |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
509 int scale = retinaScale(screenNumber); |
457 | 510 int x = rect.x == -rect.width ? rect.x * scale : rect.x; |
511 int y = rect.y == -rect.height ? rect.y * scale : rect.y; | |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
512 if (x < offsetx) offsetx = x; |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
513 if (y < offsety) offsety = y; |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
514 screenNumber++; |
448
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
515 } |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
516 return new Point(-offsetx,-offsety); |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
517 } |
344a35b7c47f
send both frame buffer size and selected screen size in Disktop size change (INIT_DATA)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
518 |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
519 public int retinaScale(int shareScreenNumber) { |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
520 int scale = 1; |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
521 GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
522 final GraphicsDevice[] devices = env.getScreenDevices(); |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
523 |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
524 try { |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
525 Field field = devices[shareScreenNumber].getClass().getDeclaredField("scale"); |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
526 |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
527 if (field != null) { |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
528 field.setAccessible(true); |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
529 Object retinaScale = field.get(devices[shareScreenNumber]); |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
530 |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
531 if (retinaScale instanceof Integer) { |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
532 scale = (Integer) retinaScale; |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
533 return scale; |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
534 } |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
535 } |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
536 } catch (Exception ignore) {} |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
537 return scale; |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
538 } |
363 | 539 |
317 | 540 @Override |
541 public void setFitScreen() { | |
542 SwingViewerWindow v = connectionPresenter.getViewer(); | |
543 if (v != null) { | |
441 | 544 v.fitScreen(); |
317 | 545 } |
546 } | |
547 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
548 } |