input
stringlengths
10
828
output
stringlengths
5
107
public void mouse exited mouse event me event
function included only to implement mouse listener interface
public void mouse released mouse event me event
function included only to implement mouse listener interface
public void paint graphics g paint g paint set color get color g paint draw rect math min get start get x get end get x math min get start get y get end get y math max get start get x get end get x math min get start get x get end get x math max get start get y get end get y math min get start get y get end get y super paint g paint
just a line between two points
public void add item string s add m wb parent add item white board item decode s add
interpret the add string and add the appropriate item to the white board
public string get type string return solidrectangle
return a string to represent the type of this item
public void mouse pressed mouse event me event if me event get modifiers mouse event button2 mask 0 me event get modifiers mouse event button3 mask 0 me event m wb parent adjust mouse event me event m wb parent set sketch in progress true m cp start new critical point me event get x me event get y m cp end new critical point me event get x me event get y
start to sketch on a left mouse click
public void mouse released mouse event me event if m wb parent is sketch in progress me event get modifiers mouse event button2 mask 0 me event get modifiers mouse event button3 mask 0 m wb parent send item create item m wb parent get local color m cp start m cp end m wb parent set sketch in progress false m cp start null m cp end null else m wb parent set sketch in progress false m cp start null m cp end null m wb parent repaint
if theyre releasing the left mouse button theyre done sketching
public void paint graphics g paint g paint set color get color g paint fill rect math min get start get x get end get x math min get start get y get end get y math max get start get x get end get x math min get start get x get end get x math max get start get y get end get y math min get start get y get end get y super paint g paint
just a line between two points
public void mouse dragged mouse event me event if m wb parent is sketch in progress me event m wb parent adjust mouse event me event m cp end new critical point me event get x me event get y m wb parent sketch item create item m wb parent get local color m cp start m cp end
if were currently sketching sketch based on where the mouse
protected shared list get new shared list return new shared white board state
subclasses should override this to return an empty instance of
protected void read item storage handler utility string item item object obj shared white board state state shared white board state obj if item name equals width state set width integer parse int item value else if item name equals height state set height integer parse int item value else if item name equals background image state set background image item value else if item name equals background state set background new color integer parse int item value
subclasses should override this to initialize from values written
public void mouse pressed mouse event me event if me event get modifiers mouse event button2 mask 0 me event get modifiers mouse event button3 mask 0 me event m wb parent adjust mouse event me event m wb parent set sketch in progress true m v points new vector m v points add element new critical point me event get x me event get y
start to sketch on a left mouse click
public void mouse released mouse event me event if m wb parent is sketch in progress me event get modifiers mouse event button2 mask 0 me event get modifiers mouse event button3 mask 0 m wb parent send item new white board free hand m wb parent get local color m v points m wb parent set sketch in progress false m v points null else m wb parent set sketch in progress false m v points null m wb parent repaint
if theyre releasing the left mouse button theyre done sketching
public void mouse dragged mouse event me event if m wb parent is sketch in progress me event m wb parent adjust mouse event me event m v points add element new critical point me event get x me event get y m wb parent sketch item new white board free hand m wb parent get local color m v points
if were currently sketching sketch based on where the mouse
public white board item create item color c color critical point cp start critical point cp end return new white board rectangle c color cp start cp end
return an item of the appropriate type for this listener
protected boolean show url string url return false
subclasses should override this to do things like open the given
public string get type string return solidoval
return a string to represent the type of this item
public vector get points return m v points
return the points making up this item
public void shift item int i xshift int i yshift critical point cp curr super shift item i xshift i yshift for int i counter 0 i counter m v points size i counter cp curr critical point m v points element at i counter cp curr set x cp curr get x i xshift cp curr set y cp curr get y i yshift
shift the item by adding the provided values to the coordinates of each
public image get image return m i image
get the image drawn in this image area
public dimension get minimum size return new dimension m i image get width this m i image get height this
return the size of the image
public dimension get preferred size return new dimension m i image get width this m i image get height this
return the size of the image
public void paint graphics g graphics super paint g graphics g graphics draw image m i image get bounds width m i image get width this 2 get bounds height m i image get height this 2 this
draw the image
public void add item white board item wbi add m v items add element wbi add update on add
add a new item to the white board
public void mouse moved mouse event me event
function included only to implement mouse motion listener interface
public void mouse released mouse event me event action listener al listener int i counter release for i counter 0 i counter m v action listeners size i counter al listener action listener m v action listeners element at i counter al listener action performed new action event this action event action performed lightweight button pushed me event get modifiers
release the button if this was a left click
public void press if m b pushed m b pushed true repaint
press this one
public string encode string s encoded s encoded s encoded get color get rgb s encoded if m i item id 0 s encoded m i item id else s encoded white board global protocol new item id placeholder return s encoded
encode this item in to a string that can be recovered by decode
public color get color return m c color
get what color this item is to be drawn in
public void disconnect try m s socket close catch ioexception ioe system out println error closing socket
close this connection
public string read connection boolean b ready try b ready m br reader ready catch ioexception ioe system out println unable to check availability of input stream return null if b ready try return m br reader read line catch ioexception ioe system out println unable to read from input stream return null else return null
read a line from this connection
public void write connection string s message m pw writer println s message
write the given string to the connection
public void mouse released mouse event me event string s command if me event get modifiers mouse event button2 mask 0 me event get modifiers mouse event button3 mask 0 m b show in progess false m l last send 0 cork changes pli m wb parent send show mouse me event s command white board global protocol showmouse m wb parent get local id 1 1 m wb parent send message s command
if theyre releasing the left mouse button theyre done sketching the line
public void mouse dragged mouse event me event string s command if m b show in progess if system current time millis m l last send 1000 white board global max showmouse sends per second me event m wb parent adjust mouse event me event m l last send system current time millis cork changes pli m wb parent send show mouse me event s command white board global protocol showmouse m wb parent get local id me event get x me event get y m wb parent send message s command
echo as we move
public string get type string return freehand
return a string to represent the type of this item
public string to external form return item encode
returns a string that can be parsed by code from external form code
public void from external form string external form item white board item decode external form
parses the string to initialize the item
public string get background image url string bg get background image see if our background is an object id if bg null bg starts with http try object id fid object id from string bg if fid null bg shared file get download url fid catch exception e return bg
method that subclasses can override to generate a usable url for the
private void connect to server try m s server new socket white board global server address white board global whiteboardserver port number catch ioexception ioe system out println unable to connect to server system exit 1
handle the process of connecting to the server
public image get image frame f new frame canvas tmp new canvas f add tmp f add notify tmp add notify force peer creation image img tmp create image width height graphics g img get graphics draw the background g set color background color g fill rect 0 0 width 1 height 1 will need to draw in background image here as well for int i 0 i size i white board item element at i paint g getting paranoid about garbage collection g dispose g null f dispose tmp remove notify tmp null return img
returns an image of the whiteboard contents
protected void init component source default component view source source source load defaults
sets up the component source
protected default relation manager init object relation manager default relation manager mgr new default relation manager this mgr load defaults return mgr
sets up the object relation manager
public modification tracker get modification tracker return modification tracker
returns the modification tracker for this context
public component view get component view object id id object tag component view cv source get component view id tag return cv
returns the component view for the given object id creating and
public void remove component view object id id object tag source remove component view id tag
removes the view for the given object id with the given tag
public string get owner name return owner
returns the owner account s for these accounts
public void set owner name string owner object old this owner this owner owner fire property change owner name old owner
sets the owner account s for these accounts
public boolean shutdown views boolean ok true for enumeration e source get object ids e has more elements ok object id id object id e next element for enumeration views source get component views id views has more elements ok component view cv component view views next element ok cv shutdown should the views be removed from sourced here return ok
shuts down all views
public account get user info string user system err println user account result null sqlconnection sql new sqlconnection jdbcdriver phpnuke server sqlaccount sqlpassword null null null sql connect string password sql get users password user null null null system err println password password if password null result new account user password if result null system err println result result else system err println result was null return result
returns the user info currently just password for the given user
public string get jdbcdriver if jdbcdriver null system err println returning jdbc return jdbcdriver else system err println its null dummy return please set
returns the jdbc driver
public void set jdbcdriver string jdbcdriver object old this jdbcdriver this jdbcdriver jdbcdriver fire property change jdbcdriver old jdbcdriver
sets the jdbc driver
public string get phpnuke server if phpnuke server null return phpnuke server else return please set
returns the phpnuke server name
public component view source get component view source return source
returns a component view source object for generating views
public void set phpnuke server string phpnuke server object old this phpnuke server this phpnuke server phpnuke server fire property change phpnuke server old phpnuke server
sets the phpnuke server name
public string get sqlaccount if sqlaccount null return sqlaccount else return please set
returns the sql database account name
protected web view get web view object id id return default web view source get instance get web view id
may be overridden to use a different web view source
public void set sqlaccount string sqlaccount object old this sqlaccount this sqlaccount sqlaccount fire property change sqlaccount old sqlaccount
sets the sql database account name
public object relation source get object relation source return relation manager
returns an object relation with the specified name and for the
public string to string return password
overiding to just return the password string
public string get sqlpassword if sqlpassword null return sqlpassword else return please set
returns the sql database password
public void set sqlpassword string sqlpassword object old this sqlpassword this sqlpassword sqlpassword fire property change sqlpassword old sqlpassword
sets the sql database password
public string get property string property string default value string prop properties source get property property default value return prop
returns the requested property
public void run while true try thread sleep 300 catch interrupted exception ie ie print stack trace synchronized thread lock for enumeration e in progress keys e has more elements authentication worker w authentication worker in progress get e next element w check for timeout
wake up occasionally and check all of the running threads
protected class get servlet class return default web view servlet class
returns the servlet class to be used by this or subclasses of this
public void set embedded object path embedded object path path this path path if path get length 0 this descriptor path get last embedded object descriptor this set path get last embedded object set
called after construction to inform the view of its embedded object
public void load properties p for enumeration e p keys e has more elements string key string e next element add web view class key p get property key null
loads object class view class mappings from a properties object
public void load input stream props throws ioexception properties p new properties p load props load p
loads object class view class mappings from a properties stream
public void load defaults try input stream in default web view source class get resource as stream default map path load in catch ioexception e e print stack trace
loads object class view class mappings from the default
public void init object id id component context context this id id this context context synchronized init lock init
called after construction to inform the view of its objectid and
public web view get web view object id id web view view null try string obj class id get classname class cl class classes get obj class if cl null fall back to name based lookup string wv class obj class web view cl class for name wv class classes put obj class cl if cl null view web view cl new instance catch exception e e print stack trace if view null view new default web view return view
returns the web view for the given object id creating and
public int get length return descriptors size
returns the length of the path
public color get local color return m c local color
get the local color
public void set length int length if length descriptors size descriptors set size length if sets null sets size 0 length 0 sets set size length 1
sets the length of the path to the given size
public component get view component result this if is readable jlabel l new jlabel this object is restricted jlabel center l set foreground color red result l else if view initialized synchronized init lock if view initialized if undo handler null undo handler new undo handler init view view initialized true free this up init lock null return result
returns a full size component for viewing and or editing the object
public embedded object descriptor get embedded object descriptor int i return embedded object descriptor descriptors element at i
returns the embedded object descriptor at the given index where 0 is
public component get thumbnail return null
returns a component that implements a hopefully lightweight
public icon get icon return icon manager get icon id
returns an icon representing the component or null if none
public hashtable get actions hashtable h new hashtable 3 h put cut action new default editor kit cut action h put copy action new default editor kit copy action h put paste action new default editor kit paste action h put select all action get default select all action if undo handler null undo handler new undo handler h put undo action undo handler get undo action h put redo action undo handler get redo action return h
returns a table of actions supported by the component
public embedded object set get embedded object set int i if sets null return null return embedded object set sets element at i
returns the embedded object set at the given index where 0 is
protected component view create component view object id id return create component view id true
constructs a new component view instance for the given object id
public embedded object descriptor get last embedded object descriptor return embedded object descriptor descriptors element at descriptors size 1
utility method that returns the terminal embedded object descriptor
public void set default component view class name string view class name this default view class view class name
sets the default view class name to be used when no object view
public string get default component view class name return default view class
returns the default view class name
public void set user info string user account account shared map item key new string map item user if account null remove key else put key new string map item account to string
sets the password and eventually other stuff for the given user
public void add component view class string object class string view class if view class null classes remove object class else classes put object class view class
adds a mapping from the given object class to the given view class
public void load properties p for enumeration e p keys e has more elements string key string e next element add component view class key p get property key null
loads object class view class mappings from a properties object
public void set last embedded object descriptor embedded object descriptor desc descriptors set element at desc descriptors size 1
utility method for setting the terminal embedded object descriptor
public void load defaults try input stream in default component view source class get resource as stream default map path load in catch ioexception e e print stack trace
loads object class view class mappings from the default
public void remove component views object id id object current views get id views remove id if current instanceof hashtable hashtable current clear
removes all views for the given object id
public account get user info string user account result null shared map item info get new string map item user if info null result new account user info to string return result
returns the user info currently just password for the given user
public embedded object set get last embedded object set if sets null sets size 0 return null else return embedded object set sets element at sets size 1
utility method that returns the terminal embedded object set the
public void remove component view object id id object tag object current views get id if current instanceof hashtable object rem hashtable current remove tag system err println removing rem system err println tag system err println hashtable current get tag dump id id
removes the view for the given object id with the given tag
public object id get object id if id null id context get replicated object client get object id object return id
returns the object id looking it up if necessary
public boolean shutdown if loaded loaded false replication manager maintains a count of references so we can safely call stop sharing here replication manager get instance stop sharing id context get replicated object client turn off replication for our parent since we started it on load embedded object set parent path get last embedded object set if parent null replication manager get instance stop sharing parent context get replicated object client remove all return true
called to inform the component that it is being closed and or disposed
public void add embedded object set parent embedded object descriptor child if sets null sets new vector sets add element parent descriptors add element child
adds a link to the path
public enumeration get object ids return views keys
returns an enumeration of all object ids that currently have
public void set group info string group account account shared map item key new string map item group prefix group if account null remove key else put key new string map item account to string
sets the group info for the given group
public enumeration get component views object id id object current views get id enumeration e null if current null e new vector 0 elements else if current instanceof component view vector tmp new vector 1 e tmp elements else e hashtable current elements return e
returns an enumeration of all component views associated with the
public replicated object client get replicated object client return client
returns the client that made the request
public embedded object path get embedded object path return path
returns the parsed path to the requested object