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

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ColorConverter.java   
/**
 * Creates a new instance of the class. Required by Log4J2.
 *
 * @param config the configuration
 * @param options the options
 * @return a new instance, or {@code null} if the options are invalid
 */
public static ColorConverter newInstance(Configuration config, String[] options) {
    if (options.length < 1) {
        LOGGER.error("Incorrect number of options on style. "
                + "Expected at least 1, received {}", options.length);
        return null;
    }
    if (options[0] == null) {
        LOGGER.error("No pattern supplied on style");
        return null;
    }
    PatternParser parser = PatternLayout.createPatternParser(config);
    List<PatternFormatter> formatters = parser.parse(options[0]);
    AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1]));
    return new ColorConverter(formatters, element);
}
项目: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);
    }
}
项目:spring-boot-concourse    文件:ColorConverter.java   
/**
 * Creates a new instance of the class. Required by Log4J2.
 *
 * @param config the configuration
 * @param options the options
 * @return a new instance, or {@code null} if the options are invalid
 */
public static ColorConverter newInstance(Configuration config, String[] options) {
    if (options.length < 1) {
        LOGGER.error("Incorrect number of options on style. "
                + "Expected at least 1, received {}", options.length);
        return null;
    }
    if (options[0] == null) {
        LOGGER.error("No pattern supplied on style");
        return null;
    }
    PatternParser parser = PatternLayout.createPatternParser(config);
    List<PatternFormatter> formatters = parser.parse(options[0]);
    AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1]));
    return new ColorConverter(formatters, element);
}
项目: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);
    }
}
项目:contestparser    文件:ColorConverter.java   
/**
 * Creates a new instance of the class. Required by Log4J2.
 *
 * @param config the configuration
 * @param options the options
 * @return a new instance, or {@code null} if the options are invalid
 */
public static ColorConverter newInstance(Configuration config, String[] options) {
    if (options.length < 1) {
        LOGGER.error("Incorrect number of options on style. "
                + "Expected at least 1, received {}", options.length);
        return null;
    }
    if (options[0] == null) {
        LOGGER.error("No pattern supplied on style");
        return null;
    }
    PatternParser parser = PatternLayout.createPatternParser(config);
    List<PatternFormatter> formatters = parser.parse(options[0]);
    AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1]));
    return new ColorConverter(formatters, element);
}
项目: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);
    }
}
项目: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();
}
项目: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();
}
项目: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);
}
项目: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   
private ColorConverter(List<PatternFormatter> formatters, AnsiElement styling) {
    super("style", "style");
    this.formatters = formatters;
    this.styling = styling;
}
项目: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));
}
项目:spring-boot-concourse    文件:ColorConverter.java   
protected String toAnsiString(String in, AnsiElement element) {
    return AnsiOutput.toString(element, in);
}
项目:spring-boot-concourse    文件:ColorConverter.java   
private ColorConverter(List<PatternFormatter> formatters, AnsiElement styling) {
    super("style", "style");
    this.formatters = formatters;
    this.styling = styling;
}
项目:spring-boot-concourse    文件:ColorConverter.java   
protected void appendAnsiString(StringBuilder toAppendTo, String in,
        AnsiElement element) {
    toAppendTo.append(AnsiOutput.toString(element, in));
}
项目:contestparser    文件:ColorConverter.java   
protected String toAnsiString(String in, AnsiElement element) {
    return AnsiOutput.toString(element, in);
}
项目:contestparser    文件:ColorConverter.java   
private ColorConverter(List<PatternFormatter> formatters, AnsiElement styling) {
    super("style", "style");
    this.formatters = formatters;
    this.styling = styling;
}
项目:contestparser    文件:ColorConverter.java   
protected void appendAnsiString(StringBuilder toAppendTo, String in,
        AnsiElement element) {
    toAppendTo.append(AnsiOutput.toString(element, in));
}