method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a3ac404b-fdb3-48d6-9037-1be1f5642a67
8
public int maximalRectangleII(char[][] matrix) { if (matrix == null || matrix.length == 0) return 0; int n = matrix[0].length; int[] L = new int[n]; int[] R = new int[n]; int[] H = new int[n]; int area = 0; for (int i = 0; i < n; i++) R[i] = n - 1; for (int i = 0; i < matrix.length; i++) { int left = 0, right = n - 1; for (int j = 0; j < n; j++) { if (matrix[i][j] == '1') { L[j] = Math.max(L[j], left); H[j] += 1; } else { left = j + 1; H[j] = 0; L[j] = 0; R[j] = n - 1; } } for (int j = n - 1; j >= 0; j--) { if (matrix[i][j] == '1') { R[j] = Math.min(R[j], right); area = Math.max(area, (R[j] - L[j] + 1) * H[j]); } else { right = j - 1; } } } return area; }
83e8b716-680f-4d5a-b97d-ec7330c60461
4
public Direction getDirectionToTarget(Entity target){ if(getX() < target.getX()){ return Direction.EAST; }else if(getX() > target.getX()){ return Direction.WEST; }else if(getY() < target.getY()){ return Direction.NORTH; }else if(getY() < target.getY()){ return Direction.SOUTH; } return null; }
7b72243f-f24d-44bc-96e3-e9086194e19c
4
@Override public boolean init() { if (game.getGameState() == GameState.LOGIN) { if (getContext().getAccount() == null || getContext().getAccount().getUsername().equals("null") || getContext().getAccount().getPassword().equals("null")) { log("You must have an account saved to use Auto Login. Make sure you press the save button. You can also try editing the Accounts.txt in your Fluid folder."); return false; } else { return true; } } return false; }
1ad4c797-1c23-4b81-8d23-418eb9b95a66
6
private void logicalNot(LogicalNot lnp) { Predicate p = lnp.getPredicates().get(0); if(p instanceof BinaryContains) { // ignore them for the time being } else if(p instanceof Contains) { this.addToCount(((Contains) p).getA().getName(), 0); } else if(p instanceof Exactly) { if(((Exactly) p).getNum() > 1) { this.addToCount(((Exactly) p).getA().getName(), 1); } else { this.addToCount(((Exactly) p).getA().getName(), 0); } } else if(p instanceof MoreThan) { if(((MoreThan) p).getNum() > 1) { this.addToCount(((MoreThan) p).getA().getName(), 1); } else { this.addToCount(((MoreThan) p).getA().getName(), 0); } } }
a490066c-921a-4773-8cba-a1a8306ce16b
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> already <S-HAS-HAVE> spidery magic.")); return false; } if(!super.invoke(mob,commands,givenTarget,auto,asLevel)) return false; final boolean success=proficiencyCheck(mob,0,auto); if(success) { final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),auto?L("^S<S-NAME> attains a climbers stance!"):L("^S<S-NAME> invoke(s) a spidery spell upon <S-HIM-HERSELF>!^?")); if(mob.location().okMessage(mob,msg)) { mob.location().send(mob,msg); beneficialAffect(mob,target,asLevel,10); } } else beneficialWordsFizzle(mob,mob.location(),L("<S-NAME> attempt(s) to invoke a spell, but fail(s).")); return success; }
9386a59a-fa0c-422f-9931-60569291dc41
1
public void run(){ File file = new File("./VanillaSwarm.txt"); try{ file.createNewFile(); }catch(IOException ex){ ex.printStackTrace(); } this.generateHaltingCriteria(); this.generateNeighbourhoods(); this.generateVeloctiyUpdate(); this.generateFunction(); this.testSwarm(file); }
7e5f2c01-d309-49c7-a64d-c19aeff3c33e
5
public void readPPM(String fileName) // read a data from a PPM file { FileInputStream fis = null; DataInputStream dis = null; try{ fis = new FileInputStream(fileName); dis = new DataInputStream(fis); System.out.println("Reading "+fileName+"..."); // read Identifier if(!dis.readLine().equals("P6")) { System.err.println("This is NOT P6 PPM. Wrong Format."); System.exit(0); } // read Comment line String commentString = dis.readLine(); // read width & height String[] WidthHeight = dis.readLine().split(" "); width = Integer.parseInt(WidthHeight[0]); height = Integer.parseInt(WidthHeight[1]); // read maximum value int maxVal = Integer.parseInt(dis.readLine()); if(maxVal != 255) { System.err.println("Max val is not 255"); System.exit(0); } // read binary data byte by byte int x,y; //fBuffer = new Pixel[height][width]; img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); byte[] rgb = new byte[3]; int pix; for(y=0;y<height;y++) { for(x=0;x<width;x++) { rgb[0] = dis.readByte(); rgb[1] = dis.readByte(); rgb[2] = dis.readByte(); setPixel(x, y, rgb); } } dis.close(); fis.close(); System.out.println("Read "+fileName+" Successfully."); } // try catch(Exception e) { System.err.println(e.getMessage()); } }
fd235087-561d-44f7-b9f4-2a60f940d33d
8
public boolean pickAndExecuteAnAction() { synchronized(orders){ for (CookOrder order: orders){ if(order.s==OrderState.cooked){ ServeOrder(order); return true; } if(order.s==OrderState.pending){ TryToCookOrder(order); return true; } } } synchronized(marketOrders){ for (MarketOrder marketOrder : marketOrders){ if(marketOrder.state == MarketOrderState.ready){ RefillInventory(marketOrder); return true; } } } synchronized(revolvingStand){ if(!revolvingStand.isEmpty()){ for (CookOrder order : revolvingStand){ orders.add(order); revolvingStand.remove(order); return true; } } } if(!cookGui.atHome()){ cookGui.DoGoHome(); } return false; }
882f6819-a0aa-4e15-9b78-d36f58825035
5
@Override public List<TravelLog> sortDate() { List<Journal> j = db.getAllJournals(); List<TravelLog> toReturn = new ArrayList<TravelLog>(); for(Journal journal : j) { List<TravelLog> tmp = journal.sort("Date"); if(toReturn.size() == 0) toReturn.addAll(tmp); else { for(TravelLog t : tmp) { int i = 0; while(i< toReturn.size() && t.getDate().before(toReturn.get(i).getDate())) i++; toReturn.add(i, t); } } } return toReturn; }
6587fa65-a674-457f-bdaa-30a1a7931d58
6
public long bindMortal(MortalMessage mortal) { if (proc != null) { try { messenger.readReadyMessage(); } catch (ProcessCommunicationException ex) { // Fail. Project probably just doesn't support being reused for scoring. TODO: Statistics on how often this happens. close(); } } if (proc == null) { // Prepare messenger messenger = new Messenger(Settings.COMMUNICATIONS_PORT); // Spawn process to execute mortal // TODO: Pass on original command line arguments ProcessBuilder pb = new ProcessBuilder( "java", "-cp", System.getProperty("java.class.path"), "genejector.risen.RisenInstanceManager" ); try { proc = pb.start(); } catch (IOException ex) { throw new RuntimeException(ex); // This shouldn't ever happen. Wrap in RuntimeException to handle. } // Throw away output. Note that getInputStream() is actually the console output for some reason StreamConsumerThread.dispatch(new StreamConsumerThread(proc.getInputStream(), System.out, false)); // TODO: Send to null? StreamConsumerThread.dispatch(new StreamConsumerThread(proc.getErrorStream(), System.err, false)); // TODO: Send to null? // Initial communication messenger.readReadyMessage(); // Receive hello (client needs to initiate conversation with something) messenger.writeMessage(new SettingsMessage(Settings.getSettings())); // Send settings messenger.readReadyMessage(); // Wait for process to become ready for first mortal } // Send mortal and receive score // TODO: Move this to its own thread as readObject could block forever. We can interrupt the thread from the outside after a timeout instead try { messenger.writeMessage(mortal); // Send mortal long score = ((ScoreMessage) messenger.readMessage()).getScore(); // Receive and return score if (score == -1) { throw new GenejectedExecutionException("Score -1 received from risen JVM"); } return score; } catch (ProcessCommunicationException ex) { // TODO: Report this case in a meaningful way for stats and stuff. Split up reasons of death? close(); throw new ProjectExecutionException("Risen realm died while scoring mortal"); } }
4f132df1-2a42-4e1a-bfa7-e142fb6a1918
4
public static void main(String[] args) { RNASequence sequence; if(args.length == 1 && args[0].equalsIgnoreCase("random")) { int len = (int)(Math.random()*30+20); StringBuilder sb = new StringBuilder(); RNABasePair[] pairs = RNABasePair.values(); for(int i = 0; i < len; i++) { sb.append(pairs[(int)(Math.random()*pairs.length)].name()); } final String seq = sb.toString(); System.out.println("sequence = "+seq); sequence = new RNASequence(seq); } else if(args.length == 1) { sequence = new RNASequence(args[0].toUpperCase().replace('T', 'U')); // allow DNA strings too } else { sequence = new RNASequence(JOptionPane.showInputDialog("Input an RNA string") .toUpperCase().replace('T', 'U')); // allow DNA strings too } new RandomFolder(sequence).fold(); }
e6d6638a-0ed7-4bad-a7c6-2f5b3c4e0f76
1
@Override public void dataModificationStateChanged(Object obj, boolean modified) { String title = getFullTitle(); if (!title.equals(mTitle.getText())) { mTitle.setText(title); mTitle.revalidate(); } }
d1020163-cc14-4c10-85ec-3898d407dc9e
8
private boolean doCollisionCheck(boolean clatter) { Debug.println("PhysicsEngine.doCollisionCheck()"); Vector3f here; Vector3f there; for (int i = 0; i < moving.length; i++) { if (moving[i]) { MovableObject[] pins = model.getPins(); here = pins[i].getPosition(); for (int j = 1; j < pins.length; j++) { if (((i != j && !moving[j]) || i < j) && !hide[j]) { there = pins[j].getPosition(); //Debug.println("there: " + there + " here: " + here); there.sub(here); // Debug.println("distance: " + there.length()); if (there.length() < COLLISION_DISTANCE) { //a collision occured doCollision(i, j, there, clatter); clatter = true; } } } } } return clatter; }
81e6a788-c6f4-4e43-87a5-850b4c530463
2
private int readConfigTable (ResTable_Config config, byte[] data, int offset) throws IOException { config.size = readUInt32(data, offset); offset += 4; config.mmc = readUInt16(data, offset); offset += 2; config.mnc = readUInt16(data, offset); offset += 2; config.language[0] = (char) data[offset]; config.language[1] = (char) data[offset + 1]; offset += 2; config.country[0] = (char) data[offset]; config.country[1] = (char) data[offset + 1]; offset += 2; config.orientation = readUInt8(data, offset); offset += 1; config.touchscreen = readUInt8(data, offset); offset += 1; config.density = readUInt16(data, offset); offset += 2; config.keyboard = readUInt8(data, offset); offset += 1; config.navigation = readUInt8(data, offset); offset += 1; config.inputFlags = readUInt8(data, offset); offset += 1; config.inputPad0 = readUInt8(data, offset); offset += 1; config.screenWidth = readUInt16(data, offset); offset += 2; config.screenHeight= readUInt16(data, offset); offset += 2; config.sdkVersion = readUInt16(data, offset); offset += 2; config.minorVersion = readUInt16(data, offset); offset += 2; if (config.size <= 28) return offset; config.screenLayout = readUInt8(data, offset); offset += 1; config.uiMode = readUInt8(data, offset); offset += 1; config.smallestScreenWidthDp = readUInt16(data, offset); offset += 2; if (config.size <= 32) return offset; config.screenWidthDp = readUInt16(data, offset); offset += 2; config.screenHeightDp = readUInt16(data, offset); offset += 2; return offset; }
53096137-e3c9-4be6-a921-b029b1e204c7
2
private void load(){ for(int yy = 0; yy < SIZE; yy++){ for(int xx = 0; xx < SIZE; xx++){ pixels[xx + yy * SIZE] = sheet.pixels[(x + xx) + (y + yy) * sheet.SIZE]; } } }
1e686709-a2f8-466d-88c5-45f278d0d557
2
public static Buffer load(String path) { Buffer buffer = new Buffer(path); if(path.endsWith(WAV_EXTENSION)) buffer = loadWAV(buffer); else if(path.endsWith(OGG_EXTENSION)) buffer = loadOGG(buffer); else throw new RuntimeException("Unrecognized File format on file " + path); return buffer; }
c88a328c-50f9-4246-83ee-c39074066409
0
@Basic @Column(name = "CSA_VALOR_TOTAL") public Double getCsaValorTotal() { return csaValorTotal; }
957ed4b8-2848-41b4-8799-dd3eda1695d9
1
public static String tanksString(ArrayList<Tank> tanks){ String tanksString = ""; for(Tank t:tanks){ String buf = tankString(t); tanksString = tanksString + buf + ":"; } return tanksString; }
90755d87-ed1c-449d-b4ea-5717bdcc7cae
6
static private boolean jj_3R_42() { if (jj_3R_16()) return true; if (jj_scan_token(DOT)) return true; if (jj_scan_token(44)) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_43()) jj_scanpos = xsp; if (jj_scan_token(RPAREN)) return true; return false; }
367628d9-8714-4bb4-ac53-aff6d70bb18c
5
private boolean isMarketCommand(CommandName input) { return input == CommandName.newTrader || input == CommandName.deleteTrader || input == CommandName.buy || input == CommandName.sell || input == CommandName.displayItems || input == CommandName.wish; }
47b5ba9a-6705-4157-b216-c35ded95a67e
2
public void init(IPacketProcessor packetProcessor, int port) { this.port = port; try { datagramSocket = new MulticastSocket(); datagramSocket.setBroadcast(true); System.out.println("datagramSocket: " + datagramSocket.getInetAddress()); } catch (SocketException e) { packetProcessor.onError(ModelNotification.CONNECTION_ERROR); } catch (IOException e) { packetProcessor.onError(ModelNotification.CONNECTION_ERROR); } }
8120480f-4a3f-461b-a18d-fc1b8bf91991
7
public static int[] profit(int[] prices) { int newMin = -1; int newMinPosition = -1; int[] result = new int[prices.length+1]; result[0] = 0; int max = prices[0]; int maxPosition = 0; int min = prices[0]; int minPosition = 0; result[1] = 0; int lastPoint = prices[0]; for(int i = 1; i < prices.length; i++) { int currentPoint = prices[i]; if(currentPoint > lastPoint) { if(newMin != -1) { int trend = currentPoint - newMin; if(trend >= result[i]) { min = newMin; minPosition = newMinPosition; max = currentPoint; maxPosition = i; newMin = -1; newMinPosition = -1; result[i+1] = trend; } else { result[i+1] = result[i]; } } else if(currentPoint > max) { result[i+1] = result[i] + (currentPoint-max); maxPosition = i; max = currentPoint; } else { result[i+1] = result[i]; } } else if(currentPoint < lastPoint) { if(currentPoint < min) { newMin = currentPoint; newMinPosition = i; } result[i+1] = result[i]; } else { result[i+1] = result[i]; } lastPoint = currentPoint; } return result; }
ead0e178-a0b2-4bde-8154-7f358820a3ce
6
public int getAdjustedNetProductionOf(GoodsType goodsType) { int result = productionCache.getNetProductionOf(goodsType); for (BuildQueue<?> queue : new BuildQueue<?>[] { buildQueue, populationQueue }) { ProductionInfo info = productionCache.getProductionInfo(queue); if (info != null) { for (AbstractGoods goods : info.getConsumption()) { if (goods.getType() == goodsType) { result += goods.getAmount(); break; } } } } return result; }
738f2757-aa32-492a-afaa-4894bc36091f
6
protected HantoMoveRecord findRandomMove(){ HantoMoveRecord aMove = null; List<HantoCell> possCells = new ArrayList<HantoCell>(); possCells.addAll(gameManager.getCellManager().generatePossibleMoves()); List<HantoMoveRecord> possMoves = getPossMoves(possCells); if (gameManager.getTurnCount() == 1){ aMove = new HantoMoveRecord(HantoPieceType.BUTTERFLY, null, new HantoCell(0, 1)); } else if (arePiecesLeftInLineup() && !possMoves.isEmpty()){ // Flip a coin, 0 - place a piece, 1 - move a piece if (randInt(0, 1) == 0){ // place a piece aMove = placeRandomPiece(possCells); } else { // move a piece aMove = possMoves.get(randInt(0, possMoves.size() - 1)); } } else if (arePiecesLeftInLineup()) { // place a piece aMove = placeRandomPiece(possCells); } else if (!possMoves.isEmpty()){ // move a piece aMove = possMoves.get(randInt(0, possMoves.size() - 1)); } else { // forfeit aMove = new HantoMoveRecord(null, null, null); } return aMove; }
5f4514d9-beeb-4ee2-8f7e-c95f0ebe1845
9
private void dctLinePoint() { if (trackingLines.isEmpty() || trackingPoints.isEmpty()) { return; } // go through all lines for (int i = 0; i < trackingLines.size(); i++) { TrackingLine line = trackingLines.get(i); // compare with all points for (int j = 0; j < trackingPoints.size(); j++) { TrackingPoint point = trackingPoints.get(j); // ****a new point is found // Frame delay of new point must be 0. That means it's a really new point. // The smallest distance of the point to the line must be lower than // maxLineDistance. // The distance from P2, which is the tip of the line, to the new point must be // lower than maxPointDistance. // The StreetObject.Type of the new point must be the same as the Type of the line. if (point.getFrameDelay() == 0 && line.getType() == point.getType() && line.getP2().distance(point) <= maxPointDistance && line.ptLineDist(point) <= maxLineDistance) { // set new tip of the line line.setLine(line.getP2(), point); // set new image for the line if it's bigger than the old one. (better quality) IplImage old = line.getImage(); IplImage nevv = point.getImage(); int x = old.height() * old.width(); int y = nevv.height() * nevv.width(); if (x < y) { line.setImage(nevv); cvReleaseImage(old); } line.resetFrameDelay(); point.releaseImage(); trackingPoints.remove(j); } // end if point recognized }// end for loop: points } }
a5ddafc7-7af1-4a18-9195-d9f263bb8549
9
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { req.setAttribute("errors", new HashMap<String, String>()); if(ServletFileUpload.isMultipartContent(req)) { req = new MultipartWrapper(req); } DaoUtil.diDao(this); String method = req.getParameter("method"); Method m = this.getClass().getMethod(method, HttpServletRequest.class,HttpServletResponse.class); //在 这里进行权限控制 int flag = checkAuth(req,m,resp); if(flag==1) { resp.sendRedirect("user.do?method=loginInput"); return; } else if(flag==2) { req.setAttribute("errorMsg", "你没有权限访问该功能"); req.getRequestDispatcher("/WEB-INF/inc/error.jsp").forward(req, resp); return; } String path = (String)m.invoke(this, req,resp); if(path.startsWith(redirPath)) { String rp = path.substring(redirPath.length()); resp.sendRedirect(rp); } else { req.getRequestDispatcher("/WEB-INF/"+path).forward(req, resp); } } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }
c3f46140-add6-4cdd-aaad-0a18609c85cf
2
/* */ @EventHandler /* */ public void onPlayerRegen(EntityRegainHealthEvent event) /* */ { /* 405 */ if ((event.getEntity() instanceof Player)) /* */ { /* 407 */ Player p = (Player)event.getEntity(); /* */ /* 409 */ if (Main.getAPI().isSpectating(p)) /* */ { /* 411 */ event.setCancelled(true); /* */ } /* */ } /* */ }
2f5cf10f-6a41-4e83-97aa-35706c5737e4
7
public boolean method195(int j) { int k = maleEquip1; int l = maleEquip2; int i1 = anInt185; if(j == 1) { k = femaleEquip1; l = femaleEquip2; i1 = anInt162; } if(k == -1) return true; boolean flag = true; if(!Model.method463(k)) flag = false; if(l != -1 && !Model.method463(l)) flag = false; if(i1 != -1 && !Model.method463(i1)) flag = false; return flag; }
9ea1fdfe-6ede-4d37-af86-c2926efe0f38
4
private void playGame() { IOGeneric.printTitle("Here they come! Try to bring down the plane!", "-"); while (true) { try { playRound(); } catch (AntiAircraftGun.BadCoordinate e) { System.out.println("That shot missed the entire 10x10x10 grid! " + "But you can keep trying..."); } catch (BadInput e) { System.out.println("Your coordinate didn't even make sense! " + "Because of you, we lost the war.\n" + "Thanks.\n" + "Why don't you try the 'Dividing integers' exercise instead?\n" + "There's less for you to mess up. " + "I'm not saying you won't be able to, though.\n\n" + "You are clearly skilled."); playing = false; break; } catch (GameEnd e) { break; } } }
94fdc122-e46e-4256-9d05-29804b7ee8e0
6
private Mob spawn(float x, float y){ Mob e = null; short lyr = Vars.BIT_LAYER1; if(Math.random()>.5) lyr = Vars.BIT_LAYER3; switch(spawnType){ case CIVILIAN: int type = (int) (Math.random()*3) + 1; // int type = 1; e = new Mob("Civilian", "civilian" + type, -1, x, y, lyr); if(path!=null) e.moveToPath(path, true); else e.setState(spawnState, null, -1, ResetType.NEVER.toString()); e.setGameState(main); e.setDialogueScript(script); e.setAttackScript(aScript); e.setDiscoverScript(dScript); e.setResponseType(dType); e.setAttackType(aType); spawnDelay = CIV_DELAY; break; case NIGHTER: e = new Mob("", "nighter"+nighterType, -1, x, y, lyr); if(path!=null) e.moveToPath(path, true); else e.setState("followplayer", null, -1, ResetType.NEVER.toString()); e.setGameState(main); // e.setDialogueScript("nighter"+nighterType); // e.setDiscoverScript("nighterSight"+nighterType); e.setResponseType("attack"); e.setAttackType("on_sight"); spawnDelay = nighterDelay; e.addLight(new PointLight(main.getRayHandler(), Vars.LIGHT_RAYS, Vars.GHOSTLY_LIGHT, 100, x, y)); break; case SPECIAL: e = new Mob("", specialType, -1, x, y, lyr); e.setState(spawnState, null, -1, ResetType.NEVER.toString()); e.setGameState(main); e.setDialogueScript(script); e.setAttackScript(aScript); e.setDiscoverScript(dScript); e.setResponseType(dType); e.setAttackType(aType); spawnDelay = specialDelay; break; } return e; }
0fbaf2e1-a016-4bad-b84b-bc1efef2f066
2
private String getMethodName( CtClass clazz, CtMethod method ) throws NotFoundException { final CtClass[] types = method.getParameterTypes(); final StringBuilder sb = new StringBuilder(); sb.append( method.getName() ).append( '(' ); for (int k = 0; k < types.length; k++) { if (k > 0) { sb.append( ',' ); } sb.append( types[k].getSimpleName() ); } sb.append( ')' ); return sb.toString(); }
d8b08c94-51ae-409b-bb72-bd70b78c13f5
7
public void printBoard() { System.out.println("-------------------------------------------------------------------------"); System.out.println("\ta\tb\tc\td\te\tf\tg\th"); for(int i=0; i<8; i++) { System.out.print(i + "\t"); for(int j=0; j<8; j++) { if(this.checker[i][j] != null) //prevent null pointer error { switch(this.checker[i][j]) //knight and bishop are too long words { case Bishop_W: { System.out.print("Bshop_W"+"\t"); break; } case Bishop_B: { System.out.print("Bshop_B"+"\t"); break; } case Knight_W: { System.out.print("Knght_W"+"\t"); break; } case Knight_B: { System.out.print("Knght_B"+"\t"); break; } default: System.out.print(this.checker[i][j]+"\t"); break; } } else { System.out.print(" |O|" + "\t"); } } System.out.print((7-i) + "\t"); //real chess numbers != java line printing numbers System.out.println(); } System.out.println("\ta\tb\tc\td\te\tf\tg\th"); System.out.println("-------------------------------------------------------------------------"); }
27eff2e9-d47e-4347-819e-9c5545e6e160
4
private boolean moveCheck(){ if (parent.getPosition().getX() < pos.getX() + bound) return true; if (parent.getPosition().getX() + parent.getScale().getX() > pos.getX() + Window.getWidth() - bound) return true; if (parent.getPosition().getY() < pos.getY() + bound) return true; if (parent.getPosition().getY() + parent.getScale().getY() > pos.getY() + Window.getHeight() - bound) return true; return false; }
d4f87816-aa2b-497e-92d6-0c30e2742b15
5
public void takeOrder(List<MenuItem> orderList) throws RuntimeException { try { db.openConnection(ADMIN, sql, sql, sql); List keys = new ArrayList(); List values = new ArrayList(); for (MenuItem item : orderList) { keys.add("menu_id"); values.add(item.getMenuId()); db.insertRecord("menu", keys, values, true); } db.closeConnection(); } catch (IllegalArgumentException ex) { throw new RuntimeException(ex.getMessage(), ex); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex.getMessage(), ex); } catch (SQLException ex) { throw new RuntimeException(ex.getMessage(), ex); } catch (Exception ex) { throw new RuntimeException(ex.getMessage(), ex); } }
6f29e8a9-f80f-4452-9e72-ee5d282691cf
1
public void testFactoryFieldDifference5() throws Throwable { DateTimeFieldType[] types = new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.dayOfMonth(), DateTimeFieldType.dayOfWeek(), }; Partial start = new Partial(types, new int[] {1, 2, 3}); Partial end = new Partial(types, new int[] {1, 2, 3}); try { Period.fieldDifference(start, end); fail(); } catch (IllegalArgumentException ex) {} }
74453c0e-cc29-4fc3-9712-86670ef18204
5
@Override public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception { splitted[0] = splitted[0].toLowerCase(); if (splitted[0].equalsIgnoreCase("ninjaglare")) { NPCScriptManager.getInstance().start(c, 1103005); } else if (splitted[0].equalsIgnoreCase("scroll")) { NPCScriptManager.getInstance().start(c, 2022002); } else if (splitted[0].equalsIgnoreCase("shop")) { NPCScriptManager.getInstance().start(c, 1032002); } else if (splitted[0].equalsIgnoreCase("guide")) { NPCScriptManager.getInstance().start(c, 9001000); } else if (splitted[0].equalsIgnoreCase("dispose")) { NPCScriptManager.getInstance().dispose(c); mc.dropMessage("You should now be able to talk to the NPCs"); } else { mc.dropMessage(splitted[0] + " is not a valid command."); } }
276ba967-4608-401e-b64e-a1ed27de2553
8
public void putAll( Map<? extends Byte, ? extends Short> map ) { Iterator<? extends Entry<? extends Byte,? extends Short>> it = map.entrySet().iterator(); for ( int i = map.size(); i-- > 0; ) { Entry<? extends Byte,? extends Short> e = it.next(); this.put( e.getKey(), e.getValue() ); } }
dce8032d-4d4a-4bf6-8803-64fd2741521e
8
@Override public void setBounds(int x, int y, int width, int height) { super.setBounds(x, y, width, height); if ((null == canvas) || (null == canvas.getOffScreenBuffer()) || (JCanvas3D.RESIZE_IMMEDIATELY == getResizeMode())) //whatever the resize mode, i create on first setbounds(). (not doing so would create a deadlock in DELAYED mode when trying to do the first paint { createCanvas(width, height); } else if ((JCanvas3D.RESIZE_DELAYED == getResizeMode()) && ((null != canvas.getParent()) && (true == canvas.getParent().isVisible()))) { if ((null == canvas.resizeThread) || (false == canvas.resizeThread.isAlive())) { canvas.resizeThread = new ResizeThread(width, height, getResizeValidationDelay(), this); canvas.resizeThread.start(); } else { canvas.resizeThread.setWidth(width); canvas.resizeThread.setHeight(height); } } }
632fee2c-cd12-46c7-8748-cfb76fb5b0b1
0
public int getMaxAddress() { return addressMax; } // Returns the highest address reached in the program
c953b9f6-1ec4-47e4-81fb-0afde1094bc8
9
public boolean isValidEndTurn(){ //The player must have a turn to be ending, must have already acted, and can't have other critical dialogs open at the time if (gameOngoing){ if(playerTurn && hasActed && !accusationDialogOpen && !suggestionDialogOpen) { return true; } else { String message = null; if(!playerTurn){ message = "It is not your turn."; } else if(!hasActed) { message = "Please move or make an accusation first."; } else if(accusationDialogOpen) { message = "You cannot end your turn while making an accusation."; } else if(suggestionDialogOpen){ message = "You cannot end your turn while making a suggestion."; } //we give them a notification of what they're doing wrong and then do nothing: JOptionPane.showMessageDialog(null, message); return false; } } return false; }
694c6ac0-4462-4853-b2a2-b6e9e15e0e27
9
boolean removeAlignments() { // passe 1 : marquer tous les alignements for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (grid[i][j].getColor() != 0 && horizontalAligned(i, j)) { marked[i][j] = marked[i + 1][j] = marked[i + 2][j] = true; } if (grid[i][j].getColor() != 0 && verticalAligned(i, j)) { marked[i][j] = marked[i][j + 1] = marked[i][j + 2] = true; } } } // passe 2 : supprimer les cases marquées boolean modified = false; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (marked[i][j]) { grid[i][j].setColor(0); EventObjetDispatcherSingleton.getInstance().event("Destroyed_Objects", grid[i][j]); marked[i][j] = false; modified = true; } } } return modified; }
8cfa77a2-7c11-418e-899b-45694c111da2
8
@Override public float eval(IRList l) { if (l == null || l.getQuery() == null || l.getPertinence() == null) return -1; ArrayList<Integer> relevants = l.getQuery().relevants; ArrayList<Integer> pertinence = l.getPertinence(); int nRelevant = relevants.size(), nPertinence = pertinence.size(); if (nRelevant == 0) return -1; float totalPrecision = 0; int totalHit = 0; for (int i = 0; i < nPertinence; i++){ if (relevants.contains(pertinence.get(i))){ totalHit += 1; totalPrecision += (float)(totalHit) / (i + 1); if (totalHit >= nRelevant) { break; } } } if (totalHit == 0) return 0; return totalPrecision / totalHit; }
1ca3e05d-f772-40c7-8c54-a6dea097447d
1
public double getSubStackWidth(int index1, int index2) { double width = 0; for (int i = index1; i <= index2; i++) { width += intervals.get(i).getWidth(); } return width; }
82e19ab5-8766-48ac-9171-ef9e88a7ea80
5
public static void printConstructors(Class<?> c){ display2.append("コンストラクタ\r\n"); Constructor[] declaredconstructors = c.getDeclaredConstructors(); Constructor[] constructors = c.getConstructors(); ArrayList<Constructor> constructorList = new ArrayList<Constructor>(constructors.length); for(int i = 0; i < constructors.length; i++){ constructorList.add(constructors[i]); } for(int i = 0; i < declaredconstructors.length; i++){ if(!constructorList.contains(declaredconstructors[i])){ constructorList.add(declaredconstructors[i]); } } Constructor[] allConstructors = new Constructor[constructorList.size()]; for(int i = 0; i < allConstructors.length; i++){ allConstructors[i] = constructorList.get(i); } printMembers(allConstructors); }
0e272854-d367-4b9d-9c67-e341fd88dc1f
2
public String baseNumberCds2Codon(int cdsBaseNumber) { int codonNum = cdsBaseNumber / CodonChange.CODON_SIZE; int min = codonNum * CodonChange.CODON_SIZE; int max = codonNum * CodonChange.CODON_SIZE + CodonChange.CODON_SIZE; if ((min >= 0) && (max <= cds().length())) return cds().substring(min, max).toUpperCase(); return null; }
eda450d6-c4f0-4706-928b-30b8061c38e4
5
public static double[] mean(final SampleSet set) { if (set.size() == 0) return null; // final int inputsize = set.get(0).getInputSize(); final double[] result = new double[inputsize]; long ctr = 0; // // add all features values. // for (Sample sample : set) { // final double[] input = sample.getInput(); int offset = 0; for (int s = 0; s < sample.getInputLength(); s++) { for (int i = 0; i < inputsize; i++) { result[i] += input[offset++]; } ctr++; } } // // divide all values by the number of samples. // final double inv = (1.0 / (double)ctr); // for (int i = 0; i < result.length; i++) { result[i] = result[i] * inv; } return result; }
047e46fb-2864-44ad-a711-184f50debc5b
4
public void run(DebuggerVirtualMachine dvm) { enterMessage(); needToDisplayFunction = true; while (dvm.continueUntilFinished()) { if (!dvm.getReasonForStopping().isEmpty()) { UserInterface.println(dvm.getReasonForStopping()); UserInterface.println(""); } if (needToDisplayFunction) { InterfaceCommand displayFunction = new DisplayFunctionCommand(); displayFunction.init(new ArrayList<String>(), dvm); displayFunction.display(this); } needToDisplayFunction = false; dvm.setReasonForStopping(""); InterfaceCommand command; if ((command = this.getCommand(dvm)) == null) { continue; } command.execute(dvm); command.display(this); } exitMessage(); }
34a9f9d2-8cfa-4265-abc4-37f028283a3d
7
@Override public void run() { while(true){ seatNr = -1; try { for(int runs=0;runs<5;runs++){ // Versuch einen Sitzplatz zu ergattern if(blocked){ blocked = false; Thread.sleep(20); //System.out.println("leg dich schlafen"); } if((seatNr = myTable.getSeatOptimized())==-1){ System.out.println("Probleme bei der Sitzverteilung"); } // Gabelzuteilung if(seatNr%2==0){ firstfork = seatNr; secondfork = (seatNr+1)%tableSize; }else{ firstfork = (seatNr+1)%tableSize; secondfork = seatNr; } //System.out.println("Platz Nr "+seatNr+" PH "+number + "linke gabel "+firstfork+" rechte gabel "+secondfork); // Sitzen while(!getForks()){ //Warten auf Gabeln //Thread.sleep(EAT_TIME); } //Essen eat(); myTable.returnFork(firstfork); myTable.returnFork(secondfork); myTable.standUp(seatNr); //Chillen mediate(); } Thread.sleep(SLEEP_TIME); } catch (Exception e) { System.out.println("Problem PH thread -- " + number ); System.out.println(e); } } }
dbbdbf9b-c245-4b6b-aaa4-ca3e1bcc8776
6
public Matrix getQ () { Matrix X = new Matrix(m,n); double[][] Q = X.getArray(); for (int k = n-1; k >= 0; k--) { for (int i = 0; i < m; i++) { Q[i][k] = 0.0; } Q[k][k] = 1.0; for (int j = k; j < n; j++) { if (QR[k][k] != 0) { double s = 0.0; for (int i = k; i < m; i++) { s += QR[i][k]*Q[i][j]; } s = -s/QR[k][k]; for (int i = k; i < m; i++) { Q[i][j] += s*QR[i][k]; } } } } return X; }
b3457be2-daa7-4511-b668-ce600c5ffb29
0
public void addRedMarker(int markerNum) { // Change markersRed[markerNum] to true this.markersRed[markerNum] = true; }
aa35ff55-389e-4533-8bcb-246627d3cd42
8
private void pushPixels(int height, int dest[], byte src[], int destStep, int destOff, int width, int srcOff, int palette[], int srcStep) { int quarterX = -(width >> 2); width = -(width & 3); for (int i = -height; i < 0; i++) { for (int j = quarterX; j < 0; j++) { byte color = src[srcOff++]; if (color != 0) { dest[destOff++] = palette[color & 0xff]; } else { destOff++; } color = src[srcOff++]; if (color != 0) { dest[destOff++] = palette[color & 0xff]; } else { destOff++; } color = src[srcOff++]; if (color != 0) { dest[destOff++] = palette[color & 0xff]; } else { destOff++; } color = src[srcOff++]; if (color != 0) { dest[destOff++] = palette[color & 0xff]; } else { destOff++; } } for (int k = width; k < 0; k++) { byte color = src[srcOff++]; if (color != 0) { dest[destOff++] = palette[color & 0xff]; } else { destOff++; } } destOff += destStep; srcOff += srcStep; } }
51686751-ec22-49a1-ba6d-75a439375497
8
public static void main(String[] args){ programa = new ArrayList<Linea>(); File asm = new File("P1ASM.txt"); FileReader fr; BufferedReader br; Separador s = new Separador(); try { fr = new FileReader(asm); br = new BufferedReader(fr); String linea = br.readLine(); while(linea != null){ programa.add(s.separa(linea)); linea = br.readLine(); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch(IOException e){ e.printStackTrace(); } boolean b = false; for(Linea l : programa){ if(l instanceof Instruccion){ Instruccion ins = (Instruccion) l; System.out.print(ins); b = true; } else{ if(b == true) System.out.print("\nCOMENTARIO\n"); else System.out.print("COMENTARIO\n"); b = false; } } Linea ultima = programa.get(programa.size()- 1); if(ultima instanceof Instruccion){ Operador o = ((Instruccion) ultima).getOperador(); if(o.getContenido().compareToIgnoreCase("END") != 0){ System.out.println("\nError: No se encontro el END"); } } else { System.out.println("\nError: No se encontro el END"); } }
49570823-2fe0-463c-9015-ebbd27c6d8b4
0
public void setHeight(int height) { marker[markers-1].setHeight(height); }
26941ecf-d6af-4989-aa58-b9a9aab2ea10
2
public void escanearDirectorio(String path){ File f = new File(path); File[] files = f.listFiles(); if (files != null) { for (File child : files) { Date d = new Date(child.lastModified()); ((DefaultTableModel)backupT.getModel()).addRow(new Object[]{child.getName(),d.toString()}); } } else{ System.out.println(path+" no se listo"); } }
c298ec47-afef-4edc-ab59-24cf568014b4
0
public Ball getBallAt(int index) { return balls.get(index); }
848c43a4-94e1-4835-9605-bd25a12e703b
1
private void loadContent() { try { avatar_image = ImageIO.read(this.getClass().getClassLoader().getResource("img/avatar_S.png")); avatar_image_L = ImageIO.read(this.getClass().getClassLoader().getResource("img/avatar_S_L.png")); avatar_image_J_R = ImageIO.read(this.getClass().getClassLoader().getResource("img/avatar_J_R.png")); avatar_image_J_L = ImageIO.read(this.getClass().getClassLoader().getResource("img/avatar_J_L.png")); annimation_image_right = ImageIO.read(this.getClass().getClassLoader().getResource("img/annimation_image_right.png")); annimation_image_left = ImageIO.read(this.getClass().getClassLoader().getResource("img/annimation_image_left.png")); avatar_annim_R = new Animation(annimation_image_right, 18, 18, 30, 25, true, (int) x, (int) y, 0); // avatar_annim_die_R = new Animation(annimation_image_die_right, // 18, // 18, 7, 200, true, (int) x, (int) y, 0); avatar_annim_L = new Animation(annimation_image_left, 18, 18, 30, 25, true, (int) x, (int) y, 0); } catch (IOException e) { e.printStackTrace(); } }
93797156-5560-4a28-971c-a6274705ed53
8
private static final void packObjectSpawns() { Logger.log("ObjectSpawns", "Packing object spawns..."); if (!new File("data/map/packedSpawns").mkdir()) throw new RuntimeException( "Couldn't create packedSpawns directory."); try { BufferedReader in = new BufferedReader(new FileReader( "data/map/unpackedSpawnsList.txt")); while (true) { String line = in.readLine(); if (line == null) break; if (line.startsWith("//")) continue; String[] splitedLine = line.split(" - "); if (splitedLine.length != 2) throw new RuntimeException("Invalid Object Spawn line: " + line); String[] splitedLine2 = splitedLine[0].split(" "); String[] splitedLine3 = splitedLine[1].split(" "); if (splitedLine2.length != 3 || splitedLine3.length != 4) throw new RuntimeException("Invalid Object Spawn line: " + line); int objectId = Integer.parseInt(splitedLine2[0]); int type = Integer.parseInt(splitedLine2[1]); int rotation = Integer.parseInt(splitedLine2[2]); WorldTile tile = new WorldTile( Integer.parseInt(splitedLine3[0]), Integer.parseInt(splitedLine3[1]), Integer.parseInt(splitedLine3[2])); addObjectSpawn(objectId, type, rotation, tile.getRegionId(), tile, Boolean.parseBoolean(splitedLine3[3])); } in.close(); } catch (Throwable e) { Logger.handle(e); } }
40c5acf5-a7f9-446e-aa52-799163ba61dd
7
public void serializeObject() { try { int i; Class<?> c1 = null; Object obj; File file = new File(path); if (!file.exists()) file.createNewFile(); FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); for(i=0; i<((p.objects).size()); i++) { obj = p.objects.get(i); c1 = obj.getClass(); bw.write("<"+p.substr1+">\n"); bw.write(" <"+p.substr4+" xsi:type=\""+c1.getName()+"\">\n"); if(obj instanceof MyAllTypesFirst) { bw.write(" <myInt xsi:type=\"xsd:int\">"+(((MyAllTypesFirst) obj).getmyInt())+"</myInt>\n"); bw.write(" <myString xsi:type=\"xsd:string\">"+(((MyAllTypesFirst) obj).getmyString())+"</myString>\n"); bw.write(" <myDouble xsi:type=\"xsd:double\">"+(((MyAllTypesFirst) obj).getmyDouble())+"</myDouble>\n"); bw.write(" <myLong xsi:type=\"xsd:long\">"+(((MyAllTypesFirst) obj).getmyLong())+"</myLong>\n"); bw.write(" <myChar xsi:type=\"xsd:char\">"+(((MyAllTypesFirst) obj).getmyChar())+"</myChar>\n"); } else if(obj instanceof MyAllTypesSecond) { bw.write(" <myIntS xsi:type=\"xsd:int\">"+(((MyAllTypesSecond) obj).getmyIntS())+"</myIntS>\n"); bw.write(" <myStringS xsi:type=\"xsd:string\">"+(((MyAllTypesSecond) obj).getmyStringS())+"</myStringS>\n"); bw.write(" <myFloatS xsi:type=\"xsd:float\">"+(((MyAllTypesSecond) obj).getmyFloatS())+"</myFloatS>\n"); bw.write(" <myShortS xsi:type=\"xsd:short\">"+(((MyAllTypesSecond) obj).getmyShortS())+"</myShortS>\n"); bw.write(" <myCharS xsi:type=\"xsd:char\">"+(((MyAllTypesSecond) obj).getmyCharS())+"</myCharS>\n"); } bw.write(" </"+p.substr4+">\n"); bw.write("</"+p.substr1+">\n"); } bw.close(); } catch(IOException io) { System.out.println("NoSuchMethodException occured: "+io.getMessage()); System.exit(0); } catch(Exception e) { System.out.println("Exception occured: "+e.getMessage()); System.exit(0); } }
1ce80fdf-9953-4bd6-be74-d1d9140c65d1
0
public void setSatisfied(boolean satisfied) { Satisfied = satisfied; }
ff48952f-bddc-4f36-b4a4-b83edaafd8b4
4
@Override public void deserialize(Buffer buf) { super.deserialize(buf); worldX = buf.readShort(); if (worldX < -255 || worldX > 255) throw new RuntimeException("Forbidden value on worldX = " + worldX + ", it doesn't respect the following condition : worldX < -255 || worldX > 255"); worldY = buf.readShort(); if (worldY < -255 || worldY > 255) throw new RuntimeException("Forbidden value on worldY = " + worldY + ", it doesn't respect the following condition : worldY < -255 || worldY > 255"); mapId = buf.readInt(); eventType = buf.readByte(); }
4da862b6-8a8d-48b5-8666-3801a9ed6419
2
public void updateNextID() { for(Track track : this) if (Integer.parseInt(track.get("id")) > nextID) nextID = Integer.parseInt(track.get("id")); nextID++; //nextID = Integer.parseInt( this.get(new Integer(this.size()).toString()) . get("id") ); }
8f5982e1-664a-492a-b87e-adbae34cf102
5
private void initUserlistImageframeMenu(Color bg) { this.userlistImageframeMenu = new JPanel(); this.userlistImageframeMenu.setBackground(bg); this.userlistImageframeMenu.setLayout(new VerticalLayout(5, VerticalLayout.LEFT)); // image { Path initialValue = this.skin.getImgPath_UserlistImage(Imagetype.DEFAULT); ImageField defaultImage = new ImageField(initialValue, bg, true) { private final long serialVersionUID = 1L; @Override public void onFileChosen(File file) { if (file != null) { UserlistChangesMenu.this.skin.setImgPath_UserlistImage(file.toPath(), Imagetype.DEFAULT); updatePathField(UserlistChangesMenu.this.skin.getImgPath_UserlistImage(Imagetype.DEFAULT), false); } else { UserlistChangesMenu.this.skin.setImgPath_UserlistImage(null, Imagetype.DEFAULT); updatePathField(UserlistChangesMenu.this.skin.getImgPath_UserlistImage(Imagetype.DEFAULT), true); } } }; initialValue = this.skin.getImgPath_UserlistImage(Imagetype.MOUSEFOCUS); ImageField focusImage = new ImageField(initialValue, bg, true) { private final long serialVersionUID = 1L; @Override public void onFileChosen(File file) { if (file != null) { UserlistChangesMenu.this.skin.setImgPath_UserlistImage(file.toPath(), Imagetype.MOUSEFOCUS); UserlistChangesMenu.this.skin.setImgPath_UserlistImage(file.toPath(), Imagetype.FOCUSSELECTED); updatePathField(UserlistChangesMenu.this.skin.getImgPath_UserlistImage(Imagetype.MOUSEFOCUS), false); } else { UserlistChangesMenu.this.skin.setImgPath_UserlistImage(null, Imagetype.MOUSEFOCUS); UserlistChangesMenu.this.skin.setImgPath_UserlistImage(null, Imagetype.FOCUSSELECTED); updatePathField(UserlistChangesMenu.this.skin.getImgPath_UserlistImage(Imagetype.MOUSEFOCUS), true); } } }; initialValue = this.skin.getImgPath_UserlistImage(Imagetype.SELECTED); ImageField pressedImage = new ImageField(initialValue, bg, true) { private final long serialVersionUID = 1L; @Override public void onFileChosen(File file) { if (file != null) { UserlistChangesMenu.this.skin.setImgPath_UserlistImage(file.toPath(), Imagetype.SELECTED); updatePathField(UserlistChangesMenu.this.skin.getImgPath_UserlistImage(Imagetype.SELECTED), false); } else { UserlistChangesMenu.this.skin.setImgPath_UserlistImage(null, Imagetype.SELECTED); updatePathField(UserlistChangesMenu.this.skin.getImgPath_UserlistImage(Imagetype.SELECTED), true); } } }; JTabbedPane pane = createTabbedPane(bg, strImgFieldTitle + "(" + strUserimageOverlay + ")", defaultImage, focusImage, pressedImage); pane.setTitleAt(0, strImageDefault); pane.setTitleAt(1, strImageFocus); pane.setTitleAt(2, strImageSelected); this.userlistImageframeMenu.add(pane); } // size int[] size = new int[] { this.skin.getUserlistImageFrameWidth(), this.skin.getUserlistImageFrameHeight() }; this.userlistImageframeMenu.add(new SizeField(size, 4, bg, strSizeFieldTitle, true) { private final long serialVersionUID = 1L; @Override public void widthOnKeyReleased(String input) { if (!UserlistChangesMenu.this.skin.setUserlistImageFrameWidth(parseInt(input))) { updateWidthfieldColor(Color.RED); } } @Override public void heightOnKeyReleased(String input) { if (!UserlistChangesMenu.this.skin.setUserlistImageFrameHeight(parseInt(input))) { updateHeightfieldColor(Color.RED); } } @Override public void resetOnClick() { UserlistChangesMenu.this.skin.setUserlistImageFrameWidth(-1); UserlistChangesMenu.this.skin.setUserlistImageFrameHeight(-1); update(UserlistChangesMenu.this.skin.getUserlistImageFrameWidth(), UserlistChangesMenu.this.skin.getUserlistImageFrameHeight()); } }); }
37e079bf-4e45-4df2-b0f5-0c307200acfb
0
public Firewall(int id, Environment environment) { this.id = id; this.environment = environment; }
710da73c-b092-442a-aa6f-0b2cb4f24005
7
public void update() { int xa = 0, ya = 0; if (anim < 7500) anim++; else anim = 0; if (input.up) ya--; if (input.down) ya++; if (input.left) xa--; if (input.right) xa++; if (xa != 0 || ya != 0) { move(xa, ya); walking = true; } else { walking = false; } }
dea864e8-024c-440c-afa1-ed2ae8f613e0
7
public static void install() { File root=new File(Main.path); root.mkdir(); double version=0.0; //Iz internetnega naslova prenese številko trenutne verzije posodoljevalnika try { URL url=new URL("http://"+Main.ip+"/d0941e68da8f38151ff86a61fc59f7c5cf9fcaa2/computer/updaterVersion.html"); BufferedReader in=new BufferedReader(new InputStreamReader(url.openStream())); String ln; String out=""; while ((ln=in.readLine())!=null) out+=ln; in.close(); version=Double.parseDouble(out); } catch (Exception e) {} //To številko zapiše v datotekko "version.txt" try { PrintWriter out=new PrintWriter(Main.path+"version.txt"); out.print(version); out.close(); } catch (Exception e) {} //Iz strežnika prenese trenutno verzijo posodobljevalnika in jo shrani v vrhovno mapo try { URL website = new URL("http://"+Main.ip+"/d0941e68da8f38151ff86a61fc59f7c5cf9fcaa2/computer/Updater.jar"); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream(Main.path+"Updater.jar"); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } catch (Exception e) {e.printStackTrace();} //Uporabniku dodeli unikaten niz znakov in ga zašifriraj z sistemo SHA-1 //Ta niz je uporabljen za prepoznavo uporabnika v analitiki. String uuid=String.valueOf(UUID.randomUUID()); try { MessageDigest md = MessageDigest.getInstance("SHA-1"); md.update(uuid.getBytes()); byte byteData[] = md.digest(); //convert the byte to hex format method 1 StringBuffer sb = new StringBuffer(); for (int i = 0; i < byteData.length; i++) { sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1)); } uuid=sb.toString(); } catch (Exception e) {} //Ta niz shrani v datoteko "uuid.txt". try { PrintWriter uuidOut=new PrintWriter(Main.path+"uuid.txt"); uuidOut.print(uuid); uuidOut.close(); } catch (Exception e) {} }
ea1ba58e-a118-4c24-8c14-d5c9c5fc4d27
0
public Sprite getCurrentSprite() { return sprites[currentFrame]; }
a2e3074b-c2ef-4f87-8cb9-dbb096785278
7
public static void assignPropositionWeight(Proposition self, double weight) { { TruthValue tv = ((TruthValue)(Stella_Object.accessInContext(self.truthValue, self.homeContext, false))); if (weight == 1.0) { Proposition.assignTruthValue(self, Stella.TRUE_WRAPPER); } else if (weight == 0.0) { Proposition.assignTruthValue(self, Stella.FALSE_WRAPPER); } else if ((tv == Logic.TRUE_TRUTH_VALUE) || ((tv == Logic.FALSE_TRUTH_VALUE) || (tv == null))) { { TruthValue self000 = TruthValue.newTruthValue(); self000.positiveScore = weight; { Proposition object000 = self; TruthValue value000 = self000; Stella_Object oldValue001 = object000.truthValue; Stella_Object newValue000 = Stella_Object.updateInContext(oldValue001, value000, object000.homeContext, false); if (!((oldValue001 != null) && (oldValue001.primaryType() == Logic.SGT_STELLA_CS_VALUE))) { object000.truthValue = newValue000; } } } } else { ((TruthValue)(Stella_Object.accessInContext(self.truthValue, self.homeContext, false))).positiveScore = weight; } } }
20f23103-dd88-4a93-98a4-6bc60c39ec9e
6
@Override public void actionPerformed(ActionEvent e) { if((e).getSource() == view.getButtons()[ATTACKONCE]){ view.logUpdate(model.getBattle().fight()); } if((e).getSource() == view.getButtons()[AUTOATTACK]){ while(model.getBattle().getFirstTerritory().getNbrOfUnits() > 1 && (model.getBattle().getSecondTerritory().getNbrOfUnits()) != 0){ view.logUpdate(model.getBattle().fight()); } } if((e).getSource() == view.getButtons()[RETREAT]){ frame.getLayeredPane().remove(view); frame.repaint(); view.logClean(); if(view.getHeaderText().equalsIgnoreCase("Victory!")){ model.getBattle().move(); }else{ model.getBattle().resetTerritories(); model.getMove().resetTerritories(); model.nextPhase(); } view = new BattleView(frame); new BattleController(model, frame, view); model.addObserver(view); } }
93095517-d496-48c0-bfc8-edcac6868262
4
public ConnectionStringMap(ScriptFile file) { for (String line : file.getLines()) { String elementName = null; if (line.matches(".+=.+")) { elementName = line.substring(0, line.indexOf('=')).trim(); line = line.substring(line.indexOf('=') + 1, line.length()); } try { ConnectionString cs = new ConnectionString(line.trim()); if (elementName == null) elementName = cs.getSid(); map.put(elementName, cs); } catch (IllegalConnectionString e) { ConsoleHelper.error(e.getMessage()); } } }
ccd1c104-5fb5-4429-beb6-1a1e3281d91e
3
public static void main(String[] args) { long startTime = System.currentTimeMillis(); if(args.length == 0){ System.out.println("Please provide the location of the workload file!"); System.exit(1); } try { String fileName = args[0]; // number of grid user entities + any Workload entities. int num_user = 1; Calendar calendar = Calendar.getInstance(); boolean trace_flag = false; // mean trace GridSim events // Initialize the GridSim package without any statistical // functionalities. Hence, no GridSim_stat.txt file is created. System.out.println("Initializing GridSim package"); GridSim.init(num_user, calendar, trace_flag); ////////////////////////////////////////// // Creates one GridResource entity int rating = 377; // rating of each PE in MIPS int totalPE = 9; // total number of PEs for each Machine int totalMachine = 128; // total number of Machines String resName = "Res_0"; GridResource resource = createGridResource(resName, rating, totalMachine, totalPE); ////////////////////////////////////////// // Creates one Workload trace entity. WorkloadFileReader model = new WorkloadFileReader(fileName, rating); Workload workload = new Workload("Load_1", resource.get_name(), model); // Start the simulation in normal mode boolean debug = true; GridSim.startGridSimulation(debug); if(!debug) { long finishTime = System.currentTimeMillis(); System.out.println("The simulation took " + (finishTime - startTime) + " milliseconds"); } // prints the Gridlets inside a Workload entity // workload.printGridletList(trace_flag); } catch (Exception e) { e.printStackTrace(); } }
59d95226-9e42-489d-a81b-0837f1a97061
9
public void handleProcess() { if (c.ssDelay > 0) c.ssDelay--; if (c.ssDelay == 0) { soulSplitEffect(c.soulSplitDamage); } if (c.leechDelay > 0) c.leechDelay--; if (c.leechDelay == 5) { if (c.oldPlayerIndex > 0) appendRandomLeech(c.oldPlayerIndex, Misc.random(6)); else if (c.oldNpcIndex > 0) appendRandomLeech(c.oldNpcIndex, Misc.random(6)); } else if (c.leechDelay == 3) { if (c.leechTarget != null) { c.leechTarget.gfx0(c.leechEndGFX); leechEffect(c.leechType); } else if (c.leechTargetNPC != null) { c.leechTargetNPC.gfx0(c.leechEndGFX); leechEffectNPC(c.leechType); } } }
d4b6b633-cb7d-4559-9da8-f55e75805c67
5
@Override public void run() { Socket connectionSocket = null; try { // block until connection is made connectionSocket = masterSocket.accept(); // start game window.RemotePlayer = "MASTER " + Pong.address.getHostAddress(); InputStream in = connectionSocket.getInputStream(); BufferedReader inFromMaster = new BufferedReader(new InputStreamReader(in)); DataOutputStream outToMaster = new DataOutputStream(connectionSocket.getOutputStream()); String line; synchronized (this){ wait(); } while(true) { if (in.available() > 0) { line = inFromMaster.readLine(); // convert bool:keycode to event on screen int code = Integer.parseInt(line.substring(line.indexOf(':')+1)); boolean val = Boolean.valueOf(line.substring(0, line.indexOf(':'))); screen.remoteKeys[code] = val; // System.out.println("From master: " + code + "=" + val); } synchronized(screen.keystr) { if(!screen.keystr.isEmpty()) { String s = screen.keystr.poll(); // System.out.println("Sending to master: " + s); outToMaster.writeBytes(s + '\n'); outToMaster.flush(); } } } } catch (Exception ioe) { //screen.RemotePlayer = "ERROR: " + ioe.getMessage(); ioe.printStackTrace(System.err); try{ connectionSocket.close(); } catch (Exception e){} JOptionPane.showMessageDialog(null, ioe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); System.exit(1); } }
4acd2021-36b6-4d78-982c-ab611027951d
8
private void buildFollow() { follow = new ShareableHashMap<NonTerminal, SymbolSet>(); for (NonTerminal n : nonTerminals.values()) { follow.put(n, newSymbolSet()); } follow.get(startSymbol).add(endmarker); int oldSize = 0; int newSize = 0; do { oldSize = newSize; newSize = 0; for (NonTerminal n : nonTerminals.values()) { SymbolSet f = follow.get(n); for (Production p : productions) { for (int i = 0; i < p.getLength(); i++) { if (p.getSymbolAt(i) == n) { SymbolSet fs = first(p.rhs, i+1); f.addAll(fs); if (fs.contains(empty) || i == p.getLength() - 1) { // TODO: this goes wrong if nested!! why??? fs = follow.get(p.lhs); f.addAll(fs); } } } } f.remove(empty); newSize += f.size(); } } while (newSize > oldSize); }
ec7b027c-6d16-476a-80de-ae2dc1913425
4
public void addlist(Object... args) { for(Object o : args) { if(o instanceof Integer) { adduint8(T_INT); addint32(((Integer)o).intValue()); } else if(o instanceof String) { adduint8(T_STR); addstring((String)o); } else if(o instanceof Coord) { adduint8(T_COORD); addcoord((Coord)o); } } }
507e4cd5-3c56-46a7-bb9f-61cc3792ca9a
9
@Override public boolean equals(Object o) { if (o == null) { return false; } Event dest = (Event) o; if (CompareUtil.isDifferent(_getEventName(), dest._getEventName())) { return false; } if (_getEventData() != null && dest._getEventData() != null) { if (_getEventData().length != dest._getEventData().length) { return false; } else { for (int i = 0; i < _getEventData().length; i++) { if (!_getEventData()[i].equals(dest._getEventData()[i])) { return false; } } return true; } } else if (_getEventData() == null && dest._getEventData() == null) { return true; } else { return false; } }
83b13987-d49b-44c5-996d-546c7074cfa7
0
public String getName() { return Name; }
456392ad-23e5-4bc2-9dc9-e30f28450b8d
3
private void drawObjectRadius(GOut g) { String name; g.chcolor(0, 255, 0, 32); synchronized (glob.oc) { for (Gob tg : glob.oc) { name = tg.resname(); if (radiuses.containsKey(name) && (tg.sc != null)) { drawradius(g, tg.sc, radiuses.get(name)); } } } g.chcolor(); }
346a34b9-ee3f-4eb4-9427-e9d9bc87549c
5
public void charger(Element tour,Partie partie) { switch(tour.getChildText("couleurJoueur")){ case "BLANC":couleurJoueur = CouleurCase.BLANC;break; case "NOIR":couleurJoueur = CouleurCase.NOIR;break; case "VIDE":couleurJoueur = CouleurCase.VIDE; } List<Element> listdeSixFaces = tour.getChild("deSixFaces").getChildren("deSixFace"); Iterator<Element> i = listdeSixFaces.iterator(); deSixFaces = new ArrayList<DeSixFaces>(); while(i.hasNext()){ DeSixFaces tmpDe = new DeSixFaces(); tmpDe.charger(i.next()); deSixFaces.add(tmpDe); } List<Element> listlistDeplacement = tour.getChild("deplacements").getChildren("deplacement"); Iterator<Element> it = listlistDeplacement.iterator(); listDeplacement = new ArrayList<Deplacement>(); while(it.hasNext()){ Deplacement tmpDeplacement = new Deplacement(); tmpDeplacement.charger(it.next(),partie); listDeplacement.add(tmpDeplacement); } }
df26853d-a8ab-449d-b070-f7173eea76ad
7
@Override public Figur waehleFigur(String[][] spielfeld) { Figur[] figurenArray = getFigurenArray(); Figur letzteFigur = null; Figur vorletzteFigur = null; double laengsterAbstand = 0; for (Figur figur : figurenArray) { boolean figurIstImZiel = false; int[] aktuellePos = figur.getPosition(); for (int[] zielPosition : getZielPsotionen()) { if (aktuellePos[0] == zielPosition[0] && aktuellePos[1] == zielPosition[1]) { figurIstImZiel = true; } } double abstand = berechneAbstand(aktuellePos, getAktuelleZielPosition(spielfeld)); if (abstand > laengsterAbstand && !figurIstImZiel) { vorletzteFigur = letzteFigur; if (vorletzteFigur == null) { vorletzteFigur = figur; } letzteFigur = figur; laengsterAbstand = abstand; } } Figur besteFigur = testeLetzteFiguren(letzteFigur, vorletzteFigur, spielfeld); return besteFigur; }
58f4842a-6a60-40f9-87d6-2c48d5eaddc6
6
public List<Book> getBooksByAuthors(int branch_id, int [] author_id) { List<Book> list = new ArrayList<>(); Connection con = null; Statement stmt = null; try { DBconnection dbCon = new DBconnection(); Class.forName(dbCon.getJDBC_DRIVER()); con = DriverManager.getConnection(dbCon.getDATABASE_URL(), dbCon.getDB_USERNAME(), dbCon.getDB_PASSWORD()); stmt = con.createStatement(); String query="SELECT * FROM book Inner Join bookauthors On bookauthor_id=bka_id Inner Join bookstatus On bookstatus_id=bks_id WHERE author_id IN ("; for(int aid:author_id) { query+=aid+","; } query=Utils.str_RemoveLastChar(query); query+=") AND branch_id= "+branch_id+" Order by bok_id"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { Book book = new Book(); book.setId(rs.getLong(1)); book.setTitle(rs.getString(2)); book.setSubtitle(rs.getString(3)); book.setIsbn(rs.getString(4)); book.setPublisher(rs.getString(5)); book.setPublishDate(rs.getDate(6)); book.setPagesNb(rs.getInt(7)); book.setBookCategory_id(rs.getLong(8)); book.setLanguage_id(rs.getLong(9)); book.setAuthor_id(rs.getLong(10)); book.setItem_id(rs.getLong(11)); book.setBookStatus_id(rs.getLong(12)); list.add(book); } } catch (SQLException | ClassNotFoundException ex) { System.err.println("Caught Exception: " + ex.getMessage()); } finally { try { if (stmt != null) { stmt.close(); } if (con != null) { con.close(); } } catch (SQLException ex) { System.err.println("Caught Exception: " + ex.getMessage()); } } System.err.println(list.size()); return list; }
76399b0e-42b7-4747-96a9-1a92edab550a
0
@Override public void hoistDepthChanged(OutlinerDocumentEvent e) {}
d8acd0c8-3c67-41ac-b2b1-8b577958bbb0
8
public String calculate() { StringBuilder numV = new StringBuilder(); int i = 0; while (cs[i] != '#' || op.peek().getOp() != '#') { char c = cs[i]; if (Operator.isOp(c)) { if (numV.length() != 0) { num.push(numV.toString()); numV.delete(0, numV.length()); } Operator op2 = new Operator(c); switch (op.peek().compare(op2)) { case 0 : op.pop(); break; case -1 : op.push(op2); break; case 1 : String num2 = num.pop(); String num1 = num.pop(); num.push(op.pop().calculate(num1, num2)); continue; } } else { numV.append(c); } if (c != '#') { i++; } } return num.pop(); }
7756704c-f4a3-4626-a87d-4212feab19a2
2
public boolean hasArtist(String name) { boolean result = false; for (int i = 0; i < artist.size(); i++) if (name.equals(artist.get(i).getName())) result = true; return result; }
4232f2b6-4335-4326-9ab3-45db0de917ad
0
@Override public void setCountry(String c) { super.setCountry(c); }
d19e4c00-e906-4038-95cd-a5517f3ef38d
9
public AFN transformarEmAFN(Nodo nodo) throws Exception { List<AFN> afnsNodos = this.getAFNsNodos(nodo); List<AFN> afnsChars = this.getAFNsChars(nodo); List<AFN> afns = this.getAFNs(nodo, afnsNodos, afnsChars); AFN afn1 = null; AFN afn2 = null; AFN afn = null; int cont = 0; for (int i = 0; i < nodo.getCarac().length(); i++) { char c = nodo.getCarac().charAt(i); if (isOperador(c)) { if (c == ".".charAt(0)) { afn1 = afns.get(cont); cont++; afn2 = afns.get(cont); cont++; if (afn1 != null && afn2 != null) { afn = new Concatenacao().calcularConcatenacao(afn1, afn2); } else { throw new Exception("afn1 ou afn2 está nulo!"); } } else if (c == "|".charAt(0)) { afn1 = afns.get(cont); cont++; afn2 = afns.get(cont); cont++; if (afn1 != null && afn2 != null) { afn = new Uniao().calcularUniao(afn1, afn2); } else { throw new Exception("afn1 ou afn2 está nulo!"); } } else if (c == "*".charAt(0)) { } } } return afn; }
8087eb58-aaf1-4853-9de9-cfe0fc299f4f
0
public CheckResultMessage check33(int day) { return checkReport.check33(day); }
edb0248c-69cb-4cb4-b0cb-b4ccf1e83875
7
@Override public double[] maxminWRT(String op, NodeVariable x, HashMap<NodeVariable, MessageQ> modifierTable) throws ParameterNotFoundException { double[] maxes = new double[x.size()]; for (int i = 0; i < maxes.length; i++) { maxes[i] = this.otherValue; } int xIndex = this.getParameterPosition(x); int modIndex; StringTokenizer t; NodeArgument[] args; double cost; int parametersNumber = this.parametersNumber(); /*for (String key : this.costTable.keySet()) { t = new StringTokenizer(key, ";"); args = new NodeArgument[parametersNumber]; int index = 0; while (t.hasMoreTokens()) { args[index] = NodeArgument.getNodeArgument(Integer.parseInt(t.nextToken())); index++; }*/ for (NodeArgumentArray argsa : this.costTable.keySet()){ args = argsa.getArray(); if (modifierTable == null) { //cost = this.costTable.get(key); //cost = this.costTable.get(argsa); cost =this.evaluate(args); } else { cost = this.evaluateMod(args, modifierTable); } /*System.out.println("x is: "+x.toString() +" with arguments: "); for (NodeArgument a : x.getValues()){ System.out.println(a); } System.out.println("looking for: "+ args[xIndex]); modIndex = x.numberOfArgument( args[xIndex] ); System.out.println("modIndex is: "+ modIndex);*/ modIndex = x.numberOfArgument(args[xIndex]); if (op.equals("max")) { if (maxes[modIndex] < cost) { maxes[modIndex] = cost; } } else if (op.equals("min")) { if (maxes[modIndex] > cost) { maxes[modIndex] = cost; } } } return maxes; }
66351230-3552-4348-a383-82bdeef6f65c
7
public synchronized void createUnit(String name, float x, float y) { NetworkedObject unit; switch(name) { case "Asteroid": unit = new NS_Asteroid(); break; case "Drone": unit = new NS_Drone(); break; case "Fighter": unit = new NS_Fighter(); break; case "Boss": unit = new NS_Boss(); break; case "Shield": unit = new NI_Shield(); break; case "Repair": unit = new NI_Repair(); break; case "Firepower": unit = new NI_Firepower(); break; default: System.out.println("Failed to find unit "+name); return; } // Network it unit.setup(x, y, ""); // Tell the game to update it this.networkedEnts.add(unit); }
49a41abf-f506-402b-a555-a6d860ebd995
6
private String getPANIpAddress() { // returns IP address in bluetooth and USB network try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface .getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterfaces .nextElement(); // filters out 127.0.0.1 and inactive interfaces if (networkInterface.isLoopback() || !networkInterface.isUp()) continue; Enumeration<InetAddress> addresses = networkInterface .getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress ipAddress = addresses.nextElement(); if (ipAddress.getHostAddress().contains(".")) return ipAddress.getHostAddress(); } } } catch (SocketException e) { logExceptionMessage(e); } return OFFLINE; }
e941cf27-1a2e-43f0-9b6d-4b604129b67f
7
public void mouseReleased(MouseEvent e) { if (debug == true)System.out.println("NodeGraphic.mouseReleased"); if (e.getButton() == MouseEvent.BUTTON1 && MapPanel.selectedObject == MapPanel.EObjectTools.CURSOR && MapPanel.isDragging() == true) { move_vehicule_if_on(); if (debug == true) System.out.println("Node --- definitive change of node coord !"); this.setx(oldx_win + (e.getXOnScreen() - oldx_screen)); this.sety(oldy_win + (e.getYOnScreen() - oldy_screen)); // Pour etre synchro et eviter la perte de prevision avec MapPanel this.setRealX(MapPanel.scaleX(this.getx())); this.setRealY(MapPanel.scaleY(this.gety())); MapPanel.setMovedNode2(this.getx(), this.gety()); } else if (e.getButton() == MouseEvent.BUTTON1 && MapPanel.selectedObject == MapPanel.EObjectTools.ROAD) MapPanel.setRoadNode(this.getRealX(), this.getRealY()); }
a9b09eb3-d195-4f07-9b12-65b8ef182c95
2
public Pion(final Couleur couleur, final int position) { super(position); this.couleur = couleur; setOpaque(false); switch (couleur) { case BLANC : setForeground(Color.WHITE); setBackground(new Color(220, 220, 220)); break; case NOIR : setForeground(new Color(70, 70, 70)); setBackground(new Color(200, 200, 200)); break; } }
84c8c4d4-13ab-4c1b-8235-90187411e800
6
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Credentials)) { return false; } Credentials that = (Credentials) o; if (this.auth == null || this.key == null) { return false; } if (this.auth.equals(that.auth) && this.key.equals(that.key)) { return true; } return false; }
0e2c8ec4-00c6-45f8-a86c-9a64cda0c0a7
0
public Speaker getSpeaker() { return speaker; }
01a655c0-da11-4de3-9f1f-b1384e9dc12c
1
public void deposit (int amount) { if (amount < 0) { System.out.println ("Cannot deposit negative amount."); } else { this.myBalance = this.myBalance + amount; } }
7874654d-1d3d-4cf1-913f-5aa7a582eaf0
5
public static String getStaticCreeperhostLinkOrBackup (String file, String backupLink) { String resolved = (downloadServers.containsKey(Settings.getSettings().getDownloadServer())) ? "http://" + downloadServers.get(Settings.getSettings().getDownloadServer()) : Locations.masterRepo; resolved += "/FTB2/static/" + file; HttpURLConnection connection = null; boolean good = false; try { connection = (HttpURLConnection) new URL(resolved).openConnection(); connection.setRequestProperty("Cache-Control", "no-transform"); connection.setRequestMethod("HEAD"); for (String server : downloadServers.values()) { if (connection.getResponseCode() != 200) { resolved = "http://" + server + "/FTB2/static/" + file; connection = (HttpURLConnection) new URL(resolved).openConnection(); connection.setRequestProperty("Cache-Control", "no-transform"); connection.setRequestMethod("HEAD"); } else { good = true; break; } } } catch (IOException e) { } connection.disconnect(); if (good) return resolved; else { Logger.logWarn("Using backupLink for " + file); return backupLink; } }
34961e8a-f986-4494-9b12-f0df006b835d
8
public void clear() { // haltScriptExecution(); // if we halt scripts, then the scripts that may call this method will not be able to run initializationScript = null; clearMouseScripts(); clearKeyScripts(); tot = 0; kin = 0; pot = 0; lastCheckedTot = 0; lastCheckedKin = 0; setModelTime(0); enableReminder(false); reminder.setCompleted(false); stopAtNextRecordingStep = false; setTimeStep(1.0); removeAllFields(); clearTimeSeries(); boundary.setType(Boundary.DBC_ID); range_xmin = range_ymin = 20; range_xmax = range_ymax = 20; id_xmin = id_xmax = id_ymin = id_ymax = -1; ((MDView) getView()).clear(); ((MDView) getView()).enableEditor(true); properties.clear(); activateHeatBath(false); if (hasEmbeddedMovie()) insertNewTape(); if (movie != null) { movie.enableAllMovieActions(false); movie.getMovieSlider().repaint(); } // This MUST be after the call to hasEmbeddedMovie() in order for the // special case where there is only one obstacle to work. if (obstacles != null && !obstacles.isEmpty()) { for (Iterator it = obstacles.iterator(); it.hasNext();) ((RectangularObstacle) it.next()).destroy(); obstacles.clear(); } setUniverse(new Universe()); if (updateListenerList != null) { // we must clear the listener to allow gc to clean, but this method is also called by reset(), // so we save a copy of the listeners to be used after reset() is called if (updateListenerListCopy == null) updateListenerListCopy = new ArrayList<UpdateListener>(); else updateListenerListCopy.clear(); updateListenerListCopy.addAll(updateListenerList); updateListenerList.clear(); } // Do NOT remove the following listeners because we are reusing this model container! // if (pageComponentListenerList != null) pageComponentListenerList.clear(); // if(modelListenerList!=null) modelListenerList.clear(); if (job != null) job.removeAllNonSystemTasks(); }
d99260b3-75f7-4a26-b417-131c9235024b
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.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(comet_fines.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(comet_fines.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(comet_fines.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(comet_fines.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new comet_fines().setVisible(true); } }); }
8646d46b-2671-44b0-b5b5-74c1fde9bcfb
1
public void sheepDied(Sheep sheep) { SheepFeed.debug("Sheep ("+ sheep.getEntityId() +") died, removing from list (and schedule)"); if ( this.isWoolGrowingSheep(sheep) ) { // cancel task this.scheduler.cancelTask(this.woolGrowingSheep.get(sheep)); // then remove the sheep this.removeWoolGrowingSheep(sheep); } }
1455a1a3-896e-4ca7-9bbb-1a3b547647d7
7
private String readUTF(int index, final int utfLen, final char[] buf) { int endIndex = index + utfLen; byte[] b = this.b; int strLen = 0; int c; int st = 0; char cc = 0; while (index < endIndex) { c = b[index++]; switch (st) { case 0: c = c & 0xFF; if (c < 0x80) { // 0xxxxxxx buf[strLen++] = (char) c; } else if (c < 0xE0 && c > 0xBF) { // 110x xxxx 10xx xxxx cc = (char) (c & 0x1F); st = 1; } else { // 1110 xxxx 10xx xxxx 10xx xxxx cc = (char) (c & 0x0F); st = 2; } break; case 1: // byte 2 of 2-byte char or byte 3 of 3-byte char buf[strLen++] = (char) ((cc << 6) | (c & 0x3F)); st = 0; break; case 2: // byte 2 of 3-byte char cc = (char) ((cc << 6) | (c & 0x3F)); st = 1; break; } } return new String(buf, 0, strLen); }
8321ddc3-c310-4e54-b292-5325547a0cb3
7
private String convertValidateRTypes(String type) { if (type.equals("double")) { type = "numeric"; } else if (type.equals("i64") || type.equals("i32")) { type = "integer"; } else if (type.equals("bool")) { type = "logical"; } else if (type.equals("string")) { type = "character"; } else if (type.startsWith("set(")) { type = type.replace("set(", "SetOf"); type = type.replace(")", ""); } else if (type.startsWith("list(")) { type = type.replace("list(", "ListOf"); type = type.replace(")", ""); } return type; }