text
stringlengths
14
410k
label
int32
0
9
@Override public byte[] pingMsdp(final Session session, final Map<Object,Object> reportables) { try { if(reportables.size()==0) return null; List<Object> broken=null; synchronized(reportables) { Object newValue; for(final Entry<Object,Object> e : reportables.entrySet()) { newValue...
7
public static void main(String[] args) { int op = 0; boolean exit = false; do{ try{ Prints.printlnWithColor("GREEN","1- Login"); Prints.printlnWithColor("GREEN","2- Crear Usuario"); Prints.printlnWithColor("GREEN","3- ...
5
public static void main(String[] args) { if (args.length > 0) { CommandLineMode commandLineMode = new CommandLineMode(args[0], new PlotterController()); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void ...
1
public double distance(DatasetObject o_1, DatasetObject o_2) { int dist=0; TreeMap q_knp=ros.kNearestReferenceObjects(o_1,ks); Iterator q_iter=q_knp.keySet().iterator(); int q_p_pos=0; while(q_iter.hasNext()) { q_p_pos++; Integer q_p=(Integer)q...
4
public boolean verifySquenceOfBST(int[] squence , int start , int end){ if(squence == null || end < start ){ throw new NullPointerException("Input is null."); } int root = squence[end]; int i = start ; for(; i < end ; i++){ if(squence[i] > root){ break; } } int j = i ; for( ; j < end ; ...
9
public void modifierVitesse(float c) { if (c != vitesse) { vitesse = c; timer.cancel(); timer.purge(); timer = new Timer(); timer.scheduleAtFixedRate(new Timing(this), 0, (int) (50.0f / vitesseBase)); } }
1
public void paint(Graphics g) { super.paint(g); LOGGER.info("Desenhando Cliente:\t" + cliente.toString() ); if (fase != null && cliente != null && cliente.getMario() != null && cliente.getLuigi() != null) { g.drawImage(fase.getBackground(), 0,0, this); g.drawImage(fase.getMarioDirImg(), cliente.getMa...
4
public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[11]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 6; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if...
8
public void setCount(int value) { this._count = value; }
0
public Exponential(double lambda) throws ParameterException { if (lambda <= 0) { throw new ParameterException("Exponential parameter lambda > 0."); } else { this.lambda = lambda; unif = new ContinuousUniform(0, 1); } }
1
public MyComparer(int rId, Settings settings) { _rId = rId; MAX_WORDS_BETWEEN_RESULTS = settings.getCompareJumpLength(); NUM_WORDS_TO_COMPARE = settings.getCompareSentenceLength(); THRESHOLD = ((double) settings.getThreshold()) / 100; }
0
@Override public void performEmptyAction(GameObject gameObj) { if(gameObj instanceof Unit) { ((Unit)gameObj).kill(); } else if(gameObj instanceof Building) { ((Building)gameObj).destroy(); } }
2
public static String zeroString(String str, int size) { str = str == null ? "" : str.trim(); char[] ch = str.toCharArray(); int len = ch.length; int lens = size - len; if (lens <= 0) { return str; } String rStr = ""; for (int i = 0; i < size; i++) { if (lens > i) { ...
4
public void removeOldImagesIfNecessary() { removeOldImagesIfDatabaseIsFull(); removeOldImagesAfter2DaysPeriod(); }
0
@Override public void init(ILogger logger, IRemoteServerConnection rsc) throws Exception { synchronized (this) { doInit(logger, rsc); } }
0
public void update(double time) { Vector2d _location = new Vector2d(location.getX(), location.getY()); location.add(Vector2d.multiply(velocity, time)); if (Collision.isBulletIntersectingMap(this)) { if (bounces <= 0) { destroyed = true; return; } bounces--; location = _location; Vector2d x...
4
public void setMasterVolume(float volume) { // I know I that this may be 'overkill', but, i'd rather make the point // in the logs that the volume control wasn't found for volume many // times, to make it easier to find if it's gone wrong if (volumeControl == null) logger.error(new NullPointerException(), "V...
3
public boolean start() { if (doing) { System.out.println("Server already runnning!"); return false; } if (ipaddress == null) { Socket s; try { s = new Socket("google.com", 80); ipaddress = (s.getLocalAddress().getHostAddress()); if (ipaddress == null) { noInternet = true; ipaddre...
5
@Override public String toString() { String rval = ""; if(type.equalsIgnoreCase(TYPE_RECT)) { rval = "Rectangle(x=" + rect.x + ", y=" + rect.y + ", width=" + rect.width + ", height=" + rect.height + ")"; } else if(type.equalsIgnoreCase(TYPE_POLY)) { rval = "Polygon(xpoint...
3
public int compareTo( Object obj ) { if( obj == null ) { return( 1 ); } else if( obj instanceof GenKbSecUserByUEMailIdxKey ) { GenKbSecUserByUEMailIdxKey rhs = (GenKbSecUserByUEMailIdxKey)obj; if( getRequiredClusterId() < rhs.getRequiredClusterId() ) { return( -1 ); } else if( getRequiredCluste...
9
private void doSaveImage() { BufferedImage image = board.getImage(); // The image currently displayed in the MosaicPanel. JFileChooser fileDialog = new JFileChooser(); String defaultName = "pentominos_" + rows + "x" + cols + ".png"; // Default name for file to be saved. File selectedFile = new ...
5
private double[] refactorDistApart(double[] distApart, double threshold) { for (int i = 0; i < window; i++) { distApart[i] = threshold; } for (int i = distApart.length - window; i < distApart.length; i++) { distApart[i] = threshold; } for (int i = 0; i <...
9
public void setShortMessageFontsize(int fontsize) { if (fontsize <= 0) { this.shortMessageFontSize = UIFontInits.SHORTMESSAGE.getSize(); } else { this.shortMessageFontSize = fontsize; } somethingChanged(); }
1
public void addSICCode(String code) throws Exception { if (null == Sic) { Sic = new ArrayList<String>(); } else if (1000 == Sic.size()) { throw new Exception("Maxiumum of 1000 SIC codes are allowed for Search"); } if (!Sic.contains(code)) { Sic.add(code); } }
3
public void testStopPositons() throws IOException { StringBuilder sb = new StringBuilder(); ArrayList a = new ArrayList(); for (int i=0; i<20; i++) { String w = English.intToEnglish(i).trim(); sb.append(w).append(" "); if (i%3 != 0) a.add(w); } log(sb.toString()); String stopWo...
7
boolean startsWithBreakPoint() { for ( int i=0;i<rows.size();i++ ) { Row r = rows.get(i); if ( r.cells.size()>0 && r.versions.nextSetBit(base)==base ) { FragList fl = r.cells.get(0); if ( fl.fragments.size()>0 ) { ...
4
public boolean checkIfSubTree(Node T1, Node T2) { if (T1 == null && T2 == null) return true; if (T1 == null && T2 != null) return false; if (T1 != null && T2 == null) return false; if (T1.value == T2.value) { checkIfSubTree(T1.left, T2...
7
@EventHandler public void SpiderWeakness(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getSpiderConfig().getDouble("Spider.Weakne...
6
private Allocation allocate(int payLoad) { int offset = currentItemOffset.addAndGet(ItemMeta.META_SIZE + payLoad); if (capacity < offset) return null; return new Allocation(offset - ItemMeta.META_SIZE - payLoad); }
1
public static SingleWriter getInstance(String fileName) throws IOException { if (instance == null) { instance = new SingleWriter(); } out = new PrintWriter(fileName, "UTF-8"); return instance; }
1
private double[][] read(Scanner scanner) throws IOException { st = new StringTokenizer(scanner.nextLine()); if (st == null || st.countTokens() != 2) { throw new IOException("Input data is incorrect"); } r = Integer.parseInt(st.nextToken()); c = Integer.parseInt(st.nex...
8
public static Integer[] solveLargestFirst(Graph graph) { ArrayList<Integer> cache = new ArrayList<>(graph.graph.size()); Integer[] result = new Integer[graph.graph.size()]; for (int i = 0; i < result.length; ++i) { result[i] = -1; } int color = 0; while (cache...
8
@Override public void addItems(String fromDirectory, Collection<String> items) throws IOException { for (String item : items) { addItem(fromDirectory, item); } }
1
public int candy(int[] ratings) { if (ratings.length == 0) { return 0; } if (ratings.length == 1) { return 1; } int[] candy = new int[ratings.length]; int result = candy.length; for (int i = 1; i < candy.length; i++) { if (ratings[i] > ratings[i - 1]) { candy[i] = candy[i - 1] + 1; } } ...
8
protected void outOfOrder() { JOptionPane.showMessageDialog(frame, "That action is inappropriate for this step!", "Out of Order", JOptionPane.ERROR_MESSAGE); }
0
public boolean containsNaive() throws Exception { Stack<StackElement> stack = new Stack<>(); int currentLiteralPos = 0; calcViewPositions(); //List<Literal> remainingLiterals = new ArrayList<>(); //remainingLiterals.addAll(Arrays.asList(query.literals)); //Literal first...
9
public void insert(BatBitmap b, int x, int y){ //Fills this bitmap with b, at (x,y) int x0 = x; int x1 = x0 + b.width; int y0 = y; int y1 = y0 + b.height; if(x0 < 0) x0 = 0; if(y0 < 0) y0 = 0; if(x1 > this.width) x1 = this.width; if(y1 > this.height) y1 = this.height; int fillWidth = x1 - x0; i...
7
public void update(float delta) { timer += delta / 1000; if (timer > minSpawnTime) { Random rng = new Random(System.currentTimeMillis()); int r1 = rng.nextInt(); int spawnTime = maxSpawnTime - minSpawnTime; if ((int) r1 % spawnTime == 0 || timer > (spawnTi...
5
@Override public void requestCS(int pid) { choosing[pid]=true; for (int i = 0; i < n; i++){ if(number[i] > number[pid]){ number[pid]=number[i]; } } number[pid]++; choosing[pid]=false; for (int i = 0; i < n; i++) { while(choosing[i]); while((number[i]!= 0) && ((number[i...
8
public void onStartUp() { if (this.fileLocation == null) { this.file = new File(this.plugin.getDataFolder(), this.fileName + this.fileExtension); } else { this.file = new File(this.fileLocation, this.fileName + this.fileExtension); } try { this.fileConfig = YamlConfiguration.load...
4
private MoveResult determineGameResult() { MoveResult result; boolean isBlueWinner = board.checkIfPlayerLost(HantoPlayerColor.RED); boolean isRedWinner = board.checkIfPlayerLost(HantoPlayerColor.BLUE); if (isBlueWinner && isRedWinner) { result = MoveResult.DRAW; } else if (isBlueWinner) { result = Mov...
5
public AnswerCombination getAnswer() { return answer; };
0
public void drawInput(Graphics2D g, InputConnector ip) { int[] xs = null, ys = null; if (ip.pos == Position.left) { xs = new int[] { x - connectorSize / 2, x + connectorSize / 2, x - connectorSize / 2 }; ys = new int[] { y + height / 2 - connectorSize / 2, y + height / 2, y + height / 2 + connectorS...
5
public static void writeFile(RuleSet ruleSets, String ruleFileOutputName, ErrorLogs errorLogs, String errorFileOutputName) { // The name of the file to open. if(ruleFileOutputName == "" || errorFileOutputName == ""){ errorLogs.getErrorMsgs().add("The specified output path(s) are empty"); } System.out.prin...
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CallendarAdapter that = (CallendarAdapter) o; if (events != null ? !events.equals(that.events) : that.events != null) return false; return tru...
5
public double variance(int col) { int n = 0; double mean = columnMean(col); double sum = 0; for (List<Double> row : data) { double val = row.get(col) - mean; if (val != UNKNOWN_VALUE) { sum += (val * val); n++; } ...
3
protected JPanel getSamplePanel() { if (samplePanel == null) { Border titledBorder = BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), ("Sample")); Border empty = BorderFactory.createEmptyBorder(5, 10, 10, 10); Border border = B...
1
public void hanoiIteratif2(int n, Tour depart,Tour arrivee, Tour intermediaire){ int i = 0; int hauteur = depart.getHauteur(); if(n%2==0) while(arrivee.getHauteur()!= hauteur){ deplacementPetit(i,depart,arrivee,intermediaire); deplacementAutre(i,depart...
3
public void dailyBonus(Player player) { switch (this) { case GOLD_MINE: player.addResource(ResourceType.GOLD, 1000); break; case ORE_MINE: player.addResource(ResourceType.ORE, 1); break; case WOOD_MINE: player.addResource(ResourceType.WOOD, 2); break; default: } }
3
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
6
GenericGFPoly addOrSubtract(GenericGFPoly other) { if (!field.equals(other.field)) { throw new IllegalArgumentException("GenericGFPolys do not have same GenericGF field"); } if (isZero()) { return other; } if (other.isZero()) { return this; } int[] smallerCoefficients = th...
5
private void replaceNodeInParent(FineNode<T> curr, FineNode<T> _new) { if (curr.getParent() != null) { if (curr == curr.getParent().getLeft()) { curr.getParent().setLeft(_new); } else { curr.getParent().setRight(_new); } } else { if (_new == null) { root.setValue(null); } else { root ...
5
public static void invokePlugin(final String pluginName, final PluginRef plugin, final List<Variable> variables) { try { if (pluginMethods.get(pluginName) == null) { throw new AzotException("Plugin '" + pluginName + "' not found."); } final List<Variable> inheritedVariables = new ArrayList<Variable>(...
8
public void JoinGame(InetAddress adr) { Player player = new Player(); if(player.connect(adr)){ StartGame(player); } else { JOptionPane.showMessageDialog(null, "Could not connect to: "+adr, "IP conflict", WIDTH); try{ player.disconnect(); ...
2
static byte DispenserFix(byte data, String kierunek) { if (kierunek.equals("right")) { if (data == 2) { return 5; } if (data == 4) { return 2; } if (data == 5) { return 3; } if (data == 3) { return 4; } } e...
9
private void paivitaPeli(){ RuutuTyyli tormays = paivitaMato(); if(tormays == RuutuTyyli.Hedelma){ hedelmatSyoty++; pisteet += seuraavanHedelmanPisteet; uusiHedelma(); } if(tormays == RuutuTyyli.Hedelma && (hedelmatSyoty % 5) == 0){ ...
9
public int candy(int[] ratings) { if (ratings == null || ratings.length == 0) return 0; int[] A = new int[ratings.length]; A[0] = 1; for (int i = 1; i < ratings.length; i++) { if (ratings[i] > ratings[i - 1]) A[i] = A[i - 1] + 1; else A[i] = 1; } for (int i = ratings.length - 2; i >= 0; i--...
7
public void serialEvent(SerialPortEvent event) { String finalString = ""; if(event.getEventType() == SerialPortEvent.DATA_AVAILABLE) { sleep(100); try { byte[] readBuffer = new byte[40]; while(inputStream.available() > 0) { inp...
7
@Override public void run() { try { while(!closed) { if (run) { this.sleep(1000); while (run) { time.setSeconds(time.getSeconds() - 1); notifyListeners(); this.sleep(10...
4
private JSONWriter append(String string) throws JSONException { if (string == null) { throw new JSONException("Null pointer"); } if (this.mode == 'o' || this.mode == 'a') { try { if (this.comma && this.mode == 'a') { this.writer.write('...
7
public static void main(String[] args) throws IOException { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Ariyalur"); XStream xStream = new XStream(); xStream.alias("office", Office.class); xStream.alias("offices", Offices.class); xStream.addImplicitCollection(Offices.c...
9
public static int getOptimizationByDirect01(int[] vs, int[] ws, int[] nums, int c){ int length = 0; for(int num : nums){ length += num; } int[] vs1 = new int[length]; int[] ws1 = new int[length]; int index = 0; for(int i=0; i<vs.length; i++){ ...
7
public static String getFileExtension(File f) { String filename=f.getName(); return (filename.lastIndexOf(".")==-1)?"": filename.substring(filename.lastIndexOf(".")+1,filename.length()) .toLowerCase(); }
1
private static boolean saveOpenDocumentList() { // Harvest Data to save and close each document ArrayList openFileList = new ArrayList(); Iterator it = Outliner.documents.getDefaultOpenDocumentIterator(); while (it.hasNext()) { OutlinerDocument doc = (OutlinerDocument) it.next(); if (OutlinerWindowMon...
4
public int findLargestSumPair(int[] nums) { if (nums.length == 0) return 0; if (nums.length == 1) return nums[0]; int first = Integer.MIN_VALUE, second = Integer.MIN_VALUE; for (int i=0; i<nums.length; i++) { int t = nums[i]; if (t >= firs...
6
public void juagadaMin(int dato) { Nodo busqueda = this.reducirArbol(dato); if(busqueda != null) { if(busqueda.getAcumulado() <= MiniMax.getLimit() - 1) { if(busqueda.getAcumulado() < this.acumuladoMaximo) { ...
9
void attackPlaceVerticallyBelow(int position, char[] boardElements, int dimension, int numberOfLinesBelow) { while (numberOfLinesBelow > 0) { if (isPossibleToPlaceOnNextLine(boardElements, elementVerticallyBelow(dimension, position, numberOfLinesBelow)) && isBoardElementEmpty(boa...
3
@Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String command =e.getActionCommand(); if(command.equals("regame")) { clean(); gameRunning = false; freshMessage("遊戲進行中"); } ...
4
@Override @Deprecated public void mouseExited(MouseEvent event) { int radiusBase = AppliWindow.getInstance().getTilesSize(); int xM = event.getX(), yM = event.getY(); int distX = 0, distY = 0; for(Base b : Game.getInstance().getBaseManager().getBases()){ distX = (int) Math.abs(xM - b.getPosition().get...
3
public void setLeft(boolean left) { this.left = left; }
0
public static GroundItem getSpice() { return GroundItems.getNearest(new Filter<GroundItem>() { public boolean accept(GroundItem item) { if (item == null) return false; boolean valid = item.getId() >= 7480 && item.getId() <= 7495; return valid; } }); }
2
static Object create(Context cx, Class cl, Callable function) { if (!cl.isInterface()) throw new IllegalArgumentException(); Scriptable topScope = ScriptRuntime.getTopCallScope(cx); ClassCache cache = ClassCache.get(topScope); InterfaceAdapter adapter; adapter = (InterfaceAd...
8
public void updateGrid(final Modele plateau) { if (!plateau.getFin()) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateGrid(plateau); ...
2
private void drawElement(Integer i, Node currentNode, boolean isDeletedNode, Graphics2D g2d, int nextLeft, int numberNextLeft, int numberIncrementLeft, int dimensionTop, int numberTop) { // Drawing rectangle BasicStroke bs2 = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER); g2d.setStroke(bs2)...
4
protected static boolean reportError(final Electronics me, final Software controlI, final MOB mob, final String literalMessage, final String controlMessage) { if((mob!=null) && (mob.location()==CMLib.map().roomLocation(me)) && (literalMessage!=null)) mob.tell(literalMessage); if(controlMessage!=null) { if(...
7
private boolean isPositionOutOfFrame(LifePosition lifePosition) { return lifePosition.getPosition()[0] < 0 || lifePosition.getPosition()[1] < 0 || lifePosition.getPosition()[0] >(frame.height()-1) || lifePosition.getPosition()[1] > (frame.width()-1); }
3
private void keyEventProcess(final KeyEvent ke){ if( ke.isShiftDown() ){ final java.awt.Component comp = ke.getComponent(); switch( ke.getKeyCode() ){ case KeyEvent.VK_RIGHT: rotarFocus(true, comp); break; case KeyE...
8
private void jButton0MouseMouseClicked(MouseEvent event) { String sql = jTextField0.getText(); if(sql == null || "".equals(sql)){ jLabel1.setForeground(Color.red); }else{ jLabel1.setForeground(Color.black); } if (";".equals(sql.substring(sql.length()-1,sql.length()))){ System.out.printl...
3
public void load() throws IOException { URL url2 = new URL(url); int begin = url.lastIndexOf("/"); if (begin == -1) { System.out.println("index of url = -1"); return; } String name = url.substring(begin + 1, url.length()); Path path = Paths.get("im...
1
public static void updateInsuranceInfo(int studentID, String insName, String policyNum, String start, String end, float copayment){ try{ if(start == null || start.isEmpty()) start = "13-APR-2014"; if(end == null || end.isEmpty()) end = "15-APR-2016"; if(copayment == 0) copayment = 30; in...
7
public final void reset() { grass.clear(); wall.clear(); entities.clear(); step = 0; final int fieldWidth = Parameter.FIELD_WIDTH.getValue(); final int fieldHeight = Parameter.FIELD_HEIGHT.getValue(); final int fieldSize = fieldWidth * fieldHeight; /* pl...
3
public ButtonImageListener(final AbstractButton button, final ImageIcon idleImg, final ImageIcon hoverImg, final ImageIcon clickImg) { button.setContentAreaFilled(false); button.setBorder(BorderFactory.createEmptyBorder()); if (idleImg != null) { try { setIcon(button, idleImg); } catch (InvalidIconEx...
7
private int [] calcTilePattern (int numWindows) { // local vars int numColumns; int windowsAccountedFor; // no pattern for no windows if (numWindows < 1) { return null ; } // calculate pattern engine parameters int numRows = Math.round((float)Math.sqrt(numWindows)); boolean uneven = (numWindo...
4
public static void main(String[] args) { if (args.length != 2) { System.err.println("usage: java Converter srcfile dstfile"); return; } try { Media.convert(args[0], args[1]); } catch (InvalidMediaFormatException imfe) { System.out.println("Unable to convert " + args[0] + " to " + args[1]); S...
4
public static Simulator initSim( long initialTime ) { Room r0 = new Room(64, 64, 4, SimpleBlock.EMPTY_STACK); for( int y=r0.getHeight()-1; y>=0; --y ) for( int x=r0.getWidth()-1; x>=0; --x ) { r0.blockField.setStack(x, y, 0, SimpleBlock.GRASS.stack); } CellCursor c = new CellCursor(); CellCursor c1 = ...
8
public void visitFormalTypeParameter(final String name) { if (type == TYPE_SIGNATURE || (state != EMPTY && state != FORMAL && state != BOUND)) { throw new IllegalStateException(); } CheckMethodAdapter.checkIdentifier(name, "formal type parameter"); sta...
5
public ItemStack[] getArmorContents() { ItemStack[] stack = new ItemStack[Armor.length]; for (int i = 0; i < stack.length; i++) { if (Armor[i] != null) stack[i] = Armor[i].clone(); } return stack; }
2
public TCPClientBlockManagerDataReceive(Registry r, TCPClient c, ObjectOutputStream o, Object d, int sc, int cs, boolean asThread, boolean more) { registry = r; client = c; output = o; blockChunk = (short[][]) d; //blockChunkByteArray = (byte[]) d; currentStartCollumn = s...
1
private BufferedImage makeRGBABufferedImageFromImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage) image; } // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Determine if the ima...
9
@Override public void render(Graphics g) { for (Path3D p : line) p.render(g); for (Path3D p : cross) p.render(g); }
2
private AndroidEntryPointCreator createEntryPointCreator() { AndroidEntryPointCreator entryPointCreator = new AndroidEntryPointCreator (new ArrayList<String>(this.entrypoints)); Map<String, List<String>> callbackMethodSigs = new HashMap<String, List<String>>(); for (String className : this.callbackMethods.keyS...
2
public void characters(char[] buffer, int start, int length) throws SAXException { StringBuffer buf = new StringBuffer(); if (parentElement.equals(ROOT_ELEMENT)) { if (currentElement.equals("date")) { try { transactionSearchResult.setDate(DateParserUTC.pa...
7
public String toString(){ StringBuffer sb = new StringBuffer(); switch(type){ case TYPE_VALUE: sb.append("VALUE(").append(value).append(")"); break; case TYPE_LEFT_BRACE: sb.append("LEFT BRACE({)"); break; case TYPE_RIGHT_BRACE: sb.append("RIGHT BRACE(})"); break; case TYPE_LEFT_SQUARE: ...
8
private void addMenuItemToColumn(final TableColumn column, final int index) { // create menu item final MenuItem itemName = new MenuItem(tableHeaderMenu, SWT.CHECK, index); itemName.setText(column.getText()); itemName.setSelection(column.getResizable()); itemName.addListener(SWT.Selection, new Listen...
5
public static void fillLibraryBeanToModel(DefaultTableModel model, LibraryBean[] libraryBeans){ model.getDataVector().removeAllElements(); if(libraryBeans == null || libraryBeans.length == 0){ model.setColumnIdentifiers(new String[]{"Nothing was found"}); return; } model.setColumnIdentifiers(colum...
3
public Date calculateAlarmTime() { if(!enabled) { return new Date(0); } Calendar cal = new GregorianCalendar(); Date currentTime = new Date(); cal.setTime(currentTime); cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); cal...
4
private void update(int[] x, int bowlId, int round) { if (bowlIds.contains(bowlId+round*nplayer)==false) { info.add(x.clone()); bowlIds.add(bowlId+round*nplayer); } mu=0; for(int[] y:info){ mu+=score(y); } mu=mu/info.size(); sigma=0; scores.clear(); for(int[] y:info){ int s=score(y); si...
3
public boolean contains(Vector3 point) { Vector3 min = this.getMinimumPoint(); Vector3 max = this.getMaximumPoint(); return (point.x >= min.x && point.x <= max.x && point.y >= min.y && point.y <= max.y && point.z >= min.z && point.z <= max.z); }
5
public void update(Avatar player, Map map) { if (x != -1 && y != -1) { if (missile.canbeShoot()) { if (playerIsTargetable(player, map)) direcVect = new Point2D.Float(player.getX() - this.x, player.getY() - this.y); else direcVect = null; missile.shoot(direcVect); missile.setCanbe...
4
public int zigZag(int[] arr) { int n = arr.length; int[][] z = new int[n][2]; int maxZigZagCount = 0; for (int i = 0; i < n; i++) { z[i][0] = 1; z[i][1] = 1; } for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if((arr[i] - arr[j]) > 0){ z[i][0] = max(z[i][0] , (z[j][1] +...
5