method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
fc8f939b-37dd-4344-96e2-b8e96c89726d | 5 | public static int loadTexture(BufferedImage image, boolean flip){
int[] pixels = new int[image.getWidth() * image.getHeight()];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * BYTES_PER_P... |
b02ab6ce-b83d-43b2-98fb-fe4751b2067f | 7 | void move(final double msTime) {
if (p.radius > 0) {
double offset = velocity * msTime;
if (offset < PI2) {
if (p.angle < PI2 && (p.angle + offset) >= PI2) {
cnt++;
p.angle -= PI2;
}
} else {
... |
dc884459-78e4-47f6-b3bb-e23dd723f5ad | 1 | public static float sum(double[] a2) {
long a = 0l;
for(int i = 0; i < a2.length; i++) {
a += a2[i];
}
return a;
} |
e3a9599d-1602-4d80-be72-5ee6ddda1b38 | 0 | public void setSessionId(String sessionId) {
this.sessionId = sessionId;
} |
ebf36713-6dbf-4b6a-b125-29a0d2447a28 | 0 | public Position(int x, int y) {
this.x = x;
this.y = y;
} |
3d062f54-6f48-4d76-a0b1-4818452d5531 | 7 | private void deleteUser(String username, String userToDelete) throws RequestException , ConfigurationTaskException{
if(isAdmin(username)) {
final boolean userHasObject = userHasObject(userToDelete, "");
if((userHasObject) && (_userAccounts.containsKey(userToDelete))) {
try {
deleteUserObject(userToDe... |
4419b90d-f016-45ff-bb78-9537e90f7ce2 | 2 | public void test_01() {
initSnpEffPredictor("testCase");
String fileName = "./tests/vcf.vcf";
VcfFileIterator vcf = new VcfFileIterator(fileName, genome);
vcf.setCreateChromos(true);
for (VcfEntry vcfEntry : vcf) {
for (Variant seqChange : vcfEntry.variants()) {
System.out.println(seqChange);
Stri... |
7bffb283-4fd8-45ee-bbf4-fc109d9838ac | 1 | @Override
public int findColumn(String col) throws IllegalArgumentException {
ensureOpen("findColumn");
int colIndex = columnNames.indexOf(col);
if (colIndex < 0) {
throw new IllegalArgumentException("Unable to find column: " + col);
}
return colIndex + 1;
} |
7801eeb3-1b5f-4cbe-8fde-8216cdefab21 | 6 | private <T> String getBeanName(Class<T> registeredClass) {
Class<?>[] interfaces = registeredClass.getInterfaces();
if (interfaces != null && interfaces.length > 0) {
for (Class<?> anInterface : interfaces) {
if (matchInterfaceClassName(registeredClass, anInterface)) {
... |
89309fe1-b7ef-4082-b195-8f1faf925dd1 | 5 | public void makeNext(){
currentword = (Kanji)tester.getNext();
if (currentword == null){
JOptionPane.showMessageDialog(null, "End of test!\n" + correct + " correct out of " + total);
kanjiTester.dispose();
try{
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(kanjiTester.file));
... |
4437cb26-80cc-4573-bda2-170c1fee721d | 3 | public void playStream() {
//if a row is selected
if(browseTable.getSelectedRow() >= 0) {
//get url
String url = getStreamInfo()[0];
String name = getStreamInfo()[1];
//if url = "" it fails
if(url == null || url.equals("")) {
JOptionPane.showMessageDialog(getMe()
,trans.getString("Messa... |
b9d51e3c-a806-47d4-8429-39feda5231b9 | 6 | @EventHandler(priority = EventPriority.HIGHEST)
public void entityDeath(EntityDeathEvent e) {
if(e.getEntityType().equals(EntityType.PLAYER)) {
try {
Player dead = (Player) e.getEntity();
if(e.getEntity().getKiller() != null) {
String isStaff = "";
if(dead.hasPermission("fxkdr.staff")) {
i... |
d9923118-5214-419d-8cb6-f41abb4b5fdd | 6 | protected void fillSimpleReflect(int[] pixels, int off, int adjust,
int x, int y, int w, int h) {
final float initConst = (dgdX * x) + gc;
final int[] grad = gradient;
for (int i = 0; i < h; i++) { //for every row
//initialize current value to b... |
eaf4e39c-df20-4606-bc34-c749333e4d24 | 7 | @Override
public void keyPressed(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.VK_UP) {
canvas.moveActive(canvas.getActiveX() - 1, canvas.getActiveY(),
canvas.getActiveX(), canvas.getActiveY());
}
if (event.getKeyCode() == KeyEvent.VK_DOWN
|| event.getKeyCode() == KeyEvent.VK_KP_DOWN) {
can... |
a9a296fa-a3a9-4cea-a17a-5e520370fdaa | 3 | protected static String getInnerListTag(String listType) {
if (listType.equals("dl")) {
return "dd";
}
if (listType.equals("ul") || listType.equals("ol")) {
return "li";
}
return null;
} |
a8de28c1-6c30-4214-82dc-42b0f7ca1011 | 2 | private void initialiserInterfaceGraphique()
{
// Création de la fenêtre
fenetre = new JFrame();
fenetre.setTitle("Othello");
fenetre.setSize(800, 400);
fenetre.setResizable(false);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.setJMenuBar(new BarreDeMenuDuJeu(this.fenetre));
// Cr... |
a334cb7a-885d-4525-9560-b077e2e01f76 | 9 | public void setMarkableBorders() {
String lastCategory = "O";
for (int i = 0; i < getSize(); i++) {
ConllToken t = getToken(i);
if (i-1 >= 0 && !lastCategory.equals("O") && !t.category.equals(lastCategory)) getToken(i-1).cat_end = true;
if (t.sent_start) lastCategory = "O";
if (!t.cate... |
ab19448f-081a-4d7b-aa1b-edcb6925725e | 0 | public boolean isInitialized() {
return this.initialized;
} |
1656b085-142a-4f57-b948-7cf9d29117ba | 2 | protected InputStream getAudioStream()
{
InputStream in = null;
try
{
URL url = getAudioURL();
if (url!=null)
in = url.openStream();
}
catch (IOException ex)
{
System.err.println(ex);
}
return in;
} |
bbfaeabc-eb2f-4e95-a27c-04e466e064ec | 9 | private Mesh loadMesh(String fileName){
String[] splitArray = fileName.split("\\.");
String extension = splitArray[splitArray.length -1];
if(!extension.equals("obj")){
System.err.println("Error: File format not supported for mesh data: " + extension);
new Exception().pri... |
7098fb64-e5d7-4c1b-a48d-a6013ef25678 | 4 | private int createVertShader(String filename) {
int vertShader = ARBShaderObjects.glCreateShaderObjectARB(35633);
if (vertShader == 0) {
return 0;
}
String vertexCode = "";
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(Shader.class.getResourceAsStream(filenam... |
5b7fa92a-71ba-4c96-b278-2543b24fd434 | 3 | public void clickSquare(int x, int y) throws GameFieldException {
if (model.isAvailableUnit(x, y)) {
selectUnit(x, y);
} else if (isSelected() && model.canMove(selectedSquareCoord.x, selectedSquareCoord.y, x, y)) {
model.makeMove(selectedSquareCoord.x, selectedSquareCoord.y, x, y);
selectedSquareCoord = nu... |
e1a419a2-8716-4689-b635-b2b8795d2ea2 | 5 | @Override
public void addPlayer(Player player) {
debug("Attempting to add player " + player.getName());
if (getPlayers().size() >= getMaxPlayers()) {
player.sendMessage(prefix + "This game is full");
debug("Game is full, player denied");
return;
}
... |
6917069d-1aa8-4975-b8dd-9aeaf09ffcf5 | 0 | public ClientState getState() {
return this.state;
} |
6d7373eb-9487-4448-998a-08a27cba154c | 8 | private static String processFeed(ArrayList<String> commandArray, ArrayList<City> cities, ArrayList<Mines> mines) {
boolean fed = false;
String fedName = null;
if (!commandArray.get(1).toLowerCase().equals("him")) {
return invalid + commandArray.get(1);
}
if (Integer.parseInt(commandArray.get(2)) ... |
f879b29b-302a-428e-818b-87cefc300ba5 | 2 | public static void open( final URI uri )
throws IOException
{
if ( Desktop.isDesktopSupported() ) {
Desktop.getDesktop().browse( uri );
} else if ( System.getenv( "DESKTOP_SESSION" ).startsWith( "KDE" ) ) {
new ProcessBuilder( "kfmclient", "openURL", uri.toASCIISt... |
11bf2183-6c8d-4f40-bfdf-b9201b772ff9 | 9 | public static void main(String[] args) {
System.out.println( "Available Processors = " + Runtime.getRuntime().availableProcessors() );
try {
reader = new BufferedReader(new FileReader("CityDataList.txt"));
writer = new BufferedWriter(new FileWriter("CityDataRecords.csv"));
try {
writer.write("\"Cit... |
3e187449-3afc-4cc6-ae73-4f772a6bdac0 | 5 | public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source.equals(input)) {
String line = input.getText().trim();
if (line.length() > 0) {
if (line.charAt(0) == '/') {
mainFrame.parseCmd(line);
resetLine();
addCmdToHistory(line); //... |
d6df02d6-8fce-41b0-af8b-c91e3d0be9da | 4 | public void symmetry(){
String sym;
sym = JOptionPane.showInputDialog("Give a number between zero and eleven :");
while(true){
if(sym.equals(sym.replaceAll("^[0-9]", "."))) sym = JOptionPane.showInputDialog("Give a number between zero and eleven :");
else if((Integer.parseInt(sym)<-1 || Integer.parseInt(sym... |
e28a1428-4870-4a48-89eb-add2ceaf874f | 2 | public Archive(byte src[]) {
Stream stream = new Stream(src);
int decompressedSize = stream.get24BitInt();
int compressedSize = stream.get24BitInt();
if (compressedSize != decompressedSize) {
byte dest[] = new byte[decompressedSize];
Bzip2Decompressor.decompressBuffer(dest, decompressedSize, src, compress... |
ccaf4995-7cdd-4626-8cf4-02970a85f32f | 2 | public static void main(String[] args)
{
//System.out.println("Buffon Pi Estimation");
//System.out.println("Enter the number of tries: ");
//Scanner in = new Scanner(System.in);
//int tries = in.nextInt();
int tries = 30000;
Random generator = new Random();
... |
29511fff-1103-4c98-8772-ba4d5792128d | 5 | public static Stack<Integer> findUnsafe(Bank[] bankList, double limit, Stack<Integer> unsafeBanks) {
int c, l;
boolean stateChanged = true; //initialization as true to get the logic going
//if there's been a change in state, primarily a bank in the list has been flagged as unsafe
//start from the beginnin... |
4fd2f7ee-8d97-4551-89fd-4d4f7d1836ad | 6 | @Override
public void flush() {
if(open) {
if(toConsole) {
System.out.flush();
}
if(toFile) {
try {
fw.flush();
} catch(IOException e) {
e.printStackTrace();
}
}
if(toStream) {
try {
outStream.flush();
} catch(IOException e) {
e.printStackTrace();
}
}... |
0dd6c80c-119b-4a0b-ab09-9e5b55ef17c3 | 2 | public boolean existsIntersection(String locationpath1, String locationpath2, String xsdFile){
/*
* mu-calculus satisfiability solver for XML
* entwickelt von Pierre Geneves
* stand zur Zeit der Abgabe noch nicht vollstndig zur Verfgung. Daher konnte nur der Schnitttest ohne
* XML-Schema oder DTD, nicht ... |
08237b59-a6f6-4e6e-9e55-5d027bcf5130 | 4 | public void CopyBlock(int distance, int len) throws IOException
{
int pos = _pos - distance - 1;
if (pos < 0)
pos += _windowSize;
for (; len != 0; len--)
{
if (pos >= _windowSize)
pos = 0;
_buffer[(_pos++)] = _buffer[(pos++)];
if (_pos >= _windowSize)
Flush();
... |
7a769af3-a6c3-4682-a650-01fbbf7f6b8c | 2 | private String getClassification(String data){
if(data.charAt(3) == 'h'){
return "Healthy";
}
if(data.charAt(3) == 'u'){
return "unHealthy";
}
return null;
} |
a6679d18-3074-44ba-82cb-24871ab6a9ae | 8 | public static void main(String[] args) {
// Create a variable for the connection string.
String connectionUrl =
"jdbc:sqlserver://localhost:1433;" +
"databaseName=AdventureWorks;integratedSecurity=true;";
// Declare the JDBC objects.
Connection con = null;
... |
a0c61314-65ef-4362-bf3b-94889566c53b | 0 | public void setChunkedTransfer(boolean chunkedTransfer) {
this.chunkedTransfer = chunkedTransfer;
} |
b0fb911c-21e9-4ac6-8791-95c30b7251cb | 7 | private static int[][] FileToGraphArray(String dat) {
int[][] A = null;
FileInputStream fis = null;
try {
fis = new FileInputStream(dat);
} catch (Exception e) {
System.out.println(dat + " konnte nicht geoeffnet werden");
System.out.println(e.getMessag... |
2f672769-46fc-40c9-9d97-829376949cb0 | 1 | public String getLine() {
String s;
try {
s = in.readLine();
} catch (IOException e) {
throw new RuntimeException("readLine() failed");
}
return s;
} |
5e58b97d-67e7-480a-af19-50477d66809f | 6 | public List<Entities> getContents() throws NotAContainerException {
Location containerLoc = Location.locationInFrontOf(player.getLocation(), player.getDirection());
if (board.containsLocation(containerLoc)) {
InanimateEntity on = board.tileAt(containerLoc).getOn();
if (on != null && on instanceof Inventory) {... |
49f83ce9-0889-4fbf-8360-f0e0c02f25db | 8 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
beans.SStatus sStatus = (beans.SStatus) session.getAttribute(common.BeansConfig.sStatus);
if (request.ge... |
15f2d133-2c43-46aa-9d73-91e15650b77c | 9 | public RestaurantPanel(RestaurantGui gui) {
this.gui = gui;
markets.add(new MarketAgent("Market 1"));
markets.add(new MarketAgent("Market 2"));
markets.add(new MarketAgent("Market 3"));
CookGui cookGui = new CookGui(cook, gui);
gui.animationPanel.addGui(cookGui)... |
cc9cf6fb-3b42-4575-91de-987439a269d3 | 8 | public JTimeSchedFrame() {
super("jTimeSched");
this.updateIconImage(false);
this.setPreferredSize(new Dimension(600, 200));
this.setMinimumSize(new Dimension(520, 150));
// create tray-icon and set default close-behavior
if (this.setupTrayIcon())
this.setDefaultCloseOperation(JFrame.HIDE_ON_CLO... |
ef31decb-93ac-4038-ba1a-08882b670d09 | 3 | @Override
public void mouseClick(int X, int Y) {
for(int i = 0; i < this.Matrix.size(); i++)
{
Rectangle rect = this.Matrix.get(i);
if(rect.contains(X,Y))
{
this.SelectedIndex = i;
break;
}
}
if(this.getM... |
deafadfa-de92-4905-a83a-78fdb7beabf2 | 3 | public int natrLookback( int optInTimePeriod )
{
if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) )
optInTimePeriod = 14;
else if( ((int)optInTimePeriod < 1) || ((int)optInTimePeriod > 100000) )
return -1;
return optInTimePeriod + (this.unstablePeriod[FuncUnstId.Natr.ordinal()]) ... |
14b89222-87a2-4645-9121-acadf17d20f9 | 5 | public void iterativeInOrder(TreeNode root) {
if (root == null) {
return;
}
Stack<TreeNode> stack = new Stack<TreeNode>();
TreeNode currentNode = root;
while (currentNode != null) {
if (currentNode.getLeft() != null) {
stack.push(currentNode);
currentNode = currentNode.getLeft();
} else {
... |
18f20ea1-0ca0-48f6-bb14-a028659bb11a | 7 | public static boolean getUserChoice(){
boolean shouldCallContinue = false;
chosen = null;
do {
System.out.println((userColor.equals("W"))?player1 + "'s turn:":player2 + "'s turn:");
System.out.println("Choose your piece to move: Tell me its x-coordinate. Or, to undo the last move, input -1.");
my... |
f126bec0-97e2-42c7-90a0-a6e4042700ae | 4 | public static boolean accept(AbstractSyntaxNode node, TokenReader reader)
{
boolean result = false;
if (reader.accept(Token.OPEN_BRACK))
{
final Block block = new Block();
while (Statement.accept(block, reader)
|| IfStatement.... |
019fc664-b7c5-484b-89d1-190e03707cf4 | 7 | @Override
public int getMetricInternal() {
EflUtil.runToAddressNoLimit(0, 0, curGb.pokemon.afterDVGenerationAddress, curGb.pokemon.afterWildDVGenerationAddress);
int a = curGb.getRegister(Register.AF) >> 8;
int b = curGb.getRegister(Register.BC) >> 8;
int ab = ((a & 0xFF) << 8) | (b & 0xFF);
int atk = (a >>... |
fbe5c9ec-b2bc-441e-b747-54c9837e3347 | 5 | private void pop(char c) throws JSONException {
if (this.top <= 0) {
throw new JSONException("Nesting error.");
}
char m = this.stack[this.top - 1] == null ? 'a' : 'k';
if (m != c) {
throw new JSONException("Nesting error.");
}
this.top -= 1;
... |
0dc5dcba-b686-4b57-b53c-6405e476abd4 | 9 | public static boolean isAnagramTwo(String input, String base) {
if(input == null || base == null || input.length() != base.length()) {
return false;
}
int[] charCount = new int[256];
int uniqueChars = 0;
for(char c : input.toCharArray()) {
if(charCount[c] == 0) {
uniqueChars++;
}
++charC... |
8d72e6e7-5715-45d7-96e9-2629e301f857 | 6 | public int genSurvivability(Element e){
Random r = new Random();
switch(e) {
case ICE:
return r.nextInt(20)+20+genHeat(e);
case GAS:
int id = r.nextInt(20)+0+genHeat(e)/10;
if(id<0) {
id = 0;
}
return id;
case WATER:
return r.nextInt(20)+30-genHeat(e);
case FIRE:
return r.nextInt(20... |
37b9500e-7f80-4038-b301-cced8128808e | 3 | @Override
public void close() throws MusicPlayerException {
this.mLock.lock();
try {
//auto close the current audio
try (Audio audio = this.mCurrentAudio) {
this.stop();
if ( this.mCreateOwnThread && this.mPlaybackExecutor != null ) {
((ExecutorService) this.mPlaybackExecutor).shutdown();
}
... |
bc077391-1681-4411-92d9-205dcd598ab3 | 4 | public void evaluate(List<Parameter> params) {
if (fi == null)
try {
setFormula(formula);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (Parameter p : params) {
if (fi.hasVariable(p.name)) {
fi.setVariable(p.name, p.value);
}
}
value = fi.ev... |
47dd454c-c800-4173-8d4a-58c2eb6c78ef | 3 | private int g(Node n, Node startNode) {
// g = the movement cost to move from the starting point to a n, following the path generated to get there.
int g = 0;
Node parent;
do {
// Add 10 if next point is orthogonal, 14 for diagonal. see comment above.
parent = n.parent;
if ((n.x == pa... |
293594cc-9b25-4178-944b-f32a9fc838a1 | 3 | @Override
public void run() {
addMouseListener(this);
reset();
while (true) {
BufferStrategy bufferStrategy = getBufferStrategy();
try {
if (bufferStrategy == null) {
createBufferStrategy(2);
} else {
... |
d20258d6-6740-4d3c-adf5-c0ddbe6e9146 | 9 | @Test
public void testStaticMethods() throws Exception {
assertEquals(1024, bufferSizeFromPropertyName("buffer.memory.1024"));
assertEquals(2048, bufferSizeFromPropertyName("buffer.memory.2048"));
assertEquals(4096, bufferSizeFromPropertyName("buffer.memory.4096"));
assertEquals(8192... |
a92ff572-a131-41b6-b244-71f3a1ebf755 | 2 | public static void main(String[] args) {
int i = 0;
int j = 9;
do{
if(i>j--) {break;};
}while(i++<5);
System.out.print(i+" "+j);
} |
1eef69f1-0ac8-4e6c-88b1-aab033f93e4c | 5 | public static Tile create(String text) {
if(text == null) return null;
if(text.equalsIgnoreCase(MAX_TILE)){
return new MaxTile();
}
if(text.equalsIgnoreCase(MIN_TILE)){
return new MinTile();
}
if(text.equalsIgnoreCase(CLEANSING_TILE)){
return new CleansingTile();
}
if(text.equalsIgnoreCase(NEGA... |
f881d7a5-98e2-4ee4-ad19-131ae53e4273 | 0 | @Test
public void findHandFromCardSet_whenHandContainsAto5_returnsWheelStraight() {
Hand hand = findHandFromCardSet(FourFlushWithWheelStraight());
assertEquals(HandRank.Straight, hand.handRank);
assertEquals(Rank.Five, hand.ranks.get(0));
} |
f3d47bf6-8ba0-4d8d-8e2f-be3cf96ed8f5 | 3 | @SuppressWarnings("unchecked")
public void loadConfiguration() {
playerConfig = new ConfigAccessor(this, "players.yml");
playerConfig.saveDefaultConfig();
saveDefaultConfig();
if(playerConfig.getConfig().getConfigurationSection("players")!= null ) {
for(Ent... |
95fc542f-4d5c-4d27-b644-cb01fd7070eb | 9 | public Map<Position, List<Path>> findAvailablePaths(final Game game, final Position position, final int player) {
final List<List<Integer>> boardState = game.getBoardState();
if (boardState.get(position.getRow()).get(position.getCol()) != EMPTY_PLACE) {
return null;
}
fina... |
e4e9b2a3-fab9-424b-a96f-5d0713726ee5 | 8 | public QRDecomposition (Matrix A) {
// Initialize.
QR = A.getArrayCopy();
m = A.getRowDimension();
n = A.getColumnDimension();
Rdiag = new double[n];
// Main loop.
for (int k = 0; k < n; k++) {
// Compute 2-norm of k-th column without under/overflow.
double n... |
b9202a54-6237-4171-96e5-16e82a90ac65 | 1 | public void setMode(eBattleFieldMode mode) {
this.mode = mode;
for (GuiField g : displayedFields) {
g.setMode(mode);
}
} |
532c6ebe-298e-44b2-b746-aad8446ed860 | 8 | private boolean r_verb() {
int among_var;
int v_1;
// (, line 136
// [, line 137
ket = cursor;
// substring, line 137
among_var = find_among_b(a_4, 46);
if (among_var == 0)
... |
8bf1673f-7035-4af5-8258-73bf52e315ee | 9 | public static void main(String[] args) throws Exception {
Settings settings = new Settings();
for (String arg : args) {
settings.parseSetting(arg);
}
OutputStream outp;
if (settings.output.length() == 0) {
outp = System.out;
} else {
File file = new File(settings.output);
File dir = file.g... |
6d2c06b1-34c0-4a0b-8a0d-d19a40e47cf3 | 4 | public boolean search(File file)
{
try
{
Scanner in = new Scanner(new FileInputStream(file));
boolean found = false;
while (!found && in.hasNextLine())
{
String line = in.nextLine();
if (line.contains(keyword)) found = true;
}
... |
0be28bd3-2f9a-431f-bbac-53afc6873e36 | 2 | private boolean moveIfLegal(Point thePoint) {
// TODO Auto-generated method stub
boolean moveWorked=false;
if(!this.wouldBeInCheck(thePoint))//if the selected move wouldn't move it into check, then lets move it
{
Piece pieceTryingToMove = chosenPiece;
Point previousLocation =chosenPiece.myLocation;
mov... |
d9cfa949-1dcf-46ad-ab20-3dacb5bb2dad | 2 | private void bootKernel_fastbootButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bootKernel_fastbootButtonActionPerformed
JFileChooser imgChooser = new JFileChooser();
imgChooser.setDialogTitle(parser.parse("bootKernel:title"));
imgChooser.setApproveButtonText(parser.pars... |
94d88af2-4caa-486e-8251-3c77685143d0 | 6 | public void addSpline(int x, int y)
{
if (last != null && Math.sqrt(Math.pow(x - last.x, 2) + Math.pow(y - last.y, 2)) < Const.brushWidth)
return;
Spline s = new Spline(x, y, last);
if (last != null && last.prev != null)
{
if (Math.abs(getAngle(s) - getAngle(l... |
08528478-1b18-4e33-a8cf-d2bd5ed78ecd | 7 | public void initForeignService(){
File file = new File(Util.FOREIGNSERVICEPATH);
if(!file.getParentFile().exists()){
file.getParentFile().exists();
}
if(file.exists() && file.isFile() && file.length()!=0){
once = OnceClass.getOnce();
try {
InputStream in = new FileInputStream(file);
ObjectInput... |
d2a1f06b-d695-44e9-a202-ca8f4fb8720e | 1 | public Iterator iterator() {
return new Iterator() {
int pos = 0;
public boolean hasNext() {
return pos < count;
}
public Object next() {
return elementObjects[pos++];
}
public void remove() {
if (pos < count)
System.arraycopy(elementObjects, pos, elementObjects,
pos - 1, ... |
a0b1c809-e380-47df-abd6-6bbefef9891d | 2 | public final void reserve(int count) throws VerifyException {
if (stackHeight + count > maxHeight) {
maxHeight = stackHeight + count;
if (maxHeight > stack.length)
throw new VerifyException("stack overflow");
}
} |
ee62eba3-e020-4b9b-9978-799515b018c9 | 4 | private void simulate(double t) {
physicsLock.lock();
// Do physics for bodies
for (int k = 0; k < bodies.size(); k++) {
Body b = bodies.get(k);
Vector3D vHalf = b.velocity.clone().add(a[k].multiply(t / 2d));
b.position.add(vHalf.clone().multiply(t));
a[k] = getAcceleration(b);
b.velocity = vHalf.a... |
81a52ce2-d895-4e9f-86ff-cb18f2bd193e | 2 | @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
int i = 0;
Set<Map.Entry<String, String>> entries = this.entrySet();
int size = entries.size();
for (Map.Entry<String, String> entry : entries) {
... |
c6e9e810-3684-44eb-a17c-2d3720d044eb | 0 | private boolean sendObfuscatedHandshake(Socket socket, byte[] remotePeerId, boolean obfuscate) throws IOException {
OutputStream os = socket.getOutputStream();
Handshake hs = Handshake.craft_obfuscated(this.torrent.getInfoHash(), this.id, remotePeerId, obfuscate);
os.write(hs.getBytes());
logger.debug("Send Han... |
79045f73-1759-47a9-a4b5-a6b5e62b0b20 | 4 | public Platform(int id, int x, int y, int w, int h)
{
super(id,x,y,w,h);
int hv1 = (int) (Math.random()*2)+1;
if(hv1==1)
hv=-2;
if(hv1==2)
hv=2;
int vv1 = (int) (Math.random()*2)+1;
if(vv1==1)
vv=-1;
if(vv1==2)
vv=1;
vcount=0;
} |
ce2662b7-4445-401b-b223-babbc5712cc0 | 4 | private void checkCollision() {
for(int i = 0; i< StartingClass.hb.size();++i){
if(r.intersects(StartingClass.hb.get(i).r)){
visible = false;
if (StartingClass.hb.get(i).health > 0) {
StartingClass.hb.get(i).health -= 1;
}
if (StartingClass.hb.get(i).health == 0) {
StartingClass.hb.ge... |
810c582f-e9b7-488d-973f-9226df0055f2 | 9 | public ImagePyramid(ImageBuffer base) {
pyramid[0] = new ImageBuffer(base.width + 1, base.height + 1);
for (int y = 0; y < base.height; y++)
for (int x = 0; x < base.width; x++)
pyramid[0].pix[x + y * pyramid[0].width] = base.pix[x + y * base.width];
for (int level = 1; level < p... |
acdc2226-0815-44c4-807a-6adf61749bef | 0 | public void setMaxHealth(int maxHealth) {
this.maxHealth = maxHealth;
} |
e2015366-01ff-4f85-8478-9d6b5c6b6989 | 1 | private void newPLButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newPLButtonActionPerformed
//Confirm new playlist
int result = JOptionPane.showConfirmDialog(null, "Create new playlist? "
+ "Previous unsaved list will be lost.", "Create New List",
... |
3f3f1c7c-c4d5-4b58-be0a-ed7600617777 | 5 | public static <K> void main(String[] args) {
String pathname = "/Users/Roberto/git/ProjectEuler/file1.txt";
File f = new File(pathname);
HashMap<String, Integer> map = new HashMap<String, Integer>();
if ( f.canRead() ) {
try {
Reader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);... |
1e88f432-18f2-4c70-9616-4466d1c0d7c7 | 2 | int endIndexOfParameter(char[] expressionChars, int j) {
while (j < expressionChars.length && !isParameterSeparator(expressionChars[j])) {
j++;
}
return j;
} |
5b496aeb-e709-4889-9727-c633076fa752 | 8 | @Override
public DenseMatrix64F getQ( DenseMatrix64F Q , boolean compact ) {
if( compact ) {
if( Q == null ) {
Q = CommonOps.identity(numRows,minLength);
} else {
if( Q.numRows != numRows || Q.numCols != minLength ) {
throw new Ille... |
9222e2f6-8716-4260-ba8f-651a1e947585 | 6 | public static String[] split(String stringToSplit, String splitString) {
if(StringUtil.isNullOrEmpty(stringToSplit)) {
return new String[]{};
}
int splitStringLenght = splitString.length();
int searchIndex = stringToSplit.indexOf(splitString);
int startIndex = 0;
Vector resultVector = new Vector();
whi... |
0e494a45-98a6-4dd4-beb1-9c32f49b48f4 | 9 | public boolean skipPast(String to) throws JSONException {
boolean b;
char c;
int i;
int j;
int offset = 0;
int length = to.length();
char[] circle = new char[length];
/*
* First fill the circle buffer with as many characters as are in the to
* string. If we reach an early end,... |
3cbf7cc0-0a09-492c-8152-4e8f5f1c80d3 | 7 | @Override
public Quest findQuest(String qname)
{
Quest Q=fetchQuest(qname);
if(Q!=null)
return Q;
for(int i=0;i<numQuests();i++)
{
Q=fetchQuest(i);
if((Q.displayName().trim().length()>0)
&&(Q.displayName().equalsIgnoreCase(qname)))
return Q;
}
for(int i=0;i<numQuests();i++)
{
Q=fetchQ... |
f81b1fb1-0449-4b0c-8933-eaff8bf49ce4 | 8 | public void parseElement(Element element) {
this.id = element.getAttribute("id");
String marginStr = element.getAttribute("margin");
margin = Integer.parseInt(marginStr);
this.helper = new FormLayoutHelper();
NodeList components = element.getElementsByTagName("component");
... |
6aef177e-f232-4be7-86fc-160868ad5d33 | 5 | public static void handleEvent(int eventId)
{
if(eventId == 1)
{
Main.HowToPlayScreen.setVisible(false);
Main.HowToPlayScreen.setEnabled(false);
Main.HowToPlayScreen.setFocusable(false);
Main.mainFrame.remove(Main.HowToPlayScreen);
Main.mainFrame.add(Main.mainMenu);
Main.mainMenu.s... |
aa2cbe11-0d2a-4ebf-a5a4-a452c9b353e4 | 0 | public void setDepartureStation(String value) {
this._departureStation = value;
} |
4a697627-8322-4573-bf37-e92f7fb1d980 | 0 | public void setFoo1(T1 foo1)
{
this.foo1 = foo1;
} |
ca779e14-472b-4fb4-9d47-803181512a64 | 8 | private static String step5(String word)
{
// step 5a
if (word.endsWith("e") && getMeasure(stemWord(word, "e")) > 1) // (m>1) E -->
{
word = replace(word, "e", "");
}
else if (word.endsWith("e") && !endsWith_cvc(stemWord(word, "e")) &&
getMeasure(... |
03555dc7-bf8d-47ff-b373-05f834c33f5e | 8 | public MonopolyResult startGame (String gameName, int humanPlayers, int computerizedPlayers, boolean useAutomaticDiceRoll)
{
try
{
if(_gameManager.isGameExists())
{
return new MonopolyResult("only one game allowed");
}
if(game... |
be13721c-443a-4298-a994-63f3f6156bfa | 6 | public void body()
{
// Process Events until END_OF_SIMULATION is received
Sim_event ev = new Sim_event();
for (sim_get_next(ev); ev.get_tag() != GridSimTags.END_OF_SIMULATION;
sim_get_next(ev) )
{
if ( !active_ ) {
continue; // Skip proces... |
74503c1b-37cf-409e-90bc-27be0c4aef26 | 7 | private boolean processProperties(Properties properties) {
String kind = properties.getProperty("kind");
if (kind.equalsIgnoreCase("t1") || kind.equalsIgnoreCase("t3")) {
String author_id = SQL.getInstance().get_author_id(properties.getProperty("author"));
if (author_id == null) {
return false;
}
}
... |
13feb048-6ce4-489c-998e-62950060a89d | 9 | public void setData(ItemCaract caract, Numeric value) {
if (caract.getNumericType() != value.getNumericType()) {
throw new IllegalArgumentException();
}
if (data.containsKey(caract.getNumericType())) {
throw new IllegalStateException();
}
data.put(caract, value);
boolean change = false;
do {
chan... |
9d0ad33b-2c9a-44d7-9d47-c0fd24c299b1 | 3 | private static void storeMenu() {
String name = "Avakiri Sword";
System.out.println("Please enter the name of the item you would like to buy\n\n");
for(int i = 0; i < Constants.storeItemNames.length; i++)
System.out.println(" - " + Constants.storeItemNames[i]);
try{
kb.nextLine();
name = kb.nextLi... |
4da2d0c5-5224-4892-84c0-a22ce115c29f | 7 | public void placeMap() {
// fill with walls
Tile temp = new Tile("assets/data/spr_16x16Wall.png");
temp.setPassable(false);
for (int x = 0; x < map.getWidth(); x++) {
for (int y = 0; y < map.getHeight(); y++) {
map.setTile(x, y, temp);
}
}
// draw edges - TRANSPARANT BACKGROUNDS ARE NOT TRANSPARA... |
c74e9573-9326-4f03-8c60-f6c44ab1cd17 | 3 | private int getGroupPosition(String name, String fnmPrefix)
/*
* Search the hashmap entry for <name>, looking for <fnmPrefix>. Return its
* position in the list, or -1.
*/
{
ArrayList groupNames = (ArrayList) gNamesMap.get(name);
if (groupNames == null) {
System.out.println("No group names for " + name);... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.