input
stringlengths 10
828
| output
stringlengths 5
107
|
|---|---|
public void reverse if valid throw new runtime exception cannot reverse not valid polygon for int i 1 n count 1 i count 2 i n mass tmp masses i masses i masses n masses n tmp
|
reverts polygon orientation
|
public double get area throws runtime exception if valid double area 0 for int i 0 i verts length 1 i area verts i x verts i 1 y verts i 1 x verts i y return area 5 else throw new runtime exception cannot calculate area of non valid polygon
|
calculates area of this polygon
|
public void reverse throws runtime exception if valid throw new runtime exception cannot reverse not valid polygon int count get count vec2d new verts new vec2d count new verts 0 verts 0 for int i 1 i count i new verts i verts count i verts new verts update edges
|
reverts polygon orientation
|
public void paint graphics g graphic panel gp font metrics fm g get font metrics f g set font f int h fm get ascent 2 for int i 0 i pts npoints i string s integer to string i int w fm string width s 2 g draw string integer to string i pts xpoints i w pts ypoints i h
|
paint this curve into g
|
public void test find employee system out println find employee employee service instance new employee service instance find employee todo review the generated test code and remove the default call to fail fail the test case is a prototype
|
test of find employee method of class com
|
public void test get employee system out println get employee employee service instance new employee service instance get employee todo review the generated test code and remove the default call to fail fail the test case is a prototype
|
test of get employee method of class com
|
public void test create new employee system out println create new employee employee employee null employee service instance new employee service employee exp result null employee result instance create new employee employee assert equals exp result result todo review the generated test code and remove the default call to fail fail the test case is a prototype
|
test of create new employee method of class com
|
public void add canvas model listener canvas model listener l listeners add l
|
adds a canvas model listener to the drawing
|
public void remove canvas model listener canvas model listener l listeners remove l
|
removes a canvas model listener from the drawing
|
public attribute set get attribute set return this
|
returns self as an code attribute set code
|
public boolean can insert handle int handle index return false
|
inserting a handle is not currently supported
|
public boolean can delete handle int handle index return false
|
deleting a handle is not currently supported
|
public void insert handle int handle index throw new unsupported operation exception insert handle
|
inserting a handle is not currently supported
|
public void delete handle int handle index throw new unsupported operation exception delete handle
|
deleting a handle is not currently supported
|
public void add attribute listener attribute listener l listeners add l
|
add an code attribute listener code to the listeners of the class
|
public void remove attribute listener attribute listener l listeners remove l
|
remove an code attribute listener code from the listeners of the class
|
public object clone try drawing member ret drawing member super clone ret listeners new event source weak support return ret catch clone not supported exception e return null
|
clones the code drawing member code object
|
private void fire changed int action map old values map new values canvas model event e null for iterator it listeners iterator it has next canvas model listener l canvas model listener it next if e null e new canvas model event this action old values new values l model changed e
|
creates a canvas model event for each listener in the circuits listener list
|
public boolean contains attribute attribute attr return get attributes contains attr
|
determines if the code attribute set code contains the code attribute code
|
public attribute get attribute string name for iterator it get attributes iterator it has next attribute attr attribute it next if attr get name equals name return attr return null
|
returns an code attribute code whose name matches the parameter
|
public void paint graphics g selection selection set suppressed selection get draws suppressed for int i 0 n canvas objects size i n i canvas object shape canvas object canvas objects get i graphics dup g create if suppressed contains shape selection draw suppressed dup shape 0 0 else shape draw dup 0 0 dup dispose
|
draws a selection of shape objects on the given graphics object
|
public void set read only attribute attr boolean value throw new unsupported operation exception set read only
|
this operation is not supported
|
public action append action other return new action union this other
|
appends the code action code other to the current code action code
|
public canvas object get object at int x int y location loc location create x y for int i canvas objects size 1 i 0 i canvas object shape canvas object canvas objects get i if shape contains loc return shape return null
|
attempts to get an object at a specific location
|
public void do it first do it second do it
|
performs the first code action code and the second code action code
|
public void undo second undo first undo
|
performs the undo action for both code action code objects
|
public collection get objects in bounds bds array list ret null for int i 0 n canvas objects size i n i canvas object shape canvas object canvas objects get i if bds contains shape get bounds if ret null ret new array list ret add shape return ret null collections empty list ret
|
attempts to get all objects within a bounds
|
public canvas model get model return model
|
get the model the action is assigned to
|
public void add objects collection shapes array list added new array list shapes size for iterator it shapes iterator it has next object value it next if canvas objects contains value canvas objects add value added add value if added is empty fire changed canvas model event action added added 0 0 0
|
add all shapes in collection to the drawing
|
public void remove objects collection shapes array list removed new array list shapes size for iterator it shapes iterator it has next object value it next if canvas objects remove it next removed add value if removed is empty fire changed canvas model event action removed removed 0 0 0
|
removes all shapes in a collection from the drawing
|
public void move handle canvas object shape int index int dx int dy if canvas objects contains shape dx 0 dy 0 drawing member shape move handle index dx dy fire changed canvas model event action handle moved shape index dx dy
|
translates a handle for canvas object
|
public void insert handle canvas object shape int index drawing member shape insert handle index fire changed canvas model event action handle inserted shape index 0 0
|
inserts a handle for canvas object
|
public void delete handle canvas object shape int index drawing member shape delete handle index fire changed canvas model event action handle deleted shape index 0 0
|
deletes a handle for canvas object
|
public canvas tool get tool return listener get tool
|
returns the current code canvas tool code
|
public void set model canvas model value canvas model old value model if old value value if old value null old value remove canvas model listener listener model value if value null value add canvas model listener listener selection clear selected repaint fire property change tool property old value value
|
sets the current model to the specified code canvas model code
|
public void set tool canvas tool value canvas tool old value listener get tool if value old value listener set tool value fire property change tool property old value value
|
sets the active tool to the specified code canvas tool code
|
public void paint component graphics g canvas model model this model canvas tool tool listener get tool g clear rect 0 0 get width get height if model null graphics dup g create model paint g selection dup dispose if tool null graphics dup g create tool draw this dup dup dispose
|
redraws the canvas along with the circuit and tools
|
public void add selection listener selection listener l listeners add l
|
add a selection listener to this object
|
public void remove selection listener selection listener l listeners remove l
|
remove a selection listener from this object
|
private void fire changed int action collection affected selection event e null for int i 0 n listeners size i n i selection listener l selection listener listeners get i if e null e new selection event this action affected l selection changed e
|
fire a selection event
|
public boolean is empty return selected is empty
|
check if the selected objects list is empty
|
public boolean is selected canvas object shape return selected contains shape
|
check if an canvas object is contained in the selected objects list
|
public set get selected return selected view
|
get this objects set of selected canvas objects
|
public void clear selected if selected is empty array list old selected new array list selected selected clear handle shape null suppressed clear fire changed selection event action removed old selected
|
clear this objects set of selected canvas objects
|
public void set selected canvas object shape boolean value if value if selected add shape fire changed selection event action added collections singleton shape else if selected remove shape suppressed remove shape if handle shape shape handle shape null fire changed selection event action removed collections singleton shape
|
add or remove a canvas object from this objects selected list
|
public set get draws suppressed return suppressed view
|
get this objects suppressed view set
|
public void clear draws suppressed suppressed clear handle dx 0 handle dy 0
|
clear this objects suppressed view set
|
public canvas object get handle shape return handle shape
|
get this objects handle shape canvas object
|
public int get handle index return handle index
|
get the index of this objects handle shape canvas object
|
public void set handle selected canvas object shape int index handle shape shape handle index index handle dx 0 handle dy 0
|
set this objects handle shape
|
public void clear set old comps comps comps new hash set pins new circuit pins wires new circuit wires clocks clear fire event circuit event action clear old comps
|
clears internal components and variables of circuit
|
public void add circuit listener circuit listener what listeners add what
|
add a circuit listener to the circuit
|
public void remove circuit listener circuit listener what listeners remove what
|
remove a circuit listener from the circuit
|
public boolean equals object other if other instanceof wire return false wire w wire other return w e0 equals this e0 w e1 equals this e1
|
check if another object casted as a wire has the same locations
|
private void fire event int action object data fire event new circuit event action this data
|
create a circuit event and fire it
|
public int hash code return e0 hash code 31 e1 hash code
|
get the hash code for the wire object
|
private void fire event circuit event event for iterator it listeners iterator it has next circuit listener what circuit listener it next what circuit changed event
|
fire the given event by looping through all circuit listeners in
|
public int get length return e1 get y e0 get y e1 get x e0 get x
|
get the length of the wire
|
public string to string return wire e0 e1
|
get a string representation of a wire object
|
public set get width incompatibility data return wires get width incompatibility data
|
get the width incompatibility data of the wires in the circuit
|
public void add component listener component listener e
|
unused inherited method
|
public bit width get width location p return wires get width p
|
get the width of a wire at specific location
|
public void set value location pt value val component cause int delay if base null base set value this pt val cause delay
|
p sets the value of all inputs at the given point to the
|
public location get width determinant location p return wires get width determinant p
|
get the width determinant of a wire at specific location
|
public boolean has conflict component comp return wires points has conflict comp
|
check if a component has a wire conflict
|
public component factory get factory return wire factory instance
|
gets the instance of the static wire factory associated with the program
|
private set get components return collection util create unmodifiable set union comps wires get wires
|
get a set of all components and wires in the circuit
|
public location get location return e0
|
get the first location e0 of this wire object
|
public bounds get bounds int x0 e0 get x int y0 e0 get y return bounds create x0 2 y0 2 e1 get x x0 5 e1 get y y0 5
|
get the boundary box containing this wire object
|
public boolean contains component c return comps contains c wires get wires contains c
|
check if the circuit contains a component
|
public int compare to object other set data o set data other yes these subtractions may overflow this is intentional as it avoids potential wraparound problems as the counters increment int ret o time this time if ret 0 return ret return o serial number this serial number
|
compares this code set data code to the code object code
|
public set data clone for circuit state new state propagator new prop new state get propagator int dtime new prop clock state get propagator clock set data ret new set data time dtime new prop set data serial number new state loc cause val new prop set data serial number if this next null ret next this next clone for new state return ret
|
creates a new code set data code for the code component code
|
public bounds get bounds graphics g return get bounds
|
get the boundary box containing this wire object
|
public set get wires return wires get wires
|
get all wires in the circuit
|
public int hash code todo improve this hashing function return 31 cause hash code loc hash code
|
computes a hash for this code component point code
|
public set get non wires return comps
|
get all of the non wire components in the circuit
|
public boolean equals object other if other instanceof component point return false component point o component point other return this cause equals o cause this loc equals o loc
|
determines whether or not this code component point code is equal
|
public collection get components location loc return wires points get components loc
|
get a collection of all the components at a location
|
public end data get end int index location loc get end location index return new end data loc bit width unknown end data input output
|
get the data for the desired end point
|
public boolean ends at location pt return e0 equals pt e1 equals pt
|
check if either ends of the wire at at a location
|
public collection get split causes location loc return wires points get split causes loc
|
get a collection of all the split causes at a location
|
public void attribute value changed attribute event e propagator p propagator prop get if p null e get source remove attribute listener this else if e get attribute equals options sim rand attr p update randomness
|
updates the randomness value in code propagator code when it
|
public void propagate circuit state state normally this is handled by circuit wires and so it won t get called the exception is when a wire is added or removed state mark point as dirty e0 state mark point as dirty e1
|
sets each point of the wire as dirty so propagation is done correctly
|
public collection get wires location loc return wires points get wires loc
|
get wires in the circuit at a specific location
|
public collection get non wires location loc return wires points get non wires loc
|
get non wire components in the circuit at a specific location
|
public void draw component draw context context circuit state state context get circuit state graphics g context get graphics graphics util switch to width g width g set color state get value e0 get color g draw line e0 get x e0 get y e1 get x e1 get y
|
draw the wire with the given context
|
public void draw oscillating points component draw context context if is oscillating osc points draw context
|
draws only the components thar are oscillating
|
public set get split locations return wires points get split locations
|
returns a list of all points on the circuit where a wire starts
|
public object get feature object key if key custom handles class return this return null
|
get a feature of this wire
|
public collection get all containing location pt hash set ret new hash set for iterator it get components iterator it has next component comp component it next if comp contains pt ret add comp return ret
|
get all components that contain a specific location
|
public collection get all containing location pt graphics g hash set ret new hash set for iterator it get components iterator it has next component comp component it next if comp contains pt g ret add comp return ret
|
get all components in a graphics object that contain a specific location
|
public collection get all within bounds bds hash set ret new hash set for iterator it get components iterator it has next component comp component it next if bds contains comp get bounds ret add comp return ret
|
get all components that are within a boundary
|
public collection get all within bounds bds graphics g hash set ret new hash set for iterator it get components iterator it has next component comp component it next if bds contains comp get bounds g ret add comp return ret
|
get all components in a graphics object that are within a boundary
|
public wire set get wire set wire start return wires get wire set start
|
get the wire set that contains a specific wire
|
public void set read only attribute attr boolean value throw new unsupported operation exception
|
set if the wire is read only
|
public object get value attribute attr if attr dir attr return is x equal vert value horz value else if attr len attr return integer factory create get length else return null
|
get the value of one of the attributes of a wire
|
public void set name string name this name name fire event circuit event action set name name
|
set the name of the circuit
|
public void set value attribute attr object value throw new illegal argument exception read only attribute
|
set the value of an attribute
|
public void add component c if c instanceof wire wire w wire c if w get end0 equals w get end1 return wires add w else add it into the circuit wires add c comps add c if c instanceof pin pins add pin pin c else if c instanceof clock clocks add c c add component listener my component listener fire event circuit event action add c
|
add a component to the circuit
|
public void remove component c if c instanceof wire wires remove c else wires remove c comps remove c if c instanceof pin pins remove pin pin c else if c instanceof clock clocks remove c c remove component listener my component listener fire event circuit event action remove c
|
remove a component from the circuit
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.