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

Java TextColor类代码示例

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

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



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

示例1: postRender

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
@Override
public void postRender(
        TextGraphics textGraphics,
        TextGUI textGUI,
        Window window) {

    TerminalPosition windowPosition = window.getPosition();
    TerminalSize decoratedWindowSize = window.getDecoratedSize();
    textGraphics.setForegroundColor(TextColor.ANSI.BLACK);
    textGraphics.setBackgroundColor(TextColor.ANSI.BLACK);
    textGraphics.enableModifiers(SGR.BOLD);
    TerminalPosition lowerLeft = windowPosition.withRelativeColumn(2).withRelativeRow(decoratedWindowSize.getRows());
    TerminalPosition lowerRight = lowerLeft.withRelativeColumn(decoratedWindowSize.getColumns() - 1);
    textGraphics.drawLine(lowerLeft, lowerRight, ' ');
    TerminalPosition upperRight = lowerRight.withRelativeRow(-decoratedWindowSize.getRows() + 1);
    textGraphics.drawLine(lowerRight, upperRight, ' ');

    //Fill the remaining hole
    upperRight = upperRight.withRelativeColumn(-1);
    lowerRight = lowerRight.withRelativeColumn(-1);
    textGraphics.drawLine(upperRight, lowerRight, ' ');

}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:24,代码来源:WindowShadowRenderer.java


