List of usage examples for org.apache.commons.lang StringUtils center
public static String center(String str, int size)
Centers a String in a larger String of size size
using the space character (' ').
From source file:com.temenos.interaction.command.HelloWorldCommand.java
public Result execute(InteractionContext ctx) throws InteractionException { logger.warn("\n" + StringUtils.repeat("=", 102) + "\n" + StringUtils.repeat(" ", 102) + "\n" + "|" + StringUtils.center("DEMO COMMAND WORKING AGAIN", 100) + "|\n" + StringUtils.repeat(" ", 102) + "\n" + StringUtils.repeat("=", 102) + "\n"); return wrappedCommand.execute(ctx); }
From source file:com.leavesfly.lia.advsearching.SortingExample.java
public void displayResults(Query query, Sort sort) // #1 throws IOException { IndexSearcher searcher = new IndexSearcher(directory); searcher.setDefaultFieldSortScoring(true, false); // #2 TopDocs results = searcher.search(query, null, // #3 20, sort); // #3 System.out.println("\nResults for: " + // #4 query.toString() + " sorted by " + sort); System.out.println(StringUtils.rightPad("Title", 30) + StringUtils.rightPad("pubmonth", 10) + StringUtils.center("id", 4) + StringUtils.center("score", 15)); PrintStream out = new PrintStream(System.out, true, "UTF-8"); // #5 DecimalFormat scoreFormatter = new DecimalFormat("0.######"); for (ScoreDoc sd : results.scoreDocs) { int docID = sd.doc; float score = sd.score; Document doc = searcher.doc(docID); out.println(StringUtils.rightPad( // #6 StringUtils.abbreviate(doc.get("title"), 29), 30) + // #6 StringUtils.rightPad(doc.get("pubmonth"), 10) + // #6 StringUtils.center("" + docID, 4) + // #6 StringUtils.leftPad( // #6 scoreFormatter.format(score), 12)); // #6 out.println(" " + doc.get("category")); // out.println(searcher.explain(query, docID)); // #7 }/*from w w w . ja v a 2 s.com*/ searcher.close(); }
From source file:co.uk.randompanda30.sao.view.submenus.V_MENU_PH_OWNED.java
public ItemStack getHousing_IcrmRentItem(Player player) { String house = HousePlayerQuery.getHouse(player); long days = HouseHomeQuery.getHomeTimeInDays(house); return ItemBuilder.buildItem("Increase rent time!", Material.GOLD_INGOT, 1, 1, new ArrayList<String>() { {//from w w w. j a va2 s .c om add("%TClick to add another day's rent to your time"); add(" "); add(StringUtils.center( "&b&lTime remaning: &a&l" + ((days != 0 ? Long.toString(days) + " days" : "&c&l> 1 day left")), ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH)); } }); }
From source file:com.vamonossoftware.core.TextTable.java
public String toString() { StringBuilder sb = new StringBuilder(); for (Object[] objects : data) { sb.append(leftPad);//www. ja v a 2s. c o m for (int i = 0; i < objects.length; i++) { Object object = objects[i]; if (alignment.length > i) { switch (alignment[i]) { case CENTER: sb.append(StringUtils.center(object.toString(), maxWidths.get(i))); break; case RIGHT: sb.append(StringUtils.leftPad(object.toString(), maxWidths.get(i))); break; default: sb.append(StringUtils.rightPad(object.toString(), maxWidths.get(i))); break; } } sb.append(" "); } sb.append("\n"); } return sb.toString(); }
From source file:aos.lucene.search.advanced.SortingExample.java
public void displayResults(Query query, Sort sort) // throws IOException { IndexSearcher searcher = new IndexSearcher(directory); searcher.setDefaultFieldSortScoring(true, false); // TopDocs results = searcher.search(query, null, // 20, sort); // LOGGER.info("\nResults for: " + // query.toString() + " sorted by " + sort); LOGGER.info(StringUtils.rightPad("Title", 30) + StringUtils.rightPad("pubmonth", 10) + StringUtils.center("id", 4) + StringUtils.center("score", 15)); PrintStream out = new PrintStream(System.out, true, "UTF-8"); // DecimalFormat scoreFormatter = new DecimalFormat("0.######"); for (ScoreDoc sd : results.scoreDocs) { int docID = sd.doc; float score = sd.score; Document doc = searcher.doc(docID); out.println(StringUtils.rightPad( // StringUtils.abbreviate(doc.get("title"), 29), 30) + // StringUtils.rightPad(doc.get("pubmonth"), 10) + // StringUtils.center("" + docID, 4) + // StringUtils.leftPad( // scoreFormatter.format(score), 12)); // out.println(" " + doc.get("category")); //out.println(searcher.explain(query, docID)); // }// w w w. j a va 2 s .c o m searcher.close(); }
From source file:biblivre3.utils.TextUtils.java
public static String center(String text, int length) { if (text == null) { text = ""; }//from www . j av a 2s . com if (text.length() > length) { return text.substring(0, length); } return StringUtils.center(text, length); }
From source file:de.pellepelster.ant.statistics.AsciiTable.java
private void createCenteredLine(int totalTableWidth, String text, StringBuffer result) { result.append(HORIZONTAL_TABLE_BORDER); result.append(StringUtils.center(text, totalTableWidth)); result.append(HORIZONTAL_TABLE_BORDER); result.append(NEWLINE);/*from w w w . j av a 2 s .c o m*/ }
From source file:co.uk.randompanda30.sao.modules.enhancement.BoosterHandler.java
public static void startBooster(Booster booster) { setBooster(booster);/* w w w . ja v a 2s .c om*/ showingBoosterMessage = true; List<String> messages = (List<String>) Messages.MessagesValues.MODULES_BOOSTER_BOOSTERSTARTED.value; new BukkitRunnable() { @Override public void run() { for (String s : messages) { SAO.getPlugin().getServer().getScheduler().runTask(SAO.getPlugin(), () -> { if (Bukkit.getServer().getPlayer(booster.uuid) != null && Bukkit.getServer().getPlayer(booster.uuid).isOnline()) { Firework fw = (Firework) Bukkit.getServer().getPlayer(booster.uuid).getWorld() .spawnEntity(Bukkit.getServer().getPlayer(booster.uuid).getLocation(), EntityType.FIREWORK); FireworkMeta fwm = fw.getFireworkMeta(); FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.FUCHSIA) .withFade(Color.FUCHSIA).with(FireworkEffect.Type.BALL_LARGE).trail(true) .build(); fwm.addEffect(effect); fwm.setPower(0); fw.setFireworkMeta(fwm); } }); Dispatch.broadcastMessage(" ", true); String newS = s; newS = newS.replaceAll("%player", booster.name); newS = newS.replaceAll("%perc", Integer.toString(booster.percentage)); Dispatch.broadcastMessage(StringUtils.center(newS, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH), true); Yell.broadcastSound(Sound.NOTE_BASS, 5, 2); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } Yell.broadcastSound(Sound.LEVEL_UP, 5, 1); Play.broadcastEffect(Effect.ENDER_SIGNAL, 5); showingBoosterMessage = false; } }.runTaskAsynchronously(SAO.getPlugin()); }
From source file:de.pellepelster.ant.statistics.AsciiTable.java
private void createRow(Map<Integer, Integer> maxColumnWidths, String[] row, StringBuffer result) { result.append(HORIZONTAL_TABLE_BORDER); for (int columnIndex = 0; columnIndex < row.length; columnIndex++) { String cellText = row[columnIndex]; result.append(StringUtils.repeat(" ", HORIZONTAL_CELLPADDING)); result.append(StringUtils.center(cellText, maxColumnWidths.get(columnIndex))); result.append(StringUtils.repeat(" ", HORIZONTAL_CELLPADDING)); if (columnIndex < headers.length - 1) { result.append(HORIZONTAL_TABLE_BORDER); }/* w w w. ja v a 2 s .c om*/ } result.append(HORIZONTAL_TABLE_BORDER); result.append(NEWLINE); }
From source file:co.uk.randompanda30.sao.modules.player.PurgePlayerData.java
public void announce() { List<String> messages = (List<String>) Messages.MessagesValues.MODULES_PLAYERDATA_RESET.value; Bukkit.getScheduler().runTaskAsynchronously(SAO.getPlugin(), () -> { for (String s : messages) { Dispatch.sendMessage(StringUtils.center(s, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH), player); player.playSound(player.getLocation(), Sound.NOTE_BASS, 5, 2); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace();// ww w .java 2 s. c om } } }); }