本文整理汇总了Java中com.googlecode.lanterna.TextColor类的典型用法代码示例。如果您正苦于以下问题:Java TextColor类的具体用法?Java TextColor怎么用?Java TextColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextColor类属于com.googlecode.lanterna包,在下文中一共展示了TextColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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, ' ');
}
示例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);
}
}
示例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()));
}
示例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();
}
示例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();
}
示例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();
}
示例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) {
}
}
}
示例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();
}
示例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;
}
}
示例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);
// }
}
示例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");
}
示例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));
}
示例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));
}
}
示例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;
}
示例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;
}