Mercurial > hg > Applications > TreeVNC
view src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java @ 174:2e1530139169
reorganization
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 22 Jun 2014 11:22:52 +0900 |
parents | c850c2fce039 |
children | e1aa06b0d2ff |
line wrap: on
line source
package com.glavsoft.viewer; import jp.ac.u_ryukyu.treevnc.server.VncProxyService; public class TreeViewer { private boolean treeProxy; private boolean viewer; private boolean cui = false; private int width; private int height; private String hostName = null; private boolean noConnection = false; private boolean permitChangeScreen = true; private boolean showTree = false; public static void main(String[] args) { new TreeViewer().vncStart(args); } private void vncStart(String[] args) { modeSelect(args); VncProxyService vps = null; if (treeProxy) { vps = new VncProxyService(); vps.setNoConnection(noConnection); vps.proxyStart(args,width,height); if (!permitChangeScreen ) vps.getRfb().setPermitChangeScreen(false); } ViewerInterface v; if (viewer) { v = cui ? new CuiViewer() : new Viewer(); if(hostName!=null) { v.startTreeViewer(hostName,true); } else { v.startTreeViewer(); } } if (vps!=null && vps.getRfb().getAcceptThread()!=null) { vps.getRfb().getAcceptThread().waitForShutdown(); } } private void modeSelect(String[] args) { viewer = true; // default for (int i = 0; i < args.length; i++) { if ("-p".equals(args[i]) || "-r".equals(args[i])) { // no display. behave as root. // relay rfb update to clients. treeProxy = true; viewer = false; } else if ("-d".equals(args[i])) { // behave as root with display. // use this on main display such as large tv. noConnection = true; treeProxy = true; viewer = true; } else if ("--cui".equals(args[i])) { // use cui viewer cui = true; } else if ("-v".equals(args[i]) || "-c".equals(args[i])) { // behave as client. // open display and connect to some tree node. viewer = true; } else if ("--version".equals(args[i])) { System.out.println("version :" + Viewer.ver()); System.exit(0); } else if ("-ns".equals(args[i])) { permitChangeScreen = false; } else if ("--noScreenChange".equals(args[i])) { permitChangeScreen = false; } else if ("--retina".equals(args[i])) { // retina display too large for TreeVNC. // restrict display size. width = 1280; height = 800; } else if ("--width".equals(args[i])) { width = Integer.parseInt(args[i+1]); i++; } else if ("--height".equals(args[i])) { height = Integer.parseInt(args[i+1]); i++; } else if ("--host".equals(args[i])) { hostName = args[++i]; } else if ("--showTree".equals(args[i])) { // show Tree node. showTree = true; } else { System.out.println("(default) TreeVNCClient\n" + "-v or -c: View shared screen.\n" + "-p: (proxy) Share my screen and behave as tree root.\n" + "-ns --noScreenChange Viewers cannot change screen to thiers (default permite screen change)" + "-d: Show shared screen and behave as tree root.\n" + "-r: Connect to fix to specified host and port.\n" + "--host hostname: Set host name.\n" + "--retina: Limit screen size for very large display.\n" + "--width w: Set display width.\n" + "--height h: Set display height.\n"); } } } public boolean setWidthAndHeight(String[] args, int i) { if(isInteger(args[++i])&&isInteger(args[++i])) { width = Integer.parseInt(args[--i]); height = Integer.parseInt(args[++i]); return true; } else { width = 1920; height = 1080; return false; } } private boolean isInteger(String num) { try { Integer.parseInt(num); return true; } catch (NumberFormatException e) { return false; } } }