Java 类org.springframework.boot.ansi.AnsiColor 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ColorConverter.java   
@Override
public void format(LogEvent event, StringBuilder toAppendTo) {
    StringBuilder buf = new StringBuilder();
    for (PatternFormatter formatter : this.formatters) {
        formatter.format(event, buf);
    }
    if (buf.length() > 0) {
        AnsiElement element = this.styling;
        if (element == null) {
            // Assume highlighting
            element = LEVELS.get(event.getLevel().intLevel());
            element = (element == null ? AnsiColor.GREEN : element);
        }
        appendAnsiString(toAppendTo, buf.toString(), element);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringBootBanner.java   
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
        PrintStream printStream) {
    for (String line : BANNER) {
        printStream.println(line);
    }
    String version = SpringBootVersion.getVersion();
    version = (version == null ? "" : " (v" + version + ")");
    String padding = "";
    while (padding.length() < STRAP_LINE_SIZE
            - (version.length() + SPRING_BOOT.length())) {
        padding += " ";
    }

    printStream.println(AnsiOutput.toString(AnsiColor.GREEN, SPRING_BOOT,
            AnsiColor.DEFAULT, padding, AnsiStyle.FAINT, version));
    printStream.println();
}
项目:spring-boot-concourse    文件:ColorConverter.java   
@Override
public void format(LogEvent event, StringBuilder toAppendTo) {
    StringBuilder buf = new StringBuilder();
    for (PatternFormatter formatter : this.formatters) {
        formatter.format(event, buf);
    }
    if (buf.length() > 0) {
        AnsiElement element = this.styling;
        if (element == null) {
            // Assume highlighting
            element = LEVELS.get(event.getLevel().intLevel());
            element = (element == null ? AnsiColor.GREEN : element);
        }
        appendAnsiString(toAppendTo, buf.toString(), element);
    }
}
项目:spring-boot-concourse    文件:SpringBootBanner.java   
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
        PrintStream printStream) {
    for (String line : BANNER) {
        printStream.println(line);
    }
    String version = SpringBootVersion.getVersion();
    version = (version == null ? "" : " (v" + version + ")");
    String padding = "";
    while (padding.length() < STRAP_LINE_SIZE
            - (version.length() + SPRING_BOOT.length())) {
        padding += " ";
    }

    printStream.println(AnsiOutput.toString(AnsiColor.GREEN, SPRING_BOOT,
            AnsiColor.DEFAULT, padding, AnsiStyle.FAINT, version));
    printStream.println();
}
项目:contestparser    文件:ColorConverter.java   
@Override
public void format(LogEvent event, StringBuilder toAppendTo) {
    StringBuilder buf = new StringBuilder();
    for (PatternFormatter formatter : this.formatters) {
        formatter.format(event, buf);
    }
    if (buf.length() > 0) {
        AnsiElement element = this.styling;
        if (element == null) {
            // Assume highlighting
            element = LEVELS.get(event.getLevel().intLevel());
            element = (element == null ? AnsiColor.GREEN : element);
        }
        appendAnsiString(toAppendTo, buf.toString(), element);
    }
}
项目:contestparser    文件:SpringBootBanner.java   
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
        PrintStream printStream) {
    for (String line : BANNER) {
        printStream.println(line);
    }
    String version = SpringBootVersion.getVersion();
    version = (version == null ? "" : " (v" + version + ")");
    String padding = "";
    while (padding.length() < STRAP_LINE_SIZE
            - (version.length() + SPRING_BOOT.length())) {
        padding += " ";
    }

    printStream.println(AnsiOutput.toString(AnsiColor.GREEN, SPRING_BOOT,
            AnsiColor.DEFAULT, padding, AnsiStyle.FAINT, version));
    printStream.println();
}
项目:hdfs-shell    文件:ShellPromptProvider.java   
@Override
public String getPrompt() {
    return AbstractShell.shellPrompt =
            AnsiOutput.toString(AnsiColor.CYAN, "hdfs-shell ") +
                    AnsiOutput.toString(AnsiColor.YELLOW, contextCommands.getCurrentDir()) +
                    AnsiOutput.toString(AnsiColor.CYAN, " >", AnsiColor.WHITE);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void statusWhenStarted() throws Exception {
    String output = doTest("status-when-started.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(
            coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void statusWhenKilled() throws Exception {
    String output = doTest("status-when-killed.sh");
    assertThat(output).contains("Status: 1");
    assertThat(output).has(coloredString(AnsiColor.RED,
            "Not running (process " + extractPid(output) + " not found)"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void stopWhenStopped() throws Exception {
    String output = doTest("stop-when-stopped.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output)
            .has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void startWhenStarted() throws Exception {
    String output = doTest("start-when-started.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(coloredString(AnsiColor.YELLOW,
            "Already running [" + extractPid(output) + "]"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void restartWhenStopped() throws Exception {
    String output = doTest("restart-when-stopped.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output)
            .has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
    assertThat(output).has(
            coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void restartWhenStarted() throws Exception {
    String output = doTest("restart-when-started.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(coloredString(AnsiColor.GREEN,
            "Started [" + extract("PID1", output) + "]"));
    assertThat(output).has(coloredString(AnsiColor.GREEN,
            "Stopped [" + extract("PID1", output) + "]"));
    assertThat(output).has(coloredString(AnsiColor.GREEN,
            "Started [" + extract("PID2", output) + "]"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void startWhenStopped() throws Exception {
    String output = doTest("start-when-stopped.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(
            coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
private Condition<String> coloredString(AnsiColor color, String string) {
    String colorString = ESC + "[0;" + color + "m" + string + ESC + "[0m";
    return new Condition<String>() {

        @Override
        public boolean matches(String value) {
            return containsString(colorString).matches(value);
        }

    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ColorConverter.java   
@Override
protected String transform(ILoggingEvent event, String in) {
    AnsiElement element = ELEMENTS.get(getFirstOption());
    if (element == null) {
        // Assume highlighting
        element = LEVELS.get(event.getLevel().toInteger());
        element = (element == null ? AnsiColor.GREEN : element);
    }
    return toAnsiString(in, element);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBanner.java   
private void printBanner(BufferedImage image, int margin, boolean invert,
        PrintStream out) {
    AnsiElement background = (invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT);
    out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
    out.print(AnsiOutput.encode(background));
    out.println();
    out.println();
    AnsiColor lastColor = AnsiColor.DEFAULT;
    for (int y = 0; y < image.getHeight(); y++) {
        for (int i = 0; i < margin; i++) {
            out.print(" ");
        }
        for (int x = 0; x < image.getWidth(); x++) {
            Color color = new Color(image.getRGB(x, y), false);
            AnsiColor ansiColor = AnsiColors.getClosest(color);
            if (ansiColor != lastColor) {
                out.print(AnsiOutput.encode(ansiColor));
                lastColor = ansiColor;
            }
            out.print(getAsciiPixel(color, invert));
        }
        out.println();
    }
    out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
    out.print(AnsiOutput.encode(AnsiBackground.DEFAULT));
    out.println();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldResetForegroundAndBackground() {
    String banner = printBanner("black-and-white.gif");
    String expected = AnsiOutput.encode(AnsiColor.DEFAULT)
            + AnsiOutput.encode(AnsiBackground.DEFAULT);
    assertThat(banner).startsWith(expected);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerWhenInvertedShouldResetForegroundAndBackground() {
    String banner = printBanner("black-and-white.gif", INVERT_TRUE);
    String expected = AnsiOutput.encode(AnsiColor.DEFAULT)
            + AnsiOutput.encode(AnsiBackground.BLACK);
    assertThat(banner).startsWith(expected);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldPrintWhiteAsBrightWhiteHighLuminance() {
    String banner = printBanner("black-and-white.gif");
    String expected = AnsiOutput.encode(AnsiColor.BRIGHT_WHITE)
            + HIGH_LUMINANCE_CHARACTER;
    assertThat(banner).contains(expected);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerWhenInvertedShouldPrintWhiteAsBrightWhiteLowLuminance() {
    String banner = printBanner("black-and-white.gif", INVERT_TRUE);
    String expected = AnsiOutput.encode(AnsiColor.BRIGHT_WHITE)
            + LOW_LUMINANCE_CHARACTER;
    assertThat(banner).contains(expected);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerWhenShouldPrintAllColors() {
    String banner = printBanner("colors.gif");
    for (AnsiColor color : AnsiColor.values()) {
        if (color != AnsiColor.DEFAULT) {
            assertThat(banner).contains(AnsiOutput.encode(color));
        }
    }
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
@Test
public void statusWhenStarted() throws Exception {
    String output = doTest("status-when-started.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(
            coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
@Test
public void statusWhenKilled() throws Exception {
    String output = doTest("status-when-killed.sh");
    assertThat(output).contains("Status: 1");
    assertThat(output).has(coloredString(AnsiColor.RED,
            "Not running (process " + extractPid(output) + " not found)"));
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
@Test
public void stopWhenStopped() throws Exception {
    String output = doTest("stop-when-stopped.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output)
            .has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
@Test
public void startWhenStarted() throws Exception {
    String output = doTest("start-when-started.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(coloredString(AnsiColor.YELLOW,
            "Already running [" + extractPid(output) + "]"));
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
@Test
public void restartWhenStopped() throws Exception {
    String output = doTest("restart-when-stopped.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output)
            .has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)"));
    assertThat(output).has(
            coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
@Test
public void restartWhenStarted() throws Exception {
    String output = doTest("restart-when-started.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(coloredString(AnsiColor.GREEN,
            "Started [" + extract("PID1", output) + "]"));
    assertThat(output).has(coloredString(AnsiColor.GREEN,
            "Stopped [" + extract("PID1", output) + "]"));
    assertThat(output).has(coloredString(AnsiColor.GREEN,
            "Started [" + extract("PID2", output) + "]"));
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
@Test
public void startWhenStopped() throws Exception {
    String output = doTest("start-when-stopped.sh");
    assertThat(output).contains("Status: 0");
    assertThat(output).has(
            coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]"));
}
项目:spring-boot-concourse    文件:SysVinitLaunchScriptIT.java   
private Condition<String> coloredString(AnsiColor color, String string) {
    String colorString = ESC + "[0;" + color + "m" + string + ESC + "[0m";
    return new Condition<String>() {

        @Override
        public boolean matches(String value) {
            return containsString(colorString).matches(value);
        }

    };
}
项目:spring-boot-concourse    文件:ColorConverter.java   
@Override
protected String transform(ILoggingEvent event, String in) {
    AnsiElement element = ELEMENTS.get(getFirstOption());
    if (element == null) {
        // Assume highlighting
        element = LEVELS.get(event.getLevel().toInteger());
        element = (element == null ? AnsiColor.GREEN : element);
    }
    return toAnsiString(in, element);
}
项目:spring-boot-concourse    文件:ImageBanner.java   
private void printBanner(BufferedImage image, int margin, boolean invert,
        PrintStream out) {
    AnsiElement background = (invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT);
    out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
    out.print(AnsiOutput.encode(background));
    out.println();
    out.println();
    AnsiColor lastColor = AnsiColor.DEFAULT;
    for (int y = 0; y < image.getHeight(); y++) {
        for (int i = 0; i < margin; i++) {
            out.print(" ");
        }
        for (int x = 0; x < image.getWidth(); x++) {
            Color color = new Color(image.getRGB(x, y), false);
            AnsiColor ansiColor = AnsiColors.getClosest(color);
            if (ansiColor != lastColor) {
                out.print(AnsiOutput.encode(ansiColor));
                lastColor = ansiColor;
            }
            out.print(getAsciiPixel(color, invert));
        }
        out.println();
    }
    out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
    out.print(AnsiOutput.encode(AnsiBackground.DEFAULT));
    out.println();
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldResetForegroundAndBackground() {
    String banner = printBanner("black-and-white.gif");
    String expected = AnsiOutput.encode(AnsiColor.DEFAULT)
            + AnsiOutput.encode(AnsiBackground.DEFAULT);
    assertThat(banner).startsWith(expected);
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerWhenInvertedShouldResetForegroundAndBackground() {
    String banner = printBanner("black-and-white.gif", INVERT_TRUE);
    String expected = AnsiOutput.encode(AnsiColor.DEFAULT)
            + AnsiOutput.encode(AnsiBackground.BLACK);
    assertThat(banner).startsWith(expected);
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldPrintWhiteAsBrightWhiteHighLuminance() {
    String banner = printBanner("black-and-white.gif");
    String expected = AnsiOutput.encode(AnsiColor.BRIGHT_WHITE)
            + HIGH_LUMINANCE_CHARACTER;
    assertThat(banner).contains(expected);
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerWhenInvertedShouldPrintWhiteAsBrightWhiteLowLuminance() {
    String banner = printBanner("black-and-white.gif", INVERT_TRUE);
    String expected = AnsiOutput.encode(AnsiColor.BRIGHT_WHITE)
            + LOW_LUMINANCE_CHARACTER;
    assertThat(banner).contains(expected);
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerWhenShouldPrintAllColors() {
    String banner = printBanner("colors.gif");
    for (AnsiColor color : AnsiColor.values()) {
        if (color != AnsiColor.DEFAULT) {
            assertThat(banner).contains(AnsiOutput.encode(color));
        }
    }
}
项目:contestparser    文件:ColorConverter.java   
@Override
protected String transform(ILoggingEvent event, String in) {
    AnsiElement element = ELEMENTS.get(getFirstOption());
    if (element == null) {
        // Assume highlighting
        element = LEVELS.get(event.getLevel().toInteger());
        element = (element == null ? AnsiColor.GREEN : element);
    }
    return toAnsiString(in, element);
}
项目:webanno    文件:WebAnnoBanner.java   
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
        PrintStream printStream) {
    for (String line : BANNER) {
        printStream.println(line);
    }
    String version = SettingsUtil.getVersionString();
    printStream.println(AnsiOutput.toString(AnsiColor.GREEN, AnsiStyle.FAINT, version));
    printStream.println();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SysVinitLaunchScriptIT.java   
@Test
public void statusWhenStopped() throws Exception {
    String output = doTest("status-when-stopped.sh");
    assertThat(output).contains("Status: 3");
    assertThat(output).has(coloredString(AnsiColor.RED, "Not running"));
}