当前位置: 首页>>代码示例>>Java>>正文


Java ShownBorders类代码示例

本文整理汇总了Java中org.nocrala.tools.texttablefmt.ShownBorders的典型用法代码示例。如果您正苦于以下问题:Java ShownBorders类的具体用法?Java ShownBorders怎么用?Java ShownBorders使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ShownBorders类属于org.nocrala.tools.texttablefmt包,在下文中一共展示了ShownBorders类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderEffectsString

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
public String renderEffectsString(List<Effect> effects) {
    Table t = new Table(2, BorderStyle.CLASSIC_COMPATIBLE,
            ShownBorders.NONE);

    t.setColumnWidth(0, 16, 20);
    // t.setColumnWidth(1, 10, 13);

    int i = 1;
    for (Effect effect : effects) {
        int percent = 100 - (int) ((effect.getEffectApplications() * 100.0f) / effect.getMaxEffectApplications());
        t.addCell(drawProgressBar(percent));
        t.addCell(effect.getEffectName());
        i++;
    }
    return t.render();
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:17,代码来源:GameManager.java

示例2: getTextTable

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
/**
 * Prints Text Table based on TestResults. Method uses library:
 * http://grepcode.com/snapshot/repo1.maven.org/maven2/org.ow2.sirocco/sirocco-text-table-formatter/1.0/
 *
 * @param testResults
 */
public static String getTextTable(TestResults testResults) {
    if (testResults == null || testResults.getColumns() == null || testResults.getRows() == null || testResults.getColumns
            ().isEmpty() || testResults.getRows().isEmpty() || testResults.getNmbOfRows() == null || testResults
            .getRows().get(0).size() != testResults.getColumns().size()) {
        return "Incorrect TestResults. The table of differences can NOT be printed!";
    }
    CellStyle cs = new CellStyle(CellStyle.HorizontalAlign.left, CellStyle.AbbreviationStyle.crop,
            CellStyle.NullStyle.emptyString);
    Table t = new Table(testResults.getColumns().size(), BorderStyle.DESIGN_TUBES, ShownBorders
            .SURROUND_HEADER_AND_COLUMNS, false, "");
    for (String column : testResults.getColumns()) {
        t.addCell(column, cs);
    }
    for (List<String> row : testResults.getRows()) {
        for (String rowVal : row) {
            t.addCell("'" + rowVal + "'", cs);
        }
    }
    String stringTable = "The table of differences (" + testResults.getRows().size() + " rows):\r\n" + t.render();

    // printing to HTML report (testNG) -> generating HTML report is transparent in TestNG -> so is method call
    // below (we do not do this in test class itself)
    addReporterLog(stringTable);
    return stringTable;
}
 
开发者ID:ObjectivityLtd,项目名称:DBTestCompare,代码行数:32,代码来源:Printer.java

示例3: renderCoolDownString

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
public String renderCoolDownString(Set<CoolDown> coolDowns) {
    Table t = new Table(2, BorderStyle.CLASSIC_COMPATIBLE,
            ShownBorders.NONE);

    t.setColumnWidth(0, 19, 25);
    // t.setColumnWidth(1, 10, 13);

    int i = 1;
    for (CoolDown coolDown : coolDowns) {
        int percent = 100 - (int) (((coolDown.getOriginalNumberOfTicks() - coolDown.getNumberOfTicks()) * 100.0f) / coolDown.getOriginalNumberOfTicks());
        // 1 tick == .5 seconds.
        int approxSecondsRemaining = coolDown.getNumberOfTicks() / 2;
        FriendlyTime friendlyTime = new FriendlyTime(approxSecondsRemaining);
        String friendlyFormattedShort = friendlyTime.getFriendlyFormattedShort();
        t.addCell(drawProgressBar(percent) + friendlyFormattedShort);
        t.addCell(coolDown.getName());
        i++;
    }
    return t.render();
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:21,代码来源:GameManager.java

示例4: getInventoryPrintMenu

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
public String getInventoryPrintMenu(Map<Integer, InventoryItemForSale> menu) {
    Table t = new Table(3, BorderStyle.CLASSIC_COMPATIBLE,
            ShownBorders.HEADER_FIRST_AND_LAST_COLLUMN);
    t.setColumnWidth(0, 5, 5);
    t.setColumnWidth(1, 12, 12);
    t.setColumnWidth(2, 50, 69);
    t.addCell("#");
    t.addCell("price");
    t.addCell("description");
    Iterator<Map.Entry<Integer, InventoryItemForSale>> entries = menu.entrySet().iterator();
    while (entries.hasNext()) {
        Map.Entry<Integer, InventoryItemForSale> next = entries.next();
        t.addCell(String.valueOf(next.getKey()));
        t.addCell(NumberFormat.getNumberInstance(Locale.US).format(next.getValue().getCost()));
        t.addCell(next.getValue().getItem().getItemDescription());
    }
    return t.render() + "\r\n";
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:19,代码来源:MerchantCommandHandler.java

示例5: getMenu

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
public String getMenu() {
    Table t = new Table(3, BorderStyle.CLASSIC_COMPATIBLE,
            ShownBorders.HEADER_FIRST_AND_LAST_COLLUMN);
    t.setColumnWidth(0, 5, 5);
    t.setColumnWidth(1, 12, 16);
    t.setColumnWidth(2, 50, 69);
    t.addCell("#");
    t.addCell("price");
    t.addCell("description");
    int i = 0;
    Iterator<MerchantItemForSale> iterator = merchantItemForSales.iterator();
    while (iterator.hasNext()) {
        i++;
        MerchantItemForSale merchantItemForSale = iterator.next();
        Optional<ItemMetadata> itemMetadataOptional = gameManager.getItemStorage().get(merchantItemForSale.getInternalItemName());
        if (!itemMetadataOptional.isPresent()) {
            continue;
        }
        ItemMetadata itemMetadata = itemMetadataOptional.get();
        t.addCell(String.valueOf(i));
        t.addCell(NumberFormat.getNumberInstance(Locale.US).format(merchantItemForSale.getCost()));
        t.addCell(itemMetadata.getItemDescription());
    }
    return t.render();
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:26,代码来源:Merchant.java

示例6: buildEquipmentString

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
public String buildEquipmentString() {
    Table t = new Table(2, BorderStyle.CLASSIC_COMPATIBLE,
            ShownBorders.NONE);
    t.setColumnWidth(0, 16, 20);

    List<EquipmentSlotType> all = EquipmentSlotType.getAll();
    for (EquipmentSlotType slot : all) {
        t.addCell(capitalize(slot.getName()));
        Optional<Item> slotItemOptional = getSlotItem(slot);
        if (slotItemOptional.isPresent()) {
            t.addCell(slotItemOptional.get().getItemName());
        } else {
            t.addCell("");
        }
    }
    return t.render();
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:18,代码来源:Player.java

示例7: messageReceived

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    this.execCommand(ctx, e, () -> {
        Table table = new Table(2, BorderStyle.CLASSIC_COMPATIBLE, ShownBorders.HEADER_ONLY);
        table.setColumnWidth(0, 22, 30);
        table.setColumnWidth(1, 10, 20);
        table.addCell("Npc");
        table.addCell("# Killed");
        Map<String, Long> npcKillLog = player.getNpcKillLog();
        npcKillLog.forEach((s, aLong) -> {
            table.addCell(s);
            table.addCell(String.valueOf(aLong));
        });
        write(table.render());
    });
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:17,代码来源:KillTallyCommand.java

示例8: configureTableOutput

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
private Table configureTableOutput() {
    Table t = new Table(8, BorderStyle.BLANKS, ShownBorders.NONE);
    t.setColumnWidth(0, 20, 20);
    t.setColumnWidth(1, 15, 20);
    t.setColumnWidth(2, 13, 16);
    t.setColumnWidth(3, 10, 16);
    t.setColumnWidth(4, 13, 16);
    t.setColumnWidth(5, 10, 16);
    t.setColumnWidth(6, 13, 16);

    t.addCell("Npc");
    t.addCell("Player Level");
    t.addCell("Player Win");
    t.addCell("Npc Win");
    t.addCell("Avg Turns");
    t.addCell("Avg Gold");
    t.addCell("XP Earned");
    t.addCell("Drops");
    return t;
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:21,代码来源:NpcTestHarness.java

示例9: getBattleReport

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
private String getBattleReport(long xpEarned) {
    StringBuilder sb = new StringBuilder();
    sb.append(Color.MAGENTA).append("Battle Report----------------------------").append(Color.RESET).append("\r\n");
    sb.append("You killed a ");
    sb.append(getColorName());
    sb.append(" for ");
    sb.append(Color.GREEN);
    sb.append("+");
    sb.append(NumberFormat.getNumberInstance(Locale.US).format(xpEarned));
    sb.append(Color.RESET);
    sb.append(" experience points.");
    sb.append("\r\n");

    Set<Map.Entry<String, Long>> entries = getPlayerDamageMap().entrySet();
    Table t = new Table(2, BorderStyle.CLASSIC_COMPATIBLE,
            ShownBorders.NONE);

    t.setColumnWidth(0, 14, 24);
    t.setColumnWidth(1, 10, 13);
    t.addCell("Player");
    t.addCell("Damage");
    for (Map.Entry<String, Long> entry : entries) {
        Player player = gameManager.getPlayerManager().getPlayer(entry.getKey());
        String name = null;
        if (player != null) {
            name = player.getPlayerName();
        }
        long damageAmt = entry.getValue();
        t.addCell(name);
        t.addCell(NumberFormat.getNumberInstance(Locale.US).format(damageAmt));
    }
    sb.append(t.render());
    return sb.toString();
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:35,代码来源:Npc.java

示例10: messageReceived

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    execCommand(ctx, e, () -> {
        Optional<PlayerMetadata> playerMetadataOptional = playerManager.getPlayerMetadata(player.getPlayerId());
        if (!playerMetadataOptional.isPresent()) {
            return;
        }
        PlayerMetadata playerMetadata = playerMetadataOptional.get();
        long nextLevel = Levels.getLevel(playerMetadata.getStats().getExperience()) + 1;
        long expToNextLevel = Levels.getXp(nextLevel) - playerMetadata.getStats().getExperience();
        Meter meter = Main.metrics.meter("experience-" + player.getPlayerName());

        Table table = new Table(2, BorderStyle.CLASSIC_COMPATIBLE, ShownBorders.NONE);

        table.setColumnWidth(0, 8, 20);
        table.setColumnWidth(1, 10, 20);
        table.addCell("Window");
        table.addCell("XP/sec");
        table.addCell(" 1 min");
        table.addCell(String.valueOf(round(meter.getOneMinuteRate())));
        table.addCell(" 5 min");
        table.addCell(String.valueOf(round(meter.getFiveMinuteRate())));
        table.addCell("15 min");
        table.addCell(String.valueOf(round(meter.getFifteenMinuteRate())));

        write(NumberFormat.getNumberInstance(Locale.US).format(expToNextLevel) + " experience to level " + nextLevel + ".\r\n" + table.render());
    });
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:29,代码来源:XpCommand.java

示例11: messageReceived

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    execCommand(ctx, e, () -> {
        StringBuilder output = new StringBuilder();
        // output.append(Color.MAGENTA + "Who--------------------------------" + Color.RESET).append("\r\n");
        Table t = new Table(4, BorderStyle.BLANKS,
                ShownBorders.NONE);
        t.setColumnWidth(0, 14, 24);
        t.setColumnWidth(1, 7, 7);
        t.setColumnWidth(2, 16, 16);
        t.addCell("Player");
        t.addCell("Level");
        t.addCell("XP");
        t.addCell("Location");
        Set<Player> allPlayers = gameManager.getAllPlayers();
        for (Player allPlayer : allPlayers) {
            t.addCell(allPlayer.getPlayerName());
            Optional<PlayerMetadata> playerMetadataOptional = playerManager.getPlayerMetadata(allPlayer.getPlayerId());
            if (!playerMetadataOptional.isPresent()){
                continue;
            }
            PlayerMetadata playerMetadata = playerMetadataOptional.get();
            t.addCell(Long.toString(Levels.getLevel(playerMetadata.getStats().getExperience())));
            t.addCell(NumberFormat.getNumberInstance(Locale.US).format((playerMetadata.getStats().getExperience())));
            t.addCell(roomManager.getPlayerCurrentRoom(allPlayer).get().getRoomTitle());
        }
        output.append(t.render());
        write(output.toString());
    });
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:31,代码来源:WhoCommand.java

示例12: messageReceived

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    execCommand(ctx, e, () -> {
        Table t = new Table(4, BorderStyle.BLANKS,
                ShownBorders.NONE);
        t.setColumnWidth(0, 14, 24);
        t.setColumnWidth(1, 18, 18);
        t.setColumnWidth(2, 21, 21);
        t.addCell("Player");
        t.addCell("IP");
        t.addCell("Logged in since");
        t.addCell("Idle");
        Set<Player> allPlayers = gameManager.getAllPlayers();
        for (Player allPlayer : allPlayers) {
            t.addCell(allPlayer.getPlayerName());

            InetSocketAddress remoteAddress = (InetSocketAddress) allPlayer.getChannel().getRemoteAddress();
            String remoteUsersHost = remoteAddress.getHostString();
            t.addCell(remoteUsersHost);

            SimpleDateFormat loggedInFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
            String loginTime = loggedInFormat.format(new Date(playerManager.getSessionManager().getSession(allPlayer.getPlayerId()).getInitialLoginTime()));
            t.addCell(loginTime);

            long lastActivity = playerManager.getSessionManager().getSession(allPlayer.getPlayerId()).getLastActivity();
            String idleTime = getFriendlyTime(new Date(lastActivity));
            t.addCell(idleTime);
        }
        write(t.render());
    });
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:32,代码来源:UsersCommand.java

示例13: messageReceived

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    execCommand(ctx, e, () -> {
        StringBuilder sb = new StringBuilder();
        Table t = new Table(2, BorderStyle.CLASSIC_COMPATIBLE,
                ShownBorders.HEADER_FIRST_AND_LAST_COLLUMN);
        t.setColumnWidth(0, 10, 30);
        t.setColumnWidth(1, 30, 55);
        t.addCell("commands");
        t.addCell("description");
        Set<Command> creeperCommands = ConfigureCommands.creeperCommandRegistry.getCreeperCommands();
        for (Command command : creeperCommands) {
            Joiner.on(" ").join(validTriggers);
            if (command.roles != null) {
                if (command.roles.contains(PlayerRole.ADMIN)) {
                    if (!playerManager.hasRole(player, PlayerRole.ADMIN)) {
                        continue;
                    }
                }
            }
            t.addCell(command.correctUsage);
            t.addCell(command.description);
        }
        sb.append(t.render());
        sb.append("\r\n");
        write(sb.toString());
    });
}
 
开发者ID:chriskearney,项目名称:creeper,代码行数:29,代码来源:HelpCommand.java

示例14: displaySavedTimesStatistics

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
@AfterSuite
public  void displaySavedTimesStatistics(){
    savedTimesList.sort(Comparator.comparing(SavedTimes::getDuration).reversed());
    Map<String, List<SavedTimes>> savedTimesListGrouped =
            savedTimesList.stream().collect(Collectors.groupingBy(w -> w.getTestName()));

    CellStyle cs = new CellStyle(CellStyle.HorizontalAlign.left, CellStyle.AbbreviationStyle.crop,
            CellStyle.NullStyle.emptyString);
    Table t = new Table(5, BorderStyle.DESIGN_TUBES, ShownBorders
            .SURROUND_HEADER_AND_COLUMNS, false, "");
    t.addCell("Test Name", cs);
    t.addCell("Measure Type", cs);
    t.addCell("Duration min:s:ms", cs);
    t.addCell("Compared rows", cs);
    t.addCell("Status", cs);
    int i=0;
    savedTimesListGrouped.forEach((String key, List<SavedTimes> value) -> {
        value.forEach((SavedTimes v) -> {
            t.addCell(v.getTestName().trim(), cs)
            ;
            t.addCell(v.getMeasureType().trim(), cs);
            t.addCell(v.getFormattedDuration().replace("min:s:ms", "").trim(), cs)
            ;
            t.addCell(v.getNumberOfComparedRows(), cs);
            t.addCell(v.getTestResult().trim(), cs);
        });
    });
    String stringTable = "Statistics of queries execution  group by test name(" + savedTimesListGrouped.size() + " rows):\r\n" + t.render();
    Printer.addReporterLog(stringTable);

    log.log(Level.OFF, "##teamcity[message '"+stringTable+"']");
    log.info(stringTable);

    Table ts = new Table(3, BorderStyle.DESIGN_TUBES, ShownBorders
            .SURROUND_HEADER_AND_COLUMNS, false, "");
    ts.addCell("Test Name", cs);
    ts.addCell("Measure Type", cs);
    ts.addCell("Duration min:s:ms", cs);
    savedTimesList.forEach(s -> {ts.addCell(s.getTestName().trim(), cs)
    ;ts.addCell(s.getMeasureType().trim(), cs);ts.addCell(s.getFormattedDuration().replace("min:s:ms","").trim(), cs);});

    stringTable = "Statistics of queries execution sorted by time execution (" + savedTimesList.size() + " rows):\r\n" + ts.render();
    Printer.addReporterLog(stringTable);

    log.log(Level.OFF, "##teamcity[message '"+stringTable+"']");
    log.info(stringTable);

}
 
开发者ID:ObjectivityLtd,项目名称:DBTestCompare,代码行数:49,代码来源:DBTestCompare.java

示例15: execute

import org.nocrala.tools.texttablefmt.ShownBorders; //导入依赖的package包/类
public static void execute(final Namespace parsedArgs) throws IOException, ValidationException {
    final Map<String, NamespaceConfig> namespaces = new Planout4jRepositoryImpl().loadAllNamespaceConfigs();
    final DisplayMode mode = parsedArgs.get("mode");
    final Table table = new Table(5, BorderStyle.CLASSIC, ShownBorders.ALL);
    addCells(table, "name", "total segs", "used segs", "definitions", "active experiments");
    final ConfigFormatter configFormatter = Planout4jTool.getConfigFormatter(parsedArgs);

    final String namePatternStr = StringUtils.lowerCase(parsedArgs.getString("name"));
    Pattern namePattern = null;
    try {
        if (namePatternStr != null && !StringUtils.isAlphanumeric(namePatternStr)) {
            LOG.debug("name pattern '{}' is not alphanumeric, assuming a regex", namePatternStr);
            namePattern = Pattern.compile(namePatternStr, Pattern.CASE_INSENSITIVE);
        }
    } catch (PatternSyntaxException e) {
        LOG.warn("Invalid name regex, listing all namespace", e);
    }

    for (String name : new TreeSet<>(namespaces.keySet())) {
        NamespaceConfig nsConf = namespaces.get(name);
        if (namePatternStr == null
                || namePattern != null && namePattern.matcher(name).matches()
                || name.toLowerCase().contains(namePatternStr))
        {
            switch (mode) {
                case full:
                    System.out.printf("********************** START of %s *********************\n", name);
                    System.out.println(configFormatter.format(nsConf.getConfig()));
                    System.out.printf("*********************** END of %s **********************\n", name);
                    break;
                case summary:
                    addCells(table, name, nsConf.getTotalSegments(), nsConf.getUsedSegments(),
                            nsConf.getExperimentDefsCount(), nsConf.getActiveExperimentsCount());
                    break;
                case experiments:
                    for (String experimentName : nsConf.getActiveExperimentNames()) {
                        System.out.println(name + "," + experimentName);
                    }
                    break;
            }
        } else {
            LOG.trace("namespace name {} doesn't match pattern {}", name, namePatternStr);
        }
    }
    if (mode == DisplayMode.summary) {
        System.out.println(table.render());
    }
}
 
开发者ID:Glassdoor,项目名称:planout4j,代码行数:49,代码来源:NslistTool.java


注:本文中的org.nocrala.tools.texttablefmt.ShownBorders类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。