• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Color类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderSteps

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
private void renderSteps(Ansi ansi, List<JobRunResultSteps> steps, Color originColor){
  for (int i = 0; i < steps.size(); i++){
    JobRunResultSteps step = steps.get(i);
    if (step.isSuccessed())
      ansi.fg(GREEN);
    else
      ansi.fg(RED);
    
    try{
      ansi.bold().a("| -- ").boldOff().a(step.getStepName()).a("\n");
      for (String msg : step.getAdditionalMsgs()){
        ansi.bold().a("| --   ").a(msg).boldOff().a("\n");        
      }
    }finally{
      ansi.fg(originColor);
    }
          
  }
  
}
 
开发者ID:detectiveframework,项目名称:detective,代码行数:21,代码来源:ResultRenderAnsiConsoleImpl.java


示例2: execute

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
@Override
public void execute() throws CommandException {

    consoleWriter.newLine().a("Export a Drop from repository: ").fg(Color.CYAN).a(repositoryParam).println(2);

    Repository repository = commandHelper.findRepositoryByName(repositoryParam);

    if (useInheritance && typeParam != ExportDropConfig.Type.REVIEW) {
        throw new CommandException("--use-inheritance can only be used with --type REVIEW");
    }

    ExportDropConfig exportDropConfig = new ExportDropConfig();
    exportDropConfig.setRepositoryId(repository.getId());
    exportDropConfig.setType(typeParam);
    exportDropConfig.setBcp47Tags(getBcp47TagsForExport(repository));
    exportDropConfig.setUseInheritance(useInheritance);

    exportDropConfig = dropClient.exportDrop(exportDropConfig);

    consoleWriter.a("Drop id: ").fg(Color.CYAN).a(exportDropConfig.getDropId()).print();

    PollableTask pollableTask = exportDropConfig.getPollableTask();
    commandHelper.waitForPollableTask(pollableTask.getId());

    consoleWriter.newLine().fg(Color.GREEN).a("Finished").println(2);
}
 
开发者ID:box,项目名称:mojito,代码行数:27,代码来源:DropExportCommand.java


示例3: getPseudoLocalizedAsset

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
LocalizedAssetBody getPseudoLocalizedAsset(Repository repository, FileMatch sourceFileMatch) throws CommandException {
    consoleWriter.a(" - Processing locale: ").fg(Color.CYAN).a(OUTPUT_BCP47_TAG).print();

    try {
        Asset assetByPathAndRepositoryId = assetClient.getAssetByPathAndRepositoryId(sourceFileMatch.getSourcePath(), repository.getId());

        String assetContent = commandHelper.getFileContent(sourceFileMatch.getPath());

        // TODO(P1) This is to inject xml:space="preserve" in the trans-unit element
        // in the xcode-generated xliff until xcode fixes the bug of not adding this attribute
        // See Xcode bug http://www.openradar.me/23410569
        if (sourceFileMatch.getFileType().getClass() == XcodeXliffFileType.class) {
            assetContent = commandHelper.setPreserveSpaceInXliff(assetContent);
        }

        LocalizedAssetBody pseudoLocalizedAsset = assetClient.getPseudoLocalizedAssetForContent(
                assetByPathAndRepositoryId.getId(),
                assetContent,
                sourceFileMatch.getFileType().getFilterConfigIdOverride());

        logger.trace("PseudoLocalizedAsset content = {}", pseudoLocalizedAsset.getContent());
        return pseudoLocalizedAsset;
    } catch (AssetNotFoundException e) {
        throw new CommandException("Asset with path [" + sourceFileMatch.getSourcePath() + "] was not found in repo [" + repositoryParam + "]", e);
    }
}
 
开发者ID:box,项目名称:mojito,代码行数:27,代码来源:PseudoLocCommand.java


示例4: initPluginColors

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
public void initPluginColors(Iterable<String> plugins, Map<String, String> configColors, String def) {
    Color[] colors = Color.values();
    //remove black, because it's often hard to read
    colors = Arrays.copyOfRange(colors, 1, colors.length);

    ImmutableMap.Builder<String, String> colorBuilder = ImmutableMap.builder();
    for (String plugin : plugins) {
        String styleCode = configColors.getOrDefault(plugin, def);
        if ("random".equalsIgnoreCase(styleCode)) {
            //ignore default
            styleCode = colors[ThreadLocalRandom.current().nextInt(colors.length - 1)].name();
        }

        colorBuilder.put(plugin, format(styleCode));
    }

    this.pluginColors = colorBuilder.build();
}
 
