gnu.vnc
Class VNCViewer

java.lang.Object
  extended by gnu.vnc.VNCViewer
All Implemented Interfaces:
java.lang.Runnable

public class VNCViewer
extends java.lang.Object
implements java.lang.Runnable

Abstracts out the details of a VNC client. Once constructed it connects to the given server and maintains a VNC connection. It spawns its own thread to handle the details of updating and protocol details. Key events can be sent. Mouse movements and clicks can be sent. Clipboard can be get/set. A screenshot of the remote frame buffer can be retrieved.

Author:
Ken Breeman (kbreeman@wpi.edu), Eric Griffel (sniffels@wpi.edu)

Constructor Summary
VNCViewer(java.lang.String host, int display, java.lang.String p)
          Creates a new VNCViewer which connects and authenticates.
VNCViewer(java.lang.String s, java.lang.String p)
          Creates a new VNCViewer which connects and authenticates.
 
Method Summary
 java.lang.String getClipboard()
           
 int getDepth()
           
 int getHeight()
           
 int[] getImage()
           
 java.lang.String getName()
           
 PixelFormat getPixelFormat()
           
 float getProtocol()
           
 java.lang.String getServerHost()
           
 int getWidth()
           
static void main(java.lang.String[] args)
          Tests out the VNC viewer with some default settings.
 void refresh(boolean incremental, int x, int y, int w, int h)
          Requests a refresh of an area of the screen.
 void run()
           
 void sendKey(int key, boolean down)
          Sends a KeyEvent to the server.
 void sendMouse(int x, int y, byte buttons)
          Sends a mouse pointer event to the server.
 void setClipboard(java.lang.String clipboard)
           
 void stop()
          Stops the client thread gracefully.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VNCViewer

public VNCViewer(java.lang.String s,
                 java.lang.String p)
          throws java.lang.Exception
Creates a new VNCViewer which connects and authenticates.

Parameters:
s - The host, host:display, or host::port to connect to.
p - The password to send.
Throws:
java.lang.Exception

VNCViewer

public VNCViewer(java.lang.String host,
                 int display,
                 java.lang.String p)
          throws java.lang.Exception
Creates a new VNCViewer which connects and authenticates.

Parameters:
host - - The host name to connect to.
display - - The display number.
Throws:
java.lang.Exception - If unable to connect or comminicate or authenticate.
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Stops the client thread gracefully.


main

public static void main(java.lang.String[] args)
Tests out the VNC viewer with some default settings.

Parameters:
args -

getClipboard

public java.lang.String getClipboard()
Returns:
The clipboard of the remote host as a String.

setClipboard

public void setClipboard(java.lang.String clipboard)
Parameters:
clipboard - The clipboard string to set on the remote host.

getName

public java.lang.String getName()
Returns:
The name of the desktop on the remote host.

getServerHost

public java.lang.String getServerHost()
Returns:
The hostname::port of the connected server.

getWidth

public int getWidth()
Returns:
The width of the VNC session.

getHeight

public int getHeight()
Returns:
The height of the VNC session.

getDepth

public int getDepth()
Returns:
The color depth of the VNC session.

getPixelFormat

public PixelFormat getPixelFormat()
Returns:
The current PixelFormat for the connection.

getImage

public int[] getImage()
Returns:
The image data of the remote desktop via RFB.

sendKey

public void sendKey(int key,
                    boolean down)
Sends a KeyEvent to the server.

Parameters:
key - Which key
down - Whether or not the key is down (pressed) or up (released).

sendMouse

public void sendMouse(int x,
                      int y,
                      byte buttons)
Sends a mouse pointer event to the server.

Parameters:
x - The x-coordinate of the event.
y - The y-coordinate of the event.
buttons - A bitmask of which buttons are pressed.

refresh

public void refresh(boolean incremental,
                    int x,
                    int y,
                    int w,
                    int h)
Requests a refresh of an area of the screen.

Parameters:
incremental - Whether or not this is an incremental request.
x - The x-coordinate.
y - The y-coordinate.
w - The width.
h - The height.

getProtocol

public float getProtocol()
Returns:
the protocol