input
stringlengths 10
828
| output
stringlengths 5
107
|
|---|---|
private boolean turn right int new direction return new direction direction 0
|
check if we have to turn right return true or left return false
|
private cell get cell int x int y throws index out of bounds exception return world get x border west get y border north
|
return the cell at coordinate x y
|
private void reset exploration for list cell line world for cell c line c set distance from home 1 c set marked false
|
reset marking of all cells
|
public string to string string result for list cell line world for cell c line result c result n return result
|
print how the vacuum agent currently see the world
|
private int double hash value k key int nb collisions return math abs key hash code capacity nb collisions secondary hash function key capacity
|
hash function applying double hash method
|
public int hash value k key return math abs key hash code scale shift capacity
|
hash function applying mad method to default hash code
|
private avltree node find closest node avltree node node double val boolean found node null while found if val node value if node left null found true else node node left else if val node value if node right null found true else node node right else found true return node
|
help function to be used by find insert and delete
|
protected int find entry k key throws invalid key exception int avail 1 check key key int i hash value key int j i nb probes 0 do nb probes entry k v e bucket i if e null if avail 0 avail i key is not in table break if key equals e get key we have found our key return i key found if e available bucket is deactivated if avail 0 avail i remember that this slot is available i i 1 capacity keep looking while i j return avail 1 first empty or available slot
|
helper search method returns index of found key or a 1
|
public v get k key throws invalid key exception int i find entry key helper method for finding a key if i 0 return null there is no value for this key return bucket i get value return the found value in this case
|
returns the value associated with a key
|
private double delete max left node avltree node node if right node is null only promote left tree if node right null node parent left node left if node left null node left parent node parent else else look deep for max value while node right null node node right update parent by replacing is right child by his right left child node parent right node left if node left null node left parent node parent return node value
|
delete max node in a left tree and return its value
|
public boolean is leaf avltree node node return node height 0
|
verify is the parameters is a leaf or not
|
private void delete leaf avltree node to delete throws avltree exception replace node to delete null
|
delete a leaf to delete must be a leaf
|
private void replace node avltree node node avltree node new node try if new node null new node parent node parent if is left child node node parent left new node else node parent right new node catch avltree exception e this root node new node
|
replace a node by another
|
public void insert double val throws avltree exception insert root node val
|
set value in the tree
|
public void delete double val throws avltree exception delete root node val
|
take away value from tree
|
public vector get vector int x int y throws illegal argument exception if x 0 x image get width y 0 y image get height throw new illegal argument exception return origin add u multiply translate coord x x add v multiply translate coord y y
|
return the vector which as the camera position for origin and
|
public void run viewport vp w get camera get view port for int x min x x max x x for int y 0 y vp get height y ray ray new ray w get camera get pos vp get vector x y log get instance debug throwing ray ray try color c cast ray 0 vp set pixel x y c catch no intersection e vp set pixel x y background color
|
main entrance of renderer threads
|
public boolean find double val if root node null return false if find closest node root node val value val return true return false
|
returns true if value is found in the tree
|
private color cast ray ray int level throws no intersection if level max level return background color return calculate color ray trace w get objects ray level
|
cast the ray an calculate the color
|
public void add object world object o objects add o
|
add a object to the world
|
public void add light light o lights add o
|
add a light to the world
|
public void set ambient light ambient light light this ambient light light
|
set the ambient light
|
public string to string return sphere super to string radius
|
return a text represention of the sphere
|
public string to string return cube super to string size
|
return a text represention of the cube
|
public string to string string result scene n camera n ambient light n for light l lights result l n for world object o objects result o n return result
|
return a text represention of the world
|
public void translate vector vector position translate vector
|
translate object with given vector
|
public string to string return cylinder super to string radius height
|
return a text represention of the cylinder
|
public double scalar product vector vect return this x vect x this y vect y this z vect z
|
return the scalar product of the current vector and the vector vect
|
public vector minus vector vect return new vector this x vect x this y vect y this z vect z
|
return the difference of the current vector and the vector vect
|
public vector add vector vect return new vector this x vect x this y vect y this z vect z
|
return the addition of the current vector and the vector vect
|
public void unitize double norm this get norm this x norm this y norm this z norm
|
make this vector a unit vector
|
public vector multiply double dist return new vector dist x dist y dist z
|
return dist this vector
|
public string to string return pos position color phong specular reflexion diffuse reflexion
|
return a text represention of the object
|
public void parse attr attributes attr double x parse double attr x default x double y parse double attr y default y double z parse double attr z default z position new vector x y z int r parse int attr r default r int g parse int attr g default g int b parse int attr b default b color new color r g b phong parse int attr phong default phong specular reflexion parse double attr specular default specular reflexion diffuse reflexion parse double attr diffuse default diffuse reflexion
|
parse attribute for this world object
|
public jtext field get name text field return this name
|
return the jtext field component use to edit the name of the chord
|
public neck get neck return this neck
|
get the neck of the chord uiedit
|
public void mouse released mouse event e if e get y neck get y e get y neck get y neck get height the click is at the height of the neck if e get x neck get x e get x neck get x neck get width the neck as been clicked modify neck e
|
process the mouse click and determine if the click was over the neck
|
public void modify chord int str int fret boolean delete if delete chord set element str fret chord empty else chord set element str fret neck get current element midi engine play chord chord new soft pattern this repaint
|
modify the chord elements
|
public void apply changes neck set editable false if chord get name equals chord set name chord set capo capo is selected chord ui get chord copy chord chord chord ui set editing false chord ui repaint
|
apply the chord maked on the chord uieditable on the chord ui
|
public neck get neck return neck
|
get the neck of the chord ui
|
public void mouse clicked mouse event e if e get source capo chord set capo capo is selected this neck repaint
|
process the capo check box events
|
public void set editing boolean editing value if editing value show editing color neck set background color orange name set foreground color gray else show normal color set selected is selected
|
set the chord ui int the editing state
|
public void set selected boolean selection value if selection value true select neck set background color blue name set foreground color blue selected true else unselect neck set background null name set foreground color selected false
|
set the chord ui in the selected or un selected state
|
protected dimension get normal dimension int width chord string nb 1 string spacing 2 horizontal margin int height chord fret nb fret spacing top margin bottom margin dimension panel size new dimension width height return panel size
|
get the dimension needed for the graphics
|
protected dimension get dimension double ratio dimension dim get normal dimension double width dim get width double height dim get height width ratio height ratio dim set size width height return dim
|
get the dimension needed for the graphics
|
private url get image url string filename url l result get class get resource filename return l result
|
retreive the location of the specified file
|
public dimension get print dimension dimension dim get dimension print ratio double width dim get width double height dim get height dim set size width height print font get size 2 return dim
|
get the dimension needed for the graphics on which
|
public void set all unselection tag chord sheet sheet boolean tag chord ui temp null for int i 0 i sheet get chord count i temp sheet get chord at i temp need unselection tag
|
add a unselection tag on each chord of the sheet
|
public dimension get export dimension dimension dim get dimension export ratio double width dim get width double height dim get height dim set size width height export font get size 2 return dim
|
get the dimension needed for the graphics on which
|
public void set look and feel string laf class name if laf class name null laf class name equals current laf current laf laf class name try uimanager set look and feel current laf swing utilities update component tree ui this pack catch exception e joption pane show message dialog this chord cast get string chordcast invalid laf chord cast get string chordcast error joption pane error message
|
set the look and feel
|
public void mouse clicked mouse event e chord ui cui chord ui this if e get click count 2 chord editor ce new chord editor cui e consume end mouse clicked
|
process the clicks on the chord ui
|
public dimension get view dimension if is editable return get dimension view ratio else return get dimension editable ratio
|
get the dimension needed for the graphics on which
|
private void close dialog window event evt dispose
|
closes the dialog
|
public byte get note for string int string number return tuning string number 1
|
1 based index
|
public string get look and feel return current laf
|
return the class name of the current look n feel
|
public int get string spacing if is editable return int string spacing view ratio else return int string spacing editable ratio
|
return the distance between two string
|
public int get fret spacing if is editable return int fret spacing view ratio else return int fret spacing editable ratio
|
return the distance between two fret
|
protected string drop extension string name string ext int index index name last index of ext if index 0 return name substring 0 index else return name
|
return the name without the extension ext
|
protected string drop path string name int x y x name last index of y name last index of if x y return name substring x 1 name length else if x y return name substring y 1 name length return name if x y 1 there is no or
|
return the name without the path
|
public chord sheet load string url throws file format exception chord sheet new chord sheet tabbed pane try parser parse new file input stream url this catch ioexception exc throw new file format exception exc catch saxexception exc throw new file format exception exc return chord sheet
|
parse a xcs file and add the chord sheet to the tabbed pane
|
public int get horizontal margin if is editable return int horizontal margin view ratio else return int horizontal margin editable ratio
|
get the x start position of the neck
|
public int get start fret return start fret
|
get the first fret shown on the chord board
|
public byte get element int string id int fret id if is correct position string id fret id return neck string id 1 fret id else return error
|
get an element at the specified position on the chord board
|
public int get top margin if is editable return int top margin view ratio else return int top margin editable ratio
|
get the y start position of the neck
|
public vector load throws file format exception vector sheets new vector file chooser set current directory chord sheet file chooser default directory if file chooser show open dialog parent jfile chooser approve option file temp files temp files file chooser get selected files for int i 0 i temp files length i try sheets add loader saver load temp files i get absolute path chord sheet sheets element at i set file name temp files i get absolute path catch file format exception exc throw exc return sheets
|
ask a file to load then load it
|
public chord sheet load string url throws file format exception file chooser set current directory chord sheet file chooser default directory try chord sheet sheet loader saver load url sheet set file name url sheet set modified false return sheet catch file format exception exc throw exc
|
load a known file
|
public int get element size if is editable return int element size view ratio else return int element size editable ratio
|
get the element size size
|
public void set name string new name if new name null new name length 0 name empty name else name new name
|
set the name of a chord
|
public boolean save chord sheet sheet string save to throws ioexception try loader saver save sheet save to return true catch ioexception exc throw exc
|
save the chord sheet in a xcs format file
|
protected string format name file f chord sheet file filter p filter string ext get extension f string name f get name string url string ext wanted p filter get file extension if ext null ext equals ext wanted good extension url f get absolute path else wrong extension int pos name last index of if pos 0 there at least one dot in the filename url file chooser get current directory name substring 0 pos ext wanted else there is no dot in the filename url file chooser get current directory get absolute path name ext wanted return url
|
obtain a filename with the extension ext wanted
|
public void set start fret int start if start 0 start this fret max this fret nb start fret start
|
set the start fret of a chord
|
public byte get current element return this current element
|
get the current element
|
public void print page graphics g int start y boolean is real print while current chord index get neck count start y neck height page height start y print line g start y is real print
|
print all the line of chord that we can in the specified page
|
public void set element int string int fret byte element if is correct position string fret if is correct change fret element neck string 1 fret element
|
change a chord element
|
public int get neck count return chord sheet get component count
|
obtain the nunber of chord contain in the chordsheet to print
|
public void set current element byte elem this current element elem
|
set the current element
|
public void copy chord chord source chord set name source chord get name set start fret source chord get start fret set capo source chord has capo string nb source chord string nb fret nb source chord fret nb neck new byte string nb fret nb 1 for int i 1 i string nb i for int j 0 j fret nb j set element i j source chord get element i j system out println element changed
|
copy the content of source chord into the current chord
|
public neck get neck int i chord ui chord ui chord ui chord sheet get component i return chord ui get neck
|
get the chord neck at the specfied index
|
public boolean has capo return capo
|
indicate if the start fret is barred by a capo
|
public void set capo boolean capo value capo capo value
|
set the the start fret to be barred by a capo or not
|
public void change border if chord get start fret 0 border set title else string ext if chord has capo ext c else ext f border set title chord get start fret ext set border border
|
permit to update the border and the startfret
|
protected boolean is empty element int string id int fret id if neck string id 1 fret id empty return true else return false
|
verify if an element of the chord is empty or not
|
protected boolean is correct position int string id int fret id if string id 1 string id string nb return false it s a non valid guitar string if fret id 0 fret id fret nb return false it s a non valid fret if fret id fret nb fret id start fret fret max return false return true
|
verify if the position of the element is representable on the chord
|
protected boolean is correct change int fret byte element if element empty element barred element exists if element empty element ixe return true this type of elements can be placed anywhere if element dot element barred this type of elements cannot be placed on the fret 0 if fret 0 return false else return true if element zero element square this type of elements can only be placed on the fret 0 if fret 0 return true else return false return false mistake in the verification else return false it s non existent element
|
verify if the change is legal
|
public int compare to object o chord c chord o return name compare to c get name
|
compare using chord name
|
public void paint component graphics g change border super paint component g g set color neck showing color dimension dim get view dimension dimension real dim new dimension get width get height if dim equals real dim false set size dim if is editable paint blank chord g 0 0 view ratio paint it self g 0 0 view ratio else paint blank chord g 0 0 editable ratio paint it self g 0 0 editable ratio
|
paint the neck
|
public void print img graphics g int start x int start y paint chord g start x start y get print dimension print ratio printing color print font print fret font
|
called to print a chord
|
public void paint img graphics g int start x int start y paint chord g start x start y get export dimension export ratio printing color export font export fret font
|
draw the chord on a graphic for generate images used in the html
|
public void set title string new title title new title set modified true
|
set the chord sheet title
|
public void set author string new author author new author set modified true
|
set the chord sheet author
|
public void set default directory file dir if dir null dir is directory false default directory new file system get property user home else default directory dir
|
set the default directory in which the file chooser open
|
public void set comments string new comments comments new comments set modified true
|
set the chord sheet comments
|
public int get string nb return string nb
|
get the number of string common for each chord of the cbord sheet
|
public color get printing color return printing color
|
get the color in which the chord will be print
|
public void set string nb int nb string nb nb set modified true
|
set the number of string common for each chord of the cbord sheet
|
public int get fret nb return fret nb
|
get the number of fret common for each chord of the cbord sheet
|
public void set fret nb int nb fret nb nb set modified true
|
set the number of fret common for each chord of the cbord sheet
|
public void add chord chord ui new chord ui new chord ui this new chord ui add mouse motion listener this new chord ui add mouse listener this new chord ui add mouse listener popup listener new chord ui add key listener new key handler new chord ui set focusable true add new chord ui set modified true revalidate
|
add a empty chord to the chord sheet
|
public void add chord chord new chord chord ui new chord ui new chord ui this new chord ui add mouse motion listener this new chord ui add mouse listener this new chord ui add mouse listener popup listener new chord ui add key listener new key handler new chord ui set focusable true new chord ui set focus traversal keys enabled true new chord ui set chord new chord add new chord ui set modified true revalidate to refresh the chord sheet on screen repaint
|
add a chord to the chord sheet
|
public void set printing color color c printing color c
|
set the color in which the chord will be print
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.