Mercurial > hg > Applications > TreeVNC
annotate src/viewer_swing/java/com/glavsoft/viewer/Viewer.java @ 630:7071b01621c2 default tip
Determine ipv4 or ipv6 and fix scond display
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 28 Apr 2020 19:49:38 +0900 |
parents | c67f0f6eae90 |
children |
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; |
514 | 34 import jp.ac.u_ryukyu.treevnc.BroadcastRFBListener; |
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
|
35 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
|
36 import jp.ac.u_ryukyu.treevnc.TreeRFBProto; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 import javax.swing.*; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 import java.awt.*; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
40 import java.awt.event.WindowEvent; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
41 import java.awt.event.WindowListener; |
626
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
42 import java.awt.geom.AffineTransform; |
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
43 import java.awt.geom.Point2D; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 import java.io.IOException; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 import java.io.InputStream; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 import java.net.Socket; |
301 | 47 import java.util.ArrayList; |
458 | 48 import java.util.Comparator; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 import java.util.jar.Attributes; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 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
|
51 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
|
52 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
|
53 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
|
54 import java.util.logging.Logger; |
32 | 55 |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
56 @SuppressWarnings("serial") |
179 | 57 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
|
58 |
224 | 59 private Logger logger; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
60 public int paramsMask; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
61 public boolean allowAppletInteractiveConnections; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
62 |
60 | 63 public final ConnectionParams connectionParams; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
64 public String passwordFromParams; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
65 public boolean isSeparateFrame = true; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
66 public boolean isApplet = true; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
67 public final ProtocolSettings settings; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
68 public UiSettings uiSettings; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
69 private volatile boolean isAppletStopped = false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
70 private ConnectionPresenter connectionPresenter; |
65 | 71 boolean isTreeVNC = false; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
72 public TreeRFBProto myRfb; |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
73 public boolean noConnection; |
175 | 74 public int vncport = ConnectionParams.DEFAULT_RFB_PORT; |
75 private int fbWidth; | |
224 | 76 private boolean showTree = false; |
225 | 77 public int width; |
78 public int height; | |
257 | 79 public int fixingSizeWidth; |
80 public int fixingSizeHeight; | |
512 | 81 private boolean useMulticast; |
514 | 82 static public BroadcastRFBListener broadcastRFBListener = new BroadcastRFBListener(); |
139 | 83 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
84 public static void main(String[] args) { |
224 | 85 Parser parser = new Parser(); |
86 ParametersHandler.completeParserOptions(parser); | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 |
224 | 88 parser.parse(args); |
89 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
90 printUsage(parser.optionsUsage()); | |
91 System.exit(0); | |
92 } | |
93 Viewer viewer = new Viewer(parser); | |
94 SwingUtilities.invokeLater(viewer); | |
95 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
96 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
97 public static void printUsage(String additional) { |
224 | 98 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
|
99 " or¥n" + |
224 | 100 " java -jar (progfilename) [Options]Â¥n" + |
101 " or¥n java -jar (progfilename) -help¥n to view this help¥n¥n" + | |
102 "Where Options are:Â¥n" + additional + | |
103 "¥nOptions format: -optionName=optionValue. Ex. -host=localhost -port=5900 -viewonly=yes¥n" + | |
104 "Both option name and option value are case insensitive."); | |
105 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 |
224 | 107 public Viewer() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
108 logger = Logger.getLogger(getClass().getName()); |
224 | 109 connectionParams = new ConnectionParams(); |
110 settings = ProtocolSettings.getDefaultSettings(); | |
111 uiSettings = new UiSettings(); | |
112 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 |
224 | 114 private Viewer(Parser parser) { |
115 this(); | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
116 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
|
117 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
|
118 Level.INFO); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
119 |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
120 paramsMask = ParametersHandler.completeSettingsFromCLI(parser, connectionParams, settings, uiSettings); |
224 | 121 passwordFromParams = parser.getValueFor(ParametersHandler.ARG_PASSWORD); |
122 logger.info("TightVNC Viewer version " + ver()); | |
123 isApplet = false; | |
124 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
126 private void setLoggingLevel(Level levelToSet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
127 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
|
128 appLogger.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
129 ConsoleHandler ch = null; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
130 for (Handler h : appLogger.getHandlers()) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
131 if (h instanceof ConsoleHandler) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
132 ch = (ConsoleHandler) h; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
133 break; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
134 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
135 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
136 if (null == ch) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
137 ch = new ConsoleHandler(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
138 appLogger.addHandler(ch); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
139 } |
224 | 140 // ch.setFormatter(new SimpleFormatter()); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
141 ch.setLevel(levelToSet); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
142 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
145 @Override |
224 | 146 public void windowClosing(WindowEvent e) { |
147 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
|
148 final Window w = e.getWindow(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
149 if (w != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
150 w.setVisible(false); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
151 w.dispose(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
152 } |
224 | 153 } |
154 closeApp(); | |
155 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156 |
224 | 157 /** |
158 * Closes App(lication) or stops App(let). | |
159 */ | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
160 public void closeApp() { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
161 if (connectionPresenter != null) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
162 connectionPresenter.cancelConnection(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
163 logger.info("Connections cancelled."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
164 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
165 if (isApplet) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
166 if ( ! isAppletStopped) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
167 logger.severe("Applet is stopped."); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
168 isAppletStopped = true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
169 repaint(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
170 stop(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
171 } |
224 | 172 } else { |
173 System.exit(0); | |
174 } | |
175 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 |
224 | 177 @Override |
178 public void paint(Graphics g) { | |
179 if ( ! isAppletStopped) { | |
180 super.paint(g); | |
181 } else { | |
182 getContentPane().removeAll(); | |
183 g.clearRect(0, 0, getWidth(), getHeight()); | |
184 g.drawString("Disconnected", 10, 20); | |
185 } | |
186 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 |
224 | 188 @Override |
189 public void destroy() { | |
190 closeApp(); | |
191 super.destroy(); | |
192 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 |
224 | 194 @Override |
195 public void init() { | |
196 paramsMask = ParametersHandler.completeSettingsFromApplet(this, connectionParams, settings, uiSettings); | |
197 isSeparateFrame = ParametersHandler.isSeparateFrame; | |
198 passwordFromParams = getParameter(ParametersHandler.ARG_PASSWORD); | |
199 isApplet = true; | |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
200 allowAppletInteractiveConnections = ParametersHandler.allowAppletInteractiveConnections; |
224 | 201 repaint(); |
57
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 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
204 SwingUtilities.invokeAndWait(this); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
205 } catch (Exception e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
206 logger.severe(e.getMessage()); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
207 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
208 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 |
224 | 210 @Override |
211 public void start() { | |
212 super.start(); | |
213 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
215 public boolean checkJsch() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
216 try { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
217 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
|
218 return true; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
219 } catch (ClassNotFoundException e) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
220 return false; |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
221 } |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
222 } |
224 | 223 |
85 | 224 public void setNoConnection(boolean c){ |
224 | 225 noConnection = c; |
85 | 226 } |
224 | 227 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
228 @Override |
224 | 229 public void run() { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
230 final boolean hasJsch = checkJsch(); |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
231 final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
232 connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive); |
540 | 233 connectionPresenter.setIsTreeVNC(isTreeVNC); |
512 | 234 connectionPresenter.setMulticast(useMulticast); |
488 | 235 connectionPresenter.setReconnectingId(myRfb.getId()); |
85 | 236 connectionPresenter.setNoConnection(noConnection); |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
237 connectionPresenter.addModel("ConnectionParamsModel", connectionParams); |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
238 connectionPresenter.startVNCConnection(this, false, null, null); |
224 | 239 } |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 |
224 | 241 @Override |
370 | 242 public ConnectionPresenter getConnectionPresenter() { |
243 return connectionPresenter; | |
363 | 244 } |
245 | |
246 @Override | |
370 | 247 public void setConnectionPresenter(ConnectionPresenter connectionPresenter) { |
248 this.connectionPresenter = connectionPresenter; | |
369 | 249 } |
250 | |
251 @Override | |
224 | 252 public void windowOpened(WindowEvent e) { /* nop */ } |
253 @Override | |
254 public void windowClosed(WindowEvent e) { /* nop */ } | |
255 @Override | |
256 public void windowIconified(WindowEvent e) { /* nop */ } | |
257 @Override | |
258 public void windowDeiconified(WindowEvent e) { /* nop */ } | |
259 @Override | |
260 public void windowActivated(WindowEvent e) { /* nop */ } | |
261 @Override | |
262 public void windowDeactivated(WindowEvent e) { /* nop */ } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
263 |
224 | 264 public static String ver() { |
265 final InputStream mfStream = Viewer.class.getClassLoader().getResourceAsStream( | |
266 "META-INF/MANIFEST.MF"); | |
267 if (null == mfStream) { | |
268 System.out.println("No Manifest file found."); | |
269 return "-1"; | |
270 } | |
271 try { | |
272 Manifest mf = new Manifest(); | |
273 mf.read(mfStream); | |
274 Attributes atts = mf.getMainAttributes(); | |
275 return atts.getValue(Attributes.Name.IMPLEMENTATION_VERSION); | |
276 } catch (IOException e) { | |
277 return "-2"; | |
278 } | |
279 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280 |
59 | 281 |
224 | 282 public void setSocket(Socket soc) { |
283 connectionParams.setConnectionParam(soc.getInetAddress().getHostAddress(),soc.getPort()); | |
284 } | |
59 | 285 |
224 | 286 public void setOpenPort(int parseInt) { |
287 } | |
59 | 288 |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
289 public void setTerminationType(boolean b) { |
224 | 290 myRfb.setTerminationType(b); |
291 } | |
292 | |
293 /** | |
174 | 294 * Start client with new parent (including reconnection) |
295 * @param port | |
296 * @param hostname | |
297 * @throws IOException | |
298 */ | |
224 | 299 @Override |
334 | 300 public void connectToParenet(int port, String hostname) throws IOException { |
328
1a2ab6bd5ba3
add function lost child node, remove deadChild nodeList.
oc
parents:
327
diff
changeset
|
301 setTerminationType(false); |
174 | 302 closeApp(); |
179 | 303 connectionParams.setConnectionParam(hostname, port); |
174 | 304 run(); |
305 } | |
224 | 306 |
307 public void setIsTreeVNC(boolean flag) { | |
308 isTreeVNC = flag; | |
309 } | |
65 | 310 |
224 | 311 public TreeRFBProto getRfb() { |
312 return myRfb; | |
313 } | |
314 | |
315 public boolean getCuiVersion() { | |
316 return myRfb.getCuiVersion(); | |
317 } | |
318 public void setCuiVersion(boolean flag) { | |
319 myRfb.setCuiVersion(flag); | |
320 } | |
321 | |
377 | 322 public void setVncport(int vncport) { |
323 this.vncport = vncport; | |
324 } | |
325 | |
175 | 326 /** |
327 * start new VNC server receiver with | |
328 * inherited clients | |
329 * @param hostName | |
369 | 330 * @param newVNCServerId |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
331 * @param x |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
332 * @param y |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
333 * @param width |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
334 * @param height |
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
335 * @param scale |
175 | 336 */ |
176 | 337 @Override |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
338 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
|
339 final ConnectionPresenter connectionPresenter = createNewConnectionPresenter(hostName, newVNCServerId, x, y, width, height, scale); |
383 | 340 isApplet = true; |
341 this.setNoConnection(false); | |
342 final Viewer v = this; | |
343 new Thread(new Runnable() { | |
344 @Override | |
345 public void run() { | |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
346 connectionPresenter.startVNCConnection(v, false, null, null); |
383 | 347 } |
348 }, "ServerChangeThread").start(); | |
349 } | |
350 | |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
351 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
|
352 final ConnectionPresenter connectionPresenter = createNewConnectionPresenter(hostName, (short) -1, x, y, width, height, scale); |
395
704ac9e79e25
Call startVNCConnectionWithSocket for directedServerChangeReqeust
innparusu
parents:
383
diff
changeset
|
353 connectionPresenter.startVNCConnection(this, true, is, os); |
441 | 354 } |
383 | 355 |
512 | 356 @Override |
357 public void setUseMulticast(boolean useMulticast) { | |
358 this.useMulticast = useMulticast; | |
359 } | |
360 | |
361 @Override | |
362 public boolean getUseMulticast() { | |
363 return useMulticast; | |
364 } | |
365 | |
514 | 366 @Override |
367 public BroadcastRFBListener getRfbBroadcastListener() { | |
368 return broadcastRFBListener; | |
369 } | |
370 | |
551
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
371 @Override |
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
372 public boolean getIsRetinaDisplay(int shareScreenNumber) { |
626
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
373 AffineTransform defaultTransform = getAffineTransform(shareScreenNumber); |
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
374 return ! defaultTransform.isIdentity(); |
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
375 } |
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
376 |
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
377 private AffineTransform getAffineTransform(int shareScreenNumber) { |
551
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
378 GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
379 final GraphicsDevice[] devices = env.getScreenDevices(); |
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
380 GraphicsConfiguration conf = devices[shareScreenNumber].getDefaultConfiguration(); |
626
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
381 return conf.getDefaultTransform(); |
551
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
382 } |
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
383 |
428
f6a828dd37b0
Change timing for setting share screen info
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
427
diff
changeset
|
384 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
|
385 final boolean hasJsch = checkJsch(); |
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
386 final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet; |
506 | 387 final ConnectionPresenter connectionPresenter1 = new ConnectionPresenter(hasJsch, allowInteractive); |
368
b60780e1fafc
Add ServerChangeThread to inhelitClients method
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
366
diff
changeset
|
388 ConnectionParams connectionParams = new ConnectionParams(); |
179 | 389 connectionParams.setConnectionParam(hostName, vncport); |
506 | 390 connectionPresenter1.addModel("ConnectionParamsModel", connectionParams); |
391 connectionPresenter1.setConnectionParams(connectionParams); | |
392 connectionPresenter1.setReconnectingId(newVNCServerId); | |
393 connectionPresenter1.setIsTreeVNC(true); | |
394 connectionPresenter1.setNoConnection(false); | |
395 connectionPresenter1.setX(x); | |
396 connectionPresenter1.setY(y); | |
397 connectionPresenter1.setSingleWidth(width); | |
398 connectionPresenter1.setSingleHeight(height); | |
399 connectionPresenter1.setRetinaScale(scale); | |
562
87ae979b88cd
-p mode use ScreenSelectionPanel. Blocking is not working yet, but we can debug it in -p mode.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
551
diff
changeset
|
400 connectionPresenter1.setMulticast(myRfb.multicastBlocking); |
460 | 401 // System.out.println("Sarver change accepted from id :" + newVNCServerId); |
513 | 402 return connectionPresenter1; |
174 | 403 } |
404 | |
343 | 405 /** |
406 * start TreeVNC viewer | |
407 */ | |
379 | 408 public void startTreeViewer(String hostName, boolean cui, boolean addSerialNum) { |
343 | 409 TreeRFBProto rfb = new TreeRFBProto(false, this); |
410 rfb.setCuiVersion(cui); | |
379 | 411 rfb.setAddSerialNum(addSerialNum); |
343 | 412 rfb.setHasViewer(true); |
413 rfb.createConnectionAndStart(this); | |
414 CreateConnectionParam cp = new CreateConnectionParam(rfb); | |
415 if (hostName!=null) { | |
416 cp.setHostName(hostName); | |
417 } else { | |
604 | 418 findTreeVncRoot(rfb,cp); |
401
94c520535ef1
Fix selection panel
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
400
diff
changeset
|
419 // 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
|
420 if (cp.isDisplayMode() || cp.isRootMode()) { |
400
845698fd6fb6
Remove synchronized
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
399
diff
changeset
|
421 myRfb = rfb; |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
422 myRfb.setIsTreeManager(true); |
399
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
423 return; |
28d67bbfa9f1
Implement SelectionPanel processing
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
424 } |
343 | 425 } |
488 | 426 |
427 if (rfb.isTreeManager()) { | |
428 rfb.setId((short) rfb.getNewNodeId()); | |
429 } | |
343 | 430 cp.sendWhereToConnect(this); |
431 isTreeVNC = true; | |
432 myRfb = rfb; | |
433 settings.setViewOnly(true); // too avoid unnecessary upward traffic | |
434 rfb.getAcceptThread().waitForShutdown(); | |
435 } | |
436 | |
566 | 437 public void proxyStart(String[] argv, String hostName, int width, int height, boolean showTree, boolean checkDelay, boolean addSerialNum, boolean fixingSize, boolean filterSingleDisplay, boolean hasViewer, boolean connect) { |
224 | 438 fbWidth = width; |
439 this.showTree = showTree; | |
175 | 440 Parser parser = new Parser(); |
441 ParametersHandler.completeParserOptions(parser); | |
442 if (fbWidth == 0) | |
443 parser.parse(argv); | |
444 if (parser.isSet(ParametersHandler.ARG_HELP)) { | |
445 printUsage(parser.optionsUsage()); | |
446 System.exit(0); | |
447 } | |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
448 |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
449 // 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
|
450 // myRfb not null if use start panel |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
451 if (myRfb == null) { |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
452 myRfb = new TreeRFBProto(true, this); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
453 } |
455
6f3d3da40940
fix cui and hasViewer flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
454
diff
changeset
|
454 myRfb.setCuiVersion(!hasViewer); |
6f3d3da40940
fix cui and hasViewer flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
454
diff
changeset
|
455 myRfb.setHasViewer(hasViewer); |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
456 myRfb.setShowTree(showTree); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
457 myRfb.setCheckDelay(checkDelay); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
458 myRfb.setAddSerialNum(addSerialNum); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
459 myRfb.setFixingSize(fixingSize); |
266 | 460 if(fixingSize) { |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
461 myRfb.fixingSizeWidth = fixingSizeWidth; |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
462 myRfb.fixingSizeHeight = fixingSizeHeight; |
266 | 463 } |
402
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
464 if (myRfb.getAcceptThread() == null) { |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
465 myRfb.createConnectionAndStart(this); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
466 } else { |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
467 myRfb.startTreeRootFindThread(); |
73c96a1d4a3a
Fix wasteful thread start
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
401
diff
changeset
|
468 } |
179 | 469 setIsTreeVNC(true); |
377 | 470 if (hostName == null) { |
471 hostName = "localhost"; | |
472 } | |
473 connectionParams.setConnectionParam(hostName, vncport); | |
179 | 474 isApplet = true; |
449
d5bcae14c2cd
reuse FrameUpdateRequest for all code
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
448
diff
changeset
|
475 settings.setViewOnly(true); // to avoid unnecessary upward traffic |
566 | 476 if (connect) |
477 createScreenSelectionPanel(null); | |
562
87ae979b88cd
-p mode use ScreenSelectionPanel. Blocking is not working yet, but we can debug it in -p mode.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
551
diff
changeset
|
478 myRfb.getAcceptThread().waitForShutdown(); |
179 | 479 } |
480 | |
207 | 481 public void initRoot(TreeRFBProto myRfbProto, String hostName) { |
179 | 482 setIsTreeVNC(true); |
483 connectionParams.setConnectionParam(hostName, vncport); | |
484 isApplet = true; | |
485 myRfbProto.createConnectionAndStart(this); | |
486 run(); | |
175 | 487 } |
224 | 488 |
192 | 489 @Override |
490 public void setVisible(boolean b) { | |
366 | 491 if(connectionPresenter == null) return; |
224 | 492 SwingViewerWindow v = connectionPresenter.getViewer(); |
493 if (v != null) | |
494 v.setVisible(b); | |
192 | 495 } |
188 | 496 |
224 | 497 @Override |
498 public Socket getVNCSocket() { | |
499 return connectionPresenter.getSocket(); | |
500 } | |
202 | 501 |
204
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
502 @Override |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
503 public boolean getShowTree() { |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
504 return showTree; |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
505 } |
d9d234715853
TreeManager for each interface
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
506 |
225 | 507 @Override |
508 public void setWidth(int w) { | |
509 width = w; | |
510 } | |
511 | |
512 @Override | |
513 public void setHeight(int h) { | |
514 height = h; | |
515 } | |
516 | |
257 | 517 @Override |
518 public void setFixingSize(int width, int height) { | |
519 this.fixingSizeWidth = width; | |
520 this.fixingSizeHeight = height; | |
521 } | |
301 | 522 |
523 @Override | |
458 | 524 public ArrayList<FbRectangle> getScreenRectangles() { |
314 | 525 // New screen server has one or more screens. |
526 // Screens are numbered in the order from left. | |
527 // put screens in an ArrayList. | |
301 | 528 ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>(); |
529 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
530 GraphicsDevice[] gs = ge.getScreenDevices(); | |
417
c225c7963778
Send screen position
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
402
diff
changeset
|
531 |
314 | 532 for (GraphicsDevice gd : gs) { |
533 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
|
534 Rectangle rect = r.getBounds(); |
563 | 535 //System.out.println("screen "+ rectangles.length() +":"+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
|
536 rectangles.add(rect); |
301 | 537 } |
538 } | |
458 | 539 Point offset = getScreenOffset(rectangles); |
540 ArrayList<FbRectangle> fbRectangles = new ArrayList<FbRectangle>(); | |
541 int screenNumber = 0; | |
542 for (Rectangle rect : rectangles) { | |
626
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
543 AffineTransform aft = getAffineTransform(screenNumber); |
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
544 FbRectangle fbrect = new FbRectangle(rect.x, rect.y, rect.width, rect.height, screenNumber, (int)aft.getScaleX(), !aft.isIdentity(),aft); |
461
b7d43b12651c
fix getFbRectangles x may have minus value now, but xFb is always plus
kono
parents:
460
diff
changeset
|
545 fbrect.setXfb(rect.x + offset.x); |
466 | 546 fbrect.setYfb(rect.y + offset.y); |
461
b7d43b12651c
fix getFbRectangles x may have minus value now, but xFb is always plus
kono
parents:
460
diff
changeset
|
547 fbRectangles.add(fbrect); |
458 | 548 screenNumber++; |
549 } | |
459 | 550 |
563 | 551 fbRectangles.sort((t0, t1) -> t0.getX() < t1.getX() ? -1 : t0.getX() == t1.getX() ? 0 : 1); |
458 | 552 |
553 int retinaOffsetX = 0; | |
554 FbRectangle fbRectanglesPrev = fbRectangles.get(0); | |
555 for (int i = 1; i < fbRectangles.size(); i++) { | |
556 FbRectangle fbRect = fbRectangles.get(i); | |
630
7071b01621c2
Determine ipv4 or ipv6 and fix scond display
riono <e165729@ie.u-ryukyu.ac.jp>
parents:
628
diff
changeset
|
557 if (fbRectanglesPrev.getRetinaScale() != 1) { |
469 | 558 if (fbRectanglesPrev.x + fbRectanglesPrev.width <= fbRect.x) { |
458 | 559 // previous screen is touch with this screen, fix retina scale offset |
560 retinaOffsetX += fbRectanglesPrev.getWidth() * (fbRectanglesPrev.retinaScale - 1); | |
561 } | |
562 } | |
461
b7d43b12651c
fix getFbRectangles x may have minus value now, but xFb is always plus
kono
parents:
460
diff
changeset
|
563 fbRect.setXfb((int) (fbRect.getXfb() + retinaOffsetX)); |
458 | 564 fbRectanglesPrev = fbRect; |
565 } | |
566 | |
563 | 567 fbRectangles.sort((t0, t1) -> t0.getY() < t1.getY() ? -1 : t0.getY() == t1.getY() ? 0 : 1); |
459 | 568 |
458 | 569 int retinaOffsetY = 0; |
570 fbRectanglesPrev = fbRectangles.get(0); | |
571 for (int i = 1; i < fbRectangles.size(); i++) { | |
572 FbRectangle fbRect = fbRectangles.get(i); | |
630
7071b01621c2
Determine ipv4 or ipv6 and fix scond display
riono <e165729@ie.u-ryukyu.ac.jp>
parents:
628
diff
changeset
|
573 if (fbRectanglesPrev.getRetinaScale() != 1) { |
469 | 574 if (fbRectanglesPrev.y + fbRectanglesPrev.height <= fbRect.y) { |
458 | 575 // previous screen is touch with this screen, fix retina scale offset |
576 retinaOffsetY += fbRectanglesPrev.getHeight() * (fbRectanglesPrev.retinaScale - 1); | |
577 } | |
578 } | |
461
b7d43b12651c
fix getFbRectangles x may have minus value now, but xFb is always plus
kono
parents:
460
diff
changeset
|
579 fbRect.setYfb((int) (fbRect.getYfb() + retinaOffsetY)); |
458 | 580 fbRectanglesPrev = fbRect; |
581 } | |
628
c67f0f6eae90
remove retina scale debug message
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
627
diff
changeset
|
582 /* |
c67f0f6eae90
remove retina scale debug message
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
627
diff
changeset
|
583 for (int i = 0; i < fbRectangles.size(); i++) { |
626
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
584 FbRectangle rect = fbRectangles.get(i); |
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
585 double[] r = { rect.x, rect.y , rect.x+rect.width, rect.y+rect.height}; |
627 | 586 Point2D p = rect.aft.transform( new Point2D.Double((double) rect.x, (double) rect.y ), null); |
587 Point2D q = rect.aft.transform(new Point2D.Double((double) rect.x+rect.width, (double) rect.y+rect.height), null); | |
588 System.out.println("fbRectangle " +rect+ "p " +p+ " q" +q); | |
628
c67f0f6eae90
remove retina scale debug message
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
627
diff
changeset
|
589 } */ |
458 | 590 return fbRectangles; |
301 | 591 } |
592 | |
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
|
593 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
|
594 // 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
|
595 // 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
|
596 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
|
597 int offsety = 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
|
598 for (Rectangle rect : rectangles) { |
459 | 599 if (rect.x < offsetx) offsetx = rect.x; |
600 if (rect.y < offsety) offsety = rect.y; | |
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
|
601 } |
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
|
602 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
|
603 } |
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
|
604 |
626
b37ae3e512cc
try to use affin transform for retina display
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
604
diff
changeset
|
605 @Override |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
606 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
|
607 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
|
608 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
|
609 final GraphicsDevice[] devices = env.getScreenDevices(); |
551
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
610 GraphicsConfiguration conf = devices[shareScreenNumber].getDefaultConfiguration(); |
e912db2ab778
fix RetinaDisplay API for java9 and above
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
540
diff
changeset
|
611 scale = (int)conf.getDefaultTransform().getScaleX(); |
630
7071b01621c2
Determine ipv4 or ipv6 and fix scond display
riono <e165729@ie.u-ryukyu.ac.jp>
parents:
628
diff
changeset
|
612 System.out.println("scale:" + scale + "\n\n"); |
456
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
613 return scale; |
34277b436cac
Using retina scale to share screnn if minus postion
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
455
diff
changeset
|
614 } |
363 | 615 |
317 | 616 @Override |
617 public void setFitScreen() { | |
618 SwingViewerWindow v = connectionPresenter.getViewer(); | |
619 if (v != null) { | |
441 | 620 v.fitScreen(); |
317 | 621 } |
622 } | |
623 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
624 } |