/** * This function is used to re-run the analyser, and re-create the rows corresponding the its * results. */ private void refreshReviewTable() { reviewPanel.removeAll(); rows.clear(); GridBagLayout gbl = new GridBagLayout(); reviewPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; try { Map<String, Long> sums = analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate()); for (Entry<String, Long> entry : sums.entrySet()) { String project = entry.getKey(); double hours = 1.0 * entry.getValue() / (1000 * 3600); addRow(gbl, gbc, project, hours); } for (String project : main.getProjectsTree().getTopLevelProjects()) if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0); gbc.insets = new Insets(10, 0, 0, 0); addLeftLabel(gbl, gbc, "TOTAL"); gbc.gridx = 1; gbc.weightx = 1; totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); gbl.setConstraints(totalLabel, gbc); reviewPanel.add(totalLabel); gbc.weightx = 0; addRightLabel(gbl, gbc); } catch (IOException e) { e.printStackTrace(); } recomputeTotal(); pack(); }
public static void main(String[] args) { Scanner in = new Scanner(System.in); int a, b, c; int L1, R1, C1; while (in.hasNext()) { L1 = in.nextInt(); R1 = in.nextInt(); C1 = in.nextInt(); if (L1 == 0 && R1 == 0 && C1 == 0) break; a = b = c = 0; char map1[][][] = new char[L1][R1][C1]; for (int i = 0; i < L1; i++) for (int j = 0; j < R1; j++) { map1[i][j] = in.next().toCharArray(); for (int k = 0; k < C1; k++) { if (map1[i][j][k] == 'S') { a = i; b = j; c = k; } } } Main m = new Main(map1, L1, R1, C1); int sum = m.bfs(a, b, c); if (sum != -1) System.out.printf("Escaped in %d minute(s).\n", sum); else System.out.printf("Trapped!\n"); } }
public static void main(String[] args) { if (args.length == 0) { gui = new Gui(); gui.setVisible(true); } else if (args.length == 3 || args.length == 4) { Main.setBlogName(args[0]); Main.load(); if (args.length == 3) { int start, limit; try { start = Integer.parseInt(args[1]); limit = Integer.parseInt(args[2]); } catch (Exception e) { Main.status("usage: Main <blogname> <start_page> <end_page> -hires"); Main.status("start_page and end_page must be integers >= 1"); return; } Main.run(start, limit); Main.save(); } else if (args.length == 4 && args[3].equals("-hires")) { Main.downloadHiRes(); Main.save(); } else { Main.status("usage: Main <blogname> <start_page> <end_page> -hires"); } } else { Main.status("usage: Main <blogname> <start_page> <end_page> -hires"); } }
/** * DOCUMENT ME! * * @return DOCUMENT ME! */ public static FortfuehrungsanlaesseDialog getInstance() { if (INSTANCE == null) { INSTANCE = new FortfuehrungsanlaesseDialog(Main.getCurrentInstance(), false); INSTANCE.setLocationRelativeTo(Main.getCurrentInstance()); } return INSTANCE; }
public static void save() { Main.status("Saving databases."); File file = new File(blogdir, "picpic.db"); List<Object> objects = new ArrayList<>(); objects.add(Main.post_post_hash); Helper.saveObjectToFile(file, objects); Main.status("Done saving databases."); }
private void updateRepeatMode() { if (Main.getAudioPlayer() != null) { if (repeat) { Main.getAudioPlayer().setNumberOfLoops(-1); } else { Main.getAudioPlayer().setNumberOfLoops(0); } } }
public void input(int slot, ClickType action) { ItemStack is = null; if (slot >= 0 && slot <= 8) { if (slot == 8) { this.sfx(Sound.CLICK); this.close(true); return; } is = this.inventory.getItem(slot); if (is != null) { String s = Main.getItemData(is, 0); if (!s.isEmpty()) { if (s.startsWith("#")) { try { int id = Integer.parseInt(s.substring(1)); this.sfx(Sound.CLICK); this.recipe.remove((Object) id); Main.giveReward(this.editing, id); } catch (NumberFormatException e) { } } } } } else if (slot >= 9 && slot <= 45) { if (slot >= 9 && slot <= 35) { is = this.editing.getInventory().getItem(slot); } else if (slot >= 36 && slot <= 45) { is = this.editing.getInventory().getItem(slot - 36); } if (is != null) { String s = Main.getItemData(is, 0); if (!s.isEmpty()) { if (s.startsWith("#")) { try { int id = Integer.parseInt(s.substring(1)); if (this.recipe.size() >= 4) { this.editing.sendMessage("Cannot fuse more than 4 cards."); this.sfx(Sound.FIRE_IGNITE); return; } this.recipe.add(id); this.sfx(Sound.CLICK); is = is.clone(); is.setAmount(1); this.editing.getInventory().removeItem(is); } catch (NumberFormatException e) { } } } } } this.updateInterface(); }
public Boolean call() { if (!used.getAndSet(true)) { initContext(); notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>(); compilerMain.setAPIMode(true); result = compilerMain.compile(args, classNames, context, fileObjects, processors); cleanup(); return result == 0; } else { throw new IllegalStateException("multiple calls to method 'call'"); } }
private static void writeDuplicates() { Main.status("Writing duplicates."); if (!dup_post_list.isEmpty()) { Main.status(String.format("%s\t%s", "older_post", "newer_post")); for (Post post : dup_post_list.keySet()) { Main.status(String.format("%s\t%s", post.post_id, dup_post_list.get(post).post_id)); } } else { Main.status("There are no duplicates."); } Main.status("Writing duplicates done."); }
public void run() { ArrayList<Double> output = new ArrayList(); while (true) { int numStudents = Integer.parseInt(Main.ReadLn(1000000)); double runningTotal = 0; double current = 0; double average = 0; double runningTransfer = 0; if (numStudents == 0) break; else if (numStudents > 1000) throw new NumberFormatException(); else if (numStudents % 2 == 0) throw new NumberFormatException(); ArrayList<Double> expenses = new ArrayList(); for (int i = 0; i < numStudents; i++) { current = Double.parseDouble(Main.ReadLn(1000000)); runningTotal = runningTotal + current; expenses.add(current); if (current > 10000 || current < 0) throw new NumberFormatException(); } average = Math.floor((runningTotal * 100) / numStudents) / 100; for (Double d : expenses) { if (d.doubleValue() < average) { runningTransfer = runningTransfer + (average - d.doubleValue()); } } output.add(runningTransfer); } Iterator it = output.iterator(); StringBuilder builder = new StringBuilder(); while (it.hasNext()) { builder.append("$" + String.format("%.2f", it.next())); if (it.hasNext()) { builder.append("\n"); } else { break; } } System.out.println(builder); }
public static void main(String[] args) throws ParseException, InterruptedException { out.println("Usage:"); out.println("create(name, timezone, active)"); out.println("modify(name, timezone, active)"); out.println("addEvent(name, text, datetime)"); out.println("addRandomTimeEvent(name, text, dateFrom, dateTo)"); out.println("removeEvent(name, text)"); out.println("cloneEvent(name, text, nameTo)"); out.println("showInfo(name)"); Main main = new Main(); main.scannerLoop(); main.coordinator(); }
public static void main(String[] args) { Main main = new Main(); main.header("Liquibase SDK"); try { main.init(args); if (main.command == null) { throw new UserError("No command passed"); } if (main.command.equals("help")) { main.printHelp(); return; } VagrantControl vagrantControl; if (main.command.equals("vagrant")) { vagrantControl = new VagrantControl(main); } else { throw new UserError("Unknown command: " + main.command); } CommandLineParser commandParser = new GnuParser(); try { CommandLine commandArguments = commandParser.parse( vagrantControl.getOptions(), main.commandArgs.toArray(new String[main.commandArgs.size()])); vagrantControl.execute(commandArguments); } catch (ParseException e) { throw new UserError("Error parsing command arguments: " + e.getMessage()); } main.divider(); main.out("Command executed successfully"); } catch (UserError userError) { main.out(""); main.header("ERROR EXECUTING COMMAND"); main.out(userError.getMessage()); main.out(""); main.out(""); return; } catch (Throwable exception) { System.out.println("Unexpected error: " + exception.getMessage()); exception.printStackTrace(); } }
public void updateInterface() { ItemStack is = null; this.inventory.clear(); for (Integer card : this.recipe) { is = new ItemStack(Material.PAPER); Duelist.createOwnedCardInfo(is, Card.fromId(card).copy()); this.inventory.addItem(is); } is = new ItemStack(Material.PAPER); Main.setItemName(is, "Confirm"); Main.giveLore(is, 1); Main.setItemData(is, 0, "Initiate Fusion"); this.inventory.setItem(8, is); }
private static void tryResUrls(Picture picture) { String hi_res = ""; String url = picture.media_url.toString(); for (String ending : Main.endings) { try { hi_res = url.replace(url.substring(url.lastIndexOf("_"), url.lastIndexOf(".")), ending); URL hi_url = new URL(hi_res); File hi_name = Helper.extractMediaFileNameFromURL(hi_url); if (hi_name.equals(picture.media_name)) { picture.hi_url = hi_url; picture.hi_name = hi_name; picture.downloaded_hi = true; break; } else { boolean success = Helper.downloadFileFromURLToFileInTemp(hi_url, hi_name); if (success) { picture.hi_url = hi_url; picture.hi_name = hi_name; picture.downloaded_hi = true; Helper.moveTempImageToStore(hi_name, new File(Main.blogdir, picture.md5_id)); break; } } } catch (MalformedURLException ex) { Main.error(String.format("Attempted hi res url %s is a malformed URL.", hi_res)); } } }
public static void load() { Main.status("Loading databases."); File file = new File(blogdir, "picpic.db"); List<Object> objects = Helper.loadObjectFromFile(file); if (objects == null || objects.size() != 1) { Main.error("Unable to load database files so creating new database."); reset(); } else { Main.post_post_hash = (HashMap<Post, Post>) objects.get(0); Main.pic_pic_hash.clear(); Main.pic_post_hash.clear(); Main.dup_post_list.clear(); Main.setupPosts(); } Main.status("Done loading databases."); }
public static void main(String[] args) { ArrayList<Instrument> differentInstrument = new ArrayList<Instrument>(10); try { for (int i = 0; i < 10; i++) { switch (Main.randomGenerator(0, 2)) { case 0: differentInstrument.add(i, new Flute()); break; case 1: differentInstrument.add(i, new Guitar()); break; case 2: differentInstrument.add(i, new Piano()); break; } } } catch (Exception e) { System.out.println(e); } for (int i = 0; i < 10; i++) { if (differentInstrument.get(i) instanceof Piano) System.out.println( "Piano says " + differentInstrument.get(i).message + "\t at index is \t" + i); else if (differentInstrument.get(i) instanceof Guitar) System.out.println( "Guitar says " + differentInstrument.get(i).message + "\t at index is\t " + i); else System.out.println( "Flute says " + differentInstrument.get(i).message + "\t at index is \t" + i); } }
public static void main(String args[]) throws IOException { String[] params = new String[1]; params[0] = args[0] + ".sho"; Main.main(params); }
public ThrowsTagImpl(String text, ClassDocImpl contextClass, MemberDocImpl contextMember) { super(text); char[] textarr = text.toCharArray(); int i = 0; for (; i < textarr.length; ++i) { if (!Parser.isWhitespace(textarr[i])) break; } for (; i < textarr.length; ++i) { if (Parser.isWhitespace(textarr[i])) { this.exceptionName = new String(textarr, 0, i).trim(); this.exceptionComment = new String(textarr, i, textarr.length - i).trim(); break; } } if (null != exceptionName) { if (contextClass == null) { this.exception = Main.getRootDoc().classNamed(exceptionName); } else { this.exception = contextClass.findClass(exceptionName); } if (exception != null) this.exceptionName = exception.qualifiedName(); else { if (text.trim().startsWith("<")) { Main.getRootDoc() .printWarning( "Expected exception name but got '" + text + "' in class " + contextClass.getClassName()); } } } else { Main.getRootDoc() .printWarning( "@throws tag in comment for " + contextClass.qualifiedName() + "." + contextMember.name() + " doesn't specify an exception."); } if (this.exceptionComment != null) { setBody(this.exceptionComment, contextClass, contextMember); } }
public static void quit() { try { if (instance.onQuit()) { System.exit(0); } } catch (Exception e) { Logger().severe("Error when quiting: " + e.getMessage()); } }
public static void main(String[] args) throws IOException { Kronometre kron = new Kronometre(); Main.dataFileName = "data-simulation/large-dataset/DataMatrix.txt"; Map<String, GeneAlt> genes = Main.loadAlterations(); PairSearcher ps = new PairSearcher(genes); ps.search("pair-results.txt"); kron.stop(); kron.print(); }
public static void closeWindow(AbstractWindow window) { if (window.getJustHide()) { window.setVisible(false); } else { if (window.onClose() && instance.onClose(window)) { window.setVisible(false); removeWindow(window); } } }
public static void main(String[] args) throws IOException { // in = new BufferedReader(new FileReader("input.txt")); // out = new PrintWriter(new FileWriter("output.txt")); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); Main.solve(); out.close(); in.close(); }
void Begin() { String input; StringTokenizer idata; final int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129 }; int[][] result = new int[1121][15]; int siz; int inp; int prm; int n; int r; result[0][0] = 1; // for(i = 0; i < 1121; i++) // result[i][0] = 1; // need prime loop first to prevent repeats for (prm = 0; prm < 189; prm++) { for (inp = 1120; inp >= primes[prm]; inp--) // need to decrement to prevent { for (siz = 1; siz < 15; siz++) { result[inp][siz] += result[inp - primes[prm]][siz - 1]; // if(inp <= 24 && siz <= 3 && result[inp - primes[prm]][siz - 1] != 0) // System.out.println("GOT " + primes[prm] + ": [" + inp + "][" + siz + "] = " + // result[inp][siz]); } } } /* for(i=0;i<189;i++) for(j=1120;j>=primes[i];j--) for(k=1;k<15;k++) result[j][k]+=result[j-primes[i]][k-1]; */ // System.out.println(""); while (true) { input = Main.ReadLn(255); idata = new StringTokenizer(input); n = Integer.parseInt(idata.nextToken()); r = Integer.parseInt(idata.nextToken()); if (n == 0 && r == 0) break; System.out.println(result[n][r]); } }
@Override protected void tearDown() throws Exception { super.tearDown(); framework.stop(); IO.delete(tmp); Main.stop(); IO.delete(IO.getFile("generated/cache")); IO.delete(IO.getFile("generated/storage")); framework.waitForStop(100000); super.tearDown(); }
public static void configInit() { DCServerConfig dcs = Main.getServerConfig(); if (dcs != null) { TrackServer.setTcpIdleTimeout(dcs.getTcpIdleTimeoutMS(Constants.TIMEOUT_TCP_IDLE)); TrackServer.setTcpPacketTimeout(dcs.getTcpPacketTimeoutMS(Constants.TIMEOUT_TCP_PACKET)); TrackServer.setTcpSessionTimeout(dcs.getTcpSessionTimeoutMS(Constants.TIMEOUT_TCP_SESSION)); TrackServer.setUdpIdleTimeout(dcs.getUdpIdleTimeoutMS(Constants.TIMEOUT_UDP_IDLE)); TrackServer.setUdpPacketTimeout(dcs.getUdpPacketTimeoutMS(Constants.TIMEOUT_UDP_PACKET)); TrackServer.setUdpSessionTimeout(dcs.getUdpSessionTimeoutMS(Constants.TIMEOUT_UDP_SESSION)); } }
public static void downloadHiRes() { Main.status("Downloading hi res versions of photos in database."); if (gui != null) { gui.setProgress(0); gui.setMaxProgress(pic_pic_hash.keySet().size()); } int progress = 0; for (Picture picture : pic_pic_hash.keySet()) { if (!picture.downloaded_hi) { tryResUrls(picture); } if (gui != null) { gui.setProgress(progress); progress++; } } if (gui != null) { gui.setProgress(progress); progress++; } Main.status("Done downloading hi res versions."); }
private void prepareCompiler() throws IOException { if (used.getAndSet(true)) { if (compiler == null) throw new IllegalStateException(); } else { initContext(); compilerMain.setOptions(Options.instance(context)); compilerMain.filenames = new LinkedHashSet<File>(); Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args), classNames); if (!filenames.isEmpty()) throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " ")); compiler = JavaCompiler.instance(context); compiler.keepComments = true; compiler.genEndPos = true; // NOTE: this value will be updated after annotation processing compiler.initProcessAnnotations(processors); notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>(); for (JavaFileObject file : fileObjects) notYetEntered.put(file, null); genList = new ListBuffer<Env<AttrContext>>(); // endContext will be called when all classes have been generated // TODO: should handle the case after each phase if errors have occurred args = null; classNames = null; } }
private static void showHelpAndExit( final Context context, final boolean headers, final List<CompileParameter> parameters) { if (headers) { context.show("DSL Platform - Command-Line Client (" + Main.getVersion() + ")"); context.show( "This tool allows you to compile provided DSL to various languages such as Java, Scala, PHP, C#, etc... or create an SQL migration between two DSL models."); } context.show(); context.show(); context.show("Command parameters:"); int max = 0; for (final CompileParameter cp : parameters) { if (cp.getShortDescription() == null) { continue; } int width = cp.getAlias().length(); if (cp.getUsage() != null) { width += 1 + cp.getUsage().length(); } if (max < width) { max = width; } } max += 2; for (final CompileParameter cp : parameters) { if (cp.getShortDescription() == null) { continue; } final StringBuilder sb = new StringBuilder(); sb.append(" -").append(cp.getAlias()); int len = max - cp.getAlias().length(); if (cp.getUsage() != null) { sb.append("=").append(cp.getUsage()); len -= cp.getUsage().length() + 1; } for (; len >= 0; len--) { sb.append(' '); } sb.append(cp.getShortDescription()); context.show(sb.toString()); } context.show(); context.show("Example usages:"); context.show("\ttarget=java_client,revenj.java postgres=localhost/Database?user=postgres"); context.show( "\tjava_client=model.jar revenj.net=Model.dll postgres=localhost/Database?user=postgres"); context.show("\tproperties=development.props download"); }
public void close(boolean fuse) { PluginVars.commu_mode.remove(this.editing); this.editing.closeInventory(); if (fuse) { if (!this.editing.isOnline()) { this.returnCards(); return; } else if (!this.receiver.isOnline()) { this.editing.sendMessage( "Player " + this.receiver.getDisplayName() + ChatColor.WHITE + " has gone offline"); this.returnCards(); return; } if (this.recipe.size() > 4 || this.recipe.size() < 3) { this.editing.sendMessage("You must use 3 or 4 cards in a commu fusion!"); this.returnCards(); return; } else { if (this.editing.getLocation().distance(this.receiver.getLocation()) > 6.0d) { this.editing.sendMessage("MISS!"); this.editing.sendMessage( "Player " + this.receiver.getDisplayName() + " has gone out of reach."); this.returnCards(); return; } this.editing .getWorld() .playSound(this.editing.getLocation(), Sound.FIREWORK_BLAST, 1.0f, 1.0f); this.receiver .getWorld() .playSound(this.receiver.getLocation(), Sound.FIREWORK_BLAST, 1.0f, 1.0f); try { int result = this.fuse(); Main.giveReward(this.receiver, result); this.receiver.sendMessage("Commu Fusion: " + Card.fromId(result).name); this.editing.sendMessage(ChatColor.GREEN + "SUCCESS!!!"); } catch (NoCardCreatedException e) { this.editing.sendMessage( ChatColor.RED + "FAILED!!!\n" + ChatColor.YELLOW + "\nNo card created."); } } } else { this.editing.sendMessage("Cancelled fusion"); this.returnCards(); } }
JavacTaskImpl( Main compilerMain, String[] args, String[] classNames, Context context, List<JavaFileObject> fileObjects) { this.ccw = ClientCodeWrapper.instance(context); this.compilerMain = compilerMain; this.args = args; this.classNames = classNames; this.context = context; this.fileObjects = fileObjects; setLocale(Locale.getDefault()); // null checks compilerMain.getClass(); args.getClass(); fileObjects.getClass(); }