开发者ID:games647,项目名称:ColorConsole,代码行数:19,代码来源:CommonFormatter.java


示例5: title

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
@Override
public ShellConsole title(String fmt, Object... args) {
	try {
		Ansi ansi =
			Ansi.
				ansi().
					bold().
					bg(Color.DEFAULT).
					fg(Color.RED).
					a(String.format(fmt,args)).
					reset();
		this.output.print(ansi);
	} catch (Exception e) {
		showFailure(e, fmt, args);
	}
	return this;
}
 
开发者ID:ldp4j,项目名称:eswc2015-tutorial,代码行数:18,代码来源:ShellUtil.java


示例6: VisageFormatter

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
public VisageFormatter() {
	colors.put(Level.FINER, Color.BLACK);
	colors.put(Level.FINE, Color.GREEN);
	colors.put(Level.INFO, Color.BLUE);
	colors.put(Level.WARNING, Color.YELLOW);
	colors.put(Level.SEVERE, Color.RED);
	colors.put(Level.OFF, Color.MAGENTA);
	
	names.put(Level.FINEST, "TRACE");
	names.put(Level.FINER, "DEBUG");
	names.put(Level.FINE, " FINE");
	names.put(Level.INFO, " INFO");
	names.put(Level.WARNING, " WARN");
	names.put(Level.SEVERE, "ERROR");
	names.put(Level.OFF, "FATAL");
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:17,代码来源:VisageFormatter.java


示例7: format

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
@Override
public String format(LogRecord record) {
	if (record.getThrown() != null) {
		record.getThrown().printStackTrace();
	}
	Ansi ansi = Ansi.ansi();
	if (Visage.ansi) {
		ansi.fgBright(Color.BLACK);
	}
	Date date = new Date(record.getMillis());
	ansi.a("@");
	ansi.a(format.format(date));
	if (Visage.ansi) {
		ansi.reset();
	}
	ansi.a(Strings.padStart(Thread.currentThread().getName(), 22, ' '));
	ansi.a(" ");
	if (Visage.ansi && colors.containsKey(record.getLevel())) {
		ansi.fgBright(colors.get(record.getLevel()));
	}
	ansi.a(names.get(record.getLevel()));
	if (Visage.ansi) {
		ansi.reset();
	}
	ansi.a(": ");
	if (Visage.ansi && colors.containsKey(record.getLevel()) && record.getLevel().intValue() >= Level.SEVERE.intValue()) {
		ansi.bold();
		ansi.fgBright(colors.get(record.getLevel()));
	}
	ansi.a(record.getMessage());
	if (Visage.ansi) {
		ansi.reset();
	}
	ansi.a("\n");
	return ansi.toString();
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:37,代码来源:VisageFormatter.java


示例8: createAnsiCode

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
Ansi createAnsiCode(JobRunResult result){
  Ansi ansi = ansi();
  
  Color currentColor;
  if (result.isIgnored()){
    currentColor = BLUE;
  }else if (result.getSuccessed())
    currentColor = GREEN;
  else
    currentColor = RED;
  
  ansi.fg(currentColor);
    
  ansi.bold().a("Story Name: ").a(result.getStoryName()).boldOff()
    .a("\n").bold().a("| -- Scenario Name: ").boldOff().a(result.getScenarioName());
  
  if (result.isIgnored()){
    ansi.a("\n").bold().a("| -- Ignored:       Yes").boldOff();
  }else{
    ansi.a("\n").bold().a("| -- Successed:     ").boldOff().a(result.getSuccessed() ? "Yes" : "Failed" );
  }
    
  ansi.a("\n");
  
  renderSteps(ansi, result.getSteps(), currentColor);
  
  if (result.getError() != null){
    ansi.bold().a("| -- Error:         ").a(result.getError().getMessage()).boldOff().a("\n");
    ansi.bold().a("| -- Error Callstack:").boldOff().a(Utils.getStackTrace(result.getError())).a("\n");
  }

  ansi.reset();
  
  return ansi;
}
 
开发者ID:detectiveframework,项目名称:detective,代码行数:36,代码来源:ResultRenderAnsiConsoleImpl.java


示例9: mapColorToValue

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
private Color mapColorToValue(int rgbVal) {
	
	TetrisColor tetrisColor = TetrisColor.getColorByRgb(rgbVal);
	
	switch (tetrisColor) {
	case RED:
		return Color.RED;
	case BLUE:
		return Color.BLUE;
	case CYAN:
		return Color.CYAN;
	case GREEN:
		return Color.GREEN;
	case MAGENTA:
		return Color.MAGENTA;
	case WHITE:
		return Color.WHITE;
	case YELLOW:
		return Color.YELLOW;
	default:
		return Color.DEFAULT;
	}
	
}
 
开发者ID:manuelz120,项目名称:tetris4j,代码行数:25,代码来源:TetrisView.java


示例10: withColor

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
String withColor( Color color, boolean bright, Attribute attribute, String text ) {
    if( withColor ) {
        Ansi ansi = bright ? Ansi.ansi().fgBright( color ) : Ansi.ansi().fg( color );
        if( attribute != null ) {
            ansi = ansi.a( attribute );
        }
        return ansi.a( text ).reset().toString();
    }
    return text;
}
 
开发者ID:TNG,项目名称:JGiven,代码行数:11,代码来源:PlainTextWriter.java


示例11: getLocalizedAsset

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
LocalizedAssetBody getLocalizedAsset(Repository repository, FileMatch sourceFileMatch, RepositoryLocale repositoryLocale, String outputBcp47tag) throws CommandException {
    consoleWriter.a(" - Processing locale: ").fg(Color.CYAN).a(repositoryLocale.getLocale().getBcp47Tag()).print();

    try {
        logger.debug("Getting the asset for path: {} and locale: {}", sourceFileMatch.getSourcePath(), repositoryLocale.getLocale().getBcp47Tag());
        Asset assetByPathAndRepositoryId = assetClient.getAssetByPathAndRepositoryId(sourceFileMatch.getSourcePath(), repository.getId());

        String assetContent = commandHelper.getFileContent(sourceFileMatch.getPath());

        // TODO(P1) This is to inject xml:space="preserve" in the trans-unit element
        // in the xcode-generated xliff until xcode fixes the bug of not adding this attribute
        // See Xcode bug http://www.openradar.me/23410569
        if (sourceFileMatch.getFileType().getClass() == XcodeXliffFileType.class) {
            assetContent = commandHelper.setPreserveSpaceInXliff(assetContent);
        }

        LocalizedAssetBody localizedAsset = assetClient.getLocalizedAssetForContent(
                assetByPathAndRepositoryId.getId(),
                repositoryLocale.getLocale().getId(),
                assetContent,
                outputBcp47tag,
                sourceFileMatch.getFileType().getFilterConfigIdOverride());

        logger.trace("LocalizedAsset content = {}", localizedAsset.getContent());

        return localizedAsset;
    } catch (AssetNotFoundException e) {
        throw new CommandException("Asset with path [" + sourceFileMatch.getSourcePath() + "] was not found in repo [" + repositoryParam + "]", e);
    }
}
 
开发者ID:box,项目名称:mojito,代码行数:31,代码来源:PullCommand.java


示例12: execute

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
@Override
public void execute() throws CommandException {
    consoleWriter.newLine().a("Pull pseudo localized asset from repository: ").fg(Color.CYAN).a(repositoryParam).println(2);

    repository = commandHelper.findRepositoryByName(repositoryParam);

    commandDirectories = new CommandDirectories(sourceDirectoryParam, targetDirectoryParam);

    for (FileMatch sourceFileMatch : commandHelper.getSourceFileMatches(commandDirectories, fileType, sourceLocale, sourcePathFilterRegex)) {
        consoleWriter.a("Localizing: ").fg(Color.CYAN).a(sourceFileMatch.getSourcePath()).println();
        generatePseudoLocalizedFile(repository, sourceFileMatch);
    }
    consoleWriter.fg(Color.GREEN).newLine().a("Finished").println(2);
}
 
开发者ID:box,项目名称:mojito,代码行数:15,代码来源:PseudoLocCommand.java


示例13: MainLogger

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
public MainLogger(String logFile, Boolean logDebug) {
    AnsiConsole.systemInstall();

    if (logger != null) {
        throw new RuntimeException("MainLogger has been already created");
    }
    logger = this;
    this.logFile = new File(logFile);
    if (!this.logFile.exists()) {
        try {
            this.logFile.createNewFile();
        } catch (IOException e) {
            this.logException(e);
        }
    }
    replacements.put(TextFormat.BLACK, Ansi.ansi().a(Attribute.RESET).fg(Color.BLACK).boldOff().toString());
    replacements.put(TextFormat.DARK_BLUE, Ansi.ansi().a(Attribute.RESET).fg(Color.BLUE).boldOff().toString());
    replacements.put(TextFormat.DARK_GREEN, Ansi.ansi().a(Attribute.RESET).fg(Color.GREEN).boldOff().toString());
    replacements.put(TextFormat.DARK_AQUA, Ansi.ansi().a(Attribute.RESET).fg(Color.CYAN).boldOff().toString());
    replacements.put(TextFormat.DARK_RED, Ansi.ansi().a(Attribute.RESET).fg(Color.RED).boldOff().toString());
    replacements.put(TextFormat.DARK_PURPLE, Ansi.ansi().a(Attribute.RESET).fg(Color.MAGENTA).boldOff().toString());
    replacements.put(TextFormat.GOLD, Ansi.ansi().a(Attribute.RESET).fg(Color.YELLOW).boldOff().toString());
    replacements.put(TextFormat.GRAY, Ansi.ansi().a(Attribute.RESET).fg(Color.WHITE).boldOff().toString());
    replacements.put(TextFormat.DARK_GRAY, Ansi.ansi().a(Attribute.RESET).fg(Color.BLACK).bold().toString());
    replacements.put(TextFormat.BLUE, Ansi.ansi().a(Attribute.RESET).fg(Color.BLUE).bold().toString());
    replacements.put(TextFormat.GREEN, Ansi.ansi().a(Attribute.RESET).fg(Color.GREEN).bold().toString());
    replacements.put(TextFormat.AQUA, Ansi.ansi().a(Attribute.RESET).fg(Color.CYAN).bold().toString());
    replacements.put(TextFormat.RED, Ansi.ansi().a(Attribute.RESET).fg(Color.RED).bold().toString());
    replacements.put(TextFormat.LIGHT_PURPLE, Ansi.ansi().a(Attribute.RESET).fg(Color.MAGENTA).bold().toString());
    replacements.put(TextFormat.YELLOW, Ansi.ansi().a(Attribute.RESET).fg(Color.YELLOW).bold().toString());
    replacements.put(TextFormat.WHITE, Ansi.ansi().a(Attribute.RESET).fg(Color.WHITE).bold().toString());
    replacements.put(TextFormat.BOLD, Ansi.ansi().a(Attribute.UNDERLINE_DOUBLE).toString());
    replacements.put(TextFormat.STRIKETHROUGH, Ansi.ansi().a(Attribute.STRIKETHROUGH_ON).toString());
    replacements.put(TextFormat.UNDERLINE, Ansi.ansi().a(Attribute.UNDERLINE).toString());
    replacements.put(TextFormat.ITALIC, Ansi.ansi().a(Attribute.ITALIC).toString());
    replacements.put(TextFormat.RESET, Ansi.ansi().a(Attribute.RESET).toString());
    this.logDebug = logDebug;
    this.start();
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:40,代码来源:MainLogger.java


示例14: centerText

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
/**
 * Centers and colors text
 * @param totalLen the total length to center to
 * @param toFormat the string to format
 * @param color the ANSI code to color. null will result in no color
 */
private String centerText(int totalLen, String toFormat, Color color) {
  int offset = totalLen / 2 - toFormat.length() / 2;
  String out = "";
  if (offset > 0) {
    // Print out spaces to center the version string
    out = out + String.format("%1$"+offset+"s", " ");
  }
  out = out + toFormat;
  if (color != null) {
    out = ansi().fg(color).a(out).reset().toString();
  }
  return out;
}
 
开发者ID:alda-lang,项目名称:alda-client-java,代码行数:20,代码来源:AldaRepl.java


示例15: colorize

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
private void colorize(Color bg, Color fg, String fmt, Object... args) {
	try {
		Ansi ansi =
			Ansi.
				ansi().
					bg(bg).
					fg(fg).
					a(String.format(fmt,args)).
					reset();
		this.output.print(ansi);
	} catch (Exception e) {
		showFailure(e, fmt, args);
	}
}
 
开发者ID:ldp4j,项目名称:eswc2015-tutorial,代码行数:15,代码来源:ShellUtil.java


示例16: printColor

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
private static void printColor(Color color, String msg, Object... parameters) {
    if (parameters.length > 0) {
        msg = format(msg, parameters);
    }
    if (color != null) {
        msg = ansi().fg(color).a(msg).reset().toString();
    }
    System.out.println(msg);
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:10,代码来源:DebugUtils.java


示例17: printGameBoardPresentation

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
private void printGameBoardPresentation(BoardPresentation boardPresentation) {
	
	final int[][] board = boardPresentation.getPresentation();
	final int height = board.length;
	final int width = board[0].length;
	
	for (int i = 0; i <= width + 1; i++) {
		AnsiConsole.out.print(LINE_CHARACTER);
	}
	AnsiConsole.out.println();
	
	for (int y = 0; y < height; y++) {
		AnsiConsole.out.print(WALL_CHARACTER);
		for (int x = 0; x < width; x++) {
			int val = board[y][x];
			if (val != 0) {
				Color color = mapColorToValue(val);
				AnsiConsole.out.print(Ansi.ansi().fg(color).a(BLOCK_CHARACTER).reset());
			} else {
				AnsiConsole.out.print(SPACE_CHARACTER);
			}
			
		}
		AnsiConsole.out.println(WALL_CHARACTER);
	}
	
	for (int i = 0; i <= width + 1; i++) {
		AnsiConsole.out.print(LINE_CHARACTER);
	}
	AnsiConsole.out.println();

}
 
开发者ID:manuelz120,项目名称:tetris4j,代码行数:33,代码来源:TetrisView.java


示例18: showNetworkInfoScreen

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
@Override
public void showNetworkInfoScreen() {
	gameState = GameState.NetworkInput;
	AnsiConsole.out.print(Ansi.ansi().cursor(0, 0));
	AnsiConsole.out.print(Ansi.ansi().eraseScreen());
	String[] networkInfo = Utils.readLines("/network.txt");
	for (String s : networkInfo) {
		AnsiConsole.out.println(Ansi.ansi().fg(Color.GREEN).a("\t\t" + s).reset());
	}
}
 
开发者ID:manuelz120,项目名称:tetris4j,代码行数:11,代码来源:TetrisView.java


示例19: showGameOverScreen

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
@Override
public void showGameOverScreen() {
	AnsiConsole.out.print(Ansi.ansi().cursor(0, 0));
	AnsiConsole.out.print(Ansi.ansi().eraseScreen());
	
	String[] goodbyeString = Utils.readLines("/gameover.txt");
	for (String s : goodbyeString) {
		AnsiConsole.out.println(Ansi.ansi().fg(Color.RED).a("\t" + s).reset());
	}
	
	unregisterNativeHook();
}
 
开发者ID:manuelz120,项目名称:tetris4j,代码行数:13,代码来源:TetrisView.java


示例20: showGoodbyeScreen

import org.fusesource.jansi.Ansi.Color; //导入依赖的package包/类
@Override
public void showGoodbyeScreen() {
	AnsiConsole.out.print(Ansi.ansi().cursor(0, 0));
	AnsiConsole.out.print(Ansi.ansi().eraseScreen());
	
	
	String[] goodbyeString = Utils.readLines("/goodbye.txt");
	for (String s : goodbyeString) {
		AnsiConsole.out.println(Ansi.ansi().fg(Color.GREEN).a("\t" + s).reset());
	}
	
	unregisterNativeHook();
}
 
开发者ID:manuelz120,项目名称:tetris4j,代码行数:14,代码来源:TetrisView.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Connection类代码示例发布时间:2022-05-21
下一篇:
Java ContextStatementImpl类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap