method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
---|---|---|
cc622f1a-9c09-4082-af61-5d99e2afe06e | 3 | private void queryTable(String tableName) throws SQLException {
if (conn != null)
{
PreparedStatement stmt = conn.prepareStatement(String.format("SELECT * FROM %s", tableName));
ResultSet rs = stmt.executeQuery();
while (rs.next())
{
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++)
{
System.out.println(rs.getMetaData().getColumnName(i) + "\t" + rs.getString(i));
}
}
}
} |
e41fa2ac-541d-43f4-bbb7-91fa08fb8245 | 2 | @Override
public void startSetup(Attributes atts) {
setText(atts.getValue(A_TEXT));
String mnemonic = atts.getValue(A_MNEMONIC);
if (mnemonic != null && mnemonic.length() > 0) {
mnemonic = mnemonic.trim().toUpperCase();
int mnemonicInt = mnemonic.charAt(0);
setMnemonic(mnemonicInt);
}
Outliner.menuBar.add(this);
Outliner.menuBar.revalidate();
} |
6b969a16-0644-4ca6-94d0-d099b466be17 | 4 | protected synchronized void processEvent(Sim_event ev)
{
switch ( ev.get_tag() )
{
case GridSimTags.PKT_FORWARD:
case GridSimTags.JUNK_PKT:
processNetPacket( ev, ev.get_tag() );
break;
case GridSimTags.ROUTER_AD:
receiveAd(ev);
break;
case GridSimTags.SCHEDULER_DEQUE:
this.dequeue(ev);
break;
default:
System.out.println(super.get_name() + ".body(): Unable to " +
"handle request from GridSimTags " +
"with constant number " + ev.get_tag() );
break;
}
} |
5516ea34-8587-4ec8-8324-af89025bdac4 | 6 | public static void main(String[] args) {
File f = new File("files/readme.txt");
BufferedReader reader = null;
BufferedWriter out = null;
int recuento = 0;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(f)));
String line = reader.readLine();
while (line != null) {
recuento = recuento + line.length();
line = reader.readLine();
}
System.out.println("Voy a guardar el valor " + recuento);
out = new BufferedWriter(new FileWriter("files/registro.txt", true));
Date fecha = new Date();
DateFormat hourdateFormat = new SimpleDateFormat(
"HH:mm:ss dd/MM/yyyy");
out.write("\n" + hourdateFormat.format(fecha) + " " + recuento);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (reader != null)
reader.close();
if (out != null)
out.close();
} catch (IOException e) {
}
}
} |
f4573cd9-4a3b-4aa6-be6a-ac6a1fe5baee | 9 | public Object getSelectedItem(Object component) {
String classname = getClass(component);
if ((classname == "combobox") || (classname == "tabbedpane")) {
int index = getInteger(component, "selected",
(classname == "combobox") ? -1 : 0);
return (index != -1) ? getItemImpl(component, ":comp", index) : null;
}
if ((classname == "list") || (classname == "table") || (classname == "tree")) {
for (Object item = findNextItem(component, classname, null); item != null;
item = findNextItem(component, classname, item)) {
if (getBoolean(item, "selected", false)) { return item; }
}
return null;
}
throw new IllegalArgumentException(classname);
} |
bf7fd652-aacd-4709-8b26-f69ff9c86c61 | 9 | public static void changeData(String c_id,String c_pw, String c_name, String c_email, String c_phone, String path)
{
Connection conn = null;
FileInputStream fis = null;
PreparedStatement psmt =null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://" + Server.DBIP + ":3306/po_tweeter", "POMA", "9353");
String sql = "update member set pw = ? where id =?";
psmt = conn.prepareStatement(sql);
psmt.setString(1,c_pw);
psmt.setString(2, c_id);
psmt.executeUpdate();
sql = "update member set name=? where id=?";
psmt = conn.prepareStatement(sql);
psmt.setString(1, c_name);
psmt.setString(2, c_id);
psmt.executeUpdate();
sql = "update member set email=? where id=?";
psmt = conn.prepareStatement(sql);
psmt.setString(1, c_email);
psmt.setString(2, c_id);
psmt.executeUpdate();
sql = "update member set phone=? where id=?";
psmt = conn.prepareStatement(sql);
psmt.setString(1, c_phone);
psmt.setString(2, c_id);
psmt.executeUpdate();
sql = "update member set photo=? where id=?";
psmt = conn.prepareStatement(sql);
fis = new FileInputStream(path);
psmt.setBinaryStream(1, fis);
psmt.setString(2, c_id);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO ڵ catch
e.printStackTrace();
}
finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (psmt != null) {
try {
psmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} |
f9995319-8cc1-40e1-a4a9-1b8079e28cbb | 8 | final public void Block_statement() throws ParseException {
/*@bgen(jjtree) Block_statement */
SimpleNode jjtn000 = new SimpleNode(JJTBLOCK_STATEMENT);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
Statement();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
jjtn000.jjtSetLastToken(getToken(0));
}
}
} |
65ad98a5-f7fe-4f28-9eea-b25dbdad7d0b | 3 | public static void sort(long []arr){
int k=0;
long tmp = 0;
for(int i=0;i<arr.length;i++){
k = i;
for(int j=i;j<arr.length;j++){
if(arr[j] < arr[k]){
k = j;
}
}
tmp = arr[i];
arr[i] = arr[k];
arr[k] = tmp;
}
} |
b258938f-0ebb-454d-a280-0e69b912e031 | 7 | public static String setOfSequencesToString(FastVector setOfSequences, Instances dataSet, FastVector filterAttributes) {
StringBuffer resString = new StringBuffer();
Enumeration SequencesEnum = setOfSequences.elements();
int i = 1;
boolean printSeq;
while(SequencesEnum.hasMoreElements()) {
Sequence seq = (Sequence) SequencesEnum.nextElement();
Integer filterAttr = (Integer) filterAttributes.elementAt(0);
printSeq = true;
if (filterAttr.intValue() != -1) {
for (int j=0; j < filterAttributes.size(); j++) {
filterAttr = (Integer) filterAttributes.elementAt(j);
FastVector seqElements = seq.getElements();
if (printSeq) {
for (int k=0; k < seqElements.size(); k++) {
Element currentElement = (Element) seqElements.elementAt(k);
int[] currentEvents = currentElement.getEvents();
if (currentEvents[filterAttr.intValue()] != -1) {
continue;
} else {
printSeq = false;
break;
}
}
}
}
}
if (printSeq) {
resString.append("[" + i++ + "]" + " " + seq.toNominalString(dataSet));
}
}
return resString.toString();
} |
ede81bef-a73b-408e-b28e-fcd7cfb538a2 | 5 | public static void displayResults(Event event) {
int size = loserStack.size();
for (int i = 0; i < size; i++) {
Team team = (Team) loserStack.pop();
if (i > 2) {
System.out.println(i + 1 + "th:" + " "
+ team.olympian1.getName() + " "
+ team.olympian2.getName());
event.getPlacing()[i] = team;
} else if (i == 2) {
System.out.println("3rd:" + " " + team.olympian1.getName()
+ " " + team.olympian2.getName());
event.getPlacing()[i] = team;
} else if (i == 1) {
System.out.println("2nd:" + " " + team.olympian1.getName()
+ " " + team.olympian2.getName());
event.getPlacing()[i] = team;
} else if (i == 0) {
System.out.println("1st:" + " " + team.olympian1.getName()
+ " " + team.olympian2.getName());
event.getPlacing()[i] = team;
}
}
} |
27739a82-d776-4390-9ba8-079a06c5a7ef | 5 | private StoreInstruction getExceptionStore(StructuredBlock catchBlock) {
if (!(catchBlock instanceof SequentialBlock)
|| !(catchBlock.getSubBlocks()[0] instanceof InstructionBlock))
return null;
Expression instr = ((InstructionBlock) catchBlock.getSubBlocks()[0])
.getInstruction();
if (!(instr instanceof StoreInstruction))
return null;
StoreInstruction store = (StoreInstruction) instr;
if (!(store.getLValue() instanceof LocalStoreOperator && store
.getSubExpressions()[1] instanceof NopOperator))
return null;
return store;
} |
91827aee-a93b-4bf0-8704-d2b4b4d10923 | 8 | public void loadRestrictions() {
// Clear res.
restrictions.clear();
List<String> items = plugin.getConfigHandler().getRestrictedItems();
int count = 0;
// For every name included in the config, do some things
for (String item : items) {
Restriction r = new Restriction();
int itemID = plugin.getConfigHandler().getItemID(item);
int dataValue = plugin.getConfigHandler().getDataValue(item);
if (itemID < 0) {
continue;
}
@SuppressWarnings("deprecation")
ItemStack itemStack = new ItemStack(itemID, 1, (short) dataValue);
// Set item id
r.setItemID(itemID);
// For every action, store their requirements.
for (actionType action : actionType.values()) {
List<RequirementType> reqTypes = plugin.getConfigHandler().getRequirementStrings(item, action);
List<Requirement> requirements = new ArrayList<Requirement>();
// Get all requirements
for (RequirementType reqType : reqTypes) {
Requirement requirement = plugin.getRequirementManager().createRequirement(reqType);
if (requirement != null) {
// Set the description of the requirement (from the
// restrictions.yml)
requirement.setDescription(plugin.getConfigHandler().getDescription(item, action, reqType));
// Setup this requirement with the proper options.
boolean result = requirement
.setOptions(plugin.getConfigHandler().getRequirementValues(itemStack, action, reqType));
if (!result) {
plugin.logMessage(ChatColor.RED + "The requirement value of '" + reqType.toString()
+ "' for the item '" + item + "' is not valid!");
continue; // Skip this requirement.
}
requirements.add(requirement);
} else {
plugin.logMessage(ChatColor.RED + "Requirement '" + reqType + "' for item '" + item + "' is not valid!");
}
}
r.setRequirements(action, requirements);
}
if (dataValue >= 0) {
r.setDataValue(dataValue);
}
List<String> disabledWorlds = plugin.getConfigHandler().getDisabledWorlds(itemStack);
// Add disabled worlds
for (String world : disabledWorlds) {
r.addDisabledWorld(world);
}
// Save this restriction
restrictions.add(r);
count++;
}
plugin.debugMessage("Loaded " + count + " restrictions!");
} |
6a5a0107-9487-4acf-a37f-035a6682c120 | 8 | private static void addSomeMetadata( OtuWrapper wrapper,
String inFile, String outFile, boolean rOutput )
throws Exception
{
HashMap<String, PatientMetadata> metaMap =
PatientMetadata.getAsMap();
HashMap<String, NewBiomarkerParser> bioMarkerMetaMap =
NewBiomarkerParser.getMetaMap();
//System.out.println(outFile);
BufferedReader reader = new BufferedReader(new FileReader(new File(
inFile)));
BufferedWriter writer = new BufferedWriter(new FileWriter(
outFile));
writer.write("sample\t" +
"run\tstoolOrSwab\tsubjectID\tgenotype\ttreatment\ttype\ttime\t" +
"bax_overall\tbax_surface\tbax_bottom\tbax_overall_quant\tbax_surface_quant\tbax_bottom_quant\t" +
"numSequencesPerSample\tunrarifiedRichness\tshannonDiversity\tshannonEveness");
if( rOutput)
{
writer.write("\t" + reader.readLine().replaceAll("\"", "") + "\n");
}
else
{
String[] lineSplits = reader.readLine().split("\t");
for( int x=1; x < lineSplits.length; x++ )
{
writer.write("\t" + lineSplits[x]);
}
writer.write("\n");
}
for(String s= reader.readLine(); s != null; s = reader.readLine())
{
String[] splits = s.split("\t");
String sampleKey = splits[0].replaceAll("\"", "");
String sampleID = sampleKey.split("_")[0];
if( metaMap.get(sampleID) != null )
{
writer.write(sampleKey + "\t");
writer.write(sampleKey.split("_")[1] + "\t");
if( sampleKey.startsWith("ST"))
writer.write("stool\t");
else if ( sampleKey.startsWith("SW"))
writer.write("swab\t");
else throw new Exception(" NO " );
writer.write(metaMap.get(sampleID).getStudyID() + "\t");
writer.write(metaMap.get(sampleID).getGenotype() + "\t");
writer.write(metaMap.get(sampleID).getTreatment()+ "\t");
writer.write(metaMap.get(sampleID).getType()+ "\t");
String type = metaMap.get(sampleID).getType();
String timepoint = getTimePoint(type);
writer.write(timepoint + "\t");
String bioKey = metaMap.get(sampleID).getStudyID() + "_" + getLookupTime(type);
NewBiomarkerParser nbp = bioMarkerMetaMap.get(bioKey);
/*
* private final Integer bax_overall;
private final Integer bax_surface;
private final Integer bax_bottom;
private final Double bax_overall_quant;
private final Double bax_surface_quant;
private final Double bax_bottom_quant;
*/
//"bax_overall\tbax_surface\tbax_bottom\tbax_overall_quant\tbax_surface_quant\tbax_bottom_quant\t
if( nbp != null)
{
writer.write(nbp.getBax_overall() + "\t" + nbp.getBax_surface() + "\t" + nbp.getBax_bottom() + "\t" +
getValueOrNA(nbp.getBax_overall_quant()) + "\t"
+ getValueOrNA(nbp.getBax_surface_quant()) + "\t" + getValueOrNA(nbp.getBax_bottom_quant()) + "\t");
System.out.println("Found " + bioKey );
}
else
{
writer.write("NA"+ "\t" + "NA"+ "\t" + "NA"+ "\t" +
"NA"+ "\t" + "NA"+ "\t" + "NA"+ "\t");
System.out.println("Could not find " + bioKey );
}
writer.write( wrapper.getCountsForSample(sampleKey) + "\t");
writer.write(wrapper.getRichness(sampleKey) + "\t");
writer.write(wrapper.getShannonEntropy(sampleKey) + "\t" );
writer.write(wrapper.getEvenness(sampleKey) + "" );
String[] lineSplits = s.split("\t");
for( int x=1; x < lineSplits.length; x++)
writer.write("\t" + lineSplits[x]);
writer.write("\n");
}
}
writer.flush(); writer.close();
reader.close();
} |
5def3196-421b-44be-9d3f-dafa394b22f8 | 4 | public boolean isOutOfCellBounds()
{
boolean out = false;
switch (direction) {
case 0:
out = (int)y <= (row - 1) * pixels + pixels / 2;
break;
case 1:
out = (int)x >= (column + 1) * pixels + pixels / 2;
break;
case 2:
out = (int)y >= (row + 1) * pixels + pixels / 2;
break;
case 3:
out = (int)x <= (column - 1) * pixels + pixels / 2;
break;
}
return out;
} |
d2da0f9b-f0c2-4e38-9e3e-5bac4911fe37 | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Teacher other = (Teacher) obj;
if (!Objects.equals(this.getName(), other.getName())) {
return false;
}
if (!Objects.equals(this.getAge(), other.getAge())) {
return false;
}
return true;
} |
9cdfcbe3-12f2-4a54-93e7-644d4f27e2e8 | 3 | @Override
public int compareTo(Edge o) {
if(this==o){ return 0; }
if(this.weight==o.weight){
return 0;
}
if(this.weight>o.weight){
return 1;
} else {
return -1;
}
} |
b7d13eb9-cdd3-435f-9ac2-3fe4a57fa7d5 | 2 | public void lisaaSeuraavaArvollinen(Arvollinen arvollinen)
throws IllegalArgumentException, IllegalStateException {
if (arvollinen == null) {
throw new IllegalArgumentException();
}
if (seuraavaArvollinen != null) {
throw new IllegalStateException();
}
this.seuraavaArvollinen = arvollinen;
} |
dd4b03ba-5f8d-48a4-a853-8648e76e8665 | 8 | static String filterZinOfWoord(String reeks) {
for(int i = 0; i < reeks.length(); i++) {
char temp = reeks.charAt(i);
String temp2 = Character.toString(temp);
if(reeks.charAt(i) > 31 && reeks.charAt(i) < 65)
reeks = reeks.replace(temp2," ");
else if(reeks.charAt(i) > 90 && reeks.charAt(i) < 97)
reeks = reeks.replace(temp2," ");
else if(reeks.charAt(i) > 122 && reeks.charAt(i) < 127)
reeks = reeks.replace(temp2," ");
}
for(int i = 0; i < reeks.length(); i++)
reeks = reeks.replace(" ","");
reeks = omzettenHoofdletter(reeks);
System.out.println("Gefilterde invoer: " + reeks);
return reeks;
} |
02629cfa-48b2-43b6-8921-4471175da917 | 9 | public void actionPerformed(ActionEvent e) {
if(e.getSource() == login_but)
{
if (login.getText().length() != 0 &&
password.getPassword().length != 0)
{
String pass = CallbackConstants.toMD5_String(password.getPassword().toString());
String log = login.getText();
try {
int callback = server.Sign_in(log, pass, me);
switch (callback)
{
case CallbackConstants.AUTORISATION_ERROR:
JOptionPane.showMessageDialog(this, "ERROR: Authorisation error");
break;
case CallbackConstants.USER_ONLINE:
JOptionPane.showMessageDialog(this, "ERROR: User is already online");
break;
case CallbackConstants.GOOD:
JOptionPane.showMessageDialog(this, "ERROR: LOGGED IN");
if (server.Sign_out(log) == CallbackConstants.GOOD)
{
JOptionPane.showMessageDialog(this, "ERROR: LOGGED OUT");
}
else
{
JOptionPane.showMessageDialog(this, "ERROR: FAILED");
}
//...
break;
}
} catch (RemoteException e1) {
JOptionPane.showMessageDialog(this, "ERROR: Remote invocation error");
e1.printStackTrace();
}
}
else
{
JOptionPane.showMessageDialog(this, "ERROR: Enter your login and password please.");
}
}
else if (e.getSource() == register_but)
{
parent.ShowRegisterPane();
}
} |
b2dd7796-080e-486a-bf75-855fbc837573 | 9 | @Override
public boolean isDone(Game game)
{
//END Condition: there must be in the game:
// * exactly limit amount of sprites of type stype1
// * exactly subTypesNum number of subtypes of stype1
boolean ended = super.isFinished(game);
if(ended)
return true;
int countAcum = 0;
if(itype1 != -1) countAcum += game.getNumSprites(itype1) - game.getNumDisabledSprites(itype1);
if(countAcum == limit && canEnd) {
ArrayList<Integer> subtypes = game.getSubTypes(itype1);
int countAcumSubTypes = 0;
for (Integer subtype : subtypes) {
int count = (game.getNumSprites(subtype) - game.getNumDisabledSprites(subtype));
if(count > 0)
{
if(game.getSpriteGroup(subtype) != null) //This avoids non-terminal types
{
countAcumSubTypes += count > 0 ? 1 : 0;
}
}
}
if(countAcumSubTypes == subTypesNum) {
countScore(game);
return true;
}
}
return false;
} |
2065b628-1019-44bc-ab4a-2eb3ee2a64f5 | 3 | public static void main(String[] args){
System.out.println("_________________________________________________");
System.out.println("Welcome to the Innumeracy Math Library for Java demo!");
System.out.println("Choose from 1 of the following options:");
System.out.println("_________________________________________________");
System.out.println("A: Rounding to n decimal places");
System.out.println("B: Simplify surds (Surdify)");
System.out.println("C: Simplify fractions");
System.out.println("_________________________________________________");
Scanner sc = new Scanner(System.in);
switch(sc.nextLine().toLowerCase()){
case "a":
new RoundingExample();
break;
case "b":
new SurdifyExample();
break;
case "c":
new SimplifyExample();
break;
}
sc.close();
} |
6368204f-21e4-4808-b59d-44fcead461bc | 5 | public static void Prepare(Plugin plugin) {
MySQL.setPlugin(plugin);
SQLLogin = new File(plugin.getDataFolder() + File.separator + "MySQL.yml");
System.out.println("Filepath" + SQLLogin.getPath());
if (!SQLLogin.exists()) {
System.out.println("MySQL.yml was not found, Creating it");
System.out.println("Please configure MYSQL.YML in the plguins datafolder");
System.out.println("Plugin will disable now. Reboot the server when the file is configured");
try {
SQLLogin.createNewFile();
SQLConfig = YamlConfiguration.loadConfiguration(SQLLogin);
SQLConfig.set("User", "USERNAME");
SQLConfig.set("Pass", "PASSWORD");
SQLConfig.set("Url", "jdbc:mysql://localhost:3306/database");
SQLConfig.save(SQLLogin);
plugin.getPluginLoader().disablePlugin(plugin);
} catch (IOException e) {
System.out.println("Couldn't Generate MySQL.YML, Disabling");
plugin.getPluginLoader().disablePlugin(plugin);
}
} else {
SQLConfig = YamlConfiguration.loadConfiguration(SQLLogin);
if (SQLConfig.getString("User").equals("USERNAME") && SQLConfig.getString("User").equals("PASSWORD") && SQLConfig.getString("User").equals("jdbc:mysql://localhost:3306/database")) {
System.out.println("Loaded Configuration is still the default one. Disabling");
plugin.getPluginLoader().disablePlugin(plugin);
} else {
MySQL.User = SQLConfig.getString("User");
MySQL.Pass = SQLConfig.getString("Pass");
MySQL.Url = SQLConfig.getString("Url");
}
}
} |
e332913a-6142-4cd2-a14d-6cd0d37d5054 | 4 | public BoundMethod(Object self, Method method, Object[] parameters) {
this.self = self;
this.method = method;
this.parameters = parameters;
if (method != null && parameters != null) {
Class[] methodTypes = method.getParameterTypes();
if (methodTypes.length != parameters.length) {
throw new PatternException("Parameters don't match for `" + self.getClass() + "#" + method.getName() + "`");
}
for (int i = 0; i < parameters.length; i++) {
parameters[i] = Lubricant.apply(parameters[i], methodTypes[i]);
}
}
} |
755e6e6e-0a2e-40c9-ac95-b60abb496cf4 | 3 | @EventHandler
public void onPlayerCancelRoute(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
if (this.manager.isRouteCancelItem(item) && this.manager.isRoutePlayer(player)) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location loc = event.getClickedBlock().getLocation().add(0, 1, 0);
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
}
this.manager.stopRoute(player, false);
event.setCancelled(true);
}
} |
c518e8b6-87ab-464c-82f9-04f5586442a3 | 8 | protected void drawMixedMediaText(BufferedImage target, ArrayList<MixedMediaText> lines, ElementLayout elementLayout) {
Graphics2D g = (Graphics2D) target.getGraphics();
g.setFont(elementLayout.getFont());
g.setColor(elementLayout.getCardFont().getColor());
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
FontMetrics fm = g.getFontMetrics();
int actualHeight = fm.getAscent() - fm.getDescent();
int lineHeight = fm.getHeight();
int index = 0;
for (MixedMediaText mmt: lines) {
MarkupElement me;
int offset = 0;
int spaceWidth = fm.getStringBounds(" ", g).getBounds().width;
int textBottom = (elementLayout.getY() + elementLayout.getMarginY() + actualHeight) + (index * lineHeight);
// Debugging lines
if (ConfigHolder.getConfig("debug") != null) {
g.setColor(Color.GREEN);
g.drawLine(elementLayout.getX(), textBottom, elementLayout.getWidth(), textBottom);
g.setColor(Color.BLUE);
g.drawLine(elementLayout.getX(), textBottom - fm.getAscent(), elementLayout.getWidth(), textBottom - fm.getAscent());
g.setColor(Color.RED);
g.drawLine(elementLayout.getX(), textBottom - (fm.getAscent() - fm.getDescent()), elementLayout.getWidth(), textBottom - (fm.getAscent() - fm.getDescent()));
}
g.setColor(elementLayout.getCardFont().getColor());
while ((me = mmt.next()) != null) {
int startX;
switch (elementLayout.getAlign()) {
case "right":
startX = (elementLayout.getWidth() - elementLayout.getMarginX() - mmt.getWidth());
break;
case "center":
startX = elementLayout.getMarginX() + (elementLayout.getWidth() - mmt.getWidth())/2;
break;
case "left":
default:
startX = elementLayout.getMarginX();
break;
}
if (me instanceof TextInsert) {
TextInsert ti = (TextInsert)me;
CardFont cf = elementLayout.getCardFont();
Font f = new Font(cf.getFamily(), ti.getFontWeight(), cf.getSize());
g.setFont(f);
fm = g.getFontMetrics();
spaceWidth = fm.getStringBounds(" ", g).getBounds().width;
g.drawString(me.getText(), elementLayout.getX() + startX + offset, textBottom);
offset += fm.getStringBounds(me.getText(), g).getBounds().width + spaceWidth;
} else if (me instanceof ImageInsert) {
Resource r = cardLayout.getResource(me.getText());
Integer larger = Math.max(r.getHeight(), actualHeight);
Integer diff = Math.abs(r.getHeight() - actualHeight);
Integer correction = (int)Math.round((double)diff/2.0);
Integer imageDelta = larger - correction;
g.drawImage(r.getImage(), null, elementLayout.getX() + startX + offset, (textBottom - imageDelta));
offset += r.getWidth() + spaceWidth;
}
}
index++;
}
} |
b0a4e8fc-4f23-4e0f-9dcb-3b3368654765 | 0 | @Id
@GeneratedValue
public int getId() {
return id;
} |
9e475059-9b92-4dd5-b60e-a32af82be2cc | 4 | private void deleteItem()
{
String stock_num = null;
System.out.println("Type the stock number of the item you would like to delete from the cart.");
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
stock_num = br.readLine();
} catch (Exception e) {
System.out.println("error reading input");
}
Statement st = null;
ResultSet rs = null;
try {
st = custConn.getConnection().createStatement();
String qry = "select sc.stock_number from ShoppingCart sc where sc.stock_number = '" + stock_num + "'";
rs = st.executeQuery(qry);
if (rs.next() != false)
{
System.out.println("How much of this item do you want to decrease?");
Scanner in = new Scanner(System.in);
int decreaseNum = in.nextInt();
String checkQty = "select sc.quantity from ShoppingCart sc where sc.stock_number = '" + stock_num + "'";
rs = st.executeQuery(checkQty);
rs.next();
int actQty = rs.getInt("quantity");
if (actQty < decreaseNum)
{
String deleteRow = "delete from ShoppingCart sc where sc.stock_number = '" + stock_num + "'";
rs = st.executeQuery(deleteRow);
}
else
{
int updateNum = actQty - decreaseNum;
String updateRow = "update ShoppingCart sc set sc.quantity = " + Integer.toString(updateNum) + " where sc.stock_number = '" + stock_num + "'";
rs = st.executeQuery(updateRow);
}
}
else
System.out.println("Please enter a valid stock number");
}
catch (Exception e) {
System.out.println("Error");
}
} |
17cb909a-dd4d-430c-9a57-f5ae4861f77b | 7 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
Dijkstra G = new Dijkstra(101);
while ((line = in.readLine()) != null && line.length() != 0) {
int[] nk = readInts(line);
int[] cost = readInts(in.readLine());
G.init(101);
for (int i = 0; i < cost.length; i++)
G.cost[i] = cost[i];
int[][] s = new int[nk[0]][];
boolean[][] ss = new boolean[nk[0]][101];
for (int i = 0; i < nk[0]; i++) {
s[i] = readInts(in.readLine());
for (int a = 0; a < s[i].length; a++) {
ss[i][s[i][a]] = true;
for (int b = a + 1; b < s[i].length; b++)
G.union(s[i][a], s[i][b],
cost[i] * Math.abs(s[i][b] - s[i][a]), i, true);
}
}
if (G.dijkstra(0, nk[1]) == G.INF)
out.append("IMPOSSIBLE\n");
else
out.append(G.dis[nk[1]] + "\n");
}
System.out.print(out);
} |
7378a7a1-b696-4792-af79-6fed15aa7c6c | 6 | public int find(String string) {
if (string==null) {
return -1;
}
for (int i=0;i!=m_stringOffsets.length;++i) {
int offset=m_stringOffsets[i];
int length=getShort(m_strings,offset);
if (length!=string.length()) {
continue;
}
int j=0;
for (;j!=length;++j) {
offset+=2;
if (string.charAt(j)!=getShort(m_strings,offset)) {
break;
}
}
if (j==length) {
return i;
}
}
return -1;
} |
9925ea19-4aa4-4691-82f8-c9b7a9f489c3 | 0 | public byte getBiomeID(int x,int z){
return biomeID[x][z];
} |
e85de163-bbf3-42d8-8b25-ca0bec6a0dc3 | 8 | public ManagerArchivo() {
try {
escribirLog("[" + new Date() + "] INICIO DEL PROGRAMA");
FileReader fr = null;
BufferedReader br = null;
ArrayList<String> lineas = new ArrayList<String>();
fr = new FileReader(new File("estudio_juridico.conf"));
br = new BufferedReader(fr);
String temp = "";
while ((temp = br.readLine()) != null) {
char[] cad = temp.toCharArray();
int i = 0;
boolean flag = true;
String acu = "";
while (flag && i < temp.length()) {
if (cad[i] != '#') {
acu += cad[i];
} else {
flag = false;
}
i++;
}
if (acu.length() > 5) {
lineas.add(acu);
}
}
this.procesarCadena(lineas);
if (null != fr) {
fr.close();
}
} catch (Exception e) {
escribirLog("[" + new Date() + "] ERROR al abrir Archivo de Configuracion (estudio_juridico.conf)" + e.getMessage());
escribirLog("[" + new Date() + "] Programa Finalizado -> Revise archivo: \"estudio_juridico.conf\"");
} finally {
try {
} catch (Exception e2) {
escribirLog("[" + new Date() + "] ERROR al cerrar archivo de configuracion " + e2.getMessage());
}
}
} |
d7930775-10a9-47ba-8b5e-519bdef65a13 | 9 | public Command(String name, int numberOfArgs, String helpMessage) {
this.name = name;
this.numberOfArgs = numberOfArgs;
this.helpMessage = helpMessage;
commands.add(this);
} |
564b8ea9-b4a3-4893-891b-c915680fdbe8 | 6 | public void add(double value) {
if (Double.isNaN(value)) {
value = 0d;
}
Date now = new Date();
lastValue = value;
avg30Min += value;
last30Minutes.add(new Tuple<Date, Double>(new Date(), value));
if (last30Minutes.size() > 30) {
avg30Min -= first(last30Minutes).getSecond();
last30Minutes.remove(0);
}
if (last24Hours.isEmpty()) {
avg24h += value;
last24Hours.add(new Tuple<Date, Double>(now, value));
} else {
Tuple<Date, Double> l = last(last24Hours);
if (diff(l.getFirst(), now, TimeUnit.MINUTES) >= 30) {
double avg = 0.0;
for (Tuple<Date, Double> t : last30Minutes) {
avg += t.getSecond();
}
avg = avg / last30Minutes.size();
avg24h += avg;
last24Hours.add(new Tuple<Date, Double>(now, avg));
if (last24Hours.size() > 48) {
avg24h -= first(last24Hours).getSecond();
last24Hours.remove(0);
}
}
}
} |
00ac547c-0eeb-4176-9891-b0ed26134f4c | 7 | public void remove() {
if (this.root != null) {
FibonacciHeapNode beforeHighestPriority = this.root;
FibonacciHeapNode root = this.root.next;
if (root == null) {
this.root.tree.remove();
} else {
do {
if (beforeHighestPriority.tree.top().value.compareTo(root.tree.top().value) < 0) {
beforeHighestPriority = root;
}
root = root.next;
} while (root != null);
beforeHighestPriority.tree.remove();
if (beforeHighestPriority.tree.top() == null) {
beforeHighestPriority = beforeHighestPriority.next;
}
}
if (this.root.tree.top() == null && this.root.next != null) {
this.root = this.root.next;
}
merge(this.root);
}
} |
ab95f145-17be-4610-a21d-925ec6bdc3a8 | 6 | public static void run_spell_check(File dic, File doc, String option)
{
// Creating a new SpellCheckerUtil object with the dictionary file
SpellCheckUtil mySC = new SpellCheckUtil(dic);
// Creating a list of misspelled words after checking spellcheking the document
List<String> misspelledWords = mySC.spellCheck(doc);
if (misspelledWords.size() == 0)
System.out.println("\nThere are no misspelled words in file " + doc + ".\n");
else
{
System.out.println("\nThere are " + misspelledWords.size() + " misspelled words in file " + doc + ".");
if(option.equals("-p"))
{
for(String word : misspelledWords)
System.out.println(word);
}
else if(option.equals("-f"))
try
{
FileWriter writer = new FileWriter("misspelled.txt");
for(String word : misspelledWords)
writer.write(word + "\n");
writer.close();
System.out.println("Please see misspelled.txt for a list of the words.");
}
catch (IOException e)
{
System.out.println("Unable to create a file for the misspelled words!");
return;
}
System.out.println("\nHave a nice day!\n");
}
} |
7e422a16-762f-40c8-9345-5141c9cb5f2e | 3 | public int readMono(short[] outputArray) throws IOException {
if (this.nChannels == 1) {
return read(outputArray);
} else {
int len = outputArray.length;
short[] stereoArray = new short[len * 2];
int bytesRead = read(stereoArray);
for (int i = 0; i < len; i++) {
outputArray[i] = (short) ((short) (stereoArray[i * 2] + stereoArray[i * 2 + 1]) / 2);
}
if (bytesRead == -1)
return -1;
return bytesRead / 2;
}
} |
09429d3b-1194-4cab-a4f4-d413c5c7c4a7 | 3 | private void parseArgs(String[] args) {
if (args.length <= 1) throw new IllegalArgumentException("Not enough arguments.");
String targetFilename = args[0];
if (!targetFilename.endsWith(".zip")) throw new IllegalArgumentException("The target filename must end in .zip");
outFile = new TransactionalFileOutputStream(targetFilename, false);
//Store all of the given files in an array.
filesToWrite = new String[args.length - 1];
for (int i = 1; i < args.length; i++) {
filesToWrite[i - 1] = args[i];
}
} |
70d3fdd1-4e46-4c27-9af4-e393b67170aa | 1 | public void testConstructor_RI_RD5() throws Throwable {
DateTime dt = new DateTime(TEST_TIME_NOW);
Duration dur = new Duration(-1);
try {
new MutableInterval(dt, dur);
fail();
} catch (IllegalArgumentException ex) {}
} |
5e518d21-8796-449c-b8ce-8345d839fe83 | 9 | @Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
//g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//BACKGROUND
g2d.drawImage(fundo, pos.x, pos.y, largura, altura, null);
g2d.drawImage(fundo, pos.x, pos.y - altura + 1, largura, altura, this);
//NAVE
g2d.drawImage(nave.getTile().getSprite(), nave.getBounds().x, nave.getBounds().y, nave.getBounds().width, nave.getBounds().height, this);
g2d.setColor(Color.red);
if (Desenvolvedor) {
g2d.drawRect(nave.getBounds().x, nave.getBounds().y, nave.getBounds().width, nave.getBounds().height);
g2d.setColor(Color.BLUE);
g2d.draw(nave.getColider().forma);
g2d.setColor(Color.red);
g2d.fillOval(nave.getBounds().x + nave.getBounds().width / 2 - 5, nave.getBounds().y + nave.getBounds().height / 2 - 5, 10, 10);
}
//BALAS
List<Municao> municao = nave.getMunicao();
for (Municao bala : municao) {
g2d.drawImage(bala.getTile().getSprite(), bala.getBounds().x, bala.getBounds().y, this);
if (Desenvolvedor) {
g2d.setColor(Color.blue);
g2d.drawRect(bala.getBounds().x, bala.getBounds().y, bala.getBounds().width, bala.getBounds().height);
}
//se a bala sair da tela, deleta ela
if (bala.getBounds().y + bala.getBounds().height < 0) {
bala.setDelete(true);
}
}
for (Asteroide asteroide : asteroides) {
g2d.drawImage(asteroide.getTile().getSprite(), asteroide.getBounds().x, asteroide.getBounds().y, this);
if (asteroide.getHpBar().isAparece()) {
g2d.drawImage(asteroide.getHpBar().getSprite(), asteroide.getBounds().x, asteroide.getBounds().y + asteroide.getBounds().height, asteroide.getHpBar().getHp(), asteroide.getHpBar().getSprite().getHeight(this), this);
//DIMINUI O TEMPO QUE A BARRA DE VIDA APARECE NA TELA
asteroide.getHpBar().diminuiTempo(1);
if (asteroide.getHpBar().getTempo() == 0) {
asteroide.getHpBar().setAparece(false);
asteroide.getHpBar().setTempo(100);
}
}
if (Desenvolvedor) {
g2d.setColor(Color.BLUE);
g2d.draw(asteroide.getColider().forma);
g2d.setColor(Color.red);
g2d.drawRect(asteroide.getBounds().x, asteroide.getBounds().y, asteroide.getBounds().width, asteroide.getBounds().height);
}
//se o meteoro passar da tela, deleta ele e a thread
if (asteroide.getBounds().y > altura) {
asteroide.getColider().setDelete(true);
}
}
//BARRA DE HP
g2d.drawImage(nave.getHpBar().getSprite(), 9, 10, nave.getHpBar().getSprite().getWidth(this), nave.getHpBar().getSprite().getHeight(this), this);
g.dispose();
} |
0df03570-c731-42b1-83ba-a39c0e55d71c | 1 | private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
} |
3f8f20ef-5162-4cd0-a13b-9047a28d3cf9 | 7 | public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int number = 0;
List<Integer> factors = new ArrayList<Integer>();
try {
boolean success = false;
while (!success) {
try {
System.out.print("Please enter a number to see its factors: ");
number = scan.nextInt();
if (number > 1) {
success = true;
} else {
System.out.println("Your number needs to be positive and greater than 1");
}
} catch (java.util.InputMismatchException error) {
System.out.println("ERROR: '" + scan.next() + "' is not an integer");
}
}
} finally {
scan.close();
}
int working = number;
for (int i = 2; i < number; i++) {
while (working % i == 0) {
working = working / i;
factors.add(i);
}
}
if (factors.isEmpty()) {
System.out.println(number + " is prime");
} else {
System.out.print("The factors for " + number + " are: ");
StringBuilder out = new StringBuilder();
out.append(factors.get(0));
for (int i = 1; i < factors.size(); i++) {
out.append(" * ").append(factors.get(i));
}
System.out.println(out.toString());
}
} |
7e049506-e6b2-48d1-8752-3f26db0ffe25 | 5 | @Override
public List<E> insert(E d) {
if (this.isEmpty()) {
super.insert(d);
} else {
this.setFirst();
// New item is the smallest item so far
if (list.data.compareTo(d) > 0) {
insertFirst(d);
return this;
}
// Find the item where the new item should be placed after
while (list.next != null && list.next.data.compareTo(d) < 0) {
list = list.next;
}
if (this.list.next == null) {
// New item is the largest so far
insertLast(d);
} else {
insertInOrder(d);
}
}
return this;
} |
814bf755-d445-40dc-8496-5e4d3d93f6b0 | 4 | public static void addToEmptyTeam(Player player) {
if (blueMembers == null) {
blueMembers = player;
blueFriends.add(player);
} else if (greenMembers == null) {
greenMembers = player;
greenFriends.add(player);
} else if (orangeMembers == null) {
orangeMembers = player;
orangeFriends.add(player);
} else if (redMembers == null) {
redMembers = player;
redFriends.add(player);
} else {
System.out.println("ERROR: Could not assing " + player.toString()
+ " to an empty team.");
}
} |
4ca3c5d6-3809-4bcf-bba7-33d36580dd9a | 8 | private void digOut(final LayeredMap map,
Point p, Point dir, int range, Random rand)
{
if(range < 1) {
return;
}
// System.err.println("Digging " + range + " squares.");
final Point pos = new Point(p.x, p.y);
for(int x=0; x<range; x++) {
if(pos.x >= 1 && pos.y >= 1 && pos.x < map.getWidth() - 1 && pos.y < map.getHeight()-1) {
map.set(1, pos.x, pos.y, 0);
} else {
// we would run off map ...
return;
}
if(rand.nextInt(1000) < branchChance) {
final Point side = new Point(dir.x, dir.y);
if(rand.nextBoolean()) {
rot90l(side);
} else {
rot90r(side);
}
digOut(map, pos, side, range/4 + rand.nextInt(range/5+1), rand);
}
pos.x += dir.x;
pos.y += dir.y;
}
} |
515e3642-f415-431f-a002-61928501777e | 0 | public Secteur getSecteur() {
return secteur;
} |
ca5ea999-4d80-4d68-ac9d-e3d578dc317a | 0 | protected void addMenu() {
JMenuBar bar = new JMenuBar();
JMenu op = new JMenu("");
JMenu help = new JMenu("");
JMenuItem admin = new JMenuItem("¼û");
JMenuItem exit = new JMenuItem("˳");
JMenuItem author = new JMenuItem("");
admin.setActionCommand("admin");
exit.setActionCommand("exit");
author.setActionCommand("author");
admin.addActionListener(this);
exit.addActionListener(this);
author.addActionListener(this);
op.add(admin);
op.add(exit);
help.add(author);
bar.add(op);
bar.add(help);
this.setJMenuBar(bar);
} |
008c4faa-5284-4fa9-99e2-932c82a2887e | 7 | public void genLegalDestsSaveKing(Piece king, Piece threat)
{
if ((isBlack() ? mBoard.getGame().getBlackRules() : mBoard.getGame().getWhiteRules()).objectivePiece(isBlack()) == this)
return;
if (king == null)
return;
Iterator<Square> oldLegalDests = getLegalDests().iterator();
Square sq = null;
if (mIsCaptured)
return;
List<Square> legalDests = Lists.newArrayList();
setLegalDests(legalDests);
while (oldLegalDests.hasNext())
{
sq = oldLegalDests.next();
if (threat.isBlockable(sq, king))
getLegalDests().add(sq);
else if (sq.equals(threat.getSquare()))
getLegalDests().add(sq);
}
} |
d9b75369-ff8c-4422-8636-7f1fde503ee8 | 6 | public static void main (String[] args) {
System.out.println("MAX_INPUT: " + MAX_INPUT);
int numberOfNets = 100;
Net[] nets = new Net[numberOfNets];
int netLength, netWidth;
netLength = netWidth = 6;
for (int runs = 0; runs < numberOfNets; runs++) {
Net firstNet = new Net();
firstNet.generateNet(netLength, netWidth);
Net secondNet = new Net();
secondNet.generateNet(netLength, netWidth);
for (int i = 0; i < 5000; i++) {
double expectedOutput = 10 + (NeuralNets.generator.nextInt(300)*2);
double firstOut = firstNet.runNet(expectedOutput);
double secondOut = secondNet.runNet(expectedOutput);
double firstDelta = Math.abs(expectedOutput - firstOut);
double secondDelta = Math.abs(expectedOutput - secondOut);
//System.out.println("Expected: " + expectedOutput);
//System.out.println("\tGot: " + firstOut + " Delta: " + firstDelta);
//System.out.println("\tGot: " + secondOut + " Delta: " + secondDelta);
if ( secondDelta < firstDelta ) {
//System.out.println("Net dying, age of: " + firstNet.age);
firstNet = secondNet;
firstDelta = secondDelta;
firstOut = secondOut;
}
firstNet.reset();
firstNet.age++;
secondNet = firstNet.clone();
secondNet.mutate(-firstDelta);
}
nets[runs] = firstNet;
double out = firstNet.runNet(30);
System.out.println("In: 30, Out: " + out);
}
double closest = Double.MAX_VALUE;
Net closestNet = null;
for (Net net : nets) {
double expected = 30;
double out = net.runNet(expected);
double delta = Math.abs(expected - out);
if (delta < closest) {
closest = delta;
closestNet = net;
}
}
System.out.println("\n\n------RESULT-------");
for (int i = -100; i < 100; i += 10) {
System.out.println("In: " + i + ", Out: " + closestNet.runNet(i));
}
} |
7365b0be-0588-4f92-82aa-728773c99e13 | 4 | @Override
public void toString(String indent, StringBuilder buffer)
{
if (this.length == 0)
{
buffer.append("[]");
return;
}
if (this.subtype != TYPE_NBT)
{
buffer.append("[ ");
buffer.append(Array.get(this.array, 0));
for (int i = 1; i < this.length; i++)
{
buffer.append(", ").append(Array.get(this.array, i));
}
buffer.append(" ]");
return;
}
final NamedBinaryTag[] tags = (NamedBinaryTag[]) this.array;
buffer.append("[ ");
tags[0].toString(indent, buffer);
for (int i = 1; i < this.length; i++)
{
buffer.append(", ");
tags[i].toString(indent, buffer);
}
buffer.append(" ]");
} |
24518f0b-5bd9-4981-95e2-13800417f17c | 8 | private boolean cleverRandom (Square square, Human human, Mark mark) {
Mark humanMark = new Mark(human.getMark());
if (square.belongs(humanMark, '2', 'a') && square.belongs(humanMark, '1', 'b')) {
mark.setLeftCoord('1');
mark.setTopCoord('a');
square.putMark(mark);
return true;
}
if (square.belongs(humanMark, '1', 'b') && square.belongs(humanMark, '2', 'c')) {
mark.setLeftCoord('1');
mark.setTopCoord('c');
square.putMark(mark);
return true;
}
if (square.belongs(humanMark, '3', 'b') && square.belongs(humanMark, '2', 'c')) {
mark.setLeftCoord('3');
mark.setTopCoord('c');
square.putMark(mark);
return true;
}
if (square.belongs(humanMark, '3', 'b') && square.belongs(humanMark, '2', 'a')) {
mark.setLeftCoord('3');
mark.setTopCoord('a');
square.putMark(mark);
return true;
}
return false;
} |
8e702328-8dfd-485a-a743-69a567b30d31 | 4 | protected void setAttributesByShortcut(String shortcut, TimeBanBanCommand command) {
ConfigurationSection shortcuts = config.getConfigurationSection("shortcuts");
// configure reason
String reason = shortcuts.getConfigurationSection(shortcut).getString("reason");
if (reason == null || reason.isEmpty()) {
command.setReason(stdBanReason);
} else {
command.setReason(reason);
}
// configure duration
String durationRaw = shortcuts.getConfigurationSection(shortcut).getString("duration");
if (durationRaw == null || durationRaw.isEmpty()) {
command.setUntil(UntilStringParser.parse(stdBanDuration));
} else {
command.setUntil(UntilStringParser.parse(durationRaw));
}
} |
634ad516-0b16-4df6-8903-3bfd81b5aa71 | 4 | public static boolean importHover(double xPos,double yPos) {
int check = 0;
if((xPos > importXborderL) && (xPos < importXborderR))
check+=1;
if((yPos > importYborderT) && (yPos < importYborderB))
check+=1;
return check == 2;
} |
62971eb0-749c-4870-941b-5c475d8757bc | 5 | public static int doExecuteUpdate(String storedProcedure, ArrayList<String> arglist) throws DALException
{
try {
String prepCallParams = "";
for (int i=0; i<arglist.size(); i++)
prepCallParams += prepCallParams == "" ? "?" : ",?";
cstm = conn.prepareCall(" { CALL "+storedProcedure+"(" + prepCallParams + ") }");
int i = 1;
prepCallParams = "";
for (String arg : arglist)
{
cstm.setString(i, arg);
prepCallParams += prepCallParams == "" ? arg : ", "+ arg;
i++;
}
System.out.println("doExcuteUpdate: { CALL "+storedProcedure+"(" + prepCallParams + ") }");
return cstm.executeUpdate();
} catch (SQLException e) {
throw new DALException(e); // TODO: create JDialog for errors
}
} |
36c5fb39-d0c7-47da-a563-c9ca17f22035 | 6 | private void remplirHashMap(String key) {
ArrayList<Character> al=new ArrayList<Character>();
for(int i=0;i<key.length();i++) {
if(this.alpha.contains(key.charAt(i)+"")) {
al.add(key.charAt(i));
}
}
for(int i=0;i<ALPHABET.length();i++) {
if(!al.contains(ALPHABET.charAt(i)) && this.alpha.contains(ALPHABET.charAt(i)+"")) {
al.add(ALPHABET.charAt(i));
}
}
for(int i=0;i<al.size();i++) {
this.h.put(al.get(i), al.get(al.size()-i-1));
}
} |
4960501e-89ef-4a0a-94ed-d69de9e1cdda | 9 | public boolean equals(Object object) {
if (this == object) return true;
if (!(object instanceof CacheKey)) return false;
final CacheKey cacheKey = (CacheKey) object;
if (hashcode != cacheKey.hashcode) return false;
if (checksum != cacheKey.checksum) return false;
if (count != cacheKey.count) return false;
for (int i = 0; i < updateList.size(); i++) {
Object thisObject = updateList.get(i);
Object thatObject = cacheKey.updateList.get(i);
if (thisObject == null) {
if (thatObject != null) return false;
} else {
if (!thisObject.equals(thatObject)) return false;
}
}
return true;
} |
cdd54aa7-de76-4200-9e32-d6fd3be8e237 | 2 | public ShipUnlockPanel( FTLFrame frame ) {
this.setLayout( new BoxLayout(this, BoxLayout.Y_AXIS) );
this.frame = frame;
log.trace( "Creating Ship Unlock panel" );
log.trace("Adding ship unlocks");
JPanel shipPanel = new JPanel();
shipPanel.setLayout( new GridLayout(0, 3) );
shipPanel.setBorder( BorderFactory.createTitledBorder("Ship Unlocks") );
this.add( shipPanel );
for ( ShipBlueprint ship : DataManager.get().getPlayerShips() ) {
JCheckBox shipBox = new JCheckBox( ship.getShipClass() );
frame.setCheckboxIcons(shipBox, "img/ship/" + ship.getImg() + "_base.png");
shipBoxes.add(shipBox);
shipPanel.add(shipBox);
}
log.trace("Adding ship achievements");
JPanel shipAchPanel = new JPanel();
shipAchPanel.setLayout( new GridLayout(0, 3) );
shipAchPanel.setBorder( BorderFactory.createTitledBorder("Ship Achievements") );
this.add( shipAchPanel );
for ( ShipBlueprint ship : DataManager.get().getPlayerShips() )
shipAchPanel.add( createShipPanel( ship ) );
} |
c3beaffa-6e60-49cc-a6ee-6f5e8cabcc9f | 0 | public static Text getLabel(Graphics pen, Text text, String label)
{
Text temp = new Text(label);
double x = text.getPos().x + text.getWidth(pen) / 2 - temp.getWidth(pen) / 2;
double y = text.getPos().y - 2 * text.getHeight(pen);
temp.setPos(new Point2D.Double(x, y));
return temp;
} |
e00b4c67-331a-4527-9d37-6d4201bb481d | 4 | private Action getAction(String line) {
String[] lineSplitted = line.split(" ");
int second = Integer.parseInt(lineSplitted[0]);
String filePath = lineSplitted[2];
ActionsName a = ActionsName.valueOf(lineSplitted[ACTION_INDEX]);
Action action;
switch (a) {
case ADD:
String destPath = lineSplitted[3];
action = new Add(second, filePath, destPath);
break;
case REMOVE:
action = new Remove(second, filePath);
break;
case UPDATE:
ArrayList<ByteRange> ranges = new ArrayList<ByteRange>();
for (int i=3; i<lineSplitted.length; i+=2) {
int byteStart = Integer.parseInt(lineSplitted[i]);
int byteEnd = Integer.parseInt(lineSplitted[i+1]);
ByteRange range = new ByteRange(byteStart, byteEnd);
ranges.add(range);
}
action = new Update(second, filePath, ranges);
break;
default:
action = null;
}
return action;
} |
d572850e-54cd-49a6-bd23-31e43222320d | 6 | private boolean r_post_process_last_consonants() {
int among_var;
// (, line 415
// [, line 416
ket = cursor;
// substring, line 416
among_var = find_among_b(a_23, 4);
if (among_var == 0)
{
return false;
}
// ], line 416
bra = cursor;
switch(among_var) {
case 0:
return false;
case 1:
// (, line 417
// <-, line 417
slice_from("p");
break;
case 2:
// (, line 418
// <-, line 418
slice_from("\u00E7");
break;
case 3:
// (, line 419
// <-, line 419
slice_from("t");
break;
case 4:
// (, line 420
// <-, line 420
slice_from("k");
break;
}
return true;
} |
ade9b169-9d2b-4073-b9fd-e8b07e3790e6 | 2 | public void setEnabledEditorTagged(boolean enabled) {
for (int i = 0; i < tabbed.getTabCount(); i++) {
Component c = tabbed.getComponentAt(i);
if (((Tag) componentTags.get(c)) instanceof EditorTag)
tabbed.setEnabledAt(i, enabled);
}
} |
bea01567-da2d-448f-8f51-a16a8aca630b | 5 | private void btnRenameItemActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnRenameItemActionPerformed
{//GEN-HEADEREND:event_btnRenameItemActionPerformed
String thename = JOptionPane.showInputDialog(this, "Enter the new name for the item:", "WiiExplorer", JOptionPane.QUESTION_MESSAGE);
if (thename == null || thename.trim().isEmpty()) return;
if (thename.contains("/") || thename.contains("\\"))
{
JOptionPane.showMessageDialog(this, "Invalid name entered. It must not contain slashes.", "WiiExplorer", JOptionPane.ERROR_MESSAGE);
return;
}
if (archive.fileExists(selectedPath))
archive.renameFile(selectedPath, thename);
else
archive.renameDirectory(selectedPath, thename);
FileTreeNode tn = treeNodes.get(selectedPath);
treeNodes.remove(selectedPath);
selectedPath = selectedPath.substring(0, selectedPath.lastIndexOf("/") + 1) + thename;
tn.setUserObject(selectedPath);
treeNodes.put(selectedPath, tn);
DefaultTreeModel listmodel = (DefaultTreeModel)tvFileView.getModel();
listmodel.nodeChanged(tn);
setFileDescription(tn);
trySave();
}//GEN-LAST:event_btnRenameItemActionPerformed |
72fef23e-4c02-4673-8d58-829a7c025295 | 8 | public void run () {
if (threadId == 1) {
try {
lm.Lock (1, "a", LockManager.READ);
}
catch (DeadlockException e) {
System.out.println ("Deadlock.... ");
}
try {
this.sleep (4000);
}
catch (InterruptedException e) { }
try {
lm.Lock (1, "a", LockManager.WRITE);
}
catch (DeadlockException e) {
System.out.println ("Deadlock.... ");
}
lm.UnlockAll (1);
}
else if (threadId == 2) {
try {
lm.Lock (2, "b", LockManager.READ);
}
catch (DeadlockException e) {
System.out.println ("Deadlock.... ");
}
try {
this.sleep (1000);
}
catch (InterruptedException e) { }
try {
lm.Lock (2, "a", LockManager.WRITE);
}
catch (DeadlockException e) {
System.out.println ("Deadlock.... ");
}
lm.UnlockAll (2);
}
} |
608ee5a8-a7b6-4b56-b3aa-c58a46ff0963 | 0 | private static void invokeMethod(Method m, Object obj) throws Exception {
m.invoke(obj, "dynamically invoked");
} |
3e45d2c7-e41d-40b1-b9a5-2ba121548095 | 2 | private int getChar() throws IOException
{
if(this.eof)
{
return -1;
}
int result = this.in.read();
if(result == -1)
{
this.eof = true;
}
return result;
} |
55e5ae12-f0f7-4853-8f50-478521d1026f | 9 | @Override
protected String buildHeader() {
String header = options().header();
if (options().copyHeader()) {
Configuration def = getDefaults();
if ((def != null) && (def instanceof FileConfiguration)) {
FileConfiguration filedefaults = (FileConfiguration) def;
String defaultsHeader = filedefaults.buildHeader();
if ((defaultsHeader != null) && (defaultsHeader.length() > 0)) {
return defaultsHeader;
}
}
}
if (header == null) {
return "";
}
StringBuilder builder = new StringBuilder();
String[] lines = header.split("\r?\n", -1);
boolean startedHeader = false;
for (int i = lines.length - 1; i >= 0; i--) {
builder.insert(0, "\n");
if ((startedHeader) || (lines[i].length() != 0)) {
builder.insert(0, lines[i]);
builder.insert(0, COMMENT_PREFIX);
startedHeader = true;
}
}
return builder.toString();
} |
0054f566-508e-4cb0-ab26-b10fe53afc2f | 8 | public AttackState isAdvancing(Move mov) {
int iterateVertical = mov.getEnd().row - mov.getStart().row;
int iterateHorizontal = mov.getEnd().column - mov.getStart().column;
Piece.adjLoc nextSpace = new Piece.adjLoc(mov.getEnd().row + iterateVertical, mov.getEnd().column + iterateHorizontal);
Piece.adjLoc previousSpace = new Piece.adjLoc(mov.getStart().row - iterateVertical, mov.getStart().column - iterateHorizontal);
if(Piece.isValidSpace(nextSpace)) {
if(theBoard[nextSpace.row][nextSpace.column].getColor() == oppositeColor(mov.getColor())) {
if(Piece.isValidSpace(previousSpace)) {
if(theBoard[previousSpace.row][previousSpace.column].getColor() == oppositeColor(mov.getColor())) {
return AttackState.BOTH;
}
else {
return AttackState.ADVANCING;
}
}
else {
return AttackState.ADVANCING;
}
}
else if(Piece.isValidSpace(previousSpace)) {
if(theBoard[previousSpace.row][previousSpace.column].getColor() == oppositeColor(mov.getColor())) {
return AttackState.WITHDRAWING;
}
}
}
else if(Piece.isValidSpace(previousSpace)) {
if(theBoard[previousSpace.row][previousSpace.column].getColor() == oppositeColor(mov.getColor())) {
return AttackState.WITHDRAWING;
}
}
return AttackState.NEITHER;
} |
bb7f8219-6cc2-41e6-92e4-dba03fd6e94f | 7 | public static void main(String[] args) throws InterruptedException {
int nbRows = 0, nbColumns = 0;
int minRows = 10, minCols = 10;
boolean cont = true;
while(cont) {
try {
System.out.println("Enter a number of rows (min " + minRows + ") : ");
nbRows = new Scanner(System.in).nextInt();
if(nbRows < minRows)
throw new Exception();
cont = false;
}
catch(Exception e) {
System.out.println("\nPlease, enter a correct number of rows (min " + minRows + ")\n");
}
}
cont = true;
while(cont) {
try {
System.out.println("Enter a number of columns (min " + minCols + ") : ");
nbColumns = new Scanner(System.in).nextInt();
if(nbColumns < minCols)
throw new Exception();
cont = false;
}
catch(Exception e) {
System.out.println("\nPlease, enter a correct number of columns (min " + minCols + ")\n");
}
}
World world = new World(nbRows, nbColumns);
for(int i = 0 ; i < 100 ; i++) {
world.newGeneration();
System.out.println("World n°" + (i + 1) + " : \n");
System.out.println(world);
Thread.sleep(1000);
}
} |
e12909bb-2fda-4d04-8bed-e57701c72904 | 3 | @SuppressWarnings("deprecation")
public void GET(String request, String full, Server server) {
BrowserGETRequestEvent bgre = new BrowserGETRequestEvent(this, request, full);
server.getEventSystem().callEvent(bgre);
if (bgre.isCancelled())
return;
String respond = bgre.getResponse();
if (respond.equals(""))
writer.println("HTTP/1.1 404 Not Found");
else {
writer.println("HTTP/1.1 200 OK");
writer.println("Date: " + new Date().toLocaleString());
writer.println("Content-Type: " + (bgre.isHTML() ? "text/html" : "text/plain"));
writer.println("Content-Lenght: " + respond.getBytes().length);
writer.println();
writer.println(respond);
}
CloseConnection();
} |
480f79aa-fbf7-4c98-b39e-c5ba387d32af | 2 | public int maxProfit(int k, int[] prices) {
if(k>(prices.length+1)/2){
k=(prices.length+1)/2;
}
if(k==0) return 0;
prices=handle(prices);
return f(k,prices);
// 下面是另一种解法,使用的标准DP思想,复杂度也是多项式: N*N*N ,但是会超时
// Integer[][] aux = new Integer[prices.length + 1][];
// for (Integer i = 0; i < prices.length + 1; ++i) {
// aux[i] = new Integer[k+1];
// for (int j = 0; j < aux[i].length; ++j) {
// aux[i][j] = new Integer(0);
// }
// }
// for (Integer i = prices.length - 2; i >= 0; --i) {
// for (Integer j = 1; j <=k; ++j) {
// if (j > prices.length - i) {
// aux[i][j] = aux[i][j - 1];
// continue;
// }
// Integer t = aux[i + 1][j];
// for (Integer m = i + 1; m < prices.length; ++m) {
// if (prices[m] - prices[i] + aux[m + 1][j-1] > t) {
// t = prices[m] - prices[i] + aux[m + 1][j-1];
// }
// }
// aux[i][j] = t;
// }
// }
// return aux[0][k];
} |
7387f0f0-e5a6-4c54-af44-7a213706d4b9 | 0 | public String getAlgorithm() {
return algorithm;
} |
f08b58f8-32a7-48f8-a75d-8adeabf4e004 | 1 | private boolean jj_3_77() {
if (jj_scan_token(PLUS)) return true;
return false;
} |
ed36a0dc-c0e8-442c-9ccf-0049b311b9a5 | 3 | public String getCommand(int x) {
String y;
if (x == 1) {
y = "attack";
}
else if (x == 2) {
y = "defend";
}
else if (x == 3) {
y = "jump";
}
else {
y = "";
}
return y;
} |
53fef148-107b-423a-a2f3-36f6580f15e3 | 8 | @Override
public void execute() {
SceneObject rock = SceneEntities.getNearest(Main.getRockIDs());
if (Inventory.isFull()) {
if (BANK_AREA.contains(Players.getLocal().getLocation())) {
if (Bank.isOpen()) {
Bank.deposit(Main.oreID, 28);
} else {
Bank.open();
}
} else if (MINE_AREA.contains(Players.getLocal().getLocation())) {
Path path = Walking.findPath(BANK_TILE);
path.traverse();
}
} else {
if (BANK_AREA.contains(Players.getLocal().getLocation())) {
Path path = Walking.findPath(MINE_TILE);
path.traverse();
} else if (MINE_AREA.contains(Players.getLocal().getLocation())) {
if (rock != null) {
if (rock.isOnScreen()) {
rock.interact("Mine");
} else {
Camera.turnTo(rock);
}
}
}
}
} |
7ec0ceab-0504-403c-8dab-95641134fc7d | 9 | public int compareTo(DBType dt) {
ByteArrayType bt = null;
if (dt instanceof ByteArrayType) {
bt = (ByteArrayType) dt;
} else {
return -1;
}
int thisLen = bytes!=null?bytes.length:0;
int btLen = bt.bytes!=null?bt.bytes.length:0;
if (btLen < thisLen) {
return 1;
}
if (btLen > thisLen) {
return -1;
}
for (int i = 0; i < bytes.length; i++) {
if (bytes[i] == bt.bytes[i]) {
continue;
}
if (bytes[i] > bt.bytes[i]) {
return 1;
}
if (bytes[i] < bt.bytes[i]) {
return -1;
}
}
return 0;
} |
84426ecd-ccde-4f4b-b383-80b779ebe893 | 8 | public void update() {
UP = key[KeyEvent.VK_UP] || key[KeyEvent.VK_W];
DOWN = key[KeyEvent.VK_DOWN] || key[KeyEvent.VK_S];
LEFT = key[KeyEvent.VK_LEFT] || key[KeyEvent.VK_A];
RIGHT = key[KeyEvent.VK_RIGHT] || key[KeyEvent.VK_D];
if (UP != prevUP) {
System.out.println("UP changed! UP: " + UP);
prevUP = UP;
}
if (DOWN != prevDOWN) {
System.out.println("DOWN changed! DOWN: " + DOWN);
prevDOWN = DOWN;
}
if (LEFT != prevLEFT) {
System.out.println("LEFT changed! LEFT: " + LEFT);
prevLEFT = LEFT;
}
if (RIGHT != prevRIGHT) {
System.out.println("RIGHT changed! RIGHT: " + RIGHT);
prevRIGHT = RIGHT;
}
} |
227c3314-9298-4a6a-a02d-ac742b302ff6 | 0 | public UndoQueueListener[] getUndoQueueListeners() {
return (UndoQueueListener[]) undoQueueListeners.toArray();
} |
bcfa07b7-19df-4949-9669-8b86240b6696 | 0 | @BeforeClass
public static void setUpClass() {
} |
578c423b-0dc5-45a3-8dba-61b7822c54e6 | 0 | @Id
@GeneratedValue
public int getId() {
return id;
} |
f54dea14-20c7-452f-8062-8eeb85cfff5c | 3 | public ArrayList<Edge> getEdges() {
ArrayList<Edge> g = new ArrayList<Edge>();
setState(States.ARR_ADJ);
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (arr_adj[i][j] != 0)
g.add(new Edge(i, j, arr_adj[i][j]));
}
}
return g;
} |
7b077481-db2b-4793-ade7-24bd307012e8 | 1 | public boolean _setSprite(Sprite sprite)
{
if(sprite != null)
{
this.sprite = sprite;
return true;
}
else
{
return false;
}
} |
dcb89302-8539-4cd9-9562-3b92ec878233 | 1 | private void compute_new_v()
{
// p is fully initialized from x1
//float[] p = _p;
// pp is fully initialized from p
//float[] pp = _pp;
//float[] new_v = _new_v;
//float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
//float[] p = new float[16];
//float[] pp = new float[16];
/*
for (int i=31; i>=0; i--)
{
new_v[i] = 0.0f;
}
*/
float new_v0, new_v1, new_v2, new_v3, new_v4, new_v5, new_v6, new_v7, new_v8, new_v9;
float new_v10, new_v11, new_v12, new_v13, new_v14, new_v15, new_v16, new_v17, new_v18, new_v19;
float new_v20, new_v21, new_v22, new_v23, new_v24, new_v25, new_v26, new_v27, new_v28, new_v29;
float new_v30, new_v31;
new_v0 = new_v1 = new_v2 = new_v3 = new_v4 = new_v5 = new_v6 = new_v7 = new_v8 = new_v9 =
new_v10 = new_v11 = new_v12 = new_v13 = new_v14 = new_v15 = new_v16 = new_v17 = new_v18 = new_v19 =
new_v20 = new_v21 = new_v22 = new_v23 = new_v24 = new_v25 = new_v26 = new_v27 = new_v28 = new_v29 =
new_v30 = new_v31 = 0.0f;
// float[] new_v = new float[32]; // new V[0-15] and V[33-48] of Figure 3-A.2 in ISO DIS 11172-3
// float[] p = new float[16];
// float[] pp = new float[16];
float[] s = samples;
float s0 = s[0];
float s1 = s[1];
float s2 = s[2];
float s3 = s[3];
float s4 = s[4];
float s5 = s[5];
float s6 = s[6];
float s7 = s[7];
float s8 = s[8];
float s9 = s[9];
float s10 = s[10];
float s11 = s[11];
float s12 = s[12];
float s13 = s[13];
float s14 = s[14];
float s15 = s[15];
float s16 = s[16];
float s17 = s[17];
float s18 = s[18];
float s19 = s[19];
float s20 = s[20];
float s21 = s[21];
float s22 = s[22];
float s23 = s[23];
float s24 = s[24];
float s25 = s[25];
float s26 = s[26];
float s27 = s[27];
float s28 = s[28];
float s29 = s[29];
float s30 = s[30];
float s31 = s[31];
float p0 = s0 + s31;
float p1 = s1 + s30;
float p2 = s2 + s29;
float p3 = s3 + s28;
float p4 = s4 + s27;
float p5 = s5 + s26;
float p6 = s6 + s25;
float p7 = s7 + s24;
float p8 = s8 + s23;
float p9 = s9 + s22;
float p10 = s10 + s21;
float p11 = s11 + s20;
float p12 = s12 + s19;
float p13 = s13 + s18;
float p14 = s14 + s17;
float p15 = s15 + s16;
float pp0 = p0 + p15;
float pp1 = p1 + p14;
float pp2 = p2 + p13;
float pp3 = p3 + p12;
float pp4 = p4 + p11;
float pp5 = p5 + p10;
float pp6 = p6 + p9;
float pp7 = p7 + p8;
float pp8 = (p0 - p15) * cos1_32;
float pp9 = (p1 - p14) * cos3_32;
float pp10 = (p2 - p13) * cos5_32;
float pp11 = (p3 - p12) * cos7_32;
float pp12 = (p4 - p11) * cos9_32;
float pp13 = (p5 - p10) * cos11_32;
float pp14 = (p6 - p9) * cos13_32;
float pp15 = (p7 - p8) * cos15_32;
p0 = pp0 + pp7;
p1 = pp1 + pp6;
p2 = pp2 + pp5;
p3 = pp3 + pp4;
p4 = (pp0 - pp7) * cos1_16;
p5 = (pp1 - pp6) * cos3_16;
p6 = (pp2 - pp5) * cos5_16;
p7 = (pp3 - pp4) * cos7_16;
p8 = pp8 + pp15;
p9 = pp9 + pp14;
p10 = pp10 + pp13;
p11 = pp11 + pp12;
p12 = (pp8 - pp15) * cos1_16;
p13 = (pp9 - pp14) * cos3_16;
p14 = (pp10 - pp13) * cos5_16;
p15 = (pp11 - pp12) * cos7_16;
pp0 = p0 + p3;
pp1 = p1 + p2;
pp2 = (p0 - p3) * cos1_8;
pp3 = (p1 - p2) * cos3_8;
pp4 = p4 + p7;
pp5 = p5 + p6;
pp6 = (p4 - p7) * cos1_8;
pp7 = (p5 - p6) * cos3_8;
pp8 = p8 + p11;
pp9 = p9 + p10;
pp10 = (p8 - p11) * cos1_8;
pp11 = (p9 - p10) * cos3_8;
pp12 = p12 + p15;
pp13 = p13 + p14;
pp14 = (p12 - p15) * cos1_8;
pp15 = (p13 - p14) * cos3_8;
p0 = pp0 + pp1;
p1 = (pp0 - pp1) * cos1_4;
p2 = pp2 + pp3;
p3 = (pp2 - pp3) * cos1_4;
p4 = pp4 + pp5;
p5 = (pp4 - pp5) * cos1_4;
p6 = pp6 + pp7;
p7 = (pp6 - pp7) * cos1_4;
p8 = pp8 + pp9;
p9 = (pp8 - pp9) * cos1_4;
p10 = pp10 + pp11;
p11 = (pp10 - pp11) * cos1_4;
p12 = pp12 + pp13;
p13 = (pp12 - pp13) * cos1_4;
p14 = pp14 + pp15;
p15 = (pp14 - pp15) * cos1_4;
// this is pretty insane coding
float tmp1;
new_v19/*36-17*/ = -(new_v4 = (new_v12 = p7) + p5) - p6;
new_v27/*44-17*/ = -p6 - p7 - p4;
new_v6 = (new_v10 = (new_v14 = p15) + p11) + p13;
new_v17/*34-17*/ = -(new_v2 = p15 + p13 + p9) - p14;
new_v21/*38-17*/ = (tmp1 = -p14 - p15 - p10 - p11) - p13;
new_v29/*46-17*/ = -p14 - p15 - p12 - p8;
new_v25/*42-17*/ = tmp1 - p12;
new_v31/*48-17*/ = -p0;
new_v0 = p1;
new_v23/*40-17*/ = -(new_v8 = p3) - p2;
p0 = (s0 - s31) * cos1_64;
p1 = (s1 - s30) * cos3_64;
p2 = (s2 - s29) * cos5_64;
p3 = (s3 - s28) * cos7_64;
p4 = (s4 - s27) * cos9_64;
p5 = (s5 - s26) * cos11_64;
p6 = (s6 - s25) * cos13_64;
p7 = (s7 - s24) * cos15_64;
p8 = (s8 - s23) * cos17_64;
p9 = (s9 - s22) * cos19_64;
p10 = (s10 - s21) * cos21_64;
p11 = (s11 - s20) * cos23_64;
p12 = (s12 - s19) * cos25_64;
p13 = (s13 - s18) * cos27_64;
p14 = (s14 - s17) * cos29_64;
p15 = (s15 - s16) * cos31_64;
pp0 = p0 + p15;
pp1 = p1 + p14;
pp2 = p2 + p13;
pp3 = p3 + p12;
pp4 = p4 + p11;
pp5 = p5 + p10;
pp6 = p6 + p9;
pp7 = p7 + p8;
pp8 = (p0 - p15) * cos1_32;
pp9 = (p1 - p14) * cos3_32;
pp10 = (p2 - p13) * cos5_32;
pp11 = (p3 - p12) * cos7_32;
pp12 = (p4 - p11) * cos9_32;
pp13 = (p5 - p10) * cos11_32;
pp14 = (p6 - p9) * cos13_32;
pp15 = (p7 - p8) * cos15_32;
p0 = pp0 + pp7;
p1 = pp1 + pp6;
p2 = pp2 + pp5;
p3 = pp3 + pp4;
p4 = (pp0 - pp7) * cos1_16;
p5 = (pp1 - pp6) * cos3_16;
p6 = (pp2 - pp5) * cos5_16;
p7 = (pp3 - pp4) * cos7_16;
p8 = pp8 + pp15;
p9 = pp9 + pp14;
p10 = pp10 + pp13;
p11 = pp11 + pp12;
p12 = (pp8 - pp15) * cos1_16;
p13 = (pp9 - pp14) * cos3_16;
p14 = (pp10 - pp13) * cos5_16;
p15 = (pp11 - pp12) * cos7_16;
pp0 = p0 + p3;
pp1 = p1 + p2;
pp2 = (p0 - p3) * cos1_8;
pp3 = (p1 - p2) * cos3_8;
pp4 = p4 + p7;
pp5 = p5 + p6;
pp6 = (p4 - p7) * cos1_8;
pp7 = (p5 - p6) * cos3_8;
pp8 = p8 + p11;
pp9 = p9 + p10;
pp10 = (p8 - p11) * cos1_8;
pp11 = (p9 - p10) * cos3_8;
pp12 = p12 + p15;
pp13 = p13 + p14;
pp14 = (p12 - p15) * cos1_8;
pp15 = (p13 - p14) * cos3_8;
p0 = pp0 + pp1;
p1 = (pp0 - pp1) * cos1_4;
p2 = pp2 + pp3;
p3 = (pp2 - pp3) * cos1_4;
p4 = pp4 + pp5;
p5 = (pp4 - pp5) * cos1_4;
p6 = pp6 + pp7;
p7 = (pp6 - pp7) * cos1_4;
p8 = pp8 + pp9;
p9 = (pp8 - pp9) * cos1_4;
p10 = pp10 + pp11;
p11 = (pp10 - pp11) * cos1_4;
p12 = pp12 + pp13;
p13 = (pp12 - pp13) * cos1_4;
p14 = pp14 + pp15;
p15 = (pp14 - pp15) * cos1_4;
// manually doing something that a compiler should handle sucks
// coding like this is hard to read
float tmp2;
new_v5 = (new_v11 = (new_v13 = (new_v15 = p15) + p7) + p11)
+ p5 + p13;
new_v7 = (new_v9 = p15 + p11 + p3) + p13;
new_v16/*33-17*/ = -(new_v1 = (tmp1 = p13 + p15 + p9) + p1) - p14;
new_v18/*35-17*/ = -(new_v3 = tmp1 + p5 + p7) - p6 - p14;
new_v22/*39-17*/ = (tmp1 = -p10 - p11 - p14 - p15)
- p13 - p2 - p3;
new_v20/*37-17*/ = tmp1 - p13 - p5 - p6 - p7;
new_v24/*41-17*/ = tmp1 - p12 - p2 - p3;
new_v26/*43-17*/ = tmp1 - p12 - (tmp2 = p4 + p6 + p7);
new_v30/*47-17*/ = (tmp1 = -p8 - p12 - p14 - p15) - p0;
new_v28/*45-17*/ = tmp1 - tmp2;
// insert V[0-15] (== new_v[0-15]) into actual v:
// float[] x2 = actual_v + actual_write_pos;
float dest[] = actual_v;
int pos = actual_write_pos;
dest[0 + pos] = new_v0;
dest[16 + pos] = new_v1;
dest[32 + pos] = new_v2;
dest[48 + pos] = new_v3;
dest[64 + pos] = new_v4;
dest[80 + pos] = new_v5;
dest[96 + pos] = new_v6;
dest[112 + pos] = new_v7;
dest[128 + pos] = new_v8;
dest[144 + pos] = new_v9;
dest[160 + pos] = new_v10;
dest[176 + pos] = new_v11;
dest[192 + pos] = new_v12;
dest[208 + pos] = new_v13;
dest[224 + pos] = new_v14;
dest[240 + pos] = new_v15;
// V[16] is always 0.0:
dest[256 + pos] = 0.0f;
// insert V[17-31] (== -new_v[15-1]) into actual v:
dest[272 + pos] = -new_v15;
dest[288 + pos] = -new_v14;
dest[304 + pos] = -new_v13;
dest[320 + pos] = -new_v12;
dest[336 + pos] = -new_v11;
dest[352 + pos] = -new_v10;
dest[368 + pos] = -new_v9;
dest[384 + pos] = -new_v8;
dest[400 + pos] = -new_v7;
dest[416 + pos] = -new_v6;
dest[432 + pos] = -new_v5;
dest[448 + pos] = -new_v4;
dest[464 + pos] = -new_v3;
dest[480 + pos] = -new_v2;
dest[496 + pos] = -new_v1;
// insert V[32] (== -new_v[0]) into other v:
dest = (actual_v==v1) ? v2 : v1;
dest[0 + pos] = -new_v0;
// insert V[33-48] (== new_v[16-31]) into other v:
dest[16 + pos] = new_v16;
dest[32 + pos] = new_v17;
dest[48 + pos] = new_v18;
dest[64 + pos] = new_v19;
dest[80 + pos] = new_v20;
dest[96 + pos] = new_v21;
dest[112 + pos] = new_v22;
dest[128 + pos] = new_v23;
dest[144 + pos] = new_v24;
dest[160 + pos] = new_v25;
dest[176 + pos] = new_v26;
dest[192 + pos] = new_v27;
dest[208 + pos] = new_v28;
dest[224 + pos] = new_v29;
dest[240 + pos] = new_v30;
dest[256 + pos] = new_v31;
// insert V[49-63] (== new_v[30-16]) into other v:
dest[272 + pos] = new_v30;
dest[288 + pos] = new_v29;
dest[304 + pos] = new_v28;
dest[320 + pos] = new_v27;
dest[336 + pos] = new_v26;
dest[352 + pos] = new_v25;
dest[368 + pos] = new_v24;
dest[384 + pos] = new_v23;
dest[400 + pos] = new_v22;
dest[416 + pos] = new_v21;
dest[432 + pos] = new_v20;
dest[448 + pos] = new_v19;
dest[464 + pos] = new_v18;
dest[480 + pos] = new_v17;
dest[496 + pos] = new_v16;
/*
}
else
{
v1[0 + actual_write_pos] = -new_v0;
// insert V[33-48] (== new_v[16-31]) into other v:
v1[16 + actual_write_pos] = new_v16;
v1[32 + actual_write_pos] = new_v17;
v1[48 + actual_write_pos] = new_v18;
v1[64 + actual_write_pos] = new_v19;
v1[80 + actual_write_pos] = new_v20;
v1[96 + actual_write_pos] = new_v21;
v1[112 + actual_write_pos] = new_v22;
v1[128 + actual_write_pos] = new_v23;
v1[144 + actual_write_pos] = new_v24;
v1[160 + actual_write_pos] = new_v25;
v1[176 + actual_write_pos] = new_v26;
v1[192 + actual_write_pos] = new_v27;
v1[208 + actual_write_pos] = new_v28;
v1[224 + actual_write_pos] = new_v29;
v1[240 + actual_write_pos] = new_v30;
v1[256 + actual_write_pos] = new_v31;
// insert V[49-63] (== new_v[30-16]) into other v:
v1[272 + actual_write_pos] = new_v30;
v1[288 + actual_write_pos] = new_v29;
v1[304 + actual_write_pos] = new_v28;
v1[320 + actual_write_pos] = new_v27;
v1[336 + actual_write_pos] = new_v26;
v1[352 + actual_write_pos] = new_v25;
v1[368 + actual_write_pos] = new_v24;
v1[384 + actual_write_pos] = new_v23;
v1[400 + actual_write_pos] = new_v22;
v1[416 + actual_write_pos] = new_v21;
v1[432 + actual_write_pos] = new_v20;
v1[448 + actual_write_pos] = new_v19;
v1[464 + actual_write_pos] = new_v18;
v1[480 + actual_write_pos] = new_v17;
v1[496 + actual_write_pos] = new_v16;
}
*/
} |
a911c1ee-319b-4250-9145-58bd7db09dfb | 0 | public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
} |
423b1ad4-f72a-4194-9c4a-f2ec1d819610 | 3 | private boolean notOverrideVessel(Map<String, EnumElement> board,
EnumLine line, EnumColumn column, boolean vertical,
EnumElement vessel) {
boolean empty = true;
for (int i = 1; i < (vessel.getLength() + 1); i++) {
if (vertical) {
line = EnumLine.getEnumLine(i);
empty = this.isEmpty(board, line, column);
} else {
column = EnumColumn.getEnumColumn(i);
empty = this.isEmpty(board, line, column);
}
if (!empty) {
return false;
}
}
return empty;
} |
29b1ed99-4206-4b24-80cb-e35635116220 | 4 | private void circumference (int circumference) throws IllegalArgumentException, Exception {
// Illegal call or Illegal arguments
if(socket == null) {
throw new Exception("Client:>>>Please connect to a host before specifying trust ring circumference");
} else if (circumference == 0) {
circumference = 1;
}
try {
// Change the circumference to byte[] for the message
ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE);
bb.putInt(circumference);
byte[][] data = new byte[1][bb.array().length];
data[0] = bb.array();
Message msg = new Message(true, COMMAND.C, Integer.SIZE, "", data);
// Send the message to the server
objectToServer.writeObject(msg);
objectToServer.flush();
// Check for success or failure
if(!receiveAck()) {
System.out.println("Client:>>>No acknowledgement received. Try again");
} else {
System.out.println("Client: Successfully changed circumference");
}
sessionCirc = circumference;
} catch(Exception e) {
e.printStackTrace();
}
} |
26bc96de-68c1-4584-be77-db820ce2d1bb | 1 | public ArrayList<treeNode> generateTrees(int n) {
if (n == 0) {
ArrayList<treeNode> roots = new ArrayList<treeNode>();
roots.add(null);
return roots;
}
return generateSubTree(1, n);
} |
94f2a200-f615-404f-9bb9-0f2925c56526 | 8 | public void parse()
throws FileNotFoundException, IOException, ExParser, ExManifest {
BufferedReader lReader = null;
try {
lReader = new BufferedReader(new FileReader(mManifestFile));
String lLine;
int lHighestSequencePosition = 0;
Map<String, Integer> lFileIndexes = new HashMap<String, Integer>();
LINE_LOOP:
while((lLine = lReader.readLine())!= null){
//Trim whitespace
lLine = lLine.trim();
//Skip empty lines
if("".equals(lLine)){
continue LINE_LOOP;
}
//Skip comment lines
if(lLine.charAt(0) == '#'){
continue LINE_LOOP;
}
//Attempt to parse the line as a property line (this will return null if it is not)
Map<String, String> lPromotionPropertyMap = parsePromotionPropertiesLine(lLine);
if(lPromotionPropertyMap != null){
Logger.logDebug("Parsed promotion property line");
if(mPromotionPropertyMap != null){
//Only one definition allowed per manifest
throw new ExParser("Duplicate PROMOTION definition line found");
}
mPromotionPropertyMap = lPromotionPropertyMap;
continue LINE_LOOP;
}
//Assume any other line is a manifest entry (this will error if it is not)
ManifestEntry lManifestEntry = parseManifestEntryLine(lLine, lHighestSequencePosition);
lHighestSequencePosition = lManifestEntry.getSequencePosition();
mManifestEntryList.add(lManifestEntry);
if(!lManifestEntry.isForcedDuplicate()){
mFinalProcessedFilePathSet.add(lManifestEntry.getFilePath());
}
//Record the index of the file
Integer lFileIndex = lFileIndexes.get(lManifestEntry.getFilePath());
if(lFileIndex == null){
lFileIndex = 1;
}
else {
lFileIndex++;
}
lManifestEntry.setFileIndex(lFileIndex);
lFileIndexes.put(lManifestEntry.getFilePath(), lFileIndex);
//Construct a new loader if necessary
createLoaderIfUndefined(lManifestEntry.getLoaderName());
Logger.logDebug("Parsed manifest entry for " + lManifestEntry.getFilePath());
}
}
finally {
//Close the reader to release the lock on the file
if(lReader != null){
lReader.close();
}
}
} |
05280547-d6f8-45c2-880f-12b0be1f5ffb | 9 | void compress(int init_bits, OutputStream outs) throws IOException {
int fcode;
int i /* = 0 */;
int c;
int ent;
int disp;
int hsize_reg;
int hshift;
// Set up the globals: g_init_bits - initial number of bits
g_init_bits = init_bits;
// Set up the necessary values
clear_flg = false;
n_bits = g_init_bits;
maxcode = MAXCODE(n_bits);
ClearCode = 1 << (init_bits - 1);
EOFCode = ClearCode + 1;
free_ent = ClearCode + 2;
a_count = 0; // clear packet
ent = nextPixel();
hshift = 0;
for (fcode = hsize; fcode < 65536; fcode *= 2)
++hshift;
hshift = 8 - hshift; // set hash code range bound
hsize_reg = hsize;
cl_hash(hsize_reg); // clear hash table
output(ClearCode, outs);
outer_loop: while ((c = nextPixel()) != EOF) {
fcode = (c << maxbits) + ent;
i = (c << hshift) ^ ent; // xor hashing
if (htab[i] == fcode) {
ent = codetab[i];
continue;
} else if (htab[i] >= 0) // non-empty slot
{
disp = hsize_reg - i; // secondary hash (after G. Knott)
if (i == 0)
disp = 1;
do {
if ((i -= disp) < 0)
i += hsize_reg;
if (htab[i] == fcode) {
ent = codetab[i];
continue outer_loop;
}
} while (htab[i] >= 0);
}
output(ent, outs);
ent = c;
if (free_ent < maxmaxcode) {
codetab[i] = free_ent++; // code -> hashtable
htab[i] = fcode;
} else
cl_block(outs);
}
// Put out the final code.
output(ent, outs);
output(EOFCode, outs);
} |
98bae88a-5f1b-49de-8ea0-2b438fce58f4 | 6 | public static boolean Load() {
sheets.clear();
Connection c = RpgConnection.getConnection();
if(c!=null) {
Statement s = null;
ResultSet results = null;
try {
s = c.createStatement();
results = s.executeQuery("SELECT * FROM character_sheets");
} catch (Exception e) {
e.printStackTrace();
return false;
}
try {
while(results.next()) {
CharacterSheet cs = new CharacterSheet();
cs.init();
cs.setId(results.getLong("id"));
cs.setName(results.getString("name"));
cs.setDescription(results.getString("description"));
cs.setExp(results.getInt("exp"));
cs.setNotes(results.getString("notes"));
cs.setPlayerName(results.getString("player"));
String featsString = results.getString("feats");
String[] featsArr = featsString.split(";");
for(int i = 0; i<featsArr.length; i++) {
if(!"".equals(featsArr[i])) {
System.out.println(cs.getName()+" "+featsArr[i]);
Long id = Long.parseLong(featsArr[i]);
cs.getFeats().add(id);
} else {
}
}
sheets.put(cs.getId(), cs);
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
return true;
} |
8114569c-d6f5-4043-98e8-ce21cbd92369 | 3 | static protected Location parseLocationLine(String line) {
String latitude, longitude;
int latitudeSign = 1, longitudeSign = 1;
if(log.isDebugEnabled())
log.debug("line:" + line);
latitude = line.replaceAll("^.*CENTER LOCATED NEAR ", "");
latitude = latitude.replaceAll(" AT.*$", "");
if(latitude.matches(".*S.*"))
latitudeSign = -1;
longitude = latitude.replaceAll("^.* ", "");
if(longitude.matches(".*W.*"))
longitudeSign = -1;
latitude = latitude.replaceAll("[NS] .*$", "");
longitude = longitude.replaceAll("[WE].*$", "");
return new Location(latitude, longitude, latitudeSign, longitudeSign);
} |
6161f21b-c1eb-4391-b7cc-9eed3c800a2b | 0 | @FXML
private void handleCancelButton(ActionEvent event) {
getMessageBox().userAction = UserAction.CANCEL;
hide();
} |
30706910-76c0-4fc9-9966-2bad26ec6788 | 0 | public void setStateName(String stateName) {
this.stateName.set(stateName);
} |
a351720e-c67f-45b2-bb3c-74b6c395a01b | 0 | @Override
public String getCur() {return cur.toString();} |
7a363e2c-23cf-4fc3-8f21-64e7324bf02a | 9 | protected Object computeAssign(IEnv env, Object right) {
ASTNode leftNode = left();
if (leftNode instanceof PrimaryExpr) {
PrimaryExpr expr = (PrimaryExpr) leftNode;
if (expr.hasPostfix(0) && expr.postfix(0) instanceof ArrayRef) {
Object object = expr.evaluateSubExpr(env, 1);
if (object instanceof Object[]) {
ArrayRef ref = (ArrayRef) expr.postfix(0);
Object index = ref.index().evaluate(env);
if (index instanceof Integer) {
((Object[]) object)[(int) index] = right;
return right;
}
}
throw new StoneException("bad array access", this);
}
if (expr.hasPostfix(0) && expr.postfix(0) instanceof Dot) {
Object object = expr.evaluateSubExpr(env, 1);
if (object instanceof StoneObject) {
return setField((StoneObject) object,
(Dot) expr.postfix(0), right);
}
}
}
if (leftNode instanceof Name) {
env.put(((Name) leftNode).name(), right);
return right;
}
throw new StoneException("bad assignment", this);
} |
718fc8e5-547f-4e54-ae87-8ccc43da563d | 5 | boolean wordBreakDFS( String s, Set<String> dict ) {
boolean result = false;
for( int i = 0; i < s.length(); i++ ) {
String head = s.substring(0, i + 1 );
String tail = s.substring( i + 1 );
if( dict.contains( head ) ) {
if( tail.length() == 0 ) {
result = true;
break;
}
if( cache.containsKey( tail ) ) {
result = cache.get( tail );
} else {
result = wordBreakDFS( tail, dict );
}
}
if( result ) break;
}
cache.put( s, result );
return result;
} |
9de6015f-11e5-4469-b289-3856a6b71841 | 0 | public FiguraGeometrica(double x, double y) {
posX = x;
posY = y;
} |
2e05e286-0ea6-446b-8c45-15ad292f384b | 5 | public static void debugPrintBlockedArray() {
for (int x = 0; x < MapEditorData.WIDTH_IN_TILES; x++) {
System.out.print("-");
}
System.out.println();
for (int y = 0; y < MapEditorData.HEIGHT_IN_TILES; y++) {
System.out.print("|");
for (int x = 0; x < MapEditorData.WIDTH_IN_TILES; x++) {
System.out.print((instance.blockedByEntity[x][y] ? "x" : " "));
}
System.out.println("|");
}
for (int x = 0; x < MapEditorData.WIDTH_IN_TILES; x++) {
System.out.print("-");
}
} |
a08bb2de-22d5-4cd6-9634-54a1c9fd3cfc | 4 | public static void scoreRecords(Collection<Record> records) throws SQLException
{
Map<Integer, Integer> recordScoreSum = new TreeMap<Integer, Integer>();
Map<Integer, Integer> scoreCount = new TreeMap<Integer, Integer>();
String sql = "SELECT record_id,score_value from score_history where user_id = ?";
PreparedStatement ps = Connect.getConnection().getPreparedStatement(sql);
ps.setInt(1, User.getUser("simon").getID());
ResultSet rs = ps.executeQuery();
while (rs.next())
{
int recId = rs.getInt(1);
int score = rs.getInt(2);
if (!recordScoreSum.containsKey(recId))
{
recordScoreSum.put(recId, score);
scoreCount.put(recId, 1);
}
else
{
recordScoreSum.put(recId, recordScoreSum.get(recId) + score);
scoreCount.put(recId, scoreCount.get(recId) + 1);
}
}
for (Record r : records)
if (recordScoreSum.containsKey(r.getNumber()))
r.setScore((recordScoreSum.get(r.getNumber()) + 0.0) / scoreCount.get(r.getNumber()));
} |
a1e78fd4-4ad6-4c31-bb81-35787a7034f8 | 6 | private void resize() {
width = getSkinnable().getWidth();
height = getSkinnable().getHeight();
if (getSkinnable().isKeepAspect()) {
if (aspectRatio * width > height) {
width = 1 / (aspectRatio / height);
} else if (1 / (aspectRatio / height) > width) {
height = aspectRatio * width;
}
}
if (width > 0 && height > 0) {
main.setPrefSize(width, height);
mainInnerShadow0.setRadius(3.0 / 132.0 * height);
mainInnerShadow1.setRadius(2.0 / 132.0 * height);
if (crystalOverlay.isVisible()) {
crystalClip.setWidth(width);
crystalClip.setHeight(height);
crystalOverlay.setImage(createNoiseImage(width, height, DARK_NOISE_COLOR, BRIGHT_NOISE_COLOR, 8));
crystalOverlay.setCache(true);
}
alarm.setPrefSize(0.15 * height, 0.15 * height);
alarm.setTranslateX(width - alarm.getPrefWidth() - height * 0.05);
alarm.setTranslateY(height * 0.42 - alarm.getPrefHeight());
updateFonts();
// Setup the lcd unit
secondText.setFont(secondFont);
secondText.setTextOrigin(VPos.BASELINE);
secondText.setTextAlignment(TextAlignment.RIGHT);
secondText.setX((width - secondText.getLayoutBounds().getWidth()) - height * 0.04);
secondText.setY(height - (timeText.getLayoutBounds().getHeight() * digitalFontSizeFactor) * 0.5);
valueOffsetRight = (secondText.getLayoutBounds().getWidth() + height * 0.0833333333); // distance between value and unit
timeText.setX(width - 2 - timeText.getLayoutBounds().getWidth() - valueOffsetRight);
timeText.setY(height - (timeText.getLayoutBounds().getHeight() * digitalFontSizeFactor) * 0.5);
// Visualize the lcd semitransparent background timeText
updateBackgroundText();
backgroundTimeText.setX(width - 2 - backgroundTimeText.getLayoutBounds().getWidth() - valueOffsetRight);
backgroundTimeText.setY(height - (backgroundTimeText.getLayoutBounds().getHeight() * digitalFontSizeFactor) * 0.5);
backgroundSecondText.setX((width - secondText.getLayoutBounds().getWidth()) - height * 0.04);
backgroundSecondText.setY(height - (timeText.getLayoutBounds().getHeight() * digitalFontSizeFactor) * 0.5);
// Setup the font for the lcd title, number system, min measured, max measure and former value
// Title
title.setFont(titleFont);
title.setTextOrigin(VPos.BASELINE);
title.setTextAlignment(TextAlignment.CENTER);
title.setText(getSkinnable().getTime().getDayOfWeek().name());
title.setX((width - title.getLayoutBounds().getWidth()) * 0.5);
title.setY(main.getLayoutY() + title.getLayoutBounds().getHeight() - 0.04 * height + 2);
// Date
dateText.setFont(smallFont);
dateText.setTextOrigin(VPos.BASELINE);
dateText.setTextAlignment(TextAlignment.RIGHT);
dateText.setText(getSkinnable().getTime().getMonthValue() + "/" + getSkinnable().getTime().getDayOfMonth() + "/" + getSkinnable().getTime().getYear());
dateText.setX(main.getLayoutX() + (width - dateText.getLayoutBounds().getWidth()) * 0.5);
dateText.setY(main.getLayoutY() + height - 3 - 0.0416666667 * height);
// Day of week
dayOfWeekText.setFont(smallFont);
dayOfWeekText.setTextOrigin(VPos.BASELINE);
dayOfWeekText.setTextAlignment(TextAlignment.LEFT);
dayOfWeekText.setX(0.0416666667 * height);
dayOfWeekText.setY(main.getLayoutY() + height - 3 - 0.0416666667 * height);
}
} |
5ce51b8d-25ad-44de-9e9e-d70c46237601 | 1 | public synchronized void closeAllConnections() {
for (Socket socket : openConnections) {
safeClose(socket);
}
} |
49ecd5d4-b21e-4d60-9308-1120308aa5d9 | 2 | public Dimension calculatePreferredHeaderSize(TreePanel panel) {
Font font = getHeaderFont();
int width = getWidth();
if (panel.isUserSortable()) {
width -= SORTER_WIDTH;
}
Dimension size = TextDrawing.getPreferredSize(font, TextDrawing.wrapToPixelWidth(font, getName(), width));
if (panel.isUserSortable()) {
size.width += SORTER_WIDTH;
}
return size;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.