text
stringlengths
14
410k
label
int32
0
9
public void actionPerformed (ActionEvent event) { String eventName=event.getActionCommand(); // Cancel if (eventName.equals("Cancel")) { changedTriggers=false; dispose(); } // OK if (eventName.equals("OK")) { // Check the entries if (checkTrigger()==true) { changedTriggers=true;...
3
public HashMap<String, Integer> printCheck(Check check) throws Exception { HashMap<String, Integer> result = new HashMap<String, Integer>(); if ( ! check.validate()) throw new Exception("Ошибка заполнения чека"); int command = check.getCommand(); ArrayList<Integer> ans...
8
String genoStr(String geno) { if (geno.equals("x") || geno.equals("0")) return ""; return geno; }
2
private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expe...
8
public void ls() { System.out.println(CompositeDemo.g_indent + m_name); CompositeDemo.g_indent.append(" "); for (Object obj : m_files) { // Recover the type of this object if (obj instanceof Directory) { ((Directory) obj).ls(); } else { ...
2
public static void saveToPreferences() { Preferences prefs = Preferences.getInstance(); prefs.removePreferences(MODULE); for (String key : DEFAULTS.keySet()) { Font font = UIManager.getFont(key); if (font != null) { prefs.setValue(MODULE, key, font); } } }
2
public void setReal (boolean b) { real = b; }
0
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { String label = scanner.next(); //first value entered is label if(scanner.hasNextInt()) { //check if next input is integer ...
7
@Override public Hit intersect(Ray ray) { Vector x0 = ray.getOrigin().sub(center); Vector d = ray.getNormalizedDirection(); float t1 = 0.0f; float t2 = 0.0f; if ((x0.dot(d) * x0.dot(d)) * ((x0.dot(x0)) - (radius * radius)) < 0) { return null; } if ((x0.dot(d) * x0.dot(d)) * ((x0.dot(x0)) - (radius...
3
private void addNeighbour(int x, int y, Cell cell) { if (x >= 0 && x < maxCols && y >= 0 && y < maxRows) { LogicCell c = new LogicCell(x, y); if (!nextStep.containsKey(c)) { c.neigbour = 1; nextStep.put(c, c); } else { nextStep....
5
public int send(short dest, byte[] data, int len) { //can't have too many unacked things to send if (toSend.size() > 3)//if there is 4 unacked { stat.changeStat(Status.INSUFFICIENT_BUFFER_SPACE); if(debugLevel > 0) output.println("Too many packets. Not sending"); return 0; } if(len < 0) { s...
8
public double compareStrings(String text1, String text2) { ArrayList<String> pairs1 = wordLetterPairs(text1.toUpperCase()); ArrayList<String> pairs2 = wordLetterPairs(text2.toUpperCase()); int similarityCounter = 0; int completeSize = pairs1.size() + pairs2.size(); for (int i = 0; i < pairs1.size(); i++) {...
3
public static List<Double> findRoots(Function f, double startPoint, double endPoint, int numberOfProbes, double tolerance) { double distance = Math.abs((endPoint - startPoint) / numberOfProbes); double[] evaluationPoints = getEvaluationPoints(startPoint, distance, numberOfProbes); List<Double> startingPointsT...
7
private String getWordInSingularOrPluralForm(String word, long count) { return (count > 1) ? word + "s" : word; }
1
protected boolean encodeHeader(int alphabetSize, int[] alphabet, int[] frequencies, int lr) { EntropyUtils.encodeAlphabet(this.bitstream, alphabet, alphabetSize); if (alphabetSize == 0) return true; this.bitstream.writeBits(lr-8, 3); // logRange int inc = (alphabetSize > 64) ? 16 :...
9
protected void resolveConflict(int s, int newValue) { // The set of children values TreeSet<Integer> values = new TreeSet<Integer>(); // Add the value-to-add values.add(new Integer(newValue)); // Find all existing children and add them too. for (int c = 0; c < alphabetLength; c++) { int tempNext = ge...
9
public boolean preaching() { if (preaching == 1){ if (holyBook){ startAnimation(1335); } if (unholyBook){ startAnimation(1336); } if (balanceBook){ startAnimation(1337); } preaching = 2; } if (preaching == 2){ resetPreaching(); } return true; }
5
public String getMergedfile(SmartlingKeyEntry updateEntry) throws IOException, JSONException { // for each locale (for the specific project) , get translated file from smartling String responseHtml = SmartlingRequestApi.getFileFromSmartling(updateEntry.getFileUri(), updateEntry.getProjectId(), update...
9
public Lep(int i, int j, int k, int l, int[][] t){ logger.info("Meghívták a konstruktort."); aktualispoz1=i; aktualispoz2=j; hovaakar1=k; hovaakar2=l; for(int a=0; a<8; a++) for(int b=0; b<8; b++) sajat[a][b]=t[a][b]; }
2
private ArrayList<File> dirFilelist(File f) { ArrayList<File> res = new ArrayList<>(); if (f.exists() && f.isDirectory()) { File[] chld = f.listFiles(); for (File sf : chld) { if (!sf.getName().equals(".") && !sf.getName().equals("..") && sf.isFile()) { res.add(sf); } } } return res; }
6
public void resetPositions(){ // Reposition game objects p1.setX(initialPosX_p1); p1.setY(initialPosY_p1); p2.setX(initialPosX_p2); p2.setY(initialPosY_p2); b.setY(gameWindow.getCenterY() - 14); b.setVelX(0); b.setVelY(0); // alternate the...
1
@Override public void handlePacket(Packet packet, Socket s, Main game) { if (!packet.getBoolean()) { // success JOptionPane.showMessageDialog(game.gameFrame, "You cannot do that.", "Error", JOptionPane.ERROR_MESSAGE); game.setButtons(true); return; } int rank = 0; Group group = null; for (int i...
9
public CommandHandler(String command, String pitch, String commandGrammar, String where, String summary, List<String> notes, String input, String output, String example, Options options) { if ((command == null)) { throw new IllegalArgumentException("command cannot be null.")...
9
public boolean addElementField(ElementField element) { gameFieldView().addElementFieldView(element); if (element instanceof Ball) { return _balls.add((Ball) element); } else if (element instanceof DestructibleBrick) { return _dBricks.add((DestructibleBrick) element); ...
7
public void dumpLayers() { System.out.println("<layers>"); for (Layer l : layers) { if (l instanceof CodeEntry) { System.out.println("CodeEntry: " + ((CodeEntry)l).clnm); } else if (l instanceof Code) { System.out.println("Code: " + ((Code)l).name); Field[] classfields = ((Code)l).getClass().getFi...
4
public void run(){ long lastTime = System.nanoTime(); long timer = System.currentTimeMillis(); final double ns =1000000000.0 /60.0; double delta =0; int frames =0; int updates =0; requestFocus(); while(running){ long now =System.nanoTime();//re-sets time to computer time lag delta += (now-lastTime) /ns; last...
3
private static Point2D getProjectionOnEdge(Point2D source, Point2D wayPoint, double panelWidth, double panelHeight) { final LineEquation eq = new LineEquation(source, wayPoint); double interX; // X coord of the intersection double interY; // Y coord of the intersection if (eq.a > 0) { ...
6
@Override public List<Group> findGroupByUserId(int userId) { List<Group> list = new ArrayList<Group>(); Connection cn = null; PreparedStatement ps = null; ResultSet rs = null; try { cn = ConnectionHelper.getConnection(); ps = cn.prepareStatement(QTPL...
5
public Passenger(JSONObject json) throws JSONException { try { if (json.has(AMOUNT)) { this.setAmount(Float.parseFloat(json.getString(AMOUNT))); } if (json.has(TOTAL)) { this.setTotal(Float.parseFloat(json.getString(TOTAL))); } if (json.has(NETAMOUNT)) { this.setNetamount(Float.parseFloat(j...
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Shelf other = (Shelf) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return fals...
6
public static final void itemSort(SeekableLittleEndianAccessor slea, MapleClient c) { slea.readInt(); // timestamp byte mode = slea.readByte(); boolean sorted = false; MapleInventoryType pInvType = MapleInventoryType.getByType(mode); MapleInventory pInv = c.getPlayer().getInvento...
6
public int getSize() { return statusRepo.size(); }
0
double calculatescore() { total = 0; for (int i = 0; i < seedlist.size(); i++) { double score; double chance = 0.0; double totaldis = 0.0; double difdis = 0.0; for (int j = 0; j < seedlist.size(); j++) { if (j != i) { totaldis = totaldis + Math.pow( distanceseed(seedlist.g...
9
private boolean exitTableBody(Token t, HtmlTreeBuilder tb) { if (!(tb.inTableScope("tbody") || tb.inTableScope("thead") || tb.inScope("tfoot"))) { // frag case tb.error(this); return false; } tb.clearStackToTableBodyContext(); ...
3
public static String extractTitleFrom(String filePath) /* * The extractNameFrom method checks the ID3 version of the mp3 file and * extracts the song title from the MP3 file. */{ String title = null; try { Mp3File mp3File = new Mp3File(filePath); if (mp3File.hasId3v2Tag()) { ID3v2 id3v2Tag ...
7
protected static Ptg calcInt( Ptg[] operands ) { if( operands.length != 1 ) { return PtgCalculator.getNAError(); } double dd = 0.0; try { dd = operands[0].getDoubleVal(); } catch( NumberFormatException e ) { return PtgCalculator.getValueError(); } if( new Double( dd ).isNaN() ) // Not a ...
4
public void setFrame(String panel){ switch(panel){ case "login": frame.remove(curPanel); frame.add(login); login.refresh(); frame.validate(); frame.repaint(); curPanel=login; frame.setSize(425,300); break; case "createUser": frame.remove(curPanel); frame.add(createUser); ...
7
public void destroy() { targetNode = null; currentRenderer = null; prevRenderer = null; }
0
private LinkedHashMap<Rashi, ArrayList<Nakshatra>> getStarsInRashi() { LinkedHashMap<Rashi, ArrayList<Nakshatra>> starsInRashi = new LinkedHashMap<Rashi, ArrayList<Nakshatra>>(); ArrayList<Nakshatra> starsForRashiList = new ArrayList<Nakshatra>(); for (Nakshatra nakshatra : Nakshatra.values()) { if (nakshatra...
4
private void useTeamPiece(char teamSymbol) throws Exception{ if (!NineManMill.DEBUG_VERSION){ throw new Exception ("This is not a debug version, cannot call useTeamPiece()!"); } switch (teamSymbol){ case EMPTY: return; case PLAYER1: /* Find some way to get the coordinates */ // team1.usePiece(ne...
4
public static void main(String[] args) { int elements[] = {5, 3, 2, 6, 3, 1, 8, 7, 1, 2, 4, 1, 6, 2, 3, 4, 5, 2, 3, 2, 6, 1, 1, 8, 7, 1, 2, 4, 1, 2, 2, 3, 4, 5, 2, 3, 2, 6, 1, 1, 8, 7, 1, 2, 4, 1, 1, 2, 3, 4, 5, 2, 3, 2, 6, 1, 1, 8, 7, 1, 2, 4, 7, 1, 2, 3, 4, 5, 2, 3, 5, 6, 1, 1, 8, 7, 1, 2, 4, 1, 1, 2, 3, 4, 5, 2 };...
1
public MyCanvas() { setDoubleBuffered(false); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { oX = e.getX(); oY = e.getY(); } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDra...
1
private int upgradeForGood(Service type) { final Integer key = (Integer) SupplyDepot.SERVICE_KEY.get(type) ; final Upgrade KU ; if (key == null) return -1 ; else if (key == SupplyDepot.KEY_RATIONS ) KU = RATIONS_STOCK ; else if (key == SupplyDepot.KEY_MINERALS) KU = PROSPECT_EXCHANGE ; els...
5
public boolean similar(Object other) { if (!(other instanceof JSONArray)) { return false; } int len = this.length(); if (len != ((JSONArray)other).length()) { return false; } for (int i = 0; i < len; i += 1) { Object valueThis = this.ge...
8
public void close(){ //called when room is closing, should kick all users for (ChatServerThread thread : threads){ thread.disconnect("Room is closing."); } }
1
private void salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarActionPerformed Contato contato = new Contato(); contato.setNome(nome.getText()); if((null != tel_1.getText()) && !(tel_1.getText().isEmpty())){ contato.setTelefone1(Integer.parseInt(tel_1.ge...
7
public final float apply(float x, float y, float z) { // Skew input space to relative coordinate in simplex cell s = (x + y + z) * onethird; i = fastfloor(x+s); j = fastfloor(y+s); k = fastfloor(z+s); // Unskew cell origin back to (x, y , z) space s = (i + j + k...
6
public CheckResultMessage check27(int day) { int r1 = get(39, 5); int c1 = get(40, 5); int r2 = get(41, 5); BigDecimal b = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); for (int i = r1 + 21; i < r2; i++) { ...
7
private Move getMinimaxMove(StateTree tree) throws Exception { TicTacToeBoard state = tree.getState(); if (state.getTurn() == MIN_PLAYER) { return this.getMinMove(tree); } else if (state.getTurn() == MAX_PLAYER) { return this.getMaxMove(tree); } else { throw new Exception("Invalid player turn"); ...
2
public void attdam(int maxDamage, int range) { for (Player p : server.playerHandler.players) { if(p != null) { client person = (client)p; if((person.playerName != null || person.playerName != "null")) { if(person.distanceToPoint(absX, absY) <= range && person.playerId != playerId) ...
7
public boolean jumpMayBeChanged() { return (catchBlock.jump != null || catchBlock.jumpMayBeChanged()); }
1
@Override public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, ServletException { Integer id = null; String name = null; String surname = null; Date dateOfBirth = null; Double salary = null...
4
@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 Pessoa)) { return false; } Pessoa other = (Pessoa) object; if ((this.id == null && other.id != null) || (this.i...
5
public boolean eventGeneratable(String eventName) { if (m_listenee == null) { return false; } if (m_listenee instanceof EventConstraints) { if (eventName.equals("instance")) { if (!((EventConstraints)m_listenee). eventGeneratable("incrementalClassifier")) { return false; } } ...
9
TabbedPane() { super(new GridLayout(1, 1)); JTabbedPane tabbedPane = new JTabbedPane(); java.net.URL imgURL = getClass().getResource("img/db.jpg"); ImageIcon iconDB = new ImageIcon(imgURL); panelDB = new JPanelCluster("MINE", new java.awt.event.ActionListener() { public void actionPerformed(Acti...
6
private void setPauseResume(ButtonMode mode) { BattleRunner runner = engine.getCurrentBattle(); if(mode == ButtonMode.PAUSE) { if(runner != null) { runner.setPaused(true); } btnPause.setText("Resume"); } else { if(runner != null) { runner.setPaused(false); } btnPause.setText("Pause"); ...
3
public static void main(String[] args) throws InterruptedException { Thread [] threads = new Thread[5]; CountDownLatch latch = new CountDownLatch(5);//tell it how many count downs there will be for(int i = 0; i<threads.length; i++){ final int current = i; threads[i] = new Thread(){ public void run(){...
1
public void addSum(int[] num,List<Integer> list,int target,int index){ if(target <= 0){ if(target == 0 && !result.contains(list)) result.add(new ArrayList<Integer>(list)); return; } for (int i = index;i < num.length ;i++ ) { if(num[i] > target)...
5
public Encryption(String m, String k) { if (k != "error") { char[] ck = fill(k); int[] i = fill1(ck); char[] cm = fill(m); int[] s = fill(cm); int[] r = scramble(s, i); o = em(r); }else{ //Do Nothing } return; }
1
public void clearCache() { BufferedImage cache = cachedImage == null ? null : cachedImage.get(); if (cache != null) { cache.flush(); } cacheCleared = true; if (!isCacheable()) { cachedImage = null; } }
3
public void setWidth(int width) { if(rotation == 90 || rotation == 270){ if(zoom == 1){ this.height = (int) (width/zoom); }else{ this.height = (int) (width/zoom)+1; } }else{ if(zoom == 1){ this.width = (int) (width/zoom); }else{ this.width = (int) (width/zoom)+1; } } }
4
public int AddInstanceToBestCluster(Instance inst) { double delta; double deltamax; int clustermax = -1; if (clusters.size() > 0) { int tempS = 0; int tempW = 0; if (inst instanceof SparseInstance) { for (int i = 0; i < inst.numValues(); i++) { tempS++; tempW++; } } else...
8
private void okButtonClick(ActionEvent evt) { Object[] selectedValues = templatesList.getSelectedValues(); if (selectedValues.length==0) { JOptionPane.showMessageDialog(this, "请选择模板.", "提示", JOptionPane.INFORMATION_MESSAGE); return; } String targetProject = textTa...
9
public final boolean is888() { if (!trueColour) return false; if (bpp != 32) return false; if (depth != 24) return false; if (redMax != 255) return false; if (greenMax != 255) return false; if (blueMax != 255) return false; return true; }
6
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed boolean ch=false,ch2=false; for (int i = 0; i < cont.getText().length(); i++) { if(cont.getText().charAt(i)=='['||cont.getText().charAt(i)==']'||!Character.isDigit(cont.getText().c...
9
static public Object deserializeArray(InputStream in, Class elemType, int length) throws IOException { if (elemType==null) throw new NullPointerException("elemType"); if (length<-1) throw new IllegalArgumentException("length"); Object obj = deserialize(in); Class cls = obj.getClass(); ...
6
@Override public int getIndex(TreeNode node) { if (!(node instanceof MyFile)) { throw new IllegalArgumentException("Unsupported type for the tree node " + node); } return this.files.indexOf(node); }
1
public double PrecessionEpoch(double y, int type) { switch (type) { case JULIAN_EPOCH: return JulianEpoch(y); case BESSELIAN_EPOCH: return BesselianEpoch(y); default: return 0.0; } }
2
public static Point[] getBlastRadius(Point point, int blockSize, int radius) { if(radius == 0) { return new Point[] {}; } else if(radius == 1) { return new Point[] {new Point(point.x, point.y - blockSize), new Point(point.x - blockSize, point.y), new Point(point.x + blockSize, point.y), new Poi...
6
@Override public void repaint(Graphics graphics) { Graphics2D g2 = (Graphics2D) graphics; g2.setStroke(new BasicStroke(1)); g2.setFont(g2.getFont().deriveFont(10f)); int x = X; int y = Y; g2.setColor(COLOUR_BACKGROUND); g2.fillRect(x - 2, y - 2, WIDTH, HEIGHT); g2.setColor(COLOUR_BACKGROUND_BORDER);...
6
public Fly(Animation left, Animation right, Animation deadLeft, Animation deadRight, Animation standingLeft, Animation standingRight, Animation jumpingLeft, Animation jumpingRight) { super(left, right, deadLeft, deadRight, standingLeft, standingRight, jumpingLeft, jumpingRight); }
0
public void run() { int p1Win = 0; int p2Win = 0; for (int i = 0; i < turn; i++) { Game game = null; if (i % 2 == 0) game = new Game(player1, player2, true); else game = new Game(player2, player1, true); game.clearBoard(); int result = game.play(); if (result == 1) { if (...
6
public void await() { // Set to 1 for ourselves. readyCount = 1; // Send out-going confirmations. new Thread(new Runnable() { @Override public void run() { for (ServerIdentifier identifier : servers) { if (identifier.equals(myI...
9
@Override public void paintComponent(Graphics g){ Paint paint; Graphics2D g2d; if (g instanceof Graphics2D) { g2d = (Graphics2D) g; } else { System.out.println("Error"); return; } RenderingHints qualityHints=new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); ...
4
public String getInsertStatement(String ver, int book, int chapter) throws ParseException, IOException { // String strBook = String.format("B%02d", book); // String strChapter = String.format("C%03d", chapter); String strHtml = getOneChapterContent(ver, getBookChapter(book, chapter)); int ...
6
private void despacharSolicitud(Solicitud psolicitud) { Operario operario1 = (Operario) listaOperarios.get(0); // Si hay mas de un operario, entonces asignar la solicitud a quien // tenga menos asignadas. if (listaOperarios.size() > 1 && solicitudesDespachadas.size() > 0) { Operario operario2 = (Operario...
5
public int getSize() { int counter = 0; Occurrence temp = head; while (head != null) { counter++; head = head.next; } head = temp; return counter; }
1
public void insert() { Connection conn = null; PreparedStatement pstmt = null; try { //1、加载驱动 Class.forName("com.mysql.jdbc.Driver"); String mysqlUrl = "jdbc:mysql://localhost:3306/rock"; //2、建立连接 conn = DriverManager.getConnection(mysqlUrl,"root","123456"); String sql = "insert into emp2(ename,...
5
private static DefaultComboBoxModel createModel(Color[] colors, String[] names, boolean allowCustomColors) { DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < colors.length; i++) { Color c = colors[i]; String text = null; if (i < names.lengt...
4
private void addActionListeners() { importDataMenuItem.addActionListener(e -> firePropertyChange(MainWindowController.IMPORT, 0, 1)); exportDataMenuItem.addActionListener(e -> firePropertyChange(MainWindowController.EXPORT, 0, 1)); ItemListener itemListener = new ComboBoxItemListener(); ...
5
private String makeName(DateTimeField fieldA, DateTimeField fieldB) { if (fieldA.getName().equals(fieldB.getName())) { return fieldA.getName(); } else { return fieldA.getName() + "/" + fieldB.getName(); } }
1
private boolean zzRefill() throws java.io.IOException { /* first: make room (if you can) */ if (zzStartRead > 0) { System.arraycopy(zzBuffer, zzStartRead, zzBuffer, 0, zzEndRead-zzStartRead); /* translate stored positions */ zzEndRead-= zzStartRe...
5
public static void prochaineGeneration(JCellule[][] grid, double nbrGenerations, JLabel lblGeneration, JButton btnProchaineGeneration) { ControllerGrille.grid.incrementGeneration(nbrGenerations); synchroniser(grid, lblGeneration, btnProchaineGeneration); }
0
public static void setQt (String id, char signe) throws ParseException { for (int i=0;i<list.size();i++){ if (list.get(i).getId() == Integer.parseInt(id)){ if (signe == 'd') list.remove(i); else if (signe == '+') list.get(i).setQt(list.get(i).getQt()+1); else list.get(i).setQt(list.get(i...
4
public static void main(String[] args) { /* Activity 2.1 Scanners */ Scanner k = new Scanner(System.in); while ( k.hasNext() ) { // press Ctrl/Cmd + D(?) to stop input int d = 0; String s = ""; if (k.hasNextInt()) { d = k.nextInt(); } if (k.hasNext()) { s = k.next(); k.nextLine(); // s...
5
private void Competicao_ComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Competicao_ComboBoxItemStateChanged //Atualiza Jornadas_ComboBox Jornada_ComboBox.removeAllItems(); Competicao competicao; int max_jornadas; if (Campeonato_RadioButton.isSelected()) ...
7
public long skip(long n) throws IllegalArgumentException, IOException { if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } // illegal argument if (n < 0) { throw new IllegalArgumentException("negative argument not supported"); } /...
5
public Piece makePiece(String s) { boolean color = 'W' == s.charAt(0); switch (s.charAt(1)) { case 'X': return new Blank(color); case 'B': return new Bishop(color); case 'R': return new Rook(color); case 'P': return new Pawn(color); case 'Q': return new Queen(color); case 'K': ...
7
@Override public void windowIconified(WindowEvent e) { }
0
public static String wrapString(String str, double maxLength) { StringTokenizer st = new StringTokenizer(str); double spaceLeft = maxLength; int spaceWidth = 1; StringBuilder sb = new StringBuilder(); while (st.hasMoreTokens()) { String word = st.nextToken(); if ((word.length() + spaceWidth) > spaceLeft...
2
@Override public void printValueToConsole(List<Integer> list) { // checking input parameter for null if (list == null) { throw new IllegalArgumentException("array not specified!"); } System.out.printf("\n%s", "Value of array: \n"); for (Integer foo : list) { ...
2
public static void hypothesizeLambda(GrammarEnvironment env, Grammar g) { LambdaProductionRemover remover = new LambdaProductionRemover(); Set lambdaDerivers = remover.getCompleteLambdaSet(g); if (lambdaDerivers.contains(g.getStartVariable())) { JOptionPane.showMessageDialog(env, "WARNING : The start v...
2
public byte[] removeAttribute(String name) { if (unknownAttributes != null) return (byte[]) unknownAttributes.remove(name); return null; }
1
private boolean processGMCommand(MapleClient c, MessageCallback mc, String[] splitted) { DefinitionGMCommandPair definitionCommandPair = gmcommands.get(splitted[0]); MapleCharacter player = c.getPlayer(); if (definitionCommandPair != null) { try { definitionCommandPai...
6
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } @SuppressWarnings("rawtypes") Pair other = (Pair)...
9
public static int[] getTopBins(int[] bins, int binCount, int collapseBins){ int[] topBins = new int[binCount]; List<Integer> sortedBins = new ArrayList<Integer>(); Map<Integer, List<Integer>> binCountMap = new HashMap<Integer, List<Integer>>(); for(int i = 0; i < bins.length; ++i){ if(!binCountMap.containsKe...
8
public static boolean oneIn(int x) { if (random.nextInt(x) == 0) { return true; } return false; }
1
protected BufferedImage getCache() { if (floodFill != null) return myCache; floodFill = new FloodFill(canvas,source,origin,threshold); floodEdge = null; int w = floodFill.maxX - floodFill.minX + 1; int h = floodFill.maxY - floodFill.minY + 1; int rgb = c1.getRGB(); myCache = new BufferedImage(...
6
public boolean checkEnemies() { for (Tile t : getMap()) { if (t.getClass() == Road.class) { if (((Road) t).hasEnemy() != null) ; return true; } } return false; }
3
public final void printHTML(PrintStream out) { out.println("=== " + fcommand + " ==="); if (!fcommandGrammar.trim().equals("")) { out.println("*Usage:*"); out.println(); out.println("{{{"); out.println("java randoop.main.Main " + fcommandGrammar); ...
9