示例2: parseValue

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
private TextColor parseValue(String value) {
    value = value.trim();
    if(RGB_COLOR.matcher(value).matches()) {
        int r = Integer.parseInt(value.substring(1, 3), 16);
        int g = Integer.parseInt(value.substring(3, 5), 16);
        int b = Integer.parseInt(value.substring(5, 7), 16);
        return new TextColor.RGB(r, g, b);
    }
    else if(INDEXED_COLOR.matcher(value).matches()) {
        int index = Integer.parseInt(value.substring(1));
        return new TextColor.Indexed(index);
    }
    try {
        return TextColor.ANSI.valueOf(value.toUpperCase());
    }
    catch(IllegalArgumentException e) {
        throw new IllegalArgumentException("Unknown color definition \"" + value + "\"", e);
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:20,代码来源:PropertiesTheme.java


示例3: defaultThemeWorks

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
@Test
public void defaultThemeWorks() throws IOException {
    InputStream inputStream = new FileInputStream("src/main/resources/default-theme.properties");
    Properties properties = new Properties();
    properties.load(inputStream);
    inputStream.close();

    PropertiesTheme theme = new PropertiesTheme(properties);
    ThemeDefinition defaultDefinition = theme.getDefaultDefinition();
    assertEquals(TextColor.ANSI.WHITE, defaultDefinition.getNormal().getForeground());
    assertEquals(TextColor.ANSI.BLACK, defaultDefinition.getNormal().getBackground());
    assertEquals(0, defaultDefinition.getNormal().getSGRs().size());
    assertEquals(TextColor.ANSI.YELLOW, defaultDefinition.getSelected().getForeground());
    assertEquals(TextColor.ANSI.BLUE, defaultDefinition.getSelected().getBackground());
    assertEquals(Collections.singletonList(SGR.BOLD), new ArrayList<SGR>(defaultDefinition.getSelected().getSGRs()));
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:17,代码来源:PropertiesThemeTest.java


示例4: main

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    Screen screen = new TestTerminalFactory(args).createScreen();
    screen.startScreen();

    TextGraphics writer = new ScreenTextGraphics(screen);
    writer.setForegroundColor(TextColor.ANSI.DEFAULT);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(4, 2,  "Armenian:   Ճանաչել զիմաստութիւն եւ զխրատ, իմանալ զբանս հանճարոյ");
    writer.putString(4, 3,  "Greek:      μὴ μου τοὺς κύκλους τάραττε");
    writer.putString(4, 4,  "Hebrew:     סְבָאלְבָּרְד הוא ארכיפלג הנמצא באוקיינוס הארקטי");
    writer.putString(4, 5,  "Icelandic:  þungur hnífur   þessi hnífur á að vera þungur");
    writer.putString(4, 6,  "Persian:    آنان که محیط فضل و آداب شدند  در جمع کمال شمع اصحاب شدند");
    writer.putString(4, 7,  "Russian:    Запорізькі козаки турецькому султану!");
    writer.putString(4, 8,  "Swedish:    Flygande bäckasiner söka hwila på mjuka tuvor");
    writer.putString(4, 9,  "Thai:       เสียงฦๅเสียงเล่าอ้าง    อันใด พี่เอย");
    screen.refresh();
    screen.readInput();
    screen.stopScreen();
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:20,代码来源:InternationalCharactersTest.java


示例5: main

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    Screen screen = new TestTerminalFactory(args).createScreen();
    screen.startScreen();

    TextGraphics writer = new ScreenTextGraphics(screen);
    writer.setForegroundColor(TextColor.ANSI.DEFAULT);
    writer.setBackgroundColor(TextColor.ANSI.DEFAULT);
    writer.putString(4, 2,  "Chinese (simplified):  石室诗士施氏,嗜狮,誓食十狮。");
    writer.putString(4, 3,  "                       氏时时适市视狮。");
    writer.putString(4, 5,  "Chinese (traditional): 石室詩士施氏,嗜獅,誓食十獅。 ");
    writer.putString(4, 6,  "                       氏時時適市視獅。");
    writer.putString(4, 8,  "Japanese:              祇園精舎の鐘の声、諸行無常の響あり。");
    writer.putString(4, 9,  "                       沙羅双樹の花の色、盛者必衰の理をあらはす");
    writer.putString(4, 11, "  (katakana)           ランターナ バージョンアップ!");
    writer.putString(4, 12, "  (half-width)         ランターナ バージョンアップ");
    writer.putString(4, 14, "Korean:                내 벗이 몇인가하니 수석과 송죽이라");
    writer.putString(4, 15, "                       동산에 달오르니 그 더욱 반갑도다");
    writer.putString(4, 16, "                       두어라, 이 다섯 밖에 또 더해야 무엇하리");
    screen.refresh();

    screen.readInput();
    screen.stopScreen();
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:24,代码来源:CJKScreenTest.java


示例6: main

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
    Terminal terminal = new TestTerminalFactory(args).createTerminal();
    terminal.enterPrivateMode();
    terminal.clearScreen();
    terminal.setCursorPosition(10, 5);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.enableSGR(SGR.BOLD);
    terminal.putCharacter('l');
    terminal.setForegroundColor(TextColor.ANSI.CYAN);
    terminal.putCharacter('l');
    terminal.enableSGR(SGR.REVERSE);
    terminal.putCharacter('o');
    terminal.resetColorAndSGR();
    terminal.putCharacter('!');
    terminal.setCursorPosition(0, 0);

    Thread.sleep(5000);
    terminal.exitPrivateMode();
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:21,代码来源:ResetAllTest.java


示例7: main

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    final String string = "Hello!";
    Random random = new Random();
    Terminal terminal = new TestTerminalFactory(args).createTerminal();
    terminal.enterPrivateMode();
    terminal.clearScreen();
    TerminalSize size = terminal.getTerminalSize();

    while(true) {
        if(terminal.pollInput() != null) {
            terminal.exitPrivateMode();
            return;
        }

        terminal.setForegroundColor(new TextColor.RGB(random.nextInt(255), random.nextInt(255), random.nextInt(255)));
        terminal.setBackgroundColor(new TextColor.RGB(random.nextInt(255), random.nextInt(255), random.nextInt(255)));
        terminal.setCursorPosition(random.nextInt(size.getColumns() - string.length()), random.nextInt(size.getRows()));
        printString(terminal, string);

        try {
            Thread.sleep(200);
        }
        catch(InterruptedException e) {
        }
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:27,代码来源:Terminal24bitColorTest.java


示例8: main

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    Terminal rawTerminal = new TestTerminalFactory(args).createTerminal();
    rawTerminal.enterPrivateMode();
    rawTerminal.clearScreen();
    rawTerminal.setForegroundColor(TextColor.ANSI.RED);
    rawTerminal.enableSGR(SGR.BLINK);
    rawTerminal.setCursorPosition(10, 10);
    rawTerminal.putCharacter('H');
    rawTerminal.putCharacter('e');
    rawTerminal.putCharacter('l');
    rawTerminal.putCharacter('l');
    rawTerminal.putCharacter('o');
    rawTerminal.putCharacter('!');
    rawTerminal.setCursorPosition(0, 0);
    rawTerminal.flush();
    try {
        Thread.sleep(5000);
    }
    catch(InterruptedException e) {}
    rawTerminal.exitPrivateMode();
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:22,代码来源:BlinkTest.java


示例9: getTextColor

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
private TextColor getTextColor(final int code) {
    switch (code) {
    case 0:
        return TextColor.ANSI.BLACK;
    case 1:
        return TextColor.ANSI.BLUE;
    case 2:
        return TextColor.ANSI.GREEN;
    case 3:
        return TextColor.ANSI.CYAN;
    case 4:
        return TextColor.ANSI.RED;
    case 5:
        return TextColor.ANSI.MAGENTA;
    case 6:
        return TextColor.ANSI.YELLOW;
    case 7:
        return TextColor.ANSI.WHITE;

    default:
        return TextColor.ANSI.DEFAULT;
    }
}
 
开发者ID:viktor-podzigun,项目名称:charva-lanterna,代码行数:24,代码来源:LanternaToolkit.java


示例10: LanternaCaption

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public LanternaCaption(Component component, String caption) {
	super(new LinearLayout());
	Panel panel = new Panel();
	panel.addComponent(new Label(caption));
	
	validationLabel = new Label("");
	validationLabel.setForegroundColor(TextColor.ANSI.RED);
	panel.addComponent(validationLabel);
	
	addComponent(panel);
	// if (component instanceof CheckBox) {
		addComponent(component);
	// } else {
	// 	addComponent(component, VerticalLayout.MAXIMIZES_HORIZONTALLY);
	// }
}
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:17,代码来源:LanternaCaption.java


示例11: FrontEnd

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public FrontEnd(TelnetTerminal terminal) throws IOException {
    System.out.println("Creating a new frontEnd");
    this.terminal = terminal;
    this.screen = new TerminalScreen(terminal);
    screen.startScreen();
    this.gui = new MultiWindowTextGUI(this.screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
    lang = ResourceBundle.getBundle("cnvtgTelnet/zh_CN");
}
 
开发者ID:cnVintage,项目名称:cnVintage-Telnet,代码行数:9,代码来源:FrontEnd.java


示例12: MultiWindowTextGUI

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen) {
    this(guiThreadFactory,
            screen,
            new DefaultWindowManager(),
            new WindowShadowRenderer(),
            new EmptySpace(TextColor.ANSI.BLUE));
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:8,代码来源:MultiWindowTextGUI.java


示例13: PropertiesTheme

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
public PropertiesTheme(Properties properties) {
    rootNode = new ThemeTreeNode();
    rootNode.foregroundMap.put(STYLE_NORMAL, TextColor.ANSI.WHITE);
    rootNode.backgroundMap.put(STYLE_NORMAL, TextColor.ANSI.BLACK);

    for(String key: properties.stringPropertyNames()) {
        String definition = getDefinition(key);
        ThemeTreeNode node = getNode(definition);
        node.apply(getStyle(key), properties.getProperty(key));
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:12,代码来源:PropertiesTheme.java


示例14: getForeground

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
@Override
public TextColor getForeground() {
    ListIterator<ThemeTreeNode> iterator = path.listIterator(path.size());
    while(iterator.hasPrevious()) {
        ThemeTreeNode node = iterator.previous();
        if(node.foregroundMap.containsKey(name)) {
            return node.foregroundMap.get(name);
        }
    }
    if(!name.equals(STYLE_NORMAL)) {
        return new StyleImpl(path, STYLE_NORMAL).getForeground();
    }
    return TextColor.ANSI.WHITE;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:15,代码来源:PropertiesTheme.java


示例15: getBackground

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
@Override
public TextColor getBackground() {
    ListIterator<ThemeTreeNode> iterator = path.listIterator(path.size());
    while(iterator.hasPrevious()) {
        ThemeTreeNode node = iterator.previous();
        if(node.backgroundMap.containsKey(name)) {
            return node.backgroundMap.get(name);
        }
    }
    if(!name.equals(STYLE_NORMAL)) {
        return new StyleImpl(path, STYLE_NORMAL).getBackground();
    }
    return TextColor.ANSI.BLACK;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:15,代码来源:PropertiesTheme.java


示例16: ThemeTreeNode

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
private ThemeTreeNode() {
    childMap = new HashMap<String, ThemeTreeNode>();
    foregroundMap = new HashMap<String, TextColor>();
    backgroundMap = new HashMap<String, TextColor>();
    sgrMap = new HashMap<String, EnumSet<SGR>>();
    characterMap = new HashMap<String, Character>();
    renderer = null;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:9,代码来源:PropertiesTheme.java


示例17: setForegroundColor

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
@Override
public void setForegroundColor(TextColor color) {
    try {
        backend.setForegroundColor(color);
    }
    catch(IOException e) {
        exceptionHandler.onException(e);
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:10,代码来源:IOSafeTerminalAdapter.java


示例18: setBackgroundColor

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
@Override
public void setBackgroundColor(TextColor color) {
    try {
        backend.setBackgroundColor(color);
    }
    catch(IOException e) {
        exceptionHandler.onException(e);
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:10,代码来源:IOSafeTerminalAdapter.java


示例19: SwingTerminalDeviceConfiguration

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
/**
 * Creates a new terminal device configuration object with all configurable values specified.
 * @param lineBufferScrollbackSize How many lines of scrollback buffer should the terminal save?
 * @param blinkLengthInMilliSeconds How many milliseconds does a 'blink' last
 * @param cursorStyle Style of the terminal text cursor
 * @param cursorColor Color of the terminal text cursor
 * @param cursorBlinking Should the terminal text cursor blink?
 */
@SuppressWarnings("WeakerAccess")
public SwingTerminalDeviceConfiguration(int lineBufferScrollbackSize, int blinkLengthInMilliSeconds, CursorStyle cursorStyle, TextColor cursorColor, boolean cursorBlinking) {
    this.lineBufferScrollbackSize = lineBufferScrollbackSize;
    this.blinkLengthInMilliSeconds = blinkLengthInMilliSeconds;
    this.cursorStyle = cursorStyle;
    this.cursorColor = cursorColor;
    this.cursorBlinking = cursorBlinking;
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:17,代码来源:SwingTerminalDeviceConfiguration.java


示例20: classWithoutThemePicksUpParentPackagesTheme

import com.googlecode.lanterna.TextColor; //导入依赖的package包/类
@Test
public void classWithoutThemePicksUpParentPackagesTheme() {
    Properties properties = new Properties();
    properties.setProperty("com.googlecode.lanterna.foreground", "yellow");
    PropertiesTheme theme = new PropertiesTheme(properties);
    ThemeDefinition definition = theme.getDefinition(PropertiesThemeTest.class);
    assertEquals(TextColor.ANSI.YELLOW, definition.getNormal().getForeground());
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:9,代码来源:PropertiesThemeTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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