text stringlengths 14 410k | label int32 0 9 |
|---|---|
public void setTextCursorsBlank() {
for(slideMediaObject object: mediaObjects){
if(object.getStartTime() <= count){
if(object.isText()){
JPanel textPanel = (JPanel)object.getComponent(0);
textPanel.getComponent(0).setCursor(GUI.blankCursor);
}
}
}
} | 3 |
protected void interrupt() {
logger.info(Thread.currentThread().getName() + " is interrupted");
if (!Thread.currentThread().isInterrupted()) {
Thread.currentThread().interrupt();
}
ThreadGroup root = Thread.currentThread().getThreadGroup();
Thread[] thds = new Thread[root.activeCount()];
int nthds = root.enumerate(thds);
for (int i = 0; i < nthds; i++) {
if (!thds[i].isInterrupted()) {
logger.info(thds[i].getName() + " is interrupted");
thds[i].interrupt();
}
}
} | 3 |
@EventHandler
public void CaveSpiderResistance(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.getCaveSpiderConfig().getDouble("CaveSpider.Resistance.DodgeChance") / 100;
final double ChanceOfHappening = random.nextDouble();
if (ChanceOfHappening >= randomChance) {
dodged = true;
}
if (plugin.getCaveSpiderConfig().getBoolean("CaveSpider.Resistance.Enabled", true) && damager instanceof CaveSpider && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) {
Player player = (Player) e;
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, plugin.getCaveSpiderConfig().getInt("CaveSpider.Resistance.Time"), plugin.getCaveSpiderConfig().getInt("CaveSpider.Resistance.Power")));
}
} | 6 |
public void registerScore(Object[] args)
{
int score = (Integer)args[0];
int level = (Integer)args[1];
String name = (String)JOptionPane.showInputDialog(
null,
"Please enter your name for the highscore list:",
"High score",
JOptionPane.INFORMATION_MESSAGE,
null,
null,
"");
if(name != null)
{
try
{
URLConnection hscoreConn = getHighScoreConnection(score, level, name);
if(hscoreConn != null)
{
hscoreConn.connect();
showHighScoreList(hscoreConn);
}
}
catch(IOException e)
{
System.err.println("Breakout: Could not connect to the highscore service");
e.printStackTrace();
}
}
} | 3 |
public DFAEqualityAction(FiniteStateAutomaton automaton,
Environment environment) {
super("Compare Equivalence", null);
this.environment = environment;
/*
* putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke (KeyEvent.VK_R,
* MAIN_MENU_MASK+InputEvent.SHIFT_MASK));
*/
} | 0 |
private String getLanguage(HashMap<String, Object> map) {
@SuppressWarnings("unchecked")
ArrayList<String> langs = (ArrayList<String>) map.get("primaryLanguages");
if (langs == null || langs.isEmpty()) return null;
if (langs.size() > 1)
System.err.println("Multiple primary languages " + map);
return langs.get(0);
} | 3 |
private Time getTimeFromFields() {
int activityId = getSelectedActivity().getIdActivity();
Calendar startTimeCal = getStartTimeFromFields();
Calendar endTimeCal = getEndTimeFromFields();
Timestamp startTime = null;
Timestamp endTime = null;
long duration = -1;
if (startTimeCal != null) {
startTime = new Timestamp(startTimeCal.getTimeInMillis());
}
if (endTimeCal != null) {
endTime = new Timestamp(endTimeCal.getTimeInMillis());
}
if (startTime != null && endTime != null) {
duration = Controller.calculateDuration(startTimeCal, endTimeCal);
}
String description = txaDescription.getText();
return new Time(activityId, startTime, endTime, duration, description);
} | 4 |
private static Vertex getNext(List<Vertex> vertices, Vertex already)
{
List<Vertex> possi = new ArrayList<Vertex>(vertices.size());
for (int i = 0; i < vertices.size(); i++) {
if ((vertices.get(i).getPathsCount() == 0 || vertices.get(i).getPathsCount()%2 != 0) && already.getId() != vertices.get(i).getId() && !already.getPaths().contains(new Path(already.getId(), vertices.get(i).getId())))
possi.add(vertices.get(i));
}
if(possi.size() != 0)
{
return possi.get(new java.util.Random().nextInt(possi.size()));
}
for (int i = 0; i < vertices.size(); i++) {
if (already.getId() != vertices.get(i).getId() && !already.getPaths().contains(new Path(already.getId(), vertices.get(i).getId())))
return vertices.get(i);
}
return null;
} | 9 |
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
Consultar_Label = new javax.swing.JLabel();
TabbedPane = new javax.swing.JTabbedPane();
Equipa_Panel = new javax.swing.JPanel();
SelecionarEquipa_Panel = new javax.swing.JPanel();
Escola_ComboBox = new javax.swing.JComboBox();
Escola_Label = new javax.swing.JLabel();
Escalao_Label = new javax.swing.JLabel();
Escalao_ComboBox = new javax.swing.JComboBox();
Equipa_ComboBox = new javax.swing.JComboBox();
Equipa_Label = new javax.swing.JLabel();
DadosJogadores_Table = new javax.swing.JScrollPane();
Jogadores_Table = new javax.swing.JTable();
Procurar_Button = new javax.swing.JButton();
Campeonato_Panel = new javax.swing.JPanel();
Escalao_Label2 = new javax.swing.JLabel();
Jornada_Label2 = new javax.swing.JLabel();
Jornada_ComboBox2 = new javax.swing.JComboBox();
Escalao_ComboBox2 = new javax.swing.JComboBox();
jScrollPane1 = new javax.swing.JScrollPane();
Classificaçao_Table2 = new javax.swing.JTable();
Classificaçao_Label2 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
MelhoresMarcadores_Table = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
Jornadas_Table = new javax.swing.JTable();
procura = new javax.swing.JButton();
Torneio_Panel = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
Escalao_ComboBox3 = new javax.swing.JComboBox();
jLabel3 = new javax.swing.JLabel();
Torneio_ComboBox = new javax.swing.JComboBox();
ConsultarTorneio_Button = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
MelhoresMarcadores_Table1 = new javax.swing.JTable();
VoltarMenuPrincipal_Panel = new javax.swing.JPanel();
VoltarMenuPrincipal_Button = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Associação de Escolas de Futebol - Época 13/14");
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
Consultar_Label.setFont(new java.awt.Font("Trebuchet MS", 0, 20)); // NOI18N
Consultar_Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
Consultar_Label.setText("Consultar:");
TabbedPane.setFont(new java.awt.Font("Trebuchet MS", 0, 12)); // NOI18N
SelecionarEquipa_Panel.setBorder(javax.swing.BorderFactory.createTitledBorder("Selecionar Equipa"));
Escola_ComboBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
Escola_ComboBoxItemStateChanged(evt);
}
});
Escola_Label.setText("Escola:");
Escalao_Label.setText("Escalão:");
Escalao_ComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PreEscolaA", "PreEscolaB", "MinisA", "MinisB", "EscolaA", "EscolaB", "InfantisA", "InfantisB", "IniciadosA", "IniciadosB" }));
Escalao_ComboBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
Escalao_ComboBoxItemStateChanged(evt);
}
});
Equipa_ComboBox.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseExited(java.awt.event.MouseEvent evt) {
Equipa_ComboBoxMouseExited(evt);
}
});
Equipa_Label.setText("Equipa:");
javax.swing.GroupLayout SelecionarEquipa_PanelLayout = new javax.swing.GroupLayout(SelecionarEquipa_Panel);
SelecionarEquipa_Panel.setLayout(SelecionarEquipa_PanelLayout);
SelecionarEquipa_PanelLayout.setHorizontalGroup(
SelecionarEquipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(SelecionarEquipa_PanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(SelecionarEquipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Escola_Label)
.addComponent(Escalao_Label, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(Equipa_Label))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(SelecionarEquipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(Escalao_ComboBox, 0, 182, Short.MAX_VALUE)
.addComponent(Escola_ComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Equipa_ComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
SelecionarEquipa_PanelLayout.setVerticalGroup(
SelecionarEquipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(SelecionarEquipa_PanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(SelecionarEquipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Escola_Label)
.addComponent(Escola_ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(SelecionarEquipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Escalao_Label)
.addComponent(Escalao_ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(SelecionarEquipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Equipa_Label)
.addComponent(Equipa_ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
Jogadores_Table.setAutoCreateRowSorter(true);
Jogadores_Table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null},
{null, null}
},
new String [] {
"Jogador", "Ano"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
Jogadores_Table.getTableHeader().setReorderingAllowed(false);
DadosJogadores_Table.setViewportView(Jogadores_Table);
Procurar_Button.setText("Procurar");
Procurar_Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Procurar_ButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout Equipa_PanelLayout = new javax.swing.GroupLayout(Equipa_Panel);
Equipa_Panel.setLayout(Equipa_PanelLayout);
Equipa_PanelLayout.setHorizontalGroup(
Equipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Equipa_PanelLayout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(Equipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(DadosJogadores_Table, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 704, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Equipa_PanelLayout.createSequentialGroup()
.addComponent(SelecionarEquipa_Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Procurar_Button, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(25, 25, 25))
);
Equipa_PanelLayout.setVerticalGroup(
Equipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Equipa_PanelLayout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(Equipa_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(SelecionarEquipa_Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Procurar_Button, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(DadosJogadores_Table, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
.addContainerGap())
);
TabbedPane.addTab("Equipa", Equipa_Panel);
Escalao_Label2.setText("Escalão:");
Jornada_Label2.setText("Jornada:");
Jornada_ComboBox2.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
Jornada_ComboBox2ItemStateChanged(evt);
}
});
Escalao_ComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PreEscolaA", "PreEscolaB", "EscolaA", "EscolaB", "InfantisA", "InfantisB", "IniciadosA", "IniciadosB", "MinisA", "MinisB" }));
Escalao_ComboBox2.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
Escalao_ComboBox2ItemStateChanged(evt);
}
});
Escalao_ComboBox2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Escalao_ComboBox2ActionPerformed(evt);
}
});
Classificaçao_Table2.setAutoCreateRowSorter(true);
Classificaçao_Table2.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null}
},
new String [] {
"Equipa", "Golos", "Pontos"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class
};
boolean[] canEdit = new boolean [] {
false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
Classificaçao_Table2.setFillsViewportHeight(true);
Classificaçao_Table2.getTableHeader().setReorderingAllowed(false);
jScrollPane1.setViewportView(Classificaçao_Table2);
if (Classificaçao_Table2.getColumnModel().getColumnCount() > 0) {
Classificaçao_Table2.getColumnModel().getColumn(0).setPreferredWidth(100);
Classificaçao_Table2.getColumnModel().getColumn(1).setPreferredWidth(50);
}
Classificaçao_Label2.setText("Classificação:");
MelhoresMarcadores_Table.setAutoCreateRowSorter(true);
MelhoresMarcadores_Table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null}
},
new String [] {
"Jogador", "Equipa", "Golos"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.Integer.class
};
boolean[] canEdit = new boolean [] {
false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
MelhoresMarcadores_Table.setFillsViewportHeight(true);
MelhoresMarcadores_Table.getTableHeader().setReorderingAllowed(false);
jScrollPane2.setViewportView(MelhoresMarcadores_Table);
if (MelhoresMarcadores_Table.getColumnModel().getColumnCount() > 0) {
MelhoresMarcadores_Table.getColumnModel().getColumn(0).setPreferredWidth(100);
MelhoresMarcadores_Table.getColumnModel().getColumn(2).setPreferredWidth(50);
}
jLabel1.setText("Melhores Marcadores:");
Jornadas_Table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null}
},
new String [] {
"Equipa Casa", "vs", "Equipa Fora"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
Jornadas_Table.setFillsViewportHeight(true);
Jornadas_Table.setFocusable(false);
Jornadas_Table.setShowVerticalLines(false);
Jornadas_Table.getTableHeader().setReorderingAllowed(false);
jScrollPane3.setViewportView(Jornadas_Table);
if (Jornadas_Table.getColumnModel().getColumnCount() > 0) {
Jornadas_Table.getColumnModel().getColumn(0).setResizable(false);
Jornadas_Table.getColumnModel().getColumn(0).setPreferredWidth(100);
Jornadas_Table.getColumnModel().getColumn(1).setResizable(false);
Jornadas_Table.getColumnModel().getColumn(1).setPreferredWidth(50);
Jornadas_Table.getColumnModel().getColumn(2).setResizable(false);
Jornadas_Table.getColumnModel().getColumn(2).setPreferredWidth(100);
}
procura.setText("Procurar");
procura.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
procuraActionPerformed(evt);
}
});
javax.swing.GroupLayout Campeonato_PanelLayout = new javax.swing.GroupLayout(Campeonato_Panel);
Campeonato_Panel.setLayout(Campeonato_PanelLayout);
Campeonato_PanelLayout.setHorizontalGroup(
Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Campeonato_PanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Campeonato_PanelLayout.createSequentialGroup()
.addComponent(Classificaçao_Label2)
.addGap(154, 154, 154))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Campeonato_PanelLayout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addGroup(Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(Campeonato_PanelLayout.createSequentialGroup()
.addComponent(Jornada_Label2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Jornada_ComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(113, 113, 113)))
.addGap(20, 20, 20))
.addGroup(Campeonato_PanelLayout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(Escalao_Label2)
.addGap(7, 7, 7)
.addComponent(Escalao_ComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(procura)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
Campeonato_PanelLayout.setVerticalGroup(
Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Campeonato_PanelLayout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Escalao_ComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Escalao_Label2)
.addComponent(procura))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Classificaçao_Label2)
.addComponent(jLabel1)
.addComponent(Jornada_Label2)
.addComponent(Jornada_ComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(Campeonato_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addContainerGap())
);
TabbedPane.addTab("Campeonato", Campeonato_Panel);
jLabel2.setText("Escalão:");
Escalao_ComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PreEscolaA", "PreEscolaB", "MinisA", "MinisB", "EscolaA", "EscolaB", "InfantisA", "InfantisB", "IniciadosA", "IniciadosB" }));
Escalao_ComboBox3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Escalao_ComboBox3ActionPerformed(evt);
}
});
jLabel3.setText("Torneio:");
Torneio_ComboBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
Torneio_ComboBoxItemStateChanged(evt);
}
});
ConsultarTorneio_Button.setText("Consultar Tabela do Torneio");
ConsultarTorneio_Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ConsultarTorneio_ButtonActionPerformed(evt);
}
});
jLabel4.setText("Melhores Marcadores:");
MelhoresMarcadores_Table1.setAutoCreateRowSorter(true);
MelhoresMarcadores_Table1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null},
{null, null, null}
},
new String [] {
"Jogador", "Equipa", "Golos"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.Integer.class
};
boolean[] canEdit = new boolean [] {
false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
MelhoresMarcadores_Table1.setFillsViewportHeight(true);
MelhoresMarcadores_Table1.getTableHeader().setReorderingAllowed(false);
jScrollPane4.setViewportView(MelhoresMarcadores_Table1);
if (MelhoresMarcadores_Table1.getColumnModel().getColumnCount() > 0) {
MelhoresMarcadores_Table1.getColumnModel().getColumn(0).setPreferredWidth(100);
MelhoresMarcadores_Table1.getColumnModel().getColumn(2).setPreferredWidth(50);
}
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGap(39, 39, 39))
);
javax.swing.GroupLayout Torneio_PanelLayout = new javax.swing.GroupLayout(Torneio_Panel);
Torneio_Panel.setLayout(Torneio_PanelLayout);
Torneio_PanelLayout.setHorizontalGroup(
Torneio_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Torneio_PanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(Torneio_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(Torneio_PanelLayout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Escalao_ComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(Torneio_PanelLayout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(Torneio_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Torneio_ComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ConsultarTorneio_Button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGap(56, 56, 56)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(78, 78, 78))
);
Torneio_PanelLayout.setVerticalGroup(
Torneio_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Torneio_PanelLayout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(Torneio_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(Escalao_ComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(Torneio_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(Torneio_ComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(ConsultarTorneio_Button, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(291, Short.MAX_VALUE))
.addGroup(Torneio_PanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
TabbedPane.addTab("Torneio", Torneio_Panel);
VoltarMenuPrincipal_Button.setText("Voltar Menu Anterior");
VoltarMenuPrincipal_Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
VoltarMenuPrincipal_ButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout VoltarMenuPrincipal_PanelLayout = new javax.swing.GroupLayout(VoltarMenuPrincipal_Panel);
VoltarMenuPrincipal_Panel.setLayout(VoltarMenuPrincipal_PanelLayout);
VoltarMenuPrincipal_PanelLayout.setHorizontalGroup(
VoltarMenuPrincipal_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(VoltarMenuPrincipal_PanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(VoltarMenuPrincipal_Button, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(30, Short.MAX_VALUE))
);
VoltarMenuPrincipal_PanelLayout.setVerticalGroup(
VoltarMenuPrincipal_PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(VoltarMenuPrincipal_PanelLayout.createSequentialGroup()
.addComponent(VoltarMenuPrincipal_Button, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(VoltarMenuPrincipal_Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 20, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Consultar_Label)
.addComponent(TabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 775, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(20, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(20, Short.MAX_VALUE)
.addComponent(Consultar_Label)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(TabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(VoltarMenuPrincipal_Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(20, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents | 4 |
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.jtattoo.plaf.graphite.GraphiteLookAndFeel");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JFrame j = new JFrame("Server");
ServerGame g = new ServerGame();
j.add(g);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setResizable(false);
j.setVisible(true);
j.pack();
} | 4 |
@Command(command = "demote",
aliases = {"de"},
arguments = {"target player[s]"},
description = "demotes the target player[s]",
permissions = {"demote"},
consoleOnly = true)
public static boolean demoteFromConsole(CommandSender sender, String targetPlayer) throws EssentialsCommandException {
// make sure we have a permissions manager
if(permissionsManager == null) {
throw new EssentialsCommandException("PermissionsEx isn't installed, can't demote!");
}
// get a list of all target players
ArrayList<Player> targetPlayers = PlayerSelector.selectPlayersExact(targetPlayer);
// make sure we have at least one target player
if(targetPlayers.size() == 0) {
throw new EssentialsCommandException("I couldn't find / parse target player[s] '%s' to demote!", targetPlayer);
}
// promote everyone
String reason = "for no good reason";
for(Player target: targetPlayers) {
demote(sender, target, reason);
}
return true;
} | 3 |
@Override
public DrawableItem duplicate() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
} | 0 |
public Document getDocument() {return this.doc;} | 0 |
public void move(int x, int y){
if(alive && !hasCollision(this.x+x*speed, this.y+y*speed)){
this.x += x*speed;
this.y += y*speed;
}
} | 2 |
protected void setCurrentState(final StateEnum state, final boolean enterInitialState, final C context) {
execute(new Runnable() {
@Override
public void run() {
if (!enterInitialState) {
StateEnum prevState = context.getState();
if (prevState != null) {
leave(prevState, context);
}
}
context.setState(state);
enter(state, context);
}
}, context);
} | 2 |
public void create(String personId, String name, String password) {
this.setPersonId(personId);
this.setName(name);
this.setPassword(password);
} | 0 |
public String toString() {
String print = "";
Binomialnode x = root;
while (x != null) {
print = print + x.printTree(0);
x = x.sibling;
}
return print;
} | 1 |
public static boolean getGuildInvites(String[] args, CommandSender s){
//Various checks
if(Util.isBannedFromGuilds(s) == true){
//Checking if they are banned from the guilds system
s.sendMessage(ChatColor.RED + "You are currently banned from interacting with the Guilds system. Talk to your server admin if you believe this is in error.");
return false;
}
if(args.length > 1){
//Checking if the create command has proper args
s.sendMessage(ChatColor.RED + "Incorrectly formatted check invites command! Proper syntax is: \"/guild checkinvite\"");
return false;
}
if(!s.hasPermission("zguilds.player.checkinvite")){
//Checking if they have the permission node to proceed
s.sendMessage(ChatColor.RED + "You lack sufficient permissions to check your guild invites. Talk to your server admin if you believe this is in error.");
return false;
}
if(Util.isInGuild(s) == true){
//Checking if they're already in a guild
s.sendMessage(ChatColor.RED + "You're in a guild so you don't have any invitations to check.");
return false;
}
if(Util.hasGuildInvite(s) == false){
//Checking if they are even invited to a guild at all.
s.sendMessage(ChatColor.RED + "You are not currently invited to any guild.");
return false;
}
sendersPlayerName = s.getName().toLowerCase();
sendersCurrentGuildInvitation = Main.players.getString("Players." + sendersPlayerName + ".Current_Invitation");
s.sendMessage(ChatColor.DARK_GREEN + "You are currently invited to the guild: " + ChatColor.RED + sendersCurrentGuildInvitation + ChatColor.DARK_GREEN + ".");
return true;
} | 5 |
public boolean checkUsername(String username)
{
if(username.isEmpty())
return false;
for(char c : username.toLowerCase().toCharArray())
{
int tmp = c;
if(!(tmp > 96 && tmp < 123) || tmp==230 || tmp==248 || tmp==229) // Checking username letters
return false;
}
return true;
} | 7 |
private static int packet_get_nb_frames(byte[] packet) {
int count = 0;
if (packet.length < 1) {
return -1;
}
count = packet[0]&0x3;
if (count==0)
return 1;
else if (count!=3)
return 2;
else if (packet.length<2)
return -4;
else
return packet[1]&0x3F;
} | 4 |
public void setActiveLayer(int i) {
if (i < 0 || i >= layers.size()) {
return;
}
activeLayer = i;
curLayer = layers.get(i);
callListenersLayerChange();
} | 2 |
@Override
public void acceptDraggableObject(DraggableObject object)
{
if(object instanceof DraggableObjectEntity)
{
DraggableObjectEntity fileobj = ((DraggableObjectEntity)object);
if(fileobj.uuid != null)
{
if(!fileobj.uuid.trim().equals(""))
{
setData(editor.getMap().getEntityList().getEntityWithUUID(fileobj.uuid));
changed = true;
}
}
}
} | 3 |
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
public void addTravelTrip(TravelTrip travelTrip) {
travelTripDao.register(travelTrip);
} | 0 |
@ChattingAnnotation(feature="None", type="Method")
public void buzz() {
final int lX = f.getLocationOnScreen().x;
final int lY = f.getLocationOnScreen().y;
System.out.println(lX + "+" + lY);
try {
for (int i = 0; i < 20; i++) {
Thread.sleep(10);
f.setLocation(lX, lY + 5);
Thread.sleep(10);
f.setLocation(lX, lY - 5);
Thread.sleep(10);
f.setLocation(lX + 5, lY);
Thread.sleep(10);
f.setLocation(lX, lY);
}
} catch (Exception err) {
err.printStackTrace();
}
} | 2 |
@SuppressWarnings("unchecked")
public Extensions deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject o = json.getAsJsonObject();
Extensions extensions = new Extensions();
for (Map.Entry<String, JsonElement> entry : o.entrySet()) {
String key = entry.getKey();
JsonElement jsonElement = entry.getValue();
Object extension;
Type type = typeExtensions.get(key);
if (type != null) {
extension = gson.fromJson(jsonElement, type);
}
else {
Class clazz = classExtensions.get(key);
if (clazz != null) {
extension = gson.fromJson(jsonElement, clazz);
}
else {
extension = jsonElement;
}
}
extensions.put(key, extension);
}
return extensions;
} | 3 |
public void clickChooseCharacters(Scanner kb, ArrayList<MainMenuHeroSlot> heroies) {
System.out.println("You have already chosen your characters");
} | 0 |
public static void main(String[] args) {
int i, j; // Initialize local variable i
Scanner input = new Scanner(System.in);
System.out.println("\nEnter lenght of first array: "); // allow user
// input
int SIZE = input.nextInt();
int[] array = new int[SIZE];
System.out.println("\nEnter elements ");
for (i = 0; i <= SIZE - 1; i++) {
array[i] = input.nextInt(); // input first array element
}
for (i = 0; i <= SIZE - 1; i++) {
System.out.print(" \t" + array[i]); // display first array element
}
Scanner inputArray = new Scanner(System.in);
System.out.println("\n \n enter lenght of second Array: "); // user
// input for
// second
// array
int len = inputArray.nextInt();
int[] Sarray = new int[len]; // defining second element
System.out.println("\n\nEnter Elements in second array: ");
for (j = 0; j <= len - 1; j++) {
Sarray[j] = inputArray.nextInt();
}
for (j = 0; j <= len - 1; j++) {
System.out.println("\t" + Sarray[j]);
}
int[] NewArray = new int[len];
if (SIZE == len) {
for (int k = 0; k <= len - 1; k++) {
NewArray[k] = (array[k] + Sarray[k]);
System.out.print("\t" + NewArray[k]);
}
} else {
System.out.println("Both array have no same lenght:");
}
} | 6 |
@Override
public int getGrade(Node<T> n) {
if (safety && !contains(n)) {
throw new NodeNotFoundException();
} else if (n == null) {
return 0;
}
int c = 0;
Iterator<Node<T>> children = children(n);
while (children.hasNext()) {
children.next();
c++;
}
return c;
} | 4 |
private boolean isHorizontallyOccupied(HantoCell from, HantoCell to){
boolean isOccupied = true;
if (to.getX() < from.getX()){
for (int i = from.getX() - 1; i > to.getX(); i--){
if (findCell(i, to.getY()) == null){
isOccupied = false;
break;
}
}
} else {
for (int i = from.getX() + 1; i < to.getX(); i++){
if (findCell(i, to.getY()) == null){
isOccupied = false;
break;
}
}
}
return isOccupied;
} | 5 |
public void findSweetSpots()
{
int x,y;
for(y=0;y<matrix.length;y++)
{
for(x=0;x<matrix[y].length;x++)
{
if(matrix[y][x]==matrixMax)
{
pathRek(x,y,"");
}
}
}
} | 3 |
public boolean collision(double x, double y) {
boolean solid = false;
for (int c = 0; c < 4; c++) {
double xt = (x - c % 2 * 16) / 16;
double yt = (y - c / 2 * 16) / 16;
int ix = (int) Math.ceil(xt);
int iy = (int) Math.ceil(yt);
if (c % 2 == 0) ix = (int) Math.floor(xt);
if (c / 2 == 0) iy = (int) Math.floor(yt);
// if (level.getTile(ix, iy).sprite == Sprite.planks) sprite =
// Sprite.particle_planks;
if (level.getTile(ix, iy).solid()) solid = true;
}
return solid;
} | 4 |
@Test
public void testSimple() {
final long[] times = new long[51];
final long target_median = 90;
final long margin_of_error = 10;
final Properties config = new Properties();
config.setProperty("median_latency", "" + target_median);
final Filter f = new WanFilter(new MockConnectionProcessor(), config);
for (int i = 0 ; i < times.length; ++i) {
final long before = System.currentTimeMillis();
f.filter(i);
final long after = System.currentTimeMillis();
times[i] = after - before;
}
Arrays.sort(times);
final long median = times[(times.length - 1) / 2];
Assert.assertTrue(Math.abs(target_median-median) < margin_of_error);
} | 1 |
public final int getNameCount() {
return this.filename == null ? 0 : this.dirs == null ? this.filename
.equals("/") ? 0 : 1 : this.dirs.length + 1;
} | 3 |
public QRDecomposition (Matrix A) {
// Initialize.
QR = A.getArrayCopy();
m = A.getRowDimension();
n = A.getColumnDimension();
Rdiag = new double[n];
// Main loop.
for (int k = 0; k < n; k++) {
// Compute 2-norm of k-th column without under/overflow.
double nrm = 0;
for (int i = k; i < m; i++) {
nrm = Maths.hypot(nrm,QR[i][k]);
}
if (nrm != 0.0) {
// Form k-th Householder vector.
if (QR[k][k] < 0) {
nrm = -nrm;
}
for (int i = k; i < m; i++) {
QR[i][k] /= nrm;
}
QR[k][k] += 1.0;
// Apply transformation to remaining columns.
for (int j = k+1; j < n; j++) {
double s = 0.0;
for (int i = k; i < m; i++) {
s += QR[i][k]*QR[i][j];
}
s = -s/QR[k][k];
for (int i = k; i < m; i++) {
QR[i][j] += s*QR[i][k];
}
}
}
Rdiag[k] = -nrm;
}
} | 8 |
@Override
public Element generateDataElement(LauncherAction action) {
JavaAppDesc desc = (JavaAppDesc)action.getLaunchDesc();
org.w3c.dom.Element e = createInitialElement(desc);
//Main Class
e.setAttribute("main-class", desc.getMainClass());
//Arguments
String[] args = desc.getMainArgs();
StringBuffer argLine = new StringBuffer();
if(args != null) {
for(int i=0;i<args.length;i++) {
argLine.append(args[i] + " ");
}
}
e.setAttribute("args", argLine.toString().trim());
//Permissions
if(desc.getPermissions() != null) {
e.setAttribute("permissions", "all-permissions");
}
else {
e.setAttribute("permissions", "restricted-permissions");
}
//Use WebStart
if(desc.useWebStart()) {
e.setAttribute("use-webstart", "true");
}
else {
e.setAttribute("use-webstart", "false");
}
//Use Separate VM
if(desc.useSeperateVM()) {
e.setAttribute("separate-vm", "true");
}
else {
e.setAttribute("separate-vm", "false");
}
//Use Separate VM
if(desc.useSharedClassLoader()) {
e.setAttribute("shared-classloader", "true");
}
else {
e.setAttribute("shared-classloader", "false");
}
//Java Archives
org.w3c.dom.Element resources = e.getOwnerDocument().createElement("resources");
e.appendChild(resources);
Iterator it = desc.getJavaArchives().iterator();
while(it.hasNext()) {
URL javaResource = (URL)it.next();
org.w3c.dom.Element jarElement = e.getOwnerDocument().createElement("jar");
jarElement.setAttribute("href", javaResource.toString());
resources.appendChild(jarElement);
}
//Native Archives
it = desc.getNativeArchives().iterator();
while(it.hasNext()) {
NativeLibDesc nativeLib = (NativeLibDesc)it.next();
org.w3c.dom.Element nativeElement = e.getOwnerDocument().createElement("nativelib");
nativeElement.setAttribute("href", nativeLib.getPath().toString());
nativeElement.setAttribute("os", nativeLib.getOS());
resources.appendChild(nativeElement);
}
return e;
} | 8 |
private long persistLegal(Legal legal, String table) throws SQLException {
Connection connection = null;
PreparedStatement preparedStatement = null;
String insertSQL = "INSERT INTO " + table
+ "(bank_account,TIN,company_name,company_address) VALUES"
+ "(?,?,?,?)";
try {
connection = provider.getConnection();
preparedStatement = connection.prepareStatement(insertSQL,
Statement.RETURN_GENERATED_KEYS);
preparedStatement.setString(1, legal.getBankAccount());
preparedStatement.setString(2, legal.getTIN());
preparedStatement.setString(3, legal.getCompanyName());
preparedStatement.setString(4, legal.getCompanyAddress());
preparedStatement.executeUpdate();
long lastInsertID = getLastInsertId(preparedStatement);
return lastInsertID;
} catch (SQLException e) {
if (e.getSQLState().equals(IConnectionProvider.DUPLICATE_STATE)) {
logger.warn("Duplicate entry. Keep working");
return -1;
} else {
logger.error("SQL error during 'persistDetails'", e);
throw e;
}
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (connection != null) {
connection.close();
}
}
} | 4 |
public static byte[] hexToBytes(String str) {
if (str == null) {
return null;
} else if (str.length() < 2) {
return null;
} else {
int len = str.length() / 2;
byte[] buffer = new byte[len];
for (int i = 0; i < len; i++) {
buffer[i] = (byte) Integer.parseInt(
str.substring(i * 2, i * 2 + 2), 16);
}
return buffer;
}
} | 3 |
private void setDoubleDown() {
switch(playerTurn) {
case(1):
if (canPlayer1DD) {
canPlayer1DD = false;
dd.setVisible(true);
}
else
dd.setVisible(false);
break;
case(2):
if (canPlayer2DD) {
canPlayer2DD = false;
dd.setVisible(true);
}
else
dd.setVisible(false);
break;
case(3):
if (canPlayer3DD) {
canPlayer3DD = false;
dd.setVisible(true);
}
else
dd.setVisible(false);
break;
case(4):
if (canPlayer4DD) {
canPlayer4DD = false;
dd.setVisible(true);
}
else
dd.setVisible(false);
break;
}
} | 8 |
private void getPoints() {
Random rd = new Random();
int chance;
for (int i = -this.radius; i < this.radius; i++) {
for (int j = -this.radius; j < this.radius; j++) {
chance = rd.nextInt(100) - Math.abs(i - j) - Math.abs(i + j) - Math.abs(i) - Math.abs(j) + radius;
if (chance >= 50) {
Xs.add(x + i);
Ys.add(y + j);
}
}
}
} | 3 |
public boolean DestructPlugin(Session Session, String Name)
{
int Count = Plugins.size();
for(HabboPlugin Plugin : Plugins)
{
try
{
if (Plugin.GrabName().equalsIgnoreCase(Name))
{
Grizzly.WriteOut(Plugin.GrabName() + " has been destructed by " + Session.GrabHabbo().Username);
Plugins.remove(Plugin);
break;
}
} catch (Exception Ex) { Grizzly.WriteOut(Ex.getStackTrace()); }
}
return (Count != Plugins.size());
} | 3 |
public void addOpdrachtenFromFileToDB() {
con = createConnection();
ResultSet rs = null;
try {
List<Opdracht> opdrachtenLijst = leesOpdrachtenVanBestand();
for (Opdracht opdr : opdrachtenLijst) {
pst = con
.prepareStatement("select idOpdrachtSoorten from opdrachtsoorten where OpdrachtSoortenNaam=?");
pst.setString(1, opdr.getClass().getSimpleName());
rs = pst.executeQuery();
int opdrachtSoortID = 0;
if (rs.next()) {
opdrachtSoortID = rs.getInt(1);
}
pst = con
.prepareStatement("select idOpdrachtCategorieën from opdrachtcategorieën where OpdrachtCategorieNaam=?");
pst.setString(1, opdr.getOpdrachtCategorie().toString());
rs = pst.executeQuery();
int opdrachtCategorieID = 0;
if (rs.next()) {
opdrachtCategorieID = rs.getInt(1);
}
pst = con
.prepareStatement("insert into opdrachten(vraag,antwoord,maxAantalpogingen,antwoordHint,maxAntwoordTijd,opdrachtenCategorie,soortOpdracht) values(?,?,?,?,?,?,?)");
pst.setString(1, opdr.getVraag());
pst.setString(2, opdr.getAntwoord());
pst.setInt(3, opdr.getMaxAantalPogingen());
pst.setString(4, opdr.getAntwoordHint());
pst.setInt(5, opdr.getmaxAntwoordTijd());
pst.setInt(6, opdrachtCategorieID);
pst.setInt(7, opdrachtSoortID);
pst.executeUpdate();
pst = con
.prepareStatement("select idopdrachten from opdrachten where vraag=?");
pst.setString(1, opdr.getVraag());
rs = pst.executeQuery();
int opdrachtID = 0;
if (rs.next()) {
opdrachtID = rs.getInt(1);
}
if (opdr.getClass().getSimpleName().equals("Meerkeuze")) {
String alleKeuzes = ((Meerkeuze) opdr).getAlleKeuzes();
pst = con
.prepareStatement("insert into meerkeuzeopdrachten(idmeerkeuzeOpdrachten,alleKeuzes) values(?,?)");
pst.setInt(1, opdrachtID);
pst.setString(2, alleKeuzes);
pst.executeUpdate();
} else if (opdr.getClass().getSimpleName()
.equals("Reproductie")) {
String trefwoorden = ((Reproductie) opdr).getTrefwoorden();
int minTrefwoorden = ((Reproductie) opdr)
.getMinAantalJuisteTrefwoorden();
pst = con
.prepareStatement("insert into reproductieopdrachten(idreproductieOpdrachten,trefwoorden,minAantalTrefwoorden) values(?,?,?)");
pst.setInt(1, opdrachtID);
pst.setString(2, trefwoorden);
pst.setInt(3, minTrefwoorden);
pst.executeUpdate();
} else if (opdr.getClass().getSimpleName().equals("Opsomming")) {
pst = con
.prepareStatement("insert into opsommingsopdrachten(idopsommingsOpdrachten) values(?)");
pst.setInt(1, opdrachtID);
}
}
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
// apparently this isn't needed anymore in java 7?
// finally {
// try {
// if (rs != null) {
//
// rs.close();
// }
// if (pst != null) {
// pst.close();
// }
// closeConnection();
} | 9 |
@Override
public Screen respondToInput(KeyEvent key) {
char c = key.getKeyChar();
Item[] items = this.player.getInventory().getItems();
if (letters.indexOf(c) > -1 && items.length > letters.indexOf(c) && items[letters.indexOf(c)] != null && isAcceptable(items[letters.indexOf(c)])) {
return use(items[letters.indexOf(c)]);
} else if (key.getKeyCode() == KeyEvent.VK_ESCAPE) {
return null;
}
return this;
} | 5 |
public void remove(Object o) {
for (int i = 0; i < size(); i++) {
if (list.get(i).getReturnValue().equals(o)) {
list.remove(i);
}
}
} | 2 |
public void initPublishSubscriber(final int periodMs){
Thread thread = new Thread() {
public void run() {
PortReadingResult or;
// check if the observer is still there
// we have no more than 1 observer
while(countObservers()>0){
try {
or = readData();
while(or.getStatus() == OutputPortStatus.NO_DATA
|| or.getStatus() == OutputPortStatus.OLD_DATA){
Thread.sleep(periodMs);
or = readData();
}
// if a new data is availbale notify the observer
setChanged();
notifyObservers(new OrocosPortEvent(port.getName(), or.getValue()));
} catch(InterruptedException e){
e.printStackTrace();
} catch (WrongUseOfConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
thread.start();
} | 5 |
public ListNode removeNthFromEnd(ListNode head, int n)
{
if (n < 1) {
throw new IllegalArgumentException("n cannot be smaller than 1");
}
if (head == null) {
return null;
}
int headStartCounter = 0;
ListNode remove = null;
for (ListNode lead = head; lead != null; lead = lead.next)
{
if (headStartCounter < n) {
++headStartCounter;
} else if (remove == null) {
remove = head;
} else {
remove = remove.next;
}
}
if (headStartCounter < n) {
throw new IllegalArgumentException("n is smaller than size of list");
}
if (remove == null) {
// case where n is the size of the list
return head.next;
} else {
remove.next = remove.next.next;
}
return head;
} | 7 |
private int compareAddresses( InetAddress first,
InetAddress second ) {
if( first.equals(second) )
return 0; // equal
byte[] bytesA = first.getAddress();
byte[] bytesB = second.getAddress();
if( bytesA.length != bytesB.length )
return bytesA.length - bytesB.length; // not equal
int cmp;
for( int i = 0; i < bytesA.length; i++ ) {
cmp = bytesA[i] - bytesB[i];
if( cmp != 0 )
return cmp;
}
return -1;
} | 4 |
public static void handleEnableAsyncMetadataReply(HTSMsg msg, HTSPClient client) {
Collection<String> requiredFields = Arrays.asList(new String[]{});
if (msg.keySet().containsAll(requiredFields)){
//TODO
} else if (msg.get("error") != null){
//TODO
} else{
System.out.println("Faulty reply");
}
} | 2 |
@Override
public void run() {
String str;
while(isConected){
try {
str = in.readLine().replace(";;", "\n");
request = (Map<String, Object>) yaml.load(str);
ActionDispatch.analize(request);
} catch (Exception e) {
// TODO Автоматически созданный блок catch
e.printStackTrace();
}
}
} | 2 |
public boolean isVerticalCombo(int x, int y, Orb[][] arr) {
int verCount = 0;
for (int j = 1; ((y + j) < Y && arr[y + j][x] != null)
&& arr[y][x].color == arr[y + j][x].color; j++)
verCount++;
for (int j = -1; ((y + j) >= 0 && arr[y + j][x] != null)
&& arr[y][x].color == arr[y + j][x].color; j--)
verCount++;
if (verCount >= 2)
return true;
else
return false;
} | 7 |
public static void outLog(String data){
// BatchOS.outLog(data, true);
} | 0 |
public boolean isValidField(char row, byte column)
{
if(row >= 97 && row <= 104 && column <= 7 && column >= 0)
{
return true;
}
return false;
} | 4 |
@Override
public Vector3 color(Scene scene, Ray ray) {
Vector3 color = defaultColor;
Collision collision = trace(scene, ray);
if (collision != null) {
Vector3 collisionPoint = ray.getFrom().add(ray.getDirection().multiply(collision.getDistance()));
Vector3 collisionNorm = collision.getPrimitive().getNorm(collisionPoint);
if (collision.isInversed()) {
collisionNorm = collisionNorm.inverse();
}
Material material = collision.getPrimitive().getMaterial(collisionPoint);
// Ambient
color = material.getAmbient();
// For all lights we need to calculate diffuse and specular components
for (Light light : scene.getLights()) {
double amountOfLight = findAmountOfLight(scene, light, collisionPoint);
if (amountOfLight >= MathUtils.RAY_POWER_THRESHOLD) {
Vector3 lightDirection = collisionPoint.subtract(light.getPosition()).normalize();
// Diffuse
double cos = collisionNorm.dotProduct(lightDirection.inverse());
Vector3 diffuseColor = material.getDiffuse().multiply(amountOfLight * cos);
color = color.add(diffuseColor);
// Specular
Vector3 lightReflectionDirection = MathUtils.reflect(lightDirection.inverse(), collisionNorm);
cos = lightReflectionDirection.dotProduct(ray.getDirection().inverse());
Vector3 specularColor = material.getSpecular().multiply(amountOfLight * Math.pow(cos, material.getSpecularPower()));
color = color.add(specularColor);
}
}
// Reflection
if (material.getReflectionPower() * ray.getPower() >= MathUtils.RAY_POWER_THRESHOLD) {
Vector3 reflectionDirection = MathUtils.reflect(ray.getDirection().inverse(), collisionNorm);
Ray reflectionRay = new RayImpl(collisionPoint, reflectionDirection, ray.getPower() * material.getReflectionPower());
Vector3 reflectionColor = color(scene, reflectionRay);
color = color.add(reflectionColor);
}
// Refraction
color = color.add(refractionStrategy.refract(this, scene, ray, collisionPoint, collisionNorm, collision.getPrimitive()));
}
return color.multiply(ray.getPower());
} | 5 |
* @param options
* @return Demon
*/
public static Demon defineDemon(String name, Cons options) {
{ Demon demon = Demon.newDemon();
PropertyList plist = PropertyList.newPropertyList();
Cons conslist = Stella.NIL;
Demon olddemon = null;
boolean activateP = false;
{ Stella_Object item = null;
Cons iter000 = options;
Cons collect000 = null;
for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
item = iter000.value;
if (collect000 == null) {
{
collect000 = Cons.cons(item, Stella.NIL);
if (conslist == Stella.NIL) {
conslist = collect000;
}
else {
Cons.addConsToEndOfConsList(conslist, collect000);
}
}
}
else {
{
collect000.rest = Cons.cons(item, Stella.NIL);
collect000 = collect000.rest;
}
}
}
}
plist.thePlist = conslist;
demon.demonName = name;
activateP = plist.removeAt(Stella.KWD_ACTIVATEp) == Stella.TRUE_WRAPPER;
if (Demon.incorporateDemonOptionsP(demon, plist)) {
{
olddemon = Stella.lookupDemon(name);
if (olddemon != null) {
Demon.deactivateDemon(olddemon);
olddemon.free();
}
}
Stella.$DEMONS_TABLE$.insertAt(demon.demonName, demon);
if (activateP) {
Demon.activateDemon(demon);
}
return (demon);
}
demon.free();
return (null);
}
} | 6 |
public boolean deleteRow(int row) {
if (row < 0 || row > data.size() - 2)
return false;
data.remove(row);
fireTableRowsDeleted(row, row);
return true;
} | 2 |
public void leavePercentageOutSplit(String filename, int percentage, boolean random) {
List<UserData> trainLines = new ArrayList<UserData>();
List<UserData> testLines = new ArrayList<UserData>();
Set<Integer> indices = new HashSet<Integer>();
int currentUser = -1, userIndex = -1, userSize = -1;
for (int i = 0; i < this.reader.getUserLines().size(); i++) {
UserData data = this.reader.getUserLines().get(i);
if (currentUser != data.getUserID()) { // new user
currentUser = data.getUserID();
userSize = this.reader.getUserCounts().get(currentUser);
userIndex = 1;
indices.clear();
int limit = (userSize - 1 < percentage ? userSize - 1 : percentage);
if (random) {
while (indices.size() < limit) {
indices.add(1 + (int)(Math.random() * ((userSize - 1) + 1)));
}
} else {
for (int index : getBestIndices(this.reader.getUserLines().subList(i, i + userSize), false)) {
if (indices.size() < limit) {
indices.add(index);
} else {
break;
}
}
}
}
if (indices.contains(userIndex++)) {
testLines.add(data);
} else {
trainLines.add(data);
}
}
writeWikiSample(this.reader, trainLines, filename + "_train", null);
writeWikiSample(this.reader, testLines, filename + "_test", null);
trainLines.addAll(testLines);
writeWikiSample(this.reader, trainLines, filename, null);
} | 8 |
private static void processWorkflowDirectory(final File workflowsDirectory, final Map<File, AnalysisData> processedWorkflows) {
final File workflowReportFile = new File(workflowsDirectory, "report.xml");
if (workflowReportFile.exists() && workflowReportFile.isFile()) {
//System.out .println("Azotyzing: " + workflowReportFile.getAbsolutePath());
final AnalysisData analysisData = new AnalyzeLauncher().processWorkflowReport(workflowReportFile);
processedWorkflows.put(workflowsDirectory, analysisData);
}
else {
final File[] files = workflowsDirectory.listFiles();
for (final File file : files) {
if (file.isDirectory()) {
processWorkflowDirectory(file, processedWorkflows);
}
}
}
} | 4 |
private static void playRound() {
battles++;
if (hands[0].handSize() == 0 || hands[1].handSize() == 0) {
gameOver = true;
} else {
for (int i = 0; i < hands.length; i++) {
stacks[i].put(hands[i].get());
}
compareStacks();
System.out.println("Player 0 has " + hands[0].handSize() + " Player 1 has " + hands[1].handSize());
}
} | 3 |
public String saveConfigSectionWithComments(ConfigurationSection section, boolean depth) {
StringBuilder builder = new StringBuilder();
for (Iterator<Map.Entry<String, Object>> i = section.getValues(false).entrySet().iterator(); i.hasNext();) {
Map.Entry<String, Object> entry = i.next();
// Output comment, if present
String comment = this.getComment(entry.getKey());
if (comment != null) {
builder.append(buildComment(comment));
}
if (entry.getValue() instanceof ConfigurationSection) {
// output new line before ConfigurationSection. Pretier.
builder.append('\n');
// If it's a section, get it's string representation and append it to our builder.
// If the first character isn't alphanumeric, quote it !
if (Character.isLetterOrDigit(entry.getKey().codePointAt(0)))
builder.append(entry.getKey());
else
builder.append("'" + entry.getKey() + "'");
builder.append(":" + yamlOptions.getLineBreak().getString());
builder.append(saveConfigSectionWithComments((ConfigurationSection) entry.getValue(), true));
// output new line after ConfigurationSection. Prettier.
builder.append('\n');
} else {
// If it's not a configuration section, just let yaml do it's stuff.
builder.append(yaml.dump(Collections.singletonMap(entry.getKey(), entry.getValue())));
}
}
String dump = builder.toString();
// Prepend the indentation if we aren't the root configuration.
if (depth) {
String[] lines = dump.split(Pattern.quote(yamlOptions.getLineBreak().getString()));
StringBuilder indented = new StringBuilder();
for (int i = 0;i<lines.length;i++) {
for (int indent = 0;indent<yamlOptions.getIndent();indent++) {
indented.append(" ");
}
indented.append(lines[i] + yamlOptions.getLineBreak().getString());
}
return indented.toString();
} else {
return dump;
}
} | 7 |
public void setFontProperties(Properties fontProperties)
throws IllegalArgumentException {
String errorString = "Error parsing font properties ";
try {
fontList = new ArrayList<Object[]>(150);
Enumeration fonts = fontProperties.propertyNames();
String name;
String family;
Integer decorations;
String path;
StringTokenizer tokens;
// read in font information
while (fonts.hasMoreElements()) {
name = (String) fonts.nextElement();
tokens = new StringTokenizer((String) fontProperties.get(name), "|");
// get family, decoration and path tokens
family = tokens.nextToken();
decorations = new Integer(tokens.nextToken());
path = tokens.nextToken();
if (name != null && family != null && path != null) {
fontList.add(new Object[]{name, family, decorations, path});
} else {
throw new IllegalArgumentException(errorString);
}
}
sortFontListByName();
} catch (Throwable e) {
logger.log(Level.FINE, "Error setting font properties ", e);
throw new IllegalArgumentException(errorString);
}
} | 5 |
public static void removeOpponentCaptures(Board board, int opponent, int x, int y) {
int boardSize = board.boardSize;
if (x > 0) {
removeIfCaptured(board, opponent, x - 1, y);
}
if (x < boardSize - 1) {
removeIfCaptured(board, opponent, x + 1, y);
}
if (y > 0) {
removeIfCaptured(board, opponent, x, y - 1);
}
if (y < boardSize - 1) {
removeIfCaptured(board, opponent, x, y + 1);
}
} | 4 |
private DrivingLicense(PersonName driversName, Date dateOfBirth,
LicenseNumber licenseNumber, Date dateOfIssue, boolean isFullLicense){
if (driversName.toString().isEmpty())
throw new IllegalArgumentException("The drivers name is null");
this.driversName = driversName;
this.dateOfBirth=new Date(dateOfBirth.getTime());
if (this.dateOfBirth.after(new Date((new Date().getTime()))))
throw new IllegalArgumentException("The date of birth is null");
if (licenseNumber.toString().isEmpty())
throw new IllegalArgumentException("The license number is null");
this.licenseNumber=LicenseNumber.getInstance(licenseNumber.getNameIdentifier(driversName), licenseNumber.getYearOfIssue(), licenseNumber.getSerialNumber());
this.dateOfIssue=new Date(dateOfIssue.getTime());
if (this.dateOfIssue.after(new Date((new Date().getTime()))))
throw new IllegalArgumentException("The date of issue is null");
this.isFullLicense=isFullLicense;
} | 4 |
private ArraySchema parseArraySchema(JsonNode rawSchema, URL schemaLocation) {
ArraySchema result = new ArraySchema();
JsonNode rawItems = rawSchema.get("items");
if (rawItems != null) {
result.setItems(parse(rawItems, schemaLocation));
}
JsonNode rawMinItems = rawSchema.get("minItems");
if (rawMinItems != null) {
result.setMinItems(rawMinItems.intValue());
}
JsonNode rawMaxItems = rawSchema.get("maxItems");
if (rawMaxItems != null) {
result.setMaxItems(rawMaxItems.intValue());
}
return result;
} | 3 |
public String layer_string()
{
switch (h_layer)
{
case 1:
return "I";
case 2:
return "II";
case 3:
return "III";
}
return null;
} | 3 |
private DisplayMode getBestDisplayMode() {
DisplayMode[] program_displays = { new DisplayMode(640 , 480, DisplayMode.BIT_DEPTH_MULTI, DisplayMode.REFRESH_RATE_UNKNOWN),
new DisplayMode(800 , 600, DisplayMode.BIT_DEPTH_MULTI, DisplayMode.REFRESH_RATE_UNKNOWN),
new DisplayMode(1024, 768, DisplayMode.BIT_DEPTH_MULTI, DisplayMode.REFRESH_RATE_UNKNOWN),
new DisplayMode(1280, 960, DisplayMode.BIT_DEPTH_MULTI, DisplayMode.REFRESH_RATE_UNKNOWN),
};
DisplayMode[] device_displays = device.getDisplayModes();
DisplayMode display = null;
boolean[] displays = {false, false, false, false};
double dimension_gap = 99999;
for(int i=0;i<program_displays.length;i++) { //Loop for each standard program display
for(int n=0;n<device_displays.length;n++) { //Loop for each compatible device display
if(displayModesMatch(device_displays[n], program_displays[i])) { //If the device display is also a standard program display
displays[i] = true;
program_displays[i] = device_displays[n];
}
else {
if(device_displays[n].getWidth()/4 == device_displays[n].getHeight()/3) { //Check if the device display is in ration 4:3
for(int t=0;t<program_displays.length;t++) { //Loop for each standard program display
if(Math.sqrt(Math.pow((double) device_displays[n].getWidth() - program_displays[t].getWidth(), 2.0)) <= dimension_gap) { //Check if the dimension gap < than before
display = device_displays[n];
dimension_gap = Math.sqrt(Math.pow((double) device_displays[n].getWidth() - program_displays[t].getWidth(), 2.0));
}
}
}
}
}
}
for(int i=0;i<4;i++) {System.out.println(displays[i]);}
for(int i=program_displays.length-1;i>-1;i--) {
if(displays[i]) {
System.out.println(program_displays[i].getWidth()+" "+program_displays[i].getHeight());
return program_displays[i];}
}
System.out.println(display.getWidth()+", "+display.getHeight());
return display;
} | 9 |
@Override
public boolean exportFile(String name, String path, Pattern pattern) {
try{
System.out.println("test 1" + pattern);
FileWriter fw = new FileWriter("" + path + "\\name" + ".txt");
PrintWriter pw = new PrintWriter(fw);
pw.println("patNam_" + pattern.getName());
pw.println("patPro_" + pattern.getProblem());
pw.println("patSol_" + pattern.getSolution());
pw.println("patCon_" + pattern.getConsequences());
for(Context c: pattern.getAllContexts()){
pw.println("conNam_" + c.getName());
}
for(Participant p: pattern.getAllParticipants()){
pw.println("parNam_" + p.getName());
pw.println("parVis_" + p.getVisibility());
pw.println("parInt_" + p.isIsInterface());
pw.println("parSta_" + p.isIsStatic());
pw.println("parAbs_" + p.isIsAbstract());
for(Relation r: p.getAllRelations()){
pw.println("relSor_" + r.getSortRelation());
pw.println("relRel_" + r.getRelatedParticipant().getName());
}
for(Subject s: p.getAllSubjects()){
pw.println("subTyp_" + s.getType());
pw.println("subNam_" + s.getName());
pw.println("subVis_" + s.getVisibility());
pw.println("subSta_" + s.isIsStatic());
pw.println("subAbs_" + s.isIsAbstract());
}
System.out.println("test 2");
}
pw.close();
return true;
} catch(Exception e){
System.out.println("test 3");
e.printStackTrace();
return false;
}
} | 5 |
private String getClassLocation() {
final Class cls = getClass();
URL result = null;
final String clsAsResource = cls.getName().replace('.','/').concat(".class");
final ProtectionDomain pd = cls.getProtectionDomain();
// java.lang.Class contract does not specify if 'pd' can ever be null;
// it is not the case for Sun's implementations, but guard against null
// just in case:
if (pd != null) {
final CodeSource cs = pd.getCodeSource();
// 'cs' can be null depending on the classloader behavior:
if (cs != null)
result = cs.getLocation();
}
if (result == null) {
// Try to find 'cls' definition as a resource; this is not
// documented to be legal, but Sun's implementations seem to allow this:
final ClassLoader clsLoader = cls.getClassLoader();
result = clsLoader != null ? clsLoader.getResource (clsAsResource) : ClassLoader.getSystemResource(clsAsResource);
}
String value = "";
if (result != null) {
value = path.replace( '.', '/' ) + '/';
value = result.toString() + value;
value = replace( value, "%20", " " );
value = replace( value, "file:/", "" );
}
return value;
} | 5 |
public XYSeriesCollection createFinalRobustnessDataset(Map<Integer, List<Double>> robustnessHistory) {
final XYSeriesCollection dataset = new XYSeriesCollection();
List<SummaryStatistics> sumValues = new LinkedList<>();
SummaryStatistics meanRobustness = new SummaryStatistics();
for (Integer run : robustnessHistory.keySet()) {
final XYSeries serie = new XYSeries(run);
meanRobustness.addValue(robustnessHistory.get(run).get(0));
int index = 0;
for (Double value : robustnessHistory.get(run)) {
if (index > 0) {
serie.add(index - 1, value);
if (sumValues.size() < index) {
sumValues.add(new SummaryStatistics());
}
sumValues.get(index - 1).addValue(value);
}
index++;
}
dataset.addSeries(serie);
}
final XYSeries serie = new XYSeries("Mean = " + meanRobustness.getMean());
int index = 0;
for (SummaryStatistics sumValue : sumValues) {
serie.add(index, sumValue.getMean());
index++;
}
dataset.addSeries(serie);
final XYSeries serieMax = new XYSeries("Max = " + meanRobustness.getMax());
for (Integer run : robustnessHistory.keySet()) {
if (robustnessHistory.get(run).get(0) == meanRobustness.getMax()) {
index = 0;
for (Double value : robustnessHistory.get(run)) {
if (index > 0) {
serieMax.add(index - 1, value);
}
index++;
}
}
}
dataset.addSeries(serieMax);
return dataset;
} | 9 |
public void setDetermineImageNumber(boolean newValue)
{
determineNumberOfImages = newValue;
} | 0 |
public void init(String cifra_de_bloco, String padding_str) {
try {
//Algoritmo de criptografia/modo de operacao de cifra de bloco/preenchimento
ecipher = Cipher.getInstance(cifra_de_bloco + "/" + this.mode + "/"+padding_str); //classe para criptografia
dcipher = Cipher.getInstance(cifra_de_bloco + "/" + this.mode + "/"+padding_str); //classe para decriptografia
//verifica se um vetor de inicializa��o foi definido
if (this.mode == "ECB") {
ecipher.init(Cipher.ENCRYPT_MODE, this.key);
dcipher.init(Cipher.DECRYPT_MODE, this.key);
} else {
ecipher.init(Cipher.ENCRYPT_MODE, this.key, param);
dcipher.init(Cipher.DECRYPT_MODE, this.key, param);
}
this.charSet = "ISO-8859-1";
} catch (javax.crypto.NoSuchPaddingException e) {
e.printStackTrace();
} catch (java.security.NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (java.security.InvalidKeyException e) {
System.out.println("O erro e: " + e.getMessage());
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
System.out.println("O erro e: " + e.getMessage());
e.printStackTrace();
}
} | 5 |
@Override
public boolean okMessage(final Environmental myHost, final CMMsg msg)
{
if(!(affected instanceof MOB))
return super.okMessage(myHost,msg);
final MOB mob=(MOB)affected;
if((msg.amITarget(mob))
&&(CMath.bset(msg.targetMajor(),CMMsg.MASK_MALICIOUS))
&&(msg.targetMinor()==CMMsg.TYP_CAST_SPELL)
&&(msg.tool() instanceof Ability)
&&((((Ability)msg.tool()).classificationCode()&Ability.ALL_ACODES)==Ability.ACODE_CHANT)
&&(invoker!=null)
&&(!mob.amDead())
&&(CMLib.dice().rollPercentage()<(35+super.getXLEVELLevel(invoker())+adjustedLevel(invoker(),0)-((Ability)msg.tool()).adjustedLevel(msg.source(), 0))))
{
mob.location().show(mob,null,CMMsg.MSG_OK_VISUAL,L("The barrier around <S-NAME> blocks off @x1!",msg.tool().name()));
return false;
}
return super.okMessage(myHost,msg);
} | 9 |
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
servletResponse.setContentType("text/html");
String path = ((HttpServletRequest) servletRequest).getRequestURI();
//If not in a protected page, process without interrupting
if (path.equals("/index.jsp") || path.equals("/index.jsp?session=false") || path.equals("/LoginProcessorServlet")) {
filterChain.doFilter(servletRequest, servletResponse);
} else {
try {
//Get the current user
Subject currentUser = SecurityUtils.getSubject();
//Check for the current Shiro subject for auth.
if(!currentUser.isAuthenticated()) {
//No session was found. Redirect to login page.
((HttpServletResponse)(servletResponse)).sendRedirect("/index.jsp?session=expired");
//Clear the current shiro subject and redirect if logging out
} else if (path.equals("/protected/logout.jsp")) {
if (currentUser != null) {
if (currentUser.isAuthenticated()) {
currentUser.logout();
}
}
((HttpServletResponse)(servletResponse)).sendRedirect("/index.jsp");
//All is well. Continue as per normal.
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
} catch(Exception e) {
//No session was found. Redirect to login page.
((HttpServletResponse)(servletResponse)).sendRedirect("/index.jsp?session=expired");
}
}
} | 8 |
public void addFreq(String word) {
if (mFreq < Integer.MAX_VALUE) mFreq++;
if (Character.isUpperCase(word.charAt(0))) mCapitalFreq++;
} | 2 |
public void run(CommandSender sender, String[] args) {
if(args.length == 0) {
sender.sendMessage(ChatColor.RED + "You didn't enter a group.");
return;
}
String g = args[0];
if(args.length < 2) {
if(SettingsManager.getInstance().getGroup(g) != null) {
if(SettingsManager.getInstance().getGroup(g).getPermissions().size() == 0) {
sender.sendMessage(ChatColor.YELLOW + "No permissions for " + g + ".");
return;
}
for(String permission : SettingsManager.getInstance().getGroup(g).getPermissions()) {
sender.sendMessage(ChatColor.YELLOW + permission);
return;
}
} else {
SettingsManager.getInstance().createGroup(g);
sender.sendMessage(ChatColor.GREEN + "Created group!");
return;
}
} else {
if(args[1].equalsIgnoreCase("add")) {
SettingsManager.getInstance().addGroup(args[2], g);
sender.sendMessage(ChatColor.GREEN + "Added " + args[2] + " to group " + g + ".");
return;
}else if(args[1].equalsIgnoreCase("remove")) {
SettingsManager.getInstance().removeGroup(args[2], g);
sender.sendMessage(ChatColor.GREEN + "Removed " + args[2] + " from group " + g + ".");
return;
}else if(args[1].equalsIgnoreCase("addperm")) {
SettingsManager.getInstance().getGroup(g).addPermission(args[2]);
sender.sendMessage(ChatColor.GREEN + "Added " + args[2] + " to group " + g + ".");
return;
}else if(args[1].equalsIgnoreCase("removeperm")) {
SettingsManager.getInstance().getGroup(g).removePermission(args[2]);
sender.sendMessage(ChatColor.GREEN + "Removed " + args[2] + " from group " + g + ".");
return;
}
}
} | 9 |
public static void main(String args[]){
String keyPairs[];
String keys[];
HashTable tbl=new HashTable();
long start=System.currentTimeMillis();
BufferedReader br = null;
BufferedReader br1 = null;
try {
String sCurrentLine;
String inputLine ="";
br = new BufferedReader(new FileReader("E:/Intern/Java/workspace/Translator/src/translator/first.txt"));
br1 = new BufferedReader(new FileReader("E:/Intern/Java/workspace/Translator/src/translator/second.txt"));
while (!((sCurrentLine = br.readLine()).equals(""))) {
keyPairs =sCurrentLine.split(",");
tbl.put(keyPairs[0], keyPairs[1]);
}
while ((sCurrentLine = br1.readLine()) != null) {
inputLine+=sCurrentLine+" ";
}
System.out.println(inputLine);
keys =inputLine.split(" ");
int i=0;
while(i<keys.length){
if(tbl.get(keys[i])!=null){
System.out.print(tbl.get(keys[i])+" ");
}else{
System.out.print("["+keys[i]+"]"+" ");
}
i++;
}
long end=System.currentTimeMillis();
System.out.println("\n Runnig time"+(end-start));
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
br1.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
} | 6 |
public void addPerso(String nomType, String nom, int age) throws ClassePersonnageManquanteException {
Personnage nouveauPerso;
// On fait des "if" car le switch case avec String n'est pas accepté
if(nomType.equals("Mage")) {
nouveauPerso = new Mage(nom, age);
this.addPersonnage(nouveauPerso);
} else if(nomType.equals("CavalierCeleste")) {
nouveauPerso = new CavalierCeleste(nom, age);
this.addPersonnage(nouveauPerso);
} else if(nomType.equals("Voleur")) {
nouveauPerso = new Voleur(nom, age);
this.addPersonnage(nouveauPerso);
} else if(nomType.equals("Guerrier")) {
nouveauPerso = new Guerrier(nom, age);
this.addPersonnage(nouveauPerso);
} else {
throw new ClassePersonnageManquanteException("Le type " + nomType + " n'existe pas !");
}
} | 4 |
public static String escape(String string) {
char c;
String s = string.trim();
StringBuffer sb = new StringBuffer();
int length = s.length();
for (int i = 0; i < length; i += 1) {
c = s.charAt(i);
if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
sb.append('%');
sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16));
sb.append(Character.forDigit((char)(c & 0x0f), 16));
} else {
sb.append(c);
}
}
return sb.toString();
} | 6 |
private void startFactory() {
try {
this.factory = factoryClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
} | 1 |
@Test
public void validationNegativeWithStringTest() {
view.getNumberOfPointsTextField().setText("aaa");
view.getNumberOfPointsTextField().getInputVerifier().verify(view.getNumberOfPointsTextField());
assertFalse(view.getDrawButton().isEnabled());
} | 0 |
public int GetRunAnim(int id)
{
if(id == 4151) // whip
{
return 1661;
}
if(id == 8447) // cat toy
{
return 1661;
}
if(id == 6818) // bow-sword
{
return 744;
}
if(id == 4734 || id == 837) // karils x bow
{
return 2077;
}
if(id == 4153) // maul
{
return 1664;
}
if(id == 1419) // scythe
{
return 1664;
}
if(id == 7449) // noobsmasher
{
return 1664;
}
else
{
return 0x338;
}
} | 8 |
private static CycFormulaSentence makeCycLSentence(String query, CycAccess access) {
try {
return CycLParserUtil.parseCycLSentence(query, true, access);
} catch (Exception e) {
throw new RuntimeException(e);
}
} | 1 |
private double getExpectedScore() {
double expected = 0;
for (int i = 0; i < NFRUIT; i++) {
expected += (mExpDistrib[i] * mPreferences[i]);
}
expected*=bowlSize;
return expected;
} | 1 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TwoCitiesSolution other = (TwoCitiesSolution) obj;
if (A == null) {
if (other.A != null)
return false;
} else if (!A.equals(other.A))
return false;
if (B == null) {
if (other.B != null)
return false;
} else if (!B.equals(other.B))
return false;
return true;
} | 9 |
private void findInfo() {
String line = "";
try {
while( (line = buffer.readLine()) != null) {
if( line.contains(name) ) {
while( line.contains(" ") ) {
line = line.substring(line.indexOf(" ")+1);
}
this.infoClass.setName(line.substring(0, line.length()-1));
}
else if( line.contains(method)) {
line = line.substring(method.length()+1);
String access = line.substring(0,line.indexOf(' '));
line = line.substring(access.length()+1);
String name;
name = line.substring(0,line.indexOf(')')+1);
if( name.equals(mstatic)) {
access += " ";
access += mstatic;
line = line.substring(mstatic.length()+1);
name = line.substring(0,line.indexOf(')')+1);
}
this.infoClass.addMethod(name, access);
}
else if( line.contains(field)) {
line = line.substring(field.length()+1);
String access = line.substring(0,line.indexOf(' '));
line = line.substring(access.length()+1);
if( line.contains(mstatic) ) {
access += " ";
access += mstatic;
line = line.substring(mstatic.length()+1);
}
String name = line.substring(0,line.indexOf(':'));
String type = line.substring(line.indexOf(':')+1);
this.infoClass.addField(name, access, type);
}
}
} catch (IOException e) {
e.printStackTrace();
}
} | 8 |
public void mouseMoved(MouseEvent e) {
} | 0 |
public final int getMethodIndex(String originalName, Class[] argTypes)
throws NoSuchMethodException
{
Method[] mthds = getReflectiveMethods();
for (int i = 0; i < mthds.length; i++) {
if (mthds[i] == null)
continue;
// check name and parameter types match
if (getMethodName(i).equals(originalName)
&& Arrays.equals(argTypes, mthds[i].getParameterTypes()))
return i;
}
throw new NoSuchMethodException("Method " + originalName
+ " not found");
} | 4 |
public void majInfos() {
int i;
int nb;
try {
i = territoire.getOccupant().getJoueur().getIndice();
}
catch (Exception e) {
i = Game.JOUEUR_BACKGROUND.length - 1;
}
nb = territoire.getNbUnite();
if( territoire.getOccupant() != null && territoire.getOccupant().isEnDeclin() ){
tx.setBackground(Game.JOUEUR_BACKGROUND_DECLIN[i]);
}else{
tx.setBackground(Game.JOUEUR_BACKGROUND[i]);
}
tx.setForeground(Game.JOUEUR_FOREGROUND[i]);
tx.setText(nb + "");
} | 3 |
public void setAspect(String s) throws ADataException{
if (s == null) throw new ADataException();
if (!(isValidAspect(s) || s.equals(DOUBT))) throw new ADataException();
this.aspect = s;
} | 3 |
boolean SOUTHdiagnoalHasCraftedBlock(Location startLocation)
{
boolean res = false;
// Check SOUTH 45 degrees =========================================================
// Check if there is a valid crafted ceiling block in 45 degrees upwards to the player within given distance
Location checkedLoc = new Location(startLocation.getWorld(), startLocation.getX(), startLocation.getY(), startLocation.getZ());
// set start of check to the block 45 degrees above players head in checked direction
checkedLoc.setY(checkedLoc.getY() + 2);
checkedLoc.setZ(checkedLoc.getZ() + 1);
int checkLimitY = (int)checkedLoc.getY() + Arctica.checkRadius;
for(int checkedLocY = (int)checkedLoc.getY(); checkedLocY <= checkLimitY; checkedLocY++, checkedLoc.setY(checkedLoc.getY() + 1), checkedLoc.setZ(checkedLoc.getZ() + 1)) // go one block up and SOUTH
{
//if(Arctica.debug) plugin.getServer().broadcastMessage(ChatColor.AQUA + "Gecheckt: " + checkedLoc.getBlock().getX() + " " + checkedLoc.getBlock().getY() + " " + checkedLoc.getBlock().getZ());
if (!checkedLoc.getBlock().isEmpty())
{
if(craftedBlocksIDlist.contains(checkedLoc.getBlock().getTypeId())) // its a valid crafted block
{
//if(Arctica.debug) plugin.getServer().broadcastMessage(ChatColor.AQUA + "SOUTH_TOP45 Block gefunden: " + checkedLoc.getBlock().getType().toString());
res = true;
break;
}
}
}
return (res);
} | 3 |
@Override
public void mouseClicked(MouseEvent e)
{
if (SwingUtilities.isLeftMouseButton(e))
{
if (e.getComponent().equals(circle))
{
square.setSelected(false);
ground.setSelected(false);
if (circle.isSelected())
{
pModel.setProperty(PRP_OBJECT_MODE, OBJ_CIRCLE);
}
else
{
pModel.setProperty(PRP_OBJECT_MODE, null);
}
}
else if (e.getComponent().equals(square))
{
circle.setSelected(false);
ground.setSelected(false);
if (square.isSelected())
{
pModel.setProperty(PRP_OBJECT_MODE, OBJ_SQUARE);
}
else
{
pModel.setProperty(PRP_OBJECT_MODE, null);
}
}
else if (e.getComponent().equals(ground))
{
circle.setSelected(false);
square.setSelected(false);
if (ground.isSelected())
{
pModel.setProperty(PRP_OBJECT_MODE, OBJ_GROUND);
}
else
{
pModel.setProperty(PRP_OBJECT_MODE, null);
}
}
}
} | 7 |
private void doExchangeBasket() throws InterruptedException {
int memberCount = otapiJNI.OTAPI_Basic_Basket_GetMemberCount(assetID);
boolean bSure = true;
if (otapiJNI.OTAPI_Basic_GetNym_TransactionNumCount(serverID, nymID) < (2+memberCount)) {
bSure = Helpers.getTransactionNumbers(serverID, nymID);
}
if (!bSure || otapiJNI.OTAPI_Basic_GetNym_TransactionNumCount(serverID, nymID) < (2+memberCount)) {
System.out.println("IN doExchangeBasket , failed to get transaction numbers, OT_API_GetNym_TransactionNumCount:" + otapiJNI.OTAPI_Basic_GetNym_TransactionNumCount(serverID, nymID));
return;
}
OpenTransactionAccount otAccount = new OpenTransactionAccount();
String exchangeRequest = otAccount.getExchangeBasketRequest(serverID, nymID, assetID, accountID, Integer.parseInt(jTextField1.getText()));
for (int i = 0; i < memberCount; i++) {
String memberAssetID = otapiJNI.OTAPI_Basic_Basket_GetMemberType(assetID, i);
System.out.println("In doExchangeBasket,memberAssetID:" + memberAssetID + " assetID:" + assetID + " nymID:" + nymID + " serverID:" + serverID);
new ExchangeBasketAcctDialog(null, true, memberAssetID, serverID, nymID).setVisible(true);
if (Helpers.isBasketXCancelled()) {
Helpers.setBasketXCancelled(false);
JOptionPane.showMessageDialog(null, "The basket exchange has been cancelled", "Basket Exchange Canellation", JOptionPane.INFORMATION_MESSAGE);
return;
}
String memberAccountID = Helpers.getBasketXAcct();
exchangeRequest = otapiJNI.OTAPI_Basic_AddBasketExchangeItem(serverID, nymID, exchangeRequest, memberAssetID, memberAccountID);
}
String xchangeType = inXchange == true ? "IN" : "OUT";
if (!otAccount.exchangeBasket(assetID, serverID, nymID, exchangeRequest, inXchange, memberCount, accountID)) {
JOptionPane.showMessageDialog(null, "Exchange basket failed", "Server Error", JOptionPane.ERROR_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, xchangeType + " Exchange of basket currency done successfully", "Basket Exchange Success", JOptionPane.INFORMATION_MESSAGE);
}
} | 7 |
private Server serverStart(int firstPort) throws IOException {
int port, tries;
if (firstPort < 0) {
port = FreeCol.getDefaultPort();
tries = 10;
} else {
port = firstPort;
tries = 1;
}
logger.finest("serverStart(" + firstPort + ") => " + port
+ " x " + tries);
for (int i = tries; i > 0; i--) {
try {
server = new Server(this, port);
this.port = port;
server.start();
break;
} catch (BindException be) {
if (i == 1) {
logger.log(Level.WARNING, "Bind exception starting server.",
be);
throw new IOException(be.getMessage());
}
} catch (IOException ie) {
if (i == 1) {
logger.log(Level.WARNING, "IO exception starting server.",
ie);
throw ie;
}
}
port++;
}
return server;
} | 6 |
@Override
public Object getValueAt(int row, int col)
{
{
ProductionOrder po = Porder.get(row);
switch (col)
{
case 0:
return po.getID();
case 1:
return po.getPOrder();
case 2:
return po.getDueDate();
case 3:
return po.getQuantity();
case 4:
return po.getWidth();
case 5:
return po.getSleeveID();
// case 6:
// return po.isIsDone();
// case 7:
// return po.getUsedTime();
}
return null;
}
} | 6 |
public String strStr(String haystack, String needle) {
if (haystack == null || haystack.length() == 0) {
if (needle == null || needle.length() == 0) {
return haystack;
}
return null;
}
char[] s = haystack.toCharArray(), p = needle.toCharArray();
int[] next = makeSunday(p);
for (int i = 0; i <= s.length - p.length; ) {
int l = p.length - 1;
while (l >= 0 && s[i + l] == p[l]) {
l --;
}
if (l < 0) {
return String.valueOf(s, i, s.length - i);
}
if (i >= s.length - p.length) {
break;
}
i += next[s[i + p.length] - 'a'];
}
return null;
} | 9 |
public void start() {
try {
preStartup();
running = true;
long lr = System.currentTimeMillis();
long lu = lr;
while (isRunning()) {
boolean updated = false;
if (shouldUpdate(lu)) {
int d = (int) (System.currentTimeMillis() - lu);
lu = System.currentTimeMillis();
update(d);
updated = true;
}
if ((updated && renderAfterUpdate) || shouldRender(lr)) {
int d = (int) (System.currentTimeMillis() - lr);
lr = System.currentTimeMillis();
render(d);
}
window.update();
}
} catch (Exception e) {
handleError(e);
} finally {
shutdown();
}
} | 6 |
public static double asec(double a){
if(a<1.0D && a>-1.0D) throw new IllegalArgumentException("asec argument (" + a + ") must be >= 1 or <= -1");
return Math.acos(1.0/a);
} | 2 |
@Override
protected List< ? extends Component> createBrickComponents() {
List<Component> components = new ArrayList<Component>();
JPanel wrapper = new JPanel();
String tooltip = getTooltip();
// label
if ( control.getLabel() != null ) {
label = new JLabel();
label.setName(getName()+"/label");
label.setText( control.getLabel() );
if ( tooltip != null ) label.setToolTipText( tooltip );
components.add(label);
}
/*
//TODO: implement horiz/vert orientation for Swing
if ( ((RadioButtonListT) control).getOrientation() != null &&
PanelOrientationT.VERTICAL.equals( ((RadioButtonListT) control).getOrientation() ) )
{
c.setLayout( new GridLayout( 1, false ) );
} else {
RowLayout rl = new RowLayout();
rl.wrap = false;
c.setLayout( rl );
}
*/
// radioButton
for ( ListItemT listItem : ( (RadioButtonListT) control ).getListItem() )
{
JRadioButton radioElement = new JRadioButton();
radioElement.setName(getName()+"/button/"+listItem.getEnumID());
radioElement.setText( listItem.getUiRep() );
if ( parameter != null )
{
for ( EnumPairT enumPair : parameter.getEnumPair() )
{
if ( enumPair.getEnumID() == listItem.getEnumID() )
{
radioElement.setToolTipText( enumPair.getDescription() );
break;
}
}
}
else
{
radioElement.setToolTipText( tooltip );
}
group.add( radioElement );
buttons.add( radioElement );
wrapper.add( radioElement );
}
// set initValue (Note that this has to be the enumID, not the
// wireValue)
// set initValue
if ( ControlHelper.getInitValue( control, getAtdl4jOptions() ) != null )
setValue( (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ), true );
components.add(wrapper);
return components;
} | 8 |
@Override
public final int getCounterwidth() {
return (int)Math.ceil(Calc.log(getMax()+1,2));
} | 0 |
private void load() {
// Load main model, if file is present
boolean haveOldData = false;
File file = settings.getStaticFile();
try {
FileInputStream reader = new FileInputStream(file);
XmlModelAdapter xml = new XmlModelAdapter();
xml.readModel(reader, model);
reader.close();
haveOldData = true;
} catch (FileNotFoundException e) {
System.err.println("Initial data file " + file
+ " is not found. Starting empty.");
} catch (IOException e) {
e.printStackTrace();
}
if (haveOldData) {
file = settings.getStatusFile();
try {
FileReader reader = new FileReader(file);
StatusFileModelAdapter adap = new StatusFileModelAdapter();
adap.updateStatuses(reader, model);
reader.close();
} catch (FileNotFoundException e) {
System.err.println("Status file " + file
+ " is not found. Assuming UNKNOWN for everything.");
} catch (IOException e) {
e.printStackTrace();
}
}
courses = new ArrayList<CourseRec>(model.getCourses(source));
Collections.sort(courses, new Comparator<CourseRec>() {
@Override
public int compare(CourseRec o1, CourseRec o2) {
return o1.getName().compareTo(o2.getName());
}
});
currentIndex = 0;
} | 5 |
private void deleteTeam()
{
clear();
System.out.println("Delete Team:");
System.out.println();
try
{
int matchCount = matchmgr.showCount();
int teamCount = teammgr.showCount();
int maxMatchID = matchmgr.maxMatchId();
ArrayList<Team> teams = teammgr.listAll();
printShowHeader();
for (Team t : teams)
{
System.out.println(t);
}
System.out.print("Select Team id: ");
int id = new Scanner(System.in).nextInt();
Team team = teammgr.getById(id);
if (team != null)
{
removePoints(id);
teammgr.deleteFromTeamAndMatch(id);
}
else
{
System.out.println("Team does not exist!");
}
}
catch (Exception e)
{
System.out.println(" ERROR - " + e.getMessage());
}
pause();
} | 3 |
@Override
public void dispose() {
display.dispose();
while(display.isCreated()) {
try {
Thread.sleep(100);
} catch(final InterruptedException e) {
}
}
stop();
super.dispose();
System.exit(0);
} | 2 |
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.