input
stringlengths
10
828
output
stringlengths
5
107
public int get index for color int rgb int red rgb 16 0xff int green rgb 8 0xff int blue rgb 0xff oct tree node node root for int level 0 level max level level oct tree node child int bit 0x80 level int index 0 if red bit 0 index 4 if green bit 0 index 2 if blue bit 0 index 1 child node leaf index if child null return node index else if child is leaf return child index else node child system out println get index for color failed return 0
get the color table index for a color
public void remove knot int n if num knots 4 return if n num knots 1 system arraycopy x knots n 1 x knots n num knots n 1 system arraycopy y knots n 1 y knots n num knots n 1 system arraycopy knot types n 1 knot types n num knots n 1 num knots if x knots 1 0 x knots 1 0 rebuild gradient
remove a knot
public void build color table int in pixels int table int count in pixels length maximum colors table length for int i 0 i count i insert color in pixels i if colors reduce colors reduce tree reduce colors if colors maximum colors reduce tree maximum colors build color table root table 0
a quick way to use the quantizer
public void set knots int x int y byte types int offset int count num knots count x knots new int num knots y knots new int num knots knot types new byte num knots system arraycopy x offset x knots 0 num knots system arraycopy y offset y knots 0 num knots system arraycopy types offset knot types 0 num knots sort knots rebuild gradient
set the values of a set of knots
public void split span int n int x x knots n x knots n 1 2 add knot x get color x 256 0f knot types n rebuild gradient
split a span into two by adding a knot in the middle
public void set knot position int n int x x knots n image math clamp x 0 255 sort knots rebuild gradient
set a knot position
public void set interpolation int interpolation this interpolation interpolation
set the type of interpolation to perform
public int get interpolation return interpolation
get the type of interpolation to perform
public int get knot position int n return x knots n
get a knot position
public int knot at int x for int i 1 i num knots 1 i if x knots i 1 x return i return 1
return the knot at a given position
public void set lower threshold int lower threshold this lower threshold lower threshold lower threshold3 lower threshold 3
set the lower threshold value
public int get lower threshold return lower threshold
get the lower threshold value
public void set upper threshold int upper threshold this upper threshold upper threshold upper threshold3 upper threshold 3
set the upper threshold value
public void add knot int x int color int nx new int num knots 1 int ny new int num knots 1 system arraycopy x knots 0 nx 0 num knots system arraycopy y knots 0 ny 0 num knots x knots nx y knots ny x knots num knots x y knots num knots color num knots sort knots rebuild gradient
add a new knot
public int get upper threshold return upper threshold
get the upper threshold value
public void remove knot int n if num knots 4 return if n num knots 1 system arraycopy x knots n 1 x knots n num knots n 1 system arraycopy y knots n 1 y knots n num knots n 1 num knots rebuild gradient
remove a knot
public void set knot position int n int x x knots n pixel utils clamp x sort knots rebuild gradient
set a knot position
public void randomize num knots 4 int 6 math random x knots new int num knots y knots new int num knots knot types new byte num knots for int i 0 i num knots i x knots i int 255 math random y knots i 0xff000000 int 255 math random 16 int 255 math random 8 int 255 math random knot types i rgb spline x knots 0 1 x knots 1 0 x knots num knots 2 255 x knots num knots 1 256 sort knots rebuild gradient
randomize the gradient
public void mutate float amount for int i 0 i num knots i int rgb y knots i int r rgb 16 0xff int g rgb 8 0xff int b rgb 0xff r pixel utils clamp int r amount 255 math random 0 5 g pixel utils clamp int g amount 255 math random 0 5 b pixel utils clamp int b amount 255 math random 0 5 y knots i 0xff000000 r 16 g 8 b knot types i rgb spline sort knots rebuild gradient
mutate the gradient
public void set interpolation float interpolation this interpolation interpolation
set the interpolation factor
public float get interpolation return interpolation
get the interpolation factor
public void set wavelength float wavelength this wavelength wavelength
set the wavelength of the ripples
public float get wavelength return wavelength
get the wavelength of the ripples
public void set angle float angle this angle angle p2 new point int 64 math cos angle int 64 math sin angle
specifies the angle of the texture
public void set amplitude float amplitude this amplitude amplitude
set the amplitude of the ripples
public void set radius float radius this radius radius kernel make kernel radius
set the radius of the kernel and hence the amount of blur
public float get amplitude return amplitude
get the amplitude of the ripples
public void set phase float phase this phase phase
set the phase of the ripples
public float get phase return phase
get the phase of the ripples
public float get rings return rings
returns the rings value
public void set fibres float fibres this fibres fibres
specifies the amount of fibres in the texture
public float get fibres return fibres
returns the amount of fibres in the texture
public void set gain float gain this gain gain
specifies the gain of the texture
public void set bloom float bloom this bloom bloom
set the bloom factor
public float get bloom return bloom
get the bloom factor
public void set bloom threshold float bloom threshold this bloom threshold bloom threshold
set the bloom threshold
public float get bloom threshold return bloom threshold
get the bloom threshold
public void set brightness float brightness this brightness brightness initialized false
set the filter brightness
public float get brightness return brightness
get the filter brightness
public void set contrast float contrast this contrast contrast initialized false
set the filter contrast
public float get contrast return contrast
get the filter contrast
public float get origin x return x0 int math min math min x0 x1 math min x2 x3
get the origin of the output image
public float get origin y return y0 int math min math min y0 y1 math min y2 y3
get the origin of the output image
public void prepare int width int height float lx float math cos azimuth math cos elevation float ly float math sin azimuth math cos elevation float lz float math sin elevation direction new vector3f lx ly lz direction normalize if type distant lx distance ly distance lz distance lx width centre x ly height centre y position new vector3f lx ly lz real color set new color color real color scale intensity cos cone angle float math cos cone angle
prepare the light for rendering
public void set rgb buffered image image int x int y int width int height int pixels int type image get type if type buffered image type int argb type buffered image type int rgb image get raster set data elements x y width height pixels else image set rgb x y width height pixels 0 width
a convenience method for setting argb pixels in an image
public int get color float v int n int v 255 if n 0 n 0 else if n 255 n 255 return 0xff000000 n 16 n 8 n
convert a value in the range 0
public void set foreground int foreground this foreground foreground
set the foreground color
public int get foreground return foreground
get the foreground color
public void set background int background this background background
set the background color
public void set xscale int x scale this x scale x scale
set the x scale of the texture
public int get xscale return x scale
get the x scale of the texture
public int get color float v return spectrum wavelength to rgb 380 400 image math clamp v 0 1 0f
convert a value in the range 0
public void set yscale int y scale this y scale y scale
set the y scale of the texture
public int get yscale return y scale
get the y scale of the texture
public void set fuzziness int fuzziness this fuzziness fuzziness
set the fuzziness of the texture
public int get fuzziness return fuzziness
get the fuzziness of the texture
public void set angle float angle this angle angle cos float math cos this angle sin float math sin this angle
specifies the angle of rotation
public void set color1 int color1 this color1 color1
set the first color
public int get color1 return color1
get the first color
public void set color2 int color2 this color2 color2
set the second color
public int get color2 return color2
get the second color
public int get color float v return image math mix colors image math clamp v 0 1 0f color1 color2
convert a value in the range 0
public void set distribution int distribution this distribution distribution
set the distribution of the noise
public int get distribution return distribution
get the distribution of the noise
private string insert newline token string message string tokenizer stk new string tokenizer message true string temp string newstring int maxlength increment while stk has more tokens temp stk next token newstring temp add newline if longer and don t start with a space if newstring length maxlength temp equals newstring n maxlength newstring length increment return newstring
method for parsing the string
public void action performed action event e string str action e get action command url temp url try if str action contents temp url editor pane get page editor pane set page help url if str action close more portable if delegated process window event new window event this window event window closing catch ioexception ex new error dialogue ex this
an actionlistener so must implement this method
private void add buttons jbutton btn contents new jbutton contents btn contents add action listener this jbutton btn close new jbutton close btn close add action listener this put into jpanel jpanel pane buttons new jpanel pane buttons add btn contents pane buttons add btn close add panel south get content pane add pane buttons border layout south
add buttons at the south
private void calculate location dimension screen dim toolkit get default toolkit get screen size set size new dimension width height int locationx screen dim width width 2 int locationy screen dim height height 2 set location locationx locationy
locate in middle of screen
public connection get connection todo clone return con
does what it says
public recordset open recordset recordset temp new recordset con db name return temp
return a recordset opened on this connection
public recordset open recordset string str sql string origin throws sqlexception recordset temp new recordset str sql con db name origin return temp
return a recordset opened on this connection pass in string
public void close throws java sql sqlexception result set close
close recordset by closing result set
public string get autoincrement return autoincrement fieldname
return name of autoincrement field
public int get current position throws java sql sqlexception return currentlimitposition return result set get row currentlimitposition
return current position in recordset
public string getdbname return dbname
return name of database
public string getstr sql return str sql
return sql used to create recordset
private string check truncate string str sql string tokenizer stk new string tokenizer str sql string temp1 stk next token to upper case string temp2 if stk has more tokens temp2 stk next token if temp2 to upper case equals table str sql temp1 table temp2 return str sql
bug in driver add table if not there
public boolean move first throws java sql sqlexception currentlimitposition 0 set sql boolean blntemp false blntemp result set first return blntemp
move to first record in recordset
public boolean move last throws java sql sqlexception use last int divided num rows limit if num rows limit 0 divided 1 divided currentlimitposition divided limit set sql boolean blntemp false blntemp result set last return blntemp
move to last record in recordset
private void add components add table in centre jt new jtable dtm jt set selection mode list selection model single selection jscroll pane pane new jscroll pane jt get content pane set layout new border layout get content pane add pane border layout center
like it says add em
private void calculate size int rows dtm get row count int height font font jt get font font metrics fm jt get font metrics font int rowheight fm get height rowheight rowheight 15 spaces between rows if rows maxrows height maxrows rowheight else height rows rowheight set minimum size if totalwidth 300 totalwidth 300 if height 150 height 150 this set size new dimension totalwidth 30 height
set size of window
private void find widest columns what about something like select fldname max length fldname as big from tblname group by fldname order by big desc limit 1 widestcolumns new string dtm get column count for int x 0 x dtm get column count x widestcolumns x for int x 0 x dtm get row count 1 x for int y 0 y dtm get column count y string temp string dtm get value at x y field may be null if temp null temp length widestcolumns y length widestcolumns y temp
determine widest columns in order to
public boolean move next throws java sql sqlexception boolean temp false if result set get row currentlimitposition num rows check for on cusp if result set get row limit currentlimitposition limit set sql temp result set first else temp result set next return temp
move to next record in recordset
public boolean move previous throws java sql sqlexception boolean temp false check not on cusp if currentlimitposition 0 if result set get row 1 currentlimitposition limit set sql temp result set last else temp result set previous else temp result set previous return temp
move to previous record in recordset
public void move int position throws java sql sqlexception int positionto position limit int divided position limit currentlimitposition divided limit set sql use relative result set first todo is this right result set relative positionto 1
move to exact position in recordset
public int query execute string str sql throws java sql sqlexception for updateable connections only int numberchanged 0 statement tempstmt con create statement numberchanged tempstmt execute update str sql update number of records if add or delete str sql trim int n length str sql length string strtemp str sql strtemp strtemp to upper case if strtemp starts with delete num rows if strtemp starts with insert num rows return numberchanged
insert dete or update recordset
public void re query throws java sql sqlexception close recordset if connection lost crashes here todo result set close set sql set auto increment set count set array largest columns
close recordset reopen resetting all data members
private void open about window url about url create an url object use classloader so will open from jar file try about url class loader get system resource abouthtml about window about new about window this about my sqlgraphic about url about set visible true catch exception e new error dialogue e me
informational about window using html file
private void set internal location jinternal frame jif internallocationx step internallocationy step check if extends beyond window dimension djif jif get size dimension dthis this get size if djif width internallocationy dthis width djif height internallocationx dthis height internallocationx step internallocationy step jif set location internallocationx internallocationy
find next position for internal frame
private file create query directory file f null string path system get property user home try path file separator char mysqlgraphic file separator char queries f new file path if f exists f mkdir path file separator char dbname f new file path if not exist create it if f exists f mkdir message if unable to mkdir catch exception e f null return f
create directory for queries in the home directory
public void remove peer group communications peer group peer group assume that peer groups and peer ids are one to one peer group id peer group id peer group get peer group id log info removing peer group communications for peer group peer group get peer group name n peer group get peer group id to string remove peer group communications peer group id
stop listening for communications in peer group
public void remove peer group communications peer group id peer group id end jxtapeer socket listener thread jxtapeer socket monitor jxta peer socket listener peer group listeners get peer group id jxta peer socket listener quit close listening server socket try peer group comms contexts get peer group id close catch ioexception iox iox print stack trace remove references from mappings peer groups map remove peer group id peer group comms contexts remove peer group id peer group listeners remove peer group id log info removed peer group communications for peer group id n peer group id to string
stop listening for communications in peer group with peer group id
public void remove all communications log info removing all peer group communications for peer group id peer group id peer groups map key set remove peer group communications peer group id log info all peer group communications removed
stop listening for communications for all peer groups
public peer advertisement get peer peer id peer id return peers map get peer id
returns the peer advertisement corresponding to the peer with peer id
public void add supported operation handled operation string string operation try if launched throw new illegal operation addition exception can t add a operation after launcher manager is launched supported operations add operation log info added supported operation with id operation get operation id catch illegal operation addition exception ioae ioae print stack trace
adds a supported operation
public boolean is launched return launched
test to see if handled operations have been launched
public void launch launch null
launch all handled operations
public void set request interceptor jxtarequest interceptor interceptor this interceptor interceptor
sets the interceptor for this connection server
public jxtarequest interceptor get request interceptor return interceptor
retrieves the jxtarequest interceptor used by this connection server
public boolean is initialised return initialised
authn token result must be initialised before it can be used