input
stringlengths
10
828
output
stringlengths
5
107
public void on screen shown string screen id next screen ids clear if prototype model get current screen id null previous screen ids push prototype model get current screen id
should be called when the prototype has been switched to a screen
public screen get current screen return get screen current screen id
gets the screen that is currently active
public boolean is id assigned string id return screen element factories contains key id
checks whether or not this screen contains a screen element factory with
public string get current screen id return current screen id
gets the id of the screen that is currently active
public void remove screen element factory string factory id screen element factory result screen element factories remove factory id if result null throw new identifier exception factory id unknown screen element id factory id set changed notify observers
removes the screen element factory with the given id from this screen
public void update selection for string id selection get ids component selected component edit area get screen panel get component id if selected component null select element selected component
adapts the selection to the bounds of the selected components
public screen get screen string id if id null return null return screens get id
returns the screen with the given id
public int show dialog component parent dialog result value error option jdialog dialog create dialog parent dialog add window listener new window adapter override public void window closing window event e dialog result value cancel option dialog set visible true dialog dispose dialog null return dialog result value
show font selection dialog
private void select element component component if component null selection put component get name new outline component get bounds
adds an outline with the bounds of the given component to the selection
public string get scripting language return scripting language
returns the name of the used scripting language
public string get background filename return background filename
returns the filename of the image that will be shown underneath all
public void set scripting language string scripting language this scripting language scripting language set changed notify observers
changes the used scripting language
public void set background filename string background filename set background filename background filename false
sets the background image filename of this screen
public string get start screen id return start screen id
changes the screen that should be displayed right after a prototype view
public void set start screen id string start screen id if start screen id null screens contains key start screen id throw new illegal argument exception unknown screen start screen id if start screen id null screens is empty throw new illegal argument exception one of the screens must be the start screen this start screen id start screen id set changed notify observers
changes the screen that should be displayed right after a prototype view
public gwtcolor get background color return background color
gets the background color of this screen
public void set background color gwtcolor background color this background color background color set changed notify observers
sets the background color of this screen
private void register listener gwttimer adapter timer timer add gwtevent handler this
makes this screen panel listen to firings of the given timer
private void register listener gwtsound player player player add gwtevent handler this
makes this screen panel listen to firings of the given sound player
private void set dialog title string title set text title
sets the dialog boxs caption
public string get init action return init action
gets the initializing scripting action
private void set dialog text string text html html text new html text dialog content add html text
sets the dialog boxs text
public void add component widget component int left int top add component left top
places the given component into this screen panel above all
public void set init action string init action this init action init action set changed notify observers
sets the initializing scripting action
private void trigger popup menu point p component comp screen element at p if comp null user clicked into an empty area selection clear else if selection get ids contains comp get name user clicked on a screen element that was not previouisly part of the selection selection clear select element comp jpopup menu context menu new edit area popup menu edit area get editor context menu show this p x p y
opens a context menu at the given point
public size get size return new size size
gets the size of this screen
public void stop all timers and sounds for gwttimer adapter timer timers timer stop for widget component get children if component instanceof gwtprogress bar adapter gwtprogress bar adapter component stop for gwtsound player sound player sound players maybe it s not a good idea to interrupt sounds when we switch screens but then we need another way to make sure all sound threads are terminated when protoreto exits e g a shutdown hook sound player stop
stops all timers of this screen panel that might possibly be running
public void set size size size if size width 1 size height 1 background filename null throw new illegal state exception size cannot be determined automatically when there is no background image this size new size size set changed notify observers
sets the size of this screen
public void add misclick listener mouse listener listener this method is for the prototype runtime not for the prototype editor in the editor the background label can change but in the runtime it always stays the same so it s safe to just add the listener to the current label background label add mouse listener listener
adds a listener to the current background label that is notified when the
private void preload background images for screen screen model get screens values image cache get screen get background filename new dimension screen get size width screen get size height
immediately loads the background images of all screens from disk
private void register listener named timer timer timer add action listener this
makes this screen panel listen to firings of the given timer
public string get screen id return screen id
returns the id of the shown screen
private void register listener sound player player player add action listener this
makes this screen panel listen to firings of the given sound player
public void add component component component add component put the components into a new layer above all other components this makes sure that components overlap correctly set layer component highest layer 1
places the given component into this screen panel above all
public string get screen element id return screen element id
returns the id of the changed screen element
public component get component string id for component component get prototype components if id equals component get name return component return null
gets the component of this screen panel which has the given id
public void refresh note this will reset all components and timers clear get this set visible false add background image this set size double to string screen get size width px double to string screen get size height px add screen elements refresh look and feel
recreates the background label and all screen elements
public void stop all timers and sounds for named timer timer timers timer stop for component component get components if component instanceof fake progress bar fake progress bar component pause for sound player sound player sound players maybe it s not a good idea to interrupt sounds when we switch screens but then we need another way to make sure all sound threads are terminated when protoreto exits e g a shutdown hook sound player stop
stops all timers of this screen panel that might possibly be running
public void refresh note this will reset all components and timers remove all add background label add screen elements refresh look and feel
recreates the background label and all screen elements
private int round to grid density int i return int math round double i prefs get int grid density 10 prefs get int grid density 10
rounds the given value so that it is a multiple of
public void paint grid graphics g if prefs get boolean snap to grid false return int grid density prefs get int grid density 10 g set color grid color the grid is represented by little crosshairs for int x 0 x get width x grid density for int y 0 y get height y grid density g draw line x 1 y x 1 y g draw line x y 1 x y 1
paints a grid into the given graphics with the density defined in
public string get scripting language name return scripting language name
gets the name of the used scripting language one of
public option show center the dialog over the prototype view dialog set location relative to dialog get owner dialog set visible true return selected option
displays the dialog
public string get global variable prefix return
gets the prefix with which each global variable must start in this
private void redirect error stream output stream null output stream new output stream override public void write int b throws ioexception off to nirvana with that little byte interpreter set err null output stream
redirects the interpreters err stream to dev null so that it doesnt
private int calculate scripts checksum we calculate the checksum by adding up all the hash codes of the script statements and conditions int result 0 for sandbox permission permission model get required permissions result permission get representation hash code for screen screen model get screens values if screen get init action null result screen get init action hash code for screen element factory factory screen get screen element factories values for transition transition factory get transitions if transition get condition null result transition get condition hash code if transition get action null result transition get action hash code return result
calculates a checksum that can be used to check whether any script code
private boolean is called from script this isn t very efficient but it works and is safe and speed is not that important for prototypes throwable t new throwable stack trace element stack trace t get stack trace for stack trace element element stack trace if element get class name starts with restricted package return true return false
checks if the method stack contains a method that is not associated
private void deny permission list sandbox permission no permissions collections empty list controller initialize scripting environment no permissions
is called when the user has chosen to deny the permission
private void grant permission set up the scripting environment granting all requested permissions controller initialize scripting environment model get required permissions
is called when the user has chosen to grant the permission once or
private void pack file zip output stream out file file throws ioexception create a zip entry for the file zip entry entry new zip entry file get name switch to this new entry out put next entry entry compress the file contents and write them to the zip file file input stream in new file input stream file try byte data new byte buffer size number of bytes inside the buffer which need to be processed int read 0 while read in read data 0 buffer size 1 out write data 0 read finally in close
packs the given file to the given zip output stream
public image icon get icon string filename return get icon filename default icon size
loads the icon with the given filename in default 22x22 pixels size
public image icon get icon string filename int icon size if filename null creates a transparent placeholder image image image new buffered image icon size icon size buffered image type int argb return new image icon image if icons contains key filename icons put filename new hash map integer image icon if icons get filename contains key icon size image image load image filename icon size icons get filename put icon size new image icon image return icons get filename get icon size
loads the icon with the given filename in the given size
public void copy linked hash map string screen element factory factories contents serializer serialize factories set changed notify observers
copies the given factories to the clipboard
public string get default data source name string result null open data source manager try jtwain open dsm result jtwain get default ds close data source manager jtwain close dsm catch jtwain exception exc system out println exc rc jtwain get rc return result
gets the names of the default twain devices
public boolean is empty return contents null
checks whether or not this clipboard is currently empty
public t deep copy t other return deserialize serialize other
creates and returns a deep copy of the given object
public image scan image result null try jtwain open dsm jtwain open ds data source name display the default source s configuration dialog box to the user acquire one image no matter how many images are specified if the dialog box s scan button is clicked image images jtwain acquire return if the dialog box s cancel button was clicked if images null images length 0 return null result images 0 jtwain close ds jtwain close dsm catch jtwain exception e e print stack trace return result
scans an image from the currently selected twain device
private boolean preload image image media tracker add image image 0 block this thread until the image has been loaded try media tracker wait for id 0 catch interrupted exception e should not happen as we re not using multithreading here e print stack trace check if loading the image was successful boolean error media tracker is error id 0 media tracker remove image image return error
loads the given image so that its contents are stored inside this image
public void export file string filename file target path throws ioexception file source file get file filename file utils copy file source file target path
copies the file with the given filename to the target directory with the
protected image create error image string filename buffered image image new buffered image 600 400 buffered image type int rgb graphics2 d graphics image create graphics graphics set background color white graphics clear rect 0 0 600 400 graphics set color color red graphics draw string error 0 20 graphics draw string image could not be read from file 0 40 graphics draw string filename 0 60 return image
creates a replacement image which contains an error message
public image get string filename return get filename null
gets the image from the given filename
public void import file file source file throws ioexception import file source file source file get name
copies a file to the data directory of this library
public void delete file string filename file file to delete get file filename file to delete delete
permanently deletes a file on disk
public void move file to recycle bin string filename throws ioexception if recycle bin dir null recycle bin dir file utils create temp dir file file to delete get file filename file file in recycle bin new file recycle bin dir filename file in recycle bin delete on exit file utils copy file file to delete file in recycle bin delete file filename
deletes a file on disk with the possibility to restore it later
public void restore file string filename throws ioexception file file in recycle bin new file recycle bin dir filename import file file in recycle bin delete the backup file in recycle bin delete
restores a file that has previously been deleted using the
public file get file string filename return new file data path filename
gets the file with the given filename in the data directory
public void save throws ioexception file xml file new file model get data path prototype xml if xml file exists existing file will be overwritten xml file delete xml file create new file xml file delete on exit file output stream fos new file output stream xml file buffered output stream bos new buffered output stream fos try xmloutputter outputter new xmloutputter format the output nicely outputter set format format get pretty format write the dom document to the file outputter output generate document bos finally bos close
generates an xml representation of the prototype model and saves it to a
private document generate document return new document create prototype element
creates a dom document for the prototype model
private element create prototype element element prototype element new element prototype prototype element set attribute language model get scripting language prototype element set attribute title model get title prototype element set attribute lookandfeel model get look and feel class name prototype element add content create description element prototype element add content create permissions element prototype element add content create screens element return prototype element
creates the dom element for the prototype model
public void run try prototype model model loader load prototype model show the prototype description in the console system out println model get description swing prototype controller controller new swing prototype controller model create the graphical user interface new prototype view model controller catch ioexception e e print stack trace catch jdomexception e e print stack trace
runs the prototype
private element create description element element description element new element description description element add content model get description return description element
creates the dom element for the description of the prototype
private element create permissions element element permissions element new element requiredpermissions for sandbox permission permission model get required permissions element permission element new element permission permission element add content permission get representation permissions element add content permission element return permissions element
creates the dom element for the security permissions required for the
private element create screens element element screens element new element screens if model get start screen id null screens element set attribute start model get start screen id for string screen id model get screens key set screen screen model get screen screen id screens element add content create screen element screen id screen return screens element
creates a dom element for the screens of the prototype model
private element create screen element string screen id screen screen element screen element new element screen screen element set attribute id screen id screen element add content create background element screen screen element add content create size element screen if screen get init action null element action element new element action action element add content screen get init action screen element add content action element screen element add content create components element screen screen element add content create timers element screen screen element add content create sounds element screen return screen element
creates a dom element for the given screen
protected void resize component component autosizer get autosize component
sets the size of the component to its preferred size if the component
private element create background element screen screen element background element new element background element color element create color element color utils color to hex new color screen get background color get red screen get background color get green screen get background color get blue color background element add content color element if screen get background filename null element wallpaper element new element wallpaper wallpaper element add content screen get background filename background element add content wallpaper element return background element
creates a dom element for the background color and background image of
private element create size element screen screen element size element new element size element width element new element width width element add content integer to string screen get size width size element add content width element element height element new element height height element add content integer to string screen get size height size element add content height element return size element
creates a dom element for the size of the given screen
public string get text note that if the component is a jpassword field get text is deprecated for security reasons it might be possible for other applications to recover the entered password from memory we don t care here because prototypes won t use any real passwords return component get text
gets the text inside the text component
public void set text string text target application event object queue push event new screen element changed event this component get name text get text text component set text text
sets the text inside the text component
public boolean is multiline return component is multiline
checks whether or not the text component adapter is in multiline mode
public void set multiline boolean multiline target application event object queue push event new screen element changed event this component get name multiline boolean to string is multiline boolean to string multiline component set multiline multiline resize component
changes whether or not the text component adapter is in multiline mode
private element create components element screen screen element components element new element components for string factory id screen get screen element factories key set screen element factory factory screen get screen element factory factory id if factory instanceof jcomponent factory components element add content create component element factory id jcomponent factory factory return components element
creates a dom element for the component factories of the given screen
public void set password boolean password target application event object queue push event new screen element changed event this component get name password boolean to string is password boolean to string password component set password mode password resize component
changes whether or not the text component adapter is in password field
public void add transition transition transition transitions add transition
adds a transitions that can be fired by a products of this factory
public void set transitions list transition transitions this transitions transitions
sets the transitions that can be fired by a product of this factory
public t create screen element t component instantiate screen element set attributes for component return component
creates a screen element component and sets its attributes according to
private element create timers element screen screen element timers element new element timers for string factory id screen get screen element factories key set screen element factory factory screen get screen element factory factory id if factory instanceof timer factory timers element add content create timer element factory id timer factory factory return timers element
creates a dom element for the timer factories of the given screen
public sound player create sound player file library file library return new sound player file library attributes get sound filename attributes is loop
creates a timer and sets its attributes according to this factory
public string get color represent the color in hex format 2 hex digits per color channel return string format 02x 02x 02x component get foreground get red component get foreground get green component get foreground get blue
gets the text color of the component
public void set color string color target application event object queue push event new screen element changed event this component get name color get color color int rgb integer parse int color 16 component set foreground new color rgb
changes the text color of the component
private element create sounds element screen screen element sounds element new element sounds for string factory id screen get screen element factories key set screen element factory factory screen get screen element factory factory id if factory instanceof sound player factory sounds element add content create sound element factory id sound player factory factory return sounds element
creates a dom element for the sound player factories of the given screen
public named timer create timer return new named timer attributes get delay attributes get mode attributes is autostart attributes is loop
creates a timer and sets its attributes according to this factory
public void set font style string style text int style font style changer get java style style text component set font component get font derive font style
the font style can be given as number or as text value
public string get bg color if component get background null return null represent the color in hex format 2 hex digits per color channel return string format 02x 02x 02x component get background get red component get background get green component get background get blue
gets the background color of the component
public void set bg color string color target application event object queue push event new screen element changed event this component get name bg color get bg color color if color null component set background null else int rgb integer parse int color 16 component set background new color rgb
changes the background color of the component
public void set unachangeable properties gwtcolor and font configurator get instance set color this gwtcolor light gray get hex value background color dom set style attribute get element border width thin dom set style attribute get element border top style inset dom set style attribute get element border right style inset dom set style attribute get element border bottom style inset dom set style attribute get element border left style inset dom set style attribute element this get element get first child element position absolute
unchangable properties for the presentation of this progress bar
private void init timer timer new timer override public void run int progress int get progress 1 if progress 100 cancel set progress progress
the timer increases the progress
public boolean needs text color and font return true
determines whether or not it makes sense to assign a foreground color and
public boolean needs bg color return true
determines whether or not it makes sense to assign a background color
public void start timer schedule repeating get delay 100
starts the progress bar