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

项目: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();
}
项目:fountain    文件:FountainBanner.java   
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
                        PrintStream printStream) {
    for (String line : BANNER) {
        printStream.println(line);
    }
    String version = FountainBanner.class.getPackage().getImplementationVersion();
    version = (version == null ? "" : " (v" + version + ")");
    String padding = "";
    while (padding.length() < STRAP_LINE_SIZE
            - (version.length() + FOUNTAIN.length())) {
        padding += " ";
    }

    printStream.println(AnsiOutput.toString(GREEN, FOUNTAIN, DEFAULT, padding,
            FAINT, version));
    printStream.println();
}
项目: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    文件: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    文件:AnsiOutputApplicationListener.java   
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            event.getEnvironment(), "spring.output.ansi.");
    if (resolver.containsProperty("enabled")) {
        String enabled = resolver.getProperty("enabled");
        AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
    }

    if (resolver.containsProperty("console-available")) {
        AnsiOutput.setConsoleAvailable(
                resolver.getProperty("console-available", Boolean.class));
    }
}
项目: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));
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldRenderGradient() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("gradient.gif", "banner.image.width=10",
            "banner.image.margin=0");
    assertThat(banner).contains("@#8&o:*.  ");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldCapWidthAndCalculateHeight() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=0");
    assertThat(getBannerWidth(banner)).isEqualTo(76);
    assertThat(getBannerHeight(banner)).isEqualTo(37);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerShouldPrintMargin() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("  @");
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ImageBannerTests.java   
@Test
public void printBannerWhenHasMarginPropertyShouldPrintSizedMargin()
        throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=4");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("    @");
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBannerTests.java   
@Test
public void renderWithColors() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("\u001B[31mThis is red.\u001B[0m");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceBannerTests.java   
@Test
public void renderWithColorsButDisabled() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("This is red.");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:InternalOutputCapture.java   
protected void captureOutput() {
    AnsiOutput.setEnabled(Enabled.NEVER);
    this.copy = new ByteArrayOutputStream();
    this.captureOut = new CaptureOutputStream(System.out, this.copy);
    this.captureErr = new CaptureOutputStream(System.err, this.copy);
    System.setOut(new PrintStream(this.captureOut));
    System.setErr(new PrintStream(this.captureErr));
}
项目:spring-boot-concourse    文件:AnsiOutputApplicationListener.java   
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            event.getEnvironment(), "spring.output.ansi.");
    if (resolver.containsProperty("enabled")) {
        String enabled = resolver.getProperty("enabled");
        AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
    }

    if (resolver.containsProperty("console-available")) {
        AnsiOutput.setConsoleAvailable(
                resolver.getProperty("console-available", Boolean.class));
    }
}
项目: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));
        }
    }
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldRenderGradient() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("gradient.gif", "banner.image.width=10",
            "banner.image.margin=0");
    assertThat(banner).contains("@#8&o:*.  ");
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldCapWidthAndCalculateHeight() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=0");
    assertThat(getBannerWidth(banner)).isEqualTo(76);
    assertThat(getBannerHeight(banner)).isEqualTo(37);
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerShouldPrintMargin() throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("  @");
    }
}
项目:spring-boot-concourse    文件:ImageBannerTests.java   
@Test
public void printBannerWhenHasMarginPropertyShouldPrintSizedMargin()
        throws Exception {
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner("large.gif", "banner.image.margin=4");
    String[] lines = banner.split(NEW_LINE);
    for (int i = 2; i < lines.length - 1; i++) {
        assertThat(lines[i]).startsWith("    @");
    }
}
项目:spring-boot-concourse    文件:ResourceBannerTests.java   
@Test
public void renderWithColors() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("\u001B[31mThis is red.\u001B[0m");
}
项目:spring-boot-concourse    文件:ResourceBannerTests.java   
@Test
public void renderWithColorsButDisabled() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("This is red.");
}
项目:spring-boot-concourse    文件:InternalOutputCapture.java   
protected void captureOutput() {
    AnsiOutput.setEnabled(Enabled.NEVER);
    this.copy = new ByteArrayOutputStream();
    this.captureOut = new CaptureOutputStream(System.out, this.copy);
    this.captureErr = new CaptureOutputStream(System.err, this.copy);
    System.setOut(new PrintStream(this.captureOut));
    System.setErr(new PrintStream(this.captureErr));
}
项目:qbit-extensions    文件:ServiceQueueInitializer.java   
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
    serviceQueueRegistry.getItems().forEach(item -> {

        final ServiceQueue serviceQueue = applicationContext.getBean(item.getKey(), ServiceQueue.class);

        if (clusteredEventManager != null && (boolean) item.getValue().get("remoteEventListener")) {
            clusteredEventManager.joinService(serviceQueue);
        }

        if (serviceEndpointServer != null && (boolean) item.getValue().get("exposeRemoteEndpoint")) {
            final String endpointLocation = (String) item.getValue().get("endpointLocation");
            logger.info(AnsiOutput.toString("Registering endpoint: ", BOLD, GREEN, endpointLocation, NORMAL));
            serviceEndpointServer.addServiceQueue(endpointLocation, serviceQueue);

            logger.info("Starting service queue as part of endpoint {}", serviceQueue.name());
            serviceQueue.startServiceQueue();
        } else {
            logger.info("Starting service queue standalone {}", serviceQueue.name());
            serviceQueue.start();
            serviceQueue.startCallBackHandler();
        }

    });
    if (serviceEndpointServer != null) {
        serviceEndpointServer.start();
    }

    applicationContext.publishEvent(new QBitStartedEvent(applicationContext));
}
项目:contestparser    文件:AnsiOutputApplicationListener.java   
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            event.getEnvironment(), "spring.output.ansi.");
    if (resolver.containsProperty("enabled")) {
        String enabled = resolver.getProperty("enabled");
        AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
    }

    if (resolver.containsProperty("console-available")) {
        AnsiOutput.setConsoleAvailable(
                resolver.getProperty("console-available", Boolean.class));
    }
}
项目:contestparser    文件:ResourceBannerTests.java   
@Test
public void renderWithColors() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
    String banner = printBanner(resource, null, null);
    assertThat(banner, startsWith("\u001B[31mThis is red.\u001B[0m"));
}
项目:contestparser    文件:ResourceBannerTests.java   
@Test
public void renderWithColorsButDisabled() throws Exception {
    Resource resource = new ByteArrayResource(
            "${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.NEVER);
    String banner = printBanner(resource, null, null);
    assertThat(banner, startsWith("This is red."));
}
项目: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    文件:ColorConverter.java   
protected String toAnsiString(String in, AnsiElement element) {
    return AnsiOutput.toString(element, in);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ColorConverter.java   
protected void appendAnsiString(StringBuilder toAppendTo, String in,
        AnsiElement element) {
    toAppendTo.append(AnsiOutput.toString(element, in));
}