本文整理汇总了Java中com.googlecode.lanterna.screen.Screen类的典型用法代码示例。如果您正苦于以下问题:Java Screen类的具体用法?Java Screen怎么用?Java Screen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Screen类属于com.googlecode.lanterna.screen包,在下文中一共展示了Screen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
void run(String[] args) throws IOException, InterruptedException {
Screen screen = new TestTerminalFactory(args).createScreen();
screen.startScreen();
MultiWindowTextGUI textGUI = new MultiWindowTextGUI(new SeparateTextGUIThread.Factory(), screen);
textGUI.setBlockingIO(false);
textGUI.setEOFWhenNoWindows(true);
textGUI.isEOFWhenNoWindows(); //No meaning, just to silence IntelliJ:s "is never used" alert
try {
init(textGUI);
AsynchronousTextGUIThread guiThread = (AsynchronousTextGUIThread)textGUI.getGUIThread();
guiThread.start();
guiThread.waitForStop();
}
finally {
screen.stopScreen();
}
}
示例2: main
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
SwingTerminalFrame terminal = new SwingTerminalFrame(SwingTerminalFrame.AutoCloseTrigger.CloseOnExitPrivateMode);
terminal.setCursorVisible(false);
Screen screen = new TerminalScreen(terminal);
screen.startScreen();
terminal.setTitle("Freedom: An arena-battle roguelike");
terminal.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
terminal.setResizable(false);
terminal.setVisible(true);
while(screen.pollInput() == null) {
if(screen.doResizeIfNecessary() != null) {
screen.refresh();
}
Thread.sleep(100);
}
screen.stopScreen();
}
示例3: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
@Override
public void display(final Screen screen) {
final TextGraphics textGraphics = screen.newTextGraphics();
textGraphics.setBackgroundColor(new RGB(0, 0, 128));
// region
new ScreenBorder(getContext(), 60, 3).display(screen, 45, 60);
textGraphics.putString(61, 46, KernelContext.getRegion(getContext()));
// gil and steps
new ScreenBorder(getContext(), 30, 6).display(screen, 38, 90);
textGraphics.putString(91, 39, "Steps");
textGraphics.putString(91, 40, Strings.padStart(String.valueOf(KernelContext.getSteps(getContext())), 28, ' '));
textGraphics.putString(91, 41, "Gil");
textGraphics.putString(91, 42, Strings.padStart(String.valueOf(KernelContext.getGil(getContext())), 28, ' '));
}
示例4: drawTable
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
public void drawTable(Screen screen, int oX, int oY, int width) {
//Leave space between each column
width -= columns - 1;
int remainingWidth = width % columns;
int perColumnsWidth = (width - remainingWidth) / columns;
int fileIndex = 0;
for (int x = 0; x < columns; x++) {
int startX = x * perColumnsWidth;
for (int y = 0; y < rows; y++) {
File file = fileTable[x][y];
if (file == null) {
continue;
}
String name = file.getName();
if (name.length() > perColumnsWidth) {
name = name.substring(0, perColumnsWidth - (1 + CUT_OFF_STRING.length())) + CUT_OFF_STRING;
}
for (int rx = 0; rx < name.length(); rx++) {
TextCharacter character = new TextCharacter(name.charAt(rx));
if (fileIndex == cursorIndex) {
character = character.withBackgroundColor(SpeedCD.SELECT_BCK_COLOR)
.withForegroundColor(SpeedCD.SELECT_FORE_COLOR);
screen.setCursorPosition(new TerminalPosition(oX + startX, oY + y));
} else {
if (file.isDirectory()) {
character = character.withBackgroundColor(FileTable.DIR_BCK_COLOR)
.withForegroundColor(FileTable.DIR_FORE_COLOR);
} else if (file.isFile()) {
character = character.withBackgroundColor(FileTable.FILE_BCK_COLOR)
.withForegroundColor(FileTable.FILE_FORE_COLOR);
}
}
screen.setCharacter(oX + rx + startX, oY + y, character);
}
fileIndex++;
}
}
}
示例5: MultiWindowTextGUI
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
public MultiWindowTextGUI(TextGUIThreadFactory guiThreadFactory, Screen screen) {
this(guiThreadFactory,
screen,
new DefaultWindowManager(),
new WindowShadowRenderer(),
new EmptySpace(TextColor.ANSI.BLUE));
}
示例6: AbstractTextGUI
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
protected AbstractTextGUI(TextGUIThreadFactory textGUIThreadFactory, Screen screen) {
if(screen == null) {
throw new IllegalArgumentException("Creating a TextGUI requires an underlying Screen");
}
this.screen = screen;
this.listeners = new CopyOnWriteArrayList<Listener>();
this.blockingIO = false;
this.dirty = false;
this.guiTheme = new PropertiesTheme(loadDefaultThemeProperties());
this.textGUIThread = textGUIThreadFactory.createTextGUIThread(this);
}
示例7: main
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
Screen screen = new TestTerminalFactory(args).createScreen();
screen.startScreen();
MultiWindowTextGUI textGUI = new MultiWindowTextGUI(screen);
textGUI.setEOFWhenNoWindows(true);
try {
final BasicWindow window = new BasicWindow("Button test");
Panel contentArea = new Panel();
contentArea.setLayoutManager(new LinearLayout(Direction.VERTICAL));
contentArea.addComponent(new Button(""));
contentArea.addComponent(new Button("TRE"));
contentArea.addComponent(new Button("Button"));
contentArea.addComponent(new Button("Another button"));
contentArea.addComponent(new EmptySpace(new TerminalSize(5, 1)));
//contentArea.addComponent(new Button("Here is a\nmulti-line\ntext segment that is using \\n"));
contentArea.addComponent(new Button("OK", new Runnable() {
@Override
public void run() {
window.close();
}
}));
window.setComponent(contentArea);
textGUI.addWindowAndWait(window);
}
finally {
screen.stopScreen();
}
}
示例8: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
@Override
public void display(final Screen screen) {
// display room
room.getRoomScreenImage().display(screen, room.getRoomScript().getTop(), room.getRoomScript().getLeft());
// display actors
Arrays.stream(Actor.values()).filter(actor -> RoomContext.actorPresent(getContext(), actor)).forEach(actor -> {
final Entry<Integer, Integer> actorPlace = RoomContext.actorPlace(getContext(), actor);
final ScreenImage actorScreenImage = actor.getImage();
actorScreenImage.display(screen, actorPlace.getKey(), actorPlace.getValue());
});
}
示例9: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
@Override
public void display(final Screen screen) {
new ScreenBorder(getContext(), 60, 8).display(screen, 30, 0);
screen.newTextGraphics().putString(2, 31, "Cloud");
screen.newTextGraphics().putString(20, 31, "6666/9999");
screen.newTextGraphics().setForegroundColor(new TextColor.RGB(255, 0, 0)).putString(26, 32, "---");
screen.newTextGraphics().setForegroundColor(new TextColor.RGB(0, 100, 255)).putString(20, 32, "------");
}
示例10: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
@Override
public void display(final Screen screen) {
int i = 10;
for (final String line : title) {
screen.newTextGraphics().putString(7, i, line);
i++;
}
screen.newTextGraphics().putString(98, 47, "© 2015 Klaus Hauschild");
mainMenu.display(screen);
}
示例11: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
@Override
public void display(final Screen screen) {
new ScreenBorder(getContext(), 83, 4).display(screen, 1, 17);
final TextGraphics textGraphics = screen.newTextGraphics();
textGraphics.setBackgroundColor(KernelContext.getColor(getContext()));
textGraphics.putString(19, 3,
String.format("[LEFT] CD %s [RIGHT] | [UP] Track [DOWN] | [ACCEPT] play/stop | [MENU] auto play", cd));
getCdMenu().display(screen);
}
示例12: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
public void display(final Screen screen) {
final TextGraphics graphics = screen.newTextGraphics();
graphics.putString(left, top + (compact ? 1 : 2) * cursorPosition, "->");
for (int i = 0; i < menuEntries.size(); i++) {
E entry = menuEntries.get(i);
if (entry.isEnabled()) {
graphics.setForegroundColor(TextColor.ANSI.DEFAULT);
} else {
graphics.setForegroundColor(new TextColor.RGB(100, 100, 100));
}
graphics.putString(left + 4, top + i * (compact ? 1 : 2), entry.getLabel());
}
}
示例13: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
@Override
public void display(final Screen screen, final int top, final int left) {
final TextGraphics textGraphics = screen.newTextGraphics();
textGraphics.setBackgroundColor(KernelContext.getColor(context));
// place corners
textGraphics.putString(left, top, "+");
textGraphics.putString(left + width - 1, top, "+");
textGraphics.putString(left, top + height - 1, "+");
textGraphics.putString(left + width - 1, top + height - 1, "+");
// draw lines
for (int i = left + 1; i < left + width - 1; i++) {
textGraphics.putString(i, top, "-");
textGraphics.putString(i, top + height - 1, "-");
}
for (int i = top + 1; i < top + height - 1; i++) {
textGraphics.putString(left, i, "|");
textGraphics.putString(left + width - 1, i, "|");
}
// fill inner space
for (int x = left + 1; x < left + width - 1; x++) {
for (int y = top + 1; y < top + height - 1; y++) {
textGraphics.putString(x, y, " ");
}
}
}
示例14: display
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
@Override
public void display(final Screen screen, final int top, final int left) {
final TextGraphics textGraphics = screen.newTextGraphics();
for (int x = 0; x < size.width; x++) {
for (int y = 0; y < size.height; y++) {
// TODO handle transparent pixels and non present text
final Color background = getBackground(x, y);
final Color foreground = getForeground(x, y);
final String text = getText(x, y);
textGraphics.setBackgroundColor(convertColor(background));
textGraphics.setForegroundColor(convertColor(foreground));
textGraphics.putString(left + x, top + y, text);
}
}
}
示例15: Section
import com.googlecode.lanterna.screen.Screen; //导入依赖的package包/类
/**
* @param screen
* @param upperLeft
* @param bottomRight
*/
public Section(Screen screen, Vec2i upperLeft, Vec2i bottomRight) {
super(screen);
this.screen = screen;
this.upperLeft = upperLeft;
this.bottomRight = bottomRight;
}