text stringlengths 14 410k | label int32 0 9 |
|---|---|
private final void setBufferStrategy() {
try {
createBufferStrategy(2);
Thread.sleep(1000);
} catch (Exception e) {
logger.error(e, "Couldn't set buffer strategy");
Runtime.getRuntime().exit(0xDEADBEEF);
}
bufferStrategy = getBufferStrategy();
} | 1 |
protected String getExtension(String path) {
String extension = "";
int i = path.lastIndexOf('.');
if (i > 0) {
extension = path.substring(i+1);
}
return extension;
} | 1 |
@Override
public void caseAParaComando(AParaComando node)
{
inAParaComando(node);
if(node.getVar() != null)
{
node.getVar().apply(this);
}
if(node.getADe() != null)
{
node.getADe().apply(this);
}
if(node.getAAte() != null)
... | 4 |
public Node<T> getSuccessor(Node<T> node) {
if (node.getRight() != null) {
node = node.getRight();
while (node.getLeft() != null)
node = node.getLeft();
return node;
}
Node<T> temp = node.getParent();
while (temp != null && node == temp.getRight()) {
node = temp;
te... | 4 |
private int writeXrefSubSection(int beginIndex) throws IOException {
int beginObjNum = entries.get(beginIndex).getReference().getObjectNumber();
// Determine how many entries in this sub-section
int nextContiguous = beginObjNum + 1;
for(int i = beginIndex+1; i < entries.size(); i++) {
... | 4 |
public void saveAs() {
try {
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Windows BMP file", "bmp");
FileNameExtensionFilter filter2 = new FileNameExtensionFilter(
"JPEG file", "jpg", "jpeg");
FileNameExtensionFilter filter3 = new FileNameExtensionFilter(
"PNG", "png");
J... | 6 |
public static void main(String[] args) {
try { test1(); }
catch (ArithmeticException e) { e.printStackTrace(); }
StdOut.println("--------------------------------");
try { test2(); }
catch (ArithmeticExc... | 8 |
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
boolean isPalindrome = false;
int counter = 0;
int middle = input.length()/2;
for (int i=0; i<middle; i++){
int m = input.length();
if (input.charAt(i... | 3 |
public String getURLName() {
return "n!\"" + name.replace(" ", "+") + (set != null ? "\"%20e:" + set : "\"");
} | 1 |
public long getS() {
return initTemps[0];
} | 0 |
public Deck(){
super();
// Populate our deck
Card.CARD_SUIT[] arrSuits = Card.CARD_SUIT.values();
Card.FACE_VALUE[] arrFaces = Card.FACE_VALUE.values();
for(Card.CARD_SUIT s : arrSuits) {
for(Card.FACE_VALUE f : arrFaces) {
this.addCard(new Card(s, f));
}
}
} | 2 |
@SuppressWarnings({"unchecked"})
private void heapifyMax(int index) {
int left = getLeft(index);
int right = getRight(index);
int greatest;
if (left < size && comparator.compare((T) queue[left], (T) queue[index]) > 0) {
greatest = left;
} else {
grea... | 5 |
public boolean insertarProceso(Proceso p) {
int prioridad = p.getPrioridadDinamica();
boolean agrego = false;
if (this.listas[prioridad].indexOf(p) == -1) {
if (prioridad < this.menorPrioridadNoVacia) {
this.menorPrioridadNoVacia = prioridad;
}
... | 3 |
private static int initOriginal(final Display display, Composite inComposite) {
final Composite originalCompsite = new Composite(inComposite, SWT.BORDER);
int heightHint = 0;
try {
original = new Image(display, Resource.class.getResourceAsStream(IMAGE_PATH));
if (original.getImageData().depth != 8 && origi... | 3 |
public void dump() {
int i = 0;
while (i<hp) {
int len = heap[i];
System.out.print("Object at address " + (i - size)
+ ", length=" + len
+ ", data=[");
for (int j=1; j<=len; j++) {
System.out.print(Integer.toString(heap[i+j]));
if (... | 3 |
@Override
public synchronized void execute() throws IOException, RoutingException
{
try
{
/* Set the local node as already asked */
nodes.put(this.localNode.getNode(), ASKED);
/**
* We add all nodes here instead of the K-Closest because there may... | 4 |
private int[] parsePrefix() {
assert (peek() != null) : "parsePrefix() can't start at EOF";
int[] toReturn = {0, 0, 0};
// First, parse a digit, if we begin with one
Boolean quitNow = parseFirstDigit(toReturn);
if (quitNow == Boolean.TRUE){
return to... | 5 |
private void connectToNotchers()
{
//define and instantiate a worker thread to create the file
//----------------------------------------------------------------------
//class SwingWorker
//
workerThread = new SwingWorker<Void, String>() {
@Override
public Void doInBackground() {... | 3 |
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;
} | 7 |
private void goToMarket() {
switch(mSSN % 4) {
case 0:
mItemsDesired.put(EnumItemType.PIZZA, sBaseWanted);
break;
case 1:
mItemsDesired.put(EnumItemType.STEAK, sBaseWanted);
break;
case 2:
mItemsDesired.put(EnumItemType.CHICKEN, sBaseWanted);
break;
case 3:
mItemsDesired.put(E... | 7 |
public long getSalary() {
return salary;
} | 0 |
@EventHandler
public void EnderDragonFastDigging(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.getEnderDragonConfig().getDouble("... | 6 |
public void mapToKey(GameAction gameAction, int keyCode) {
keyActions[keyCode] = gameAction;
} | 0 |
public void setLayout(int layoutType){
switch (layoutType) {
case LookManager.GREEN_LAYOUT:
Dimension size = (getSize().height == 0 ? getPreferredSize() : getSize());
setIcon(new ImageIcon(imgLdr.scaleBufferedImage(imgLdr.loadBufferedImage(GUIImageLoader.GREEN_BUTTON_ACTIVE), size)));
setRolloverIcon(new I... | 2 |
public void dragSelectCard(CardView clickCardView , int distance) {
int startindex = cardViews.indexOf(clickCardView);
int endIndex = 0;
if (distance < 0) {
distance -= cardGap / 2;
}
int count = distance/cardGap;
boolean isModeZero = (distance % cardGap == 0);
if(count > 0) {
endIndex = startind... | 8 |
public void updateBundles(byte[] data) {
bundles.clear();
int dIndex = 0;
while (dIndex < data.length) {
int startIndex = dIndex+2;
byte bundleID = data[dIndex+1];
int endIndex = (int)data[dIndex] + dIndex;
long value = 0;
... | 2 |
public boolean ewify() throws IOException, FileNotFoundException{
FileReader input = new FileReader(this.source);
BufferedReader bufRead = new BufferedReader(input);
String myLine = null;
ArrayList<EweRule> arrayRules=new ArrayList<EweRule>();
int currentRule=0;
boolean flagThen=false;
boolean flagWhen... | 8 |
static void graph1(Metrics metrics, Main main){
Metrics.Graph graph = metrics.createGraph("action");
String ac = main.getConfig().getString("action");
if (ac.equalsIgnoreCase("warn")) {
graph.addPlotter(new SimplePlotter("Warn"));
} else if(ac.equalsIgnoreCase("kick")){
... | 4 |
public static void noSpace(String string) throws JSONException {
int i, length = string.length();
if (length == 0) {
throw new JSONException("Empty string.");
}
for (i = 0; i < length; i += 1) {
if (Character.isWhitespace(string.charAt(i))) {
throw... | 3 |
private void jRadioButtonXMLtoJSONActionPerformed(
final java.awt.event.ActionEvent evt) {
switch (etat) {
case INIT_JSON_XML:
etat = Etat.INIT_XML_JSON;
break;
case INIT_XML_JSON:
etat = Etat.INIT_XML_JSON;
break;
case OUTPUT_JSON_XML:
throw new RuntimeException("Bouton Convertir : "
+ "... | 7 |
public static void main( String[] args ) {
JFrame frame = new JFrame( "Graph" );
frame.setBounds( 20, 20, 800, 600 );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Graph graph = new Graph();
for( GraphItem item : createTestItems() ){
graph.addItem( item );
}
ConnectionableCapabilityHand... | 1 |
public void printATMs()
{
Set<Integer> keys = supportedATMs.keySet();
System.out.println("Bank " + bankID + " ATMs:");
for(Integer key: keys)
{
System.out.println(supportedATMs.get(key));
}
} | 1 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
public synchronized void transfer(int from, int to, double amount) throws InterruptedException
{
while (accounts[from] < amount)
wait();
System.out.print(Thread.currentThread());
accounts[from] -= amount;
System.out.printf(" %10.2f from %d to %d", amount, from, to);
accounts[to... | 1 |
@Override
protected void finalize() throws Throwable {
try {
close();
} catch (final IOException ex) {
LOGGER.warn("Problem trying to auto close file handles...", ex);
} finally {
super.finalize();
}
} | 1 |
public List<Integer> findSubstring2(String S, String[] L) {
List<Integer> res = new ArrayList<Integer>();
if(S == null || S.length() == 0 || L == null || L.length == 0) return res;
int L2 = S.length();
int l = L[0].length();
int L1 = L.length * l;
for(int i = 0; i <= L2 -... | 9 |
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
try{
//Se extraen todas las caciones
leer_archivo cancionesActualizadas=new leer_archivo(100);
String [] lista_p=cancio... | 5 |
int snake( int x, int y, FragList fl )
{
while ( x<fl.fragments.size()&&y<fragments.size() )
{
if ( fragments.get(y).equals(fl.fragments.get(x)) )
{
x++;
y++;
}
else
break;
}
return x;
... | 3 |
public int calculateRewardPoints() {
int points = 0;
for (int i = 0; i < purchases; i++) {
points = points + 100;
}
return points;
} | 1 |
public void putByte(byte newByte) {
byte[] ar = new byte[1];
ar[0] = newByte;
msg = new String(ar);
if (newByte == '<') {
// new Message Start detected
// reset Msg String and add Start-delimiter
//outmsg = msg;
receivingMessage = true;
} else if (newByte == '>' && receivingMessage == true) {
... | 5 |
@Test
public void sizeIsCorrect()
{
boolean test = true;
for (int i = 0; i < 10000; i++)
{
queue.clear();
Random rand = new Random();
int r = rand.nextInt(1000);
for (int j = 0; j < r; j++) queue.enqueue("allo");
int b = (r <= 0... | 5 |
public StartMenu(GameStateManager gsm) {
this.gsm = gsm;
try {
bg = new Background("/Background/Background.png", 1, false, 0);
bg.setVector(-0.1, 0);
titleColor = new Color(128, 0, 0);
titleFont = new Font("Maximilien", Font.PLAIN, 28);
maximilien = new Font("Maximilien", Font.PLAIN, 15);
} ca... | 1 |
public synchronized static void addTheaterSeats(TheaterSeats theSeats){
if(!seats.contains(theSeats)){
if(seats.size() < cacheLimit)
seats.add(theSeats);
else{
for(int i=0;i<(cacheLimit/10);i++)
seats.removeFirst(); //Removes the oldest seat in the list
seats.add(theSeats);
}
}
else{
... | 3 |
public static String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String string = Double.toString(d);
if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
... | 7 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
public JSONArray names() {
JSONArray ja = new JSONArray();
Iterator keys = this.keys();
while (keys.hasNext()) {
ja.put(keys.next());
}
return ja.length() == 0 ? null : ja;
} | 2 |
public void updateDamageListener(String resource, int damageToAdd) {
GameActor actor = actors.get(resource);
if(actor == null) {
createPrototype(resource);
actor = actors.get(resource);
}
WeaponsComponent wc = (WeaponsComponent)actor.getComponent("Weapons... | 1 |
public ConvexMultivariateRealFunction[] getResourcesConvexConditions(double alpha)
{
resourcesConvex = null; // нужный костыль
if(resourcesConvex == null)
{
double talpha = getT(alpha);
int mainSize = db.tools.size();
int rowSize = db.resources.size();
... | 6 |
void updateHash(byte[] input, int pos, int end) {
// WINDOW_MASK
int hPos = pos & 0x7FFF;
int val = this.val;
val = ((val << 5) ^ (pos + 2 < end ? input[pos + 2] & 0xFF : 0)) & 0x7FFF;
hashVal[hPos] = val;
int tmp = head[val];
prev[hPos] = (tmp != -1 && hashVal[... | 8 |
public static void listPortals( BSPlayer p ) {
for ( ServerInfo s : portals.keySet() ) {
String message = "";
message += ChatColor.GOLD + s.getName() + ": " + ChatColor.RESET;
ArrayList<Portal> list = portals.get( s );
for ( Portal portal : list ) {
... | 2 |
public Point2D[] points() {
return (Point2D[]) verticesToPoints.values().toArray(new Point2D[0]);
} | 0 |
private void fileUpload(final DataPacket<AFile> dp, Object[] args){
/*
* Get some information out of data packet
*/
AFile recvAfile = dp.getContent();
byte[] filecontent = recvAfile.getFile();
Log fileLog = dp.getLog();
byte[] logToByte = recvAfile.getEditInfo().getBytes();
PublicKey c... | 8 |
private Integer findNext(String date, TreeSet<Integer> dates) {
int givenDate = Integer.parseInt(date.split("/")[0] + date.split("/")[1]);
for (Integer integer : dates) {
if (integer == givenDate || integer > givenDate)
return integer;
}
return 0;
} | 3 |
private void generateOpenAndClosedLists() {
/*load intial starting cell into the open list*/
for (int i = 0; i < localMap.size(); i++) {
if (localMap.get(i).locX == sX && localMap.get(i).locY == sY) {
openList.add(generateNewCell(localMap.get(i), new Cell(localMap.get(i), sX, sY, 0, 0)... | 8 |
private int countEmptyNeighbor(char colorPiece) {
int cnt = 0;
int[] nIndex = new int[TOTALPOS];
for (int t = 0; t < TOTALPOS; t++) {
nIndex[t] = TOTALPOS;
}
for (int i = 0; i < position.length; i++) {
MorrisIntersection pos = position[i];
if (pos.getLetter() == colorPiece) {
List<MorrisIntersect... | 8 |
private void recalcLevel() {
hasGainedLevels = levelOfTower.recalculateLevel();
if (hasGainedLevels != 0) {
for ( GameAction action : getGameActions()) {
if (action.getAttackData() != null) { // getAttackData() returns null if the gameAction does not have an attack.
... | 3 |
@Override
public Response list() throws IOException
{
if(username.equals(""))
{
return new MessageResponse("Please log in first.");
}
else
{
synchronized(serverIdentifier)
{
if(serverIdentifier.isEmpty())
{
return new MessageResponse("No files available");
}
else
{
Set... | 9 |
private void spawnBox(int size, int xStart, int yStart){
size = size + 2;
for (int i = 0; i < size; i++){
for (int j = 0; j < size; j++){
if (i == 0 || i == size - 1 || j == 0 || j == size - 1){
Boot.getWorldObj().getTileAtCoords(xStart + i, yStart + j).setTileID(TileID.ASPHALT);
}
}
}
} | 6 |
@Override
public List<V_Ficha_Trab_Num_C> Buscar_Ficha_Trabajador(String iddep, String dni, String nom, String ape_p, String ape_m) {
this.conn = FactoryConnectionDB.open(FactoryConnectionDB.ORACLE);
String sql = "select d.*,RHFU_VIG_CON (d.id_trabajador) as VI_CONTRATO from (select * from RHVD_TRAB... | 8 |
public static String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String string = Double.toString(d);
if (string.indexOf('.') > 0 && string.indexOf('e') < 0
... | 7 |
public char[] readFile(String filename)
{
char[] content = null;
File file = new File(filename); //for ex foo.txt
FileReader reader = null;
try {
reader = new FileReader(file);
char[] chars = new char[(int) file.length()];
reader.read(chars);
//content = ne... | 3 |
@Override
public void windowClosing(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
this.setVisible(false);
this.dispose();
}
} | 1 |
private Map<String, String> getProperties() {
Map<String, String> properties = new HashMap<String, String>();
String line;
try {
while ((line = bundle.readLine()) != null) {
boolean isComment = line.trim().length() < 1 && line.trim().startsWith("#");
i... | 5 |
public static ByteArrayInputStream readStreamToMemory(InputStream inputStream) throws IOException {
if (inputStream instanceof ByteArrayInputStream) {
inputStream.reset();
return (ByteArrayInputStream) inputStream;
}
try {
ByteArrayOutputStream outputStream = ... | 1 |
public boolean canEncode(Serializable structure) {
return false; // Serialization is deprecated as a saving method.
} | 0 |
public static void processCollision(RigidBody rigidBody1, Vector3d point1,
RigidBody rigidBody2, Vector3d point2, Vector3d relativeVelocity,
Vector3d normal, Matrix3d k, double restitution, double timeStep) {
Vector3d impulse = new Vector3d();
// Coefficient of friction
double friction = Math.max(rigidBody... | 5 |
public static void main(String[] args) {
System.out.println("hello Hyun Kyu");
} | 0 |
int writeJavaAnnotations(List<Attribute.Compound> attrs) {
if (attrs.isEmpty()) return 0;
ListBuffer<Attribute.Compound> visibles = new ListBuffer<Attribute.Compound>();
ListBuffer<Attribute.Compound> invisibles = new ListBuffer<Attribute.Compound>();
for (Attribute.Compound a : attrs) {... | 9 |
public void setDAO(String daoLine) {
if (daoLine.equals("Mock")) {
dao = new MockDAO();
}
else if (daoLine.equals("MySQL")) {
dao = new MySQLDAO();
}
} | 2 |
@Override
public void actionPerformed(ActionEvent event) {
/* Redo listenner */
if (event.getSource().equals(redo)) {
points = drawPanel.getPoints();
for (Point point : pointstoAddorRemove) {
points.add(point);
}
drawPanel.setPoints(points);
drawPanel.paintComponent(drawPanel.getNextGraphics());... | 7 |
public void insertIntoGraph(mxICell cell)
{
mxICell parent = cell.getParent();
mxICell source = cell.getTerminal(true);
mxICell target = cell.getTerminal(false);
// Fixes possible inconsistencies during insert into graph
cell.setTerminal(null, false);
cell.setTerminal(null, true);
cell.setParent(null);
... | 3 |
@Override
public int getPixel(int x, int y)
{
int bx = x / 8;
int by = y / 8;
int offs = bx + by * (width / 8) - tileOffset;
if (offs < 0)
return 0;
offs *= 64;
offs += x % 8 + 8 * (y % 8);
if (offs < 0)
return 0;
if (offs ... | 3 |
public InputStream getInputStream() throws java.io.IOException{
if (inputStream==null) {
setInputStream(socket.getInputStream());
}
return inputStream;
} | 1 |
@Override
public void logicUpdate(GameTime gameTime) {
// Decrease the timer by the current game time in milliseconds
countDownTimer.decreaseTimer(gameTime.getElapsedTimeMilli());
// If our timer is now over, time to call our timeOver method. The class
// that instantiates this will have to provide that metho... | 3 |
public String cypher(String input) throws UnsupportedEncodingException {
try {
MessageDigest md = MessageDigest.getInstance("MD5"); //MD5 is the only allowed algorithm.
String intermediate = new String(md.digest(input.getBytes("UTF-8"))); // don't do UTF-16
String output = new String();
//iterat... | 5 |
private static String formatMessage(String msg, String p, boolean b) {
String message = (b ? (PARAGRAPH + "9[SkyDregg] ") : "") + PARAGRAPH + p;
Pattern pattern = Pattern.compile("(?<NUMBER>[ ][0-9]+)|(?<WHITESPACE>[ \f\t\r\n])|(?<WORD>[^ ]+)");
Matcher matcher = pattern.matcher(msg);
while (matcher.find()) {
... | 7 |
@EventHandler
public void ZombieRegeneration(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.getZombieConfig().getDouble("Zombie.Re... | 6 |
private void encrypt(String pass) {
try {
byte[] utf8 = pass.getBytes("UTF8");
byte[] enc = this.encrypter.doFinal(utf8);
this.setEncryptedPass(Base64.encode(enc));
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (UnsupportedEncodingException e) {
}
} | 3 |
@Test
public void tiedostonMuokkaaminenToimii() {
kasittelija.setFile(tiedosto);
kasittelija.tallennaTiedostoon("testi1\ttesti2\ttesti3\ttesti4\ttesti5");
String a = "";
ArrayList<String[]> lista = new ArrayList<>();
lista.add(new String[]{"testi1", "testi2", "testi3", "testi... | 1 |
public void train(){
int sinceBelowMin = 0;
Player[] players = new Player[]{
new PlayerComputer(this),
new PlayerComputer(new ModelRandom())
};
while (sinceBelowMin < 50)
{
Game g = Game.create(players, 5, 1, false);
g.play(new Random().nextInt(players.length));
sinceBelowMin = rl.gamesSinceBel... | 1 |
public static void write() { //writes the file back out if it's been modified
if(file == null) {
JOptionPane.showMessageDialog(null,
"Read-only file was imported. Can not write.",
"Read-Only file", JOptionPane.INFORMATION_MESSAGE);
return;
}
try {
fWriter = new PrintWriter(file, "UTF-8");
wr... | 3 |
public static ListNode partition(ListNode head, int x) {
ListNode f = null;
ListNode s = null;
ListNode p = null, q = null;
ListNode h = head;
ListNode e = h;
while (null != h) {
if (h.val < x) {
if (null == f) f = h;
if (null == p) p = h;
else {
p.next = h;
p = p.next;
}
} e... | 8 |
@SuppressWarnings("rawtypes")
public final static Pedidos jsonToPedidos(String json) throws ParseException {
Pedidos ped= new Pedidos();
JSONParser parser = new JSONParser();
ContainerFactory containerFactory = new ContainerFactory() {
public List<String> creatArrayContainer() {
return new LinkedList<Stri... | 9 |
@Override
public List<Produto> searchProducts(String category, String price) {
try {
String query = "";
if (!category.equals("")) {
query = "where categoria like '%" + category + "%'";
}
if (!price.equals("") && price.equals("max")) {
... | 5 |
public static boolean isRequired(Parameter parameter)
{
boolean angleBrackets;
Requirement requirement = parameter.getProperty(Properties.REQUIREMENT);
requirement = requirement == null ? DEFAULT : requirement;
switch (requirement)
{
case REQUIRED:
... | 4 |
public BoxSelectionCapability( DefaultBox<?> box ) {
this.box = box;
} | 1 |
public void actionPerformed(ActionEvent e) {
if (e.getSource() == mntmExportar) {
do_mntmExportar_actionPerformed(e);
}
if (e.getSource() == mntmSair) {
do_mntmSair_actionPerformed(e);
}
if (e.getSource() == btnCalcularSubrede) {
do_btnCalcularSubrede_actionPerformed(e);
}
if (e.getSource() == bt... | 5 |
public void testEquipBravesNotEnoughReqGoods() {
Game game = ServerTestHelper.startServerGame(getTestMap());
AIMain aiMain = ServerTestHelper.getServer().getAIMain();
FreeColTestCase.IndianSettlementBuilder builder
= new FreeColTestCase.IndianSettlementBuilder(game);
IndianS... | 6 |
@Override
protected Rectangle[] createHandles()
{
p = createPoints(state);
Rectangle[] h = new Rectangle[4];
mxPoint p0 = state.getAbsolutePoint(0);
mxPoint pe = state.getAbsolutePoint(state.getAbsolutePointCount() - 1);
h[0] = createHandle(p0.getPoint());
h[2] = createHandle(pe.getPoint());
// Creat... | 4 |
public void clearCircle(int cx, int cy, int radius) {
int ci = getI(cx);
int cj = getJ(cy);
int iradius = getI(radius);
for (int i = ci - iradius; i < ci + iradius; i++) {
for (int j = cj - iradius; j < cj + iradius; j++) {
if (i < 0 || j < 0 || i >= voxels.length
|| j >= voxels[0].length)
co... | 9 |
public void addMessage(CheckResultMessage message) {
if (message == null || message.getMessage().trim().isEmpty()) {
return;
}
if (message.getType() == CheckResultMessage.SYSTEM) {
addSystemMessage(message.getMessage());
} else if (message.getType() == CheckResultMessage.CHECK_OK) {
this.addOkMessage(... | 6 |
public RandomListNode copyRandomList(RandomListNode head) {
if(head == null )
return head;
//copy and linked.
RandomListNode prev;
RandomListNode head2;
for(prev = head;prev != null;prev = prev.next.next){
//copy a node
RandomListNode t = new RandomListNode(prev.label);
t.next = prev.next;
//l... | 8 |
private static String getPortImageFile(PortType portType)
{
switch (portType)
{
case WOOD:
return "images/ports/port_wood.png";
case BRICK:
return "images/ports/port_brick.png";
case SHEEP:
return "images/ports/port_sheep.png";
case WHEAT:
return "images/ports/port_wheat.png";
cas... | 6 |
private void creatTPoly(){
double xO = (this.getWidth()/2. - (10.5*l)/2.);
double yO = (this.getHeight()/2. - (7*l*Math.sqrt(3))/2.);
int k = 4,alignD =1;
int num=0;
for(int i=0;i<7;i++){
if(i>3){alignD=i -3;}
else{alignD=0;}
for(int j=0;j<k;j++){
int xA=(int)((j * 3./2. * l )+ l + alignD * 3./2.... | 9 |
public boolean validateStr(String s) {
char[] tempCharArray = s.toCharArray();
boolean check = false;
if (s.equals("")) {
// if the user does not input anything: return false
return false;
} else {
// for loop cycles through each position of the char array to check
// if there are any characters
... | 9 |
@SuppressWarnings("unchecked")
public TypeComboBox(JFrame frame, EnterTyped fn) {
setEditable(true);
setModel(new MyFilterComboBoxModel(ComboElemPersistence.getComboData()));
setPreferredSize(new java.awt.Dimension(100, 21));
getEditor().getEditorComponent().addKeyListener(new KeyAdapte... | 6 |
public void dump(String prefix) {
System.out.println(toString(prefix));
if (children != null) {
for (int i = 0; i < children.length; ++i) {
SimpleNode n = (SimpleNode)children[i];
if (n != null) {
n.dump(prefix + " ");
}
}
}
} | 3 |
@Override
public Long countAll() throws Exception {
try {
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
//Query q = session.getNamedQuery("count.all");
Query q = session.getNamedQuery(getNamedQueryToCountAll());
... | 1 |
public BaiduPhotoSpider(String startSite, String dirPath, Cobweb cobweb, int maxDepth) throws Exception {
super(startSite, dirPath, cobweb, maxDepth);
} | 0 |
public JSONObject increment(String key) throws JSONException {
Object value = this.opt(key);
if (value == null) {
this.put(key, 1);
} else if (value instanceof Integer) {
this.put(key, (Integer) value + 1);
} else if (value instanceof Long) {
this.put(... | 5 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.