method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4b4f83c8-17e8-4bf7-b081-c7b9a5e349ee
8
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> <S-IS...
79c39a42-24bf-4b52-9d22-fa267c860abf
0
public String getFamilienaam() { return familienaam; }
6df27f41-b17d-41ad-a31b-d8e1b21fb363
9
public ArrayList<String> gameInventory(){ ArrayList<String> gameInv = new ArrayList<String>(); String space =" "; for(Player p: allLivingPlayers()){ gameInv.add(("* " + p.playerTag + " *").concat(space.substring(p.playerTag.length() + 4))); for(Card c: p.inventory){ gameInv.add(c.nam...
008d7abb-e01e-45b7-b90f-1e8482b46588
3
@Override protected int onReadPacketHeader( ByteBuffer in ) { if (in.remaining() < HEADER_SIZE) { return ON_READ_REWIND; } int magicNumber = in.getInt(); if (magicNumber != protocol.getMagicNumber()) { return ON_READ_CLOSE; ...
7683d932-2fc5-4932-abcf-95082faffb43
5
public int resistedCounter(Type primary, Type secondary) { int counter = 0; if (resistantTypes == null || resistantTypes.length ==0) { return 0; } for (int i = 0; i < resistantTypes.length; i++) { if (resistantTypes[i].equalsTo(primary.showType()) || resis...
e41cdcd0-af76-4c69-a0e4-12704e6af490
7
private static void update(double time) { if (Input.getKeyDown(Keyboard.KEY_ESCAPE)) { switch (getGameState()) { case DEAD: break; case LOADING: break; case MAIN_MENU: break; case PAUSED: setGameState(GameState.PLAYING); break; case PLAYING: setGameState(GameState.PAUSED); ...
11ee3b35-9a7d-4f51-8c7f-db40a61fa7b9
3
@Override public void doAction(Player player, Grid grid) throws InvalidActionException { if (player.getRemainingTurns() <= 0) throw new InvalidActionException("The player has no turns left!"); Position currentPos = player.getPosition(); Position newPos = new Position(currentPos.getxCoordinate() + 1, curren...
e3b0ebfd-1948-44cb-971b-e558ceff7778
8
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking,tickID)) return false; if(affected==null) return false; if(!(affected instanceof MOB)) return true; final MOB mob=(MOB)affected; MOB diseaser=invoker; if(diseaser==null) diseaser=mob; if((!mob.amDead())&&((...
593af1c0-51df-4eec-a442-01d7024b3ad0
8
public String toShowData(String rs) { String[] arr = rs.split(DMSHandler.SEPCHAR); int len = arr.length; String show = ""; --len; for (int i = 0; i <= len; i++) { if (this.dimensions.get(i).equals(ADFormat.CITYNAME)) { show += this.getCity(arr[i]); } else if (this.dimensions.get(i).equals(...
0aea0582-e705-4643-8ff1-b691c4eb4afc
4
private void insertSQLiteData() { if (m_sqlTable == null) { return; } SQLiteTestData data = new SQLiteTestData(); data.id = 0; data.name = "SAM"; data.time = System.currentTimeMillis(); SQLiteTestData data1 = new SQLiteTestData(); data1.id = 1; data1.name = "JAMES"; data1.time = System.curr...
2fc4241c-eb47-4026-aa79-b1b80007d281
3
@Override public int[] makeMove(final char[][] field) { int[] move = new int[2]; String cellCode = input.next(); if (cellCode.equals("back")) { move[0] = Player.CODE_TAKE_STEP_BACK; } else if (cellCode.equals("exit")) { move[0] = Player.CODE_EXIT; } ...
3d177348-6b50-4d67-84ee-ffa240ee44b3
1
public static void main(String[] args) { for (Tester test : tests) { test.runTest(); } }
1635296a-efa5-4f85-9114-058a874b3ad8
5
void init() throws IOException { if(!initialized) { char c1 = (char) super.read(); char c2 = (char) super.read(); char c3 = (char) super.read(); int v = super.read(); if(c1 != 'S' || c2 != 'N' || c3 != 'Z') { throw new FormatViolationException("Illegal prefix in SNZ stream"); } if(v != 1) { ...
0ae9c7c8-d9a9-4671-a727-11ed0f361716
7
@Override public void setPage(HelpViewer viewer) { if(isDirectory){ String header = "<html><body><ul>"; String footer = "</ul></body></html>"; StringBuffer content = new StringBuffer(); File[] children = base.listFiles(); if((children != null)&&(children.length>0)){ for(int i=0;i<children.length;+...
a0b3b544-3d3e-4c50-9b5f-083637ab2bb0
5
public int getIntCode(String key) { if (key == "up") return up; else if (key == "right") return right; else if (key == "left") return left; else if (key == "down") return down; else if (key == "jump") return jump; else return 0; }
a20d4157-a767-4759-8ffa-ba3d3527bb76
7
private static File syncAssets(File assetDir, String indexName) throws JsonSyntaxException, JsonIOException, IOException { Logger.logInfo("Syncing Assets:"); final File objects = new File(assetDir, "objects"); AssetIndex index = JsonFactory.loadAssetIndex(new File(assetDir, "indexes/{INDEX}.json...
bc1c0310-bd48-4d75-a4b2-ed2ab4119214
7
public void switchEtatBouttons(){ Carte carte1, carte2; int val; //Affiche ou efface le boutton Assurance carte1 = d.main.getCarteDansMain(0); if(carte1.getValeur() == 1 && choixAssurance == false && propAssurance == false){ boutonAssurance....
c80a98b1-03e0-4e1b-802c-0e4491241e42
4
@Override public void mouseReleased(MouseEvent e) { int x = e.getX(); int y = e.getY(); if (x >= this.x && y >= this.y && x <= this.x + this.width && y <= this.y + this.height) setState(ButtonState.HOVER); else setState(ButtonState.NORMAL); }
1ff3908c-b48c-4a9f-86d0-ede350992c01
1
public boolean isEnabled() { return comp.isEnabled() && comp.getSelectedText()!=null; }
ea4003c8-babe-4a6a-a7c0-17534d398531
6
public void insertString(int i, String s, AttributeSet attributeset) throws BadLocationException { if (s == null || "".equals(s)) return; String s1 = getText(0, i); String s2 = getMatch(s1 + s); int j = (i + s.length()) - 1; if (isStrict && s2 == null) { s2 = getMatch(s1); j--; } else ...
6373127d-0e85-4840-b42e-e381f436b376
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DateTime other = (DateTime) obj; if (am != other.am) return false; if (day != other.day) return false; if (hour != other.hour) retur...
2987ae4d-24e4-45cf-bf12-bc914755e8ee
0
private void Initialize() { //random int to use when setting the car random = new Random(); //this is also used to restart the game, but it does the same thing ResetPlayer(); //used for control speedAccelerating = 2; speedStopping = 1; //used for "cross...
5b986c47-9c51-4f10-ad83-dcd418732f85
9
private Class getPrimativeClass(Object obj) { if (obj instanceof XPath) return XPath.class; Class cl = obj.getClass(); if (cl == Double.class) { cl = double.class; } if (cl == Float.class) { cl = float.class; } else if (cl == Boolean.class) { cl = bo...
92ad95fa-1f45-4707-8f95-e3e96f7c4a0b
6
private Monopoly(Loader loader) { go = loader.getGo(); jail = loader.getJail(); playerHashMap = loader.getPlayerHashMap(); serverOperator = new ServerOperator(this, loader); actions = new HashMap<Integer, HashMap<String, ActionThread>>(); //The thread will set the next player as active and will then wait f...
589cae23-81f5-4ce4-b7f2-9cdf1d75b842
2
public static boolean isDefined(String domain, String key) { if ( !config.containsKey(domain) ) return false; if ( !config.get(domain).containsKey(key) ) return false; return true; }
5d7d2080-534b-423a-9533-d5e47af682bc
1
private void endFormals() { if (seenFormalParameter) { declaration.append('>'); seenFormalParameter = false; } }
f687db49-07a5-4c7f-956c-74067cd71c57
4
public void draw1(Graphics2D g2){ g2.setStroke(new BasicStroke(10f)); // int n = 20; // if(n > particles.size()) n = particles.size(); for(int i = 0; i < particles.size(); i++){ int n = particles.size() - particles.get(i).age/50; for(int j = 1; j < n; j++){ int k = (j+i) % particles.size(); g2.setCo...
3de7adae-2531-44cd-85fe-77edfb22b2d7
2
public void dumpExpression(TabbedPrintWriter writer) throws java.io.IOException { subExpressions[0].dumpExpression(writer, 550); writer.breakOp(); writer.print(" <=>"); if (allowsNaN) writer.print(greaterOnNaN ? "g" : "l"); writer.print(" "); subExpressions[1].dumpExpression(writer, 551); }
e984a4d2-737b-42c9-b019-bddd960601e7
1
public void save() { JSONObject json = toJson(); try { File file = new File("rounds/" + System.currentTimeMillis() + ".json"); FileWriter fw = new FileWriter(file.getAbsolutePath()); fw.write(json.toString()); fw.close(); } catch (IOException ex) { ...
49563b16-6a22-4634-98f2-ffebc5e34023
8
@Override public void run() { while (!socket.isClosed()) { DatagramPacket p = new DatagramPacket(new byte[10], 10); try { socket.receive(p); } catch (IOException e) { continue; } Message m = new Message(...
a6e50b90-76d9-4760-8a0c-bafb4addff87
8
public boolean intersects(S2Loop b) { // a->Intersects(b) if and only if !a->Complement()->Contains(b). // This code is similar to Contains(), but is optimized for the case // where both loops enclose less than half of the sphere. if (!bound.intersects(b.getRectBound())) { return false; } ...
ce75c6fe-8bab-410d-80d8-2c62b1c8286f
1
public String getLabel() { if (label == null) label = "flow_" + addr + "_" + (serialno++) + "_"; return label; }
48a4e370-8fd2-4a3e-a7a8-522d55f5b9e1
4
private void blitToComponent(Graphics gScreen) { if (m_offscreen == null) return; do { int returnCode = m_offscreen.validate(getGraphicsConfiguration()); if (returnCode == VolatileImage.IMAGE_RESTORED) { // Contents need to be restored renderOffscreen(); // restore contents } else if (returnCod...
e321ead6-50c8-4f85-a9b2-17d740421707
4
@Override public Value evaluate(Value... arguments) throws Exception { // Check the number of argument if (arguments.length == 1) { // get Value Value value = arguments[0]; // If numerical if (value.getType().isNumeric()) { return new Value(new Double(Math.tan(value.getDouble()))); } if (val...
64ee771d-58cf-4510-a7fe-ca7afb969600
0
public KeyState getMainState(){ return mainState; }
95791fbd-02af-48db-9fd4-e2784e26ff79
4
@Override public void mouseClicked(MouseEvent e) { int x = e.getX(); int y = e.getY(); int oldSel = selectedObject; for (NSMBObject obj : objects) { Rectangle or = getRectFor(obj); if (or.contains(x, y)) ...
69b0fec2-5c18-4eb2-882b-2c7620592ceb
6
public static Stella_Object accessAbstractPropositionsIteratorSlotValue(AbstractPropositionsIterator self, Symbol slotname, Stella_Object value, boolean setvalueP) { if (slotname == Logic.SYM_LOGIC_SELECTION_PATTERN) { if (setvalueP) { self.selectionPattern = ((Cons)(value)); } else { ...
a4a02ca2-c21a-45c3-b825-107486598a51
1
public static Sprite loadSprite(String url, int width, int height) { File file = new File("res\\" + url); Sprite sprite; try { sprite = new Sprite(ImageIO.read(new File("res\\" + url)), width, height); System.out.println("Loaded: " + file.getAbsolutePath()); } catch (IOException e) { sprite = Sprite.pl...
26fc0057-c668-46c0-8e0b-89613b4ca149
3
public Music() { try { AudioInputStream audioIn = AudioSystem .getAudioInputStream(new File("music/theme.wav")); data = AudioSystem.getClip(); data.open(audioIn); data.loop(Clip.LOOP_CONTINUOUSLY); } catch(LineUnavailableException e) { e.printStackTrace(); } catch(UnsupportedAudioFileException...
5d8c79eb-4bdd-4e20-b934-46abb62f1b97
2
public final void changeWait(int wait) throws ArtistBiographyException { if(wait < 100 || wait > 20000) throw new ArtistBiographyException("The wait vale is not correct"); ArtistBiography.wait= wait; }
db04ea39-4109-414c-b7e1-0fc3034c0925
6
public int hashCode() { int hash = 7; hash = 73 * hash + (this.groupRule != null ? this.groupRule.hashCode() : 0); hash = 73 * hash + (this.artifactRule != null ? this.artifactRule.hashCode() : 0); hash = 73 * hash + (this.typeRule != null ? this.typeRule.hashCode() : 0); hash = ...
445a52a6-19ac-43e7-a403-4ca435162928
8
@EventHandler public void onPressurePlateStep(PlayerInteractEvent e) { if (HyperPVP.getSpectators().containsKey(e.getPlayer().getName()) || HyperPVP.isCycling() || !HyperPVP.hasMatchBeenAnnounced()) { if (e.getAction().equals(Action.PHYSICAL) && e.getClickedBlock().getType() == Material.STONE_PLATE) { e.setC...
cde211d4-df3c-4efb-8277-9f42a65a8b08
0
public TurnOffCommand(Receiver receiver) { this.receiver = receiver; }
d008b43f-7002-44f8-9623-2bce10a3910c
9
private void rehashTable() { if (keys == null) { if (check && keyCount != 0) Kit.codeBug(); if (check && occupiedCount != 0) Kit.codeBug(); int N = 1 << power; keys = new Object[N]; values = new int[2 * N]; } else { // Check...
24a4bb49-fd24-4ee6-b193-253b5b6d740a
3
public static String CatchTitle(int n) { InputStreamReader isReader= new InputStreamReader(MyMenu.class.getClassLoader().getResourceAsStream(path)); String title = null; try (BufferedReader reader = new BufferedReader(isReader)) { String line = reader.readLine(); // read the first line containing the descri...
74fa1113-b46a-4e00-95d7-0e1585e3f45a
1
private boolean jj_2_71(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_71(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(70, xla); } }
4a9de684-0a9d-4a16-a0c8-ca345a90065b
6
public static double[] decode_exactly (String geohash){ double[] lat_interval = {-90.0 , 90.0}; double[] lon_interval = {-180.0, 180.0}; double lat_err = 90.0; double lon_err = 180.0; boolean is_even = true; int sz = geohash.length(); int bsz = bits.length; double latitude, longitude; for (int i =...
de48a937-25c6-4b1b-97a7-95a00cb128eb
8
private boolean r_postlude() { int among_var; int v_1; // repeat, line 56 replab0: while (true) { v_1 = cursor; lab1: do { // (, line 56 // [, line 58 bra = cursor; // substring, line 58 among_var = find_among(a_0, 3); if (among_var == 0) { break lab1; } // ], line 58 ...
947cc815-6830-46f5-ae2e-9ef50c9d9c4f
2
PresenterFactory discover() { Iterable<PresenterFactory> discoveredFactories = PresenterFactory.discover(); List<PresenterFactory> factories = StreamSupport.stream(discoveredFactories.spliterator(), false). collect(Collectors.toList()); if (factories.isEmpty()) { retu...
f8e940cd-199f-4a4b-b661-9e818103064e
3
private void btnReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReporteActionPerformed final int totalFilas = this.table_ticket.getRowCount(); if (totalFilas > 0) { this.progress_bar.setVisible(true); this.setCursor(Cursor.getPredefinedCursor(Cursor....
9e8c55b3-3bf2-4314-bce9-c84ee3fae0db
3
public String read(String fileName){ String data = ""; String line; try { BufferedReader reader = new BufferedReader(new FileReader(fileName)); while((line=reader.readLine())!=null){ data+=line; } } catch (FileNotFoundException e) { this.plugin.logMessage("Unable to read from "+fileName+": "+e....
635d357e-0656-4073-825c-c0e40a5aa11b
1
public void populateSongLists() { if(!playerLibrary.isEmpty()) { titlesList.setListData(playerLibrary.getAllTitles().toArray()); artistList.setListData(playerLibrary.getAllArtists().toArray()); } else { titlesList.setListData(defaultList); arti...
6e0ec0b4-e760-4eb9-9fda-658f425eba9a
2
public static Vector<Place> getPlacesDisponiblesFromZone (String numS, String date, int zone) throws BDException { Vector<Place> res = new Vector<Place>(); String requete = "select norang, noplace, numZ from lesplaces where numz=" + zone + " MINUS select lestickets.norang, lestickets.noplace, numz from LesTickets, ...
0329c66c-d6ce-4b58-b374-7be34dbfc368
1
public GeocoderResponse parse(InputStream inputStream) throws IOException { YaGeocoderHandler handler = new YaGeocoderHandler(); try { parser.parse(inputStream, handler); } catch (Exception e) { throw new IOException("Failed to parse geocoder result: " + e.toString(), e);...
ac6e5856-e528-4385-ba18-b7a065e57fcb
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
de8c37d9-bdd8-4e4c-a64f-42d0a8b1a6bb
8
@Override public void onEnable () { if(getConfig().getConfigurationSection("playerFreqs") != null){ Map<String, Object> configmap = getConfig().getConfigurationSection("playerFreqs").getValues(false); for(Entry<String, Object> entry : configmap.entrySet()){ Double val = (Double)entry.getValue(); RadioPl...
37dbefa0-b04c-4ae7-a54b-502b673fdbdb
9
public void infinteLoop() { boolean quit = false; ui.hello(); do { UserChoice userChoice = ui.userChoiceMenu(); switch(userChoice) { case ADDCARD: addCard(); break; case MODIFYCARD: modifyCard(); break; case DELCARD: delCard(); break; case DISPLAYCARD: displayCard(); break; case D...
43221ef1-e8ce-4459-af3a-f46911c3e2cd
4
public void keyTyped(KeyEvent arg0) { if (arg0.getKeyChar() == 's') { panel_1.moveDown(); } if (arg0.getKeyChar() == 'w') { panel_1.moveUp(); } if (arg0.getKeyChar() == 'a') { panel_1.moveLeft(); } if (arg0.getKeyChar() == 'd') { panel_1.moveRight(); } }
b328046a-488d-4b1b-997a-931a8a9b6571
7
private void parseData(String content, List<String>[] alldata) throws ExcelException { boolean flag = false; Matcher m = REG_AMT_WM_PT.matcher(content); if (m.find()) { String cur = m.group(1); if (Constants.QUOTEBILL_CUR_AUD.equals(cur)) { alldata[0].add(...
583ac805-e726-4c5d-b0e1-be337b116260
3
private void deleteMail(int n) { String response = ""; try { sTrace.debug("Try DELE " + n + " Command"); writeToServer("DELE " + n); response = readFromServer(); if (response.startsWith("-ERR")) { sTrace.error("Could not delete Mail " + n); } else if(response.startsWith("+OK")){ sTrace.debug(...
a11a59b7-ba96-4152-9ab3-0329957f99ed
9
public void handleCommand(Message message) { if(!conn.conected()) return; String body = message.getBody(); if(body.startsWith(prefix)){ body = body.substring(prefix.length()); }else{ //(message.getBody().startsWith(connection.getNick()){ body = body.substring(conn.getNick().length()); if(body.matches(...
7fa7d1fe-7afa-475c-8204-b8de27df9bed
2
public boolean isKeyDown(int keyCode) { if (keyCode > 0 && keyCode < 256) { return keys [keyCode]; } return false; }
7006ffa3-6d8e-4fc2-9de2-a2526aef6e2b
7
public int getPrivs(Transaction trans, String username) throws SQLException, DatabaseException { trans=new JDBCTransaction(createConnection()); Connection connection = ((JDBCTransaction)trans).getConnection(); Statement stmt=connection.createStatement(); int x = 0; if(!validString(username)) throw ...
b80a2a5e-7871-43d3-bb95-ccc9ee8f29ec
5
public static List<Utterance> loadUtterances(String path) { List<Utterance> goldUtterances = new LinkedList<Utterance>(); Scanner input = null; try { System.out.println("Loading utterances from " + path + " ..."); input = new Scanner(new File(path)); goldUtterances = new LinkedList<Utterance>(); // P...
d78b1ad6-1cd0-4977-bf17-804c2b8249de
8
private Rectangle getRectangle(int x, int y, int w, int h, int location) { switch (location) { case SwingConstants.NORTH: return new Rectangle(x + w / 2 - dist / 2, y, dist, dist); case SwingConstants.SOUTH: return new Rectangle(x + w / 2 - dist / 2, y + h - dist, dist, dist); case SwingConstants.WE...
91b24aed-df3a-461d-a879-7121d0aacf9a
9
public boolean healDebuffed(Player p){ int modifier = 0; if(!healReduxImmune(p)){ if(p.status.containsKey(Card.carrionfeast)){ modifier -= 1; } if(p.status.containsKey(Card.wounded)){ modifier -= 1; } if(hallowHarm(p)){ for(Player player: allPlayersInArea(locationArea(p.location))){ ...
8299e1a9-9d03-46d9-afe1-53c9b34ac4c4
0
public static void main(String[] args) { WordReader wordReader = new WordReader("dict.txt"); System.out.println(wordReader.getDictionary()); }
d058ac23-58a4-4965-99fc-75722ecc08d1
2
private static int getMetaFromString(String idMeta) { String data; if(idMeta.contains(":")) { String[] s = idMeta.split(":"); if(s.length < 2) { data = idMeta.replace(":", ""); } else { data = s[1]; } } else { ...
7e306659-4ae2-4410-a6cd-1d38f04beb2f
4
@Override public void deserialize(Buffer buf) { super.deserialize(buf); firstCharacterId = buf.readInt(); firstCharacterCurrentWeight = buf.readInt(); if (firstCharacterCurrentWeight < 0) throw new RuntimeException("Forbidden value on firstCharacterCurrentWeight = " + fir...
7fdb6ea3-eacf-4c80-ab11-f6b283ff61ab
9
@EventHandler public void onEntityInteract(PlayerInteractEntityEvent event) { if (event.getRightClicked() instanceof StorageMinecart) { Player player = event.getPlayer(); String playerName = player.getName(); if (Configuration.data.contains(playerName) && (Configuration.config.getBoolean("Deny Storage.e...
a7e349c4-5c34-44d3-bdde-084c22424f2e
6
public void showLine (ListElement line) { ListElement e = TopLine; int h = Leading + Ascent; int totalh = getSize().height - Descent; if (Background == null) Background = getBackground(); int lines = 0; while (lines < PageSize && e != null) { if (e == line) return; h += Leading + Height; e = e.n...
3150211c-3efe-4b0b-aeab-8bda10dd4641
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.ora...
5c16c26f-4c28-43c2-9f25-a0e4488e397b
1
public Object saveOps() { Stack state = new Stack(); int pos = currentLine.length(); while (currentBP.parentBP != null) { state.push(new Integer(currentBP.breakPenalty)); /* We don't want parentheses or unconventional line breaking */ currentBP.options = DONT_BREAK; currentBP.endPos = pos; currentB...
dcc29e76-ef79-4f4c-9698-ac4d2804811c
0
public String getRandCode() { return randCode; }
dc9a3c95-2e44-41ff-b7e0-ae898d6340d8
8
public static String getColorFromMagnitudeAndPhase(final double magnitude, final double phase) { if (magnitude <= 1D / Const.MAX_RGB) { return Const.BLACK; } final double mag = Math.min(1D, magnitude); final double pha = (phase < 0D) ? phase + Const.TAU : phase; final double p = (pha * 6...
7c41442c-1db1-4850-a3ec-088b69ce2bf9
5
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; ...
a862535f-7967-43cc-bd62-b79df1752a2d
1
public void updateAll(){ update(); for (GameObject child: children){ child.updateAll(); } }
036a339f-61b2-4a6b-bc10-2136eec308e4
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof SiteBoundary)) { return false; } SiteBoundary other = (SiteBoundary) object; if ((this.featureID == null && oth...
650fb4c7-f103-41c2-825b-435b6a60e763
6
@SuppressWarnings("serial") ControlPanel(Model model, ModelControl mc, AnimationControl ac) { super(true); this.mControl = mc; this.aControl = ac; stateField.setText(State.STOP.getText()); model.addStateChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { ...
0631fa79-2992-47b2-9de5-f1b24155588a
9
public JSlider setSlider(JPanel panel, int orientation, int minimumValue, int maximumValue, int initValue, int majorTickSpacing, int minorTickSpacing) { JSlider slider = new JSlider(orientation, minimumValue, maximumValue, initValue); ...
ed384017-5e86-464b-b7ee-e9b2fed89bc9
9
public <T extends Comparable<? super T>> int search(T[] array, T key) { if (array == null) throw new NullPointerException("argument array is null"); if (key == null) throw new NullPointerException("argument key is null"); // Make sure every element is not null. f...
d8d57083-a54b-479c-9259-3309ec92bb4c
0
public View() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int screenWidth = (int) dim.getWidth() / 2; int screenHeight = (int) dim.getHeight() / 2; setLocation(screenWidth/2, screenHeight/2); container = this.getContentPane(); se...
5ad49a4e-0ce5-4f0f-99de-bb08d895398d
4
private void preloadCountryHistory() { GenericObject hist; String tag; final GenericObject countries = EUGFileIO.load(resolver.resolveFilename("common/countries.txt"), settings); for (ObjectVariable def : countries.values) { tag = def.varname...
d4d660e5-76a1-4c70-8fdd-0b40beb2e2a3
9
private static char[] getReplacementChars(char ch) { char[] replacement = null; if (ch == '"') { replacement = QUOT_CHARS; } else if (ch == '\\') { replacement = BS_CHARS; } else if (ch == '\n') { replacement = LF_CHARS; } else if (ch == '\r') { replacement = CR_CHARS; } else if (ch == '\t') { ...
47b52e1d-8d02-4a3c-b959-78e6458c768c
6
private void reduceHighestTrack(){ int[] highTrack=null; int position=0; //calcul the highest track while(highTrack==null){ if(model.getThrone()[position]==family.getPlayer()){ highTrack=model.getThrone(); }else if (model.getCourt()[position]==family.getPlayer()){ highTrack=model.getCourt(); }e...
ea47dad2-028b-4ac2-a079-0f4a8f88c576
4
public static void saveGame() { try { File save = new File(CFG.DIR, "saves/" + new SimpleDateFormat("'Spielstand' dd.MM.yyyy HH-mm-ss").format(new Date()) + ".save"); save.createNewFile(); JSONObject o = new JSONObject(); o.put("version", CFG.VERSION); o.put("created", Game.currentGame.worldCre...
25c51bdb-03b6-4c73-93b4-e64c2d09c2d4
8
public void setHeightWidthStartPosition(String height,String width,String startPosDescriptor) { this.height=Integer.parseInt(height); this.width=Integer.parseInt(width); int p1=startPosDescriptor.indexOf(','); int p2=startPosDescriptor.indexOf(',',p1+1); ...
d5266910-ec21-4a2e-9cee-7c7e6f1c0262
3
@Test public void tenProcessos() { SoSimProcess[] processes = new SoSimProcess[]{ new SoSimProcess(PcbColor.GRAY,1), new SoSimProcess(PcbColor.GRAY,1), new SoSimProcess(PcbColor.GRAY,1), new SoSimProcess(PcbColor.GRAY,1), new SoSimProcess(PcbColor.GRAY,1), ...
e7089968-5400-4142-8516-0c76fb6dde42
0
public static void main(String [] args) { //new MessageShower("Hello java!").showStars(); // MessageShower messageShower = new StarMessageShower("Hello hello Java!"); // messageShower.show(); StringListener stringListener = new StringListener(); showMessage(new NumberMessageShower...
6dca84c3-6eb7-48a8-beec-f1dc27dbe65d
6
@Override public Geometry getGeometry() { if(geometry!=null){ return geometry; } render(); GeometryFactory gf = Helper.getGeometryFactory(); Geometry[] geometries = new Geometry[textPath.getNumberOfChars()]; LinkedList<Point> characterCentroids = new LinkedList<Point>(); for(int charnum=0; charnum<tex...
b07955c7-ceb6-407b-a59c-aa2e336a9301
4
@Override public void writeTo(WordWriter out) throws IOException { int opword = opcode.getCode(); if(opcode.isBasic()) { opword |= (valueA.evaluate() << 4) | (valueB.evaluate() << 10); } else { opword |= (valueA.evaluate() << 10); } out.writeW...
0e7edbaa-346f-430e-a4f5-0479a10b7f50
1
public void invert() { invertedBevoreMoves = 0; List<SchlangenGlied> glieder = new ArrayList<SchlangenGlied>(); addAllGlieder(glieder); while (glieder.size() > 1) { SchlangenGlied firstGlied = glieder.get(0); SchlangenGlied lastGlied = glieder.get(glieder.size() - 1); Point tmpLocation = firstG...
cb0a860f-e110-4a46-a64a-6a799907b83d
4
public void paint(Graphics g) { g.drawString("MissileNum:" + Integer.toString(mls.size()), 50, 50); g.drawString("Tanks Num:" + Integer.toString(tkEnemys.size()), 50, 70); g.drawString("Bombs Num:" + Integer.toString(bombs.size()), 50, 90); tk.draw(g); for(int i=0; i<tkEnemys.size(); i++) { tkEnemys.get(...
a0dfbc2f-ba90-4964-b52c-3344afa6e584
2
private static Device getDevice (String portId) throws IOException { try { Device dev = HostFactory.getHost ().getDevice (portId); if (isFX2 (dev)) return dev; } catch (IllegalArgumentException e) { } System.err.println ("no such FX2 device: " + portId); return null; }
ac753cd2-941e-4e1f-8b59-4c5695e7e134
8
public Worker getAvailableByActivityAndStatus ( int activityId , String status ) { Connection con = null; PreparedStatement statement = null; ResultSet rs = null; Worker worker = null; try { con = ConnectionManager.getConnection(); String searchQuery = "SELECT workers.id, workers.status, w...
32cf34c7-cc33-4e39-a154-afcdbc5ea3e4
4
@Before public void setUp() throws IOException { outputStream = new ByteArrayOutputStream(); world4x4 = worldFactory.createWorld(cells4x4); StringBuilder expected = new StringBuilder(""); for (int i = 0; i < world4x4.getWidth(); i++) { for (int j = 0; j < world4x4.getHeight(); j++) { expected.append(cel...
7dcf7299-af8e-4123-8d8a-dc78280928b2
6
@SuppressWarnings("unchecked") private JPanel createPlaySelectPanel() { JPanel productionNamePanel = new JPanel(); double size[][] = { { TableLayout.PREFERRED, 20, TableLayout.PREFERRED }, { 30, 30 } }; TableLayout layout = new TableLayout(size); productionNamePanel.setLayout(layout); productionNamePanel.ad...
ed10adcf-505b-4cd6-88df-e38c3db7ac29
5
public BoardGameItem(Board board, Controller controller) { super(); for(int i=0;i<4;i++) { for(int j=0;j<4;j++) { CaseItem b = new CaseItem(board.getCase(i,j)); board.getCase(i,j).addObserver(b); b.addActionListener(controller); cases.add(b); b.setPreferredSize(new Dimension(ViewConstan...
cd05038b-ba6e-4b4b-a249-bb424a59e8b2
4
public void searchPacientebyProntuario() { facesContext = FacesContext.getCurrentInstance(); requestContext = RequestContext.getCurrentInstance(); try { listProntuario = genericDAO.searchObject(Prontuario.class,"prontuario",null, null, new String[]{"cliente", "unidade", "pro...
24fc704f-9096-4d20-8c0b-c32113052f4b
6
public int getDPadY() { int povValue = joystick.getPOV(); if (povValue == 0 || povValue == 45 || povValue == 315){ return 1; } else if (povValue == 90 || povValue == 270 || povValue == -1){ return 0; } else { return -1; } }