annotate src/main/java/jp/ac/u_ryukyu/alicevnc/ReceiveServerInitMessage.java @ 1:a73b8a20e233

create another viewer window
author one
date Sat, 13 Sep 2014 04:57:52 +0900
parents
children e046eb8a3ac1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
a73b8a20e233 create another viewer window
one
parents:
diff changeset
1 package jp.ac.u_ryukyu.alicevnc;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
2
a73b8a20e233 create another viewer window
one
parents:
diff changeset
3 import com.glavsoft.drawing.Renderer;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
4 import com.glavsoft.rfb.IRepaintController;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
5 import com.glavsoft.rfb.encoding.ServerInitMessage;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
6 import com.glavsoft.rfb.protocol.Protocol;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
7 import com.glavsoft.rfb.protocol.ProtocolSettings;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
8 import com.glavsoft.viewer.Viewer;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
9 import com.glavsoft.viewer.cli.Parser;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
10 import com.glavsoft.viewer.swing.ParametersHandler;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
11 import com.glavsoft.viewer.swing.SwingViewerWindow;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
12 import com.glavsoft.viewer.swing.SwingViewerWindowFactory;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
13
a73b8a20e233 create another viewer window
one
parents:
diff changeset
14 import alice.codesegment.CodeSegment;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
15 import alice.datasegment.CommandType;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
16 import alice.datasegment.Receiver;
a73b8a20e233 create another viewer window
one
parents:
diff changeset
17
a73b8a20e233 create another viewer window
one
parents:
diff changeset
18 public class ReceiveServerInitMessage extends CodeSegment {
a73b8a20e233 create another viewer window
one
parents:
diff changeset
19
a73b8a20e233 create another viewer window
one
parents:
diff changeset
20 private Receiver info = ids.create(CommandType.PEEK);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
21
a73b8a20e233 create another viewer window
one
parents:
diff changeset
22
a73b8a20e233 create another viewer window
one
parents:
diff changeset
23 public ReceiveServerInitMessage(){
a73b8a20e233 create another viewer window
one
parents:
diff changeset
24 info.setKey("ServerInitMessage");
a73b8a20e233 create another viewer window
one
parents:
diff changeset
25 }
a73b8a20e233 create another viewer window
one
parents:
diff changeset
26
a73b8a20e233 create another viewer window
one
parents:
diff changeset
27 public void run() {
a73b8a20e233 create another viewer window
one
parents:
diff changeset
28
a73b8a20e233 create another viewer window
one
parents:
diff changeset
29 Parser parser = new Parser();
a73b8a20e233 create another viewer window
one
parents:
diff changeset
30 ParametersHandler.completeParserOptions(parser);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
31 if (parser.isSet(ParametersHandler.ARG_HELP)) {
a73b8a20e233 create another viewer window
one
parents:
diff changeset
32 System.exit(0);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
33 }
a73b8a20e233 create another viewer window
one
parents:
diff changeset
34 Viewer viewer = new Viewer(parser);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
35 SwingViewerWindowFactory viewerWindowFactory = new SwingViewerWindowFactory(true, false, viewer);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
36 ProtocolSettings settings = ProtocolSettings.getDefaultSettings();
a73b8a20e233 create another viewer window
one
parents:
diff changeset
37 Protocol context = new Protocol(null, null, null, settings);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
38
a73b8a20e233 create another viewer window
one
parents:
diff changeset
39 ServerInitMessage serverInitMessage = info.asClass(ServerInitMessage.class);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
40 context.setPixelFormat(serverInitMessage.getPixelFormat());
a73b8a20e233 create another viewer window
one
parents:
diff changeset
41 context.setFbWidth(serverInitMessage.getFrameBufferWidth());
a73b8a20e233 create another viewer window
one
parents:
diff changeset
42 context.setFbHeight(serverInitMessage.getFrameBufferHeight());
a73b8a20e233 create another viewer window
one
parents:
diff changeset
43 context.setRemoteDesktopName(serverInitMessage.getName());
a73b8a20e233 create another viewer window
one
parents:
diff changeset
44
a73b8a20e233 create another viewer window
one
parents:
diff changeset
45 SwingViewerWindow viewerWindow = viewerWindowFactory.createViewerWindow(context, settings, viewer.getUiSettings(), null, null);
a73b8a20e233 create another viewer window
one
parents:
diff changeset
46 IRepaintController repaintController = viewerWindow.getSurface();
a73b8a20e233 create another viewer window
one
parents:
diff changeset
47 Renderer renderer = repaintController.createRenderer(null, 1280, 800, context.getPixelFormat());
a73b8a20e233 create another viewer window
one
parents:
diff changeset
48
a73b8a20e233 create another viewer window
one
parents:
diff changeset
49 }
a73b8a20e233 create another viewer window
one
parents:
diff changeset
50
a73b8a20e233 create another viewer window
one
parents:
diff changeset
51 }