Mercurial > hg > Applications > TreeVNC
view src/viewer_swing/java/com/glavsoft/viewer/TreeViewer.java @ 271:13a809ce1212
add option comment.
author | oc |
---|---|
date | Thu, 11 Dec 2014 18:15:02 +0900 |
parents | 5f697251860b |
children | 5bab82abcc4f |
line wrap: on
line source
package com.glavsoft.viewer; import jp.ac.u_ryukyu.treevnc.VncProxyService; import java.io.FileNotFoundException; import java.io.PrintStream; public class TreeViewer { private boolean treeProxy; private boolean viewer; private boolean cui = false; private int width; private int height; private int fixingSizeWidth; private int fixingSizeHeight; private String hostName = null; private String logFileName = null; private boolean noConnection = false; private boolean permitChangeScreen = true; private boolean showTree = false; private boolean checkDelay = false; private boolean addSerialNum = false; private boolean fixingSizeDisplay = false; private boolean logFile = false; private boolean filterSingleDisplay = false; public static void main(String[] args) { new TreeViewer().vncStart(args); } private void vncStart(String[] args) { modeSelect(args); if(logFile) { PrintStream out = null; try { out = new PrintStream(logFileName + ".txt"); } catch (FileNotFoundException e) { e.printStackTrace(); } System.setOut(out); } if (treeProxy && !viewer) { // start treeManager only ( -p flag ) VncProxyService vps = new VncProxyService(); if(fixingSizeDisplay) setFixingSizeDisplay(vps); rootStart(args,vps); return; } if (viewer) { ViewerInterface v = cui ? new CuiViewer() : new Viewer(); setWidthAndHeight(v); if(fixingSizeDisplay) setFixingSizeDisplay(v); if (treeProxy) { // this viewer also works as tree root ( display mode -d flag ) // start with no connection waiting server change request rootStart(args, v); } else { v.startTreeViewer(hostName,cui); } } } public void rootStart(String[] args, ViewerInterface v) { v.setNoConnection(noConnection); // should we accept host name here? v.proxyStart(args,width,height, showTree, checkDelay, addSerialNum, fixingSizeDisplay, filterSingleDisplay); v.getRfb().setHasViewer(viewer); if (!permitChangeScreen ) v.getRfb().setPermitChangeScreen(false); v.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 ("--fixingSize".equals(args[i])) { // retina display too large for TreeVNC. // restrict display size. fixingSizeWidth = 1280; fixingSizeHeight = 800; fixingSizeDisplay = true; } else if ("--filterSingleDisplay".equals(args[i])) { // retina display too large for TreeVNC. // restrict display size. filterSingleDisplay = true; } 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 if ("--checkDelay".equals(args[i])) { // check flow of data delay. checkDelay = true; } else if ("--addSerialNum".equals(args[i])) { // add data serial number. addSerialNum = true; } else if ("--logFile".equals(args[i])) { // add log file. logFile = true; try { this.logFileName = args[++i]; } catch (ArrayIndexOutOfBoundsException e) { // not input file name. System.out.println("Please put the log file name. If you do not put file name, set file name logFile.txt"); } if (logFileName == null) { logFileName = "logFile"; } else if ("-".equals(logFileName.substring(0,1))) { // not input file name. // to continue to add option. System.out.println("Please put the log file name. If you do not put file name, set file name logFile.txt"); logFileName = "logFile"; i++; } else { i++; } } 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)\n" + "-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" + "--showTree: Show connected tree node.\n" + "--checkDelay: Check speed flow of data each node.\n" + "--logFile logFileName: Set log file name.\n" + "--filterSingleDisplay: Share single display (case of use multi display).\n" + "--fixingSize w h: Fix share screen size.\n" + "--addSerialNum: Check lost data.\n"); } } } public void setWidthAndHeight(ViewerInterface v) { if(width != 0 || height != 0) { v.setWidth(width); v.setHeight(height); } } public void setFixingSizeDisplay(ViewerInterface v) { v.setFixingSize(fixingSizeWidth, fixingSizeHeight); } private boolean isInteger(String num) { try { Integer.parseInt(num); return true; } catch (NumberFormatException e) { return false; } } }