本文整理汇总了Java中com.googlecode.lanterna.TerminalPosition类的典型用法代码示例。如果您正苦于以下问题:Java TerminalPosition类的具体用法?Java TerminalPosition怎么用?Java TerminalPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TerminalPosition类属于com.googlecode.lanterna包,在下文中一共展示了TerminalPosition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCursorPosition
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public TerminalPosition getCursorPosition() {
if(focusedInteractable == null) {
return null;
}
TerminalPosition position = focusedInteractable.getCursorLocation();
if(position == null) {
return null;
}
//Don't allow the component to set the cursor outside of its own boundaries
if(position.getColumn() < 0 ||
position.getRow() < 0 ||
position.getColumn() >= focusedInteractable.getSize().getColumns() ||
position.getRow() >= focusedInteractable.getSize().getRows()) {
return null;
}
return focusedInteractable.toBasePane(position);
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:19,代码来源:AbstractBasePane.java
示例2: onAdded
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public void onAdded(WindowBasedTextGUI textGUI, Window window, List<Window> allWindows) {
WindowDecorationRenderer decorationRenderer = getWindowDecorationRenderer(window);
TerminalSize expectedDecoratedSize = decorationRenderer.getDecoratedSize(window, window.getPreferredSize());
window.setDecoratedSize(expectedDecoratedSize);
if(allWindows.isEmpty()) {
window.setPosition(TerminalPosition.OFFSET_1x1);
}
else if(window.getHints().contains(Window.Hint.CENTERED)) {
int left = (lastKnownScreenSize.getColumns() - expectedDecoratedSize.getColumns()) / 2;
int top = (lastKnownScreenSize.getRows() - expectedDecoratedSize.getRows()) / 2;
window.setPosition(new TerminalPosition(left, top));
}
else {
TerminalPosition nextPosition = allWindows.get(allWindows.size() - 1).getPosition().withRelative(2, 1);
if(nextPosition.getColumn() + expectedDecoratedSize.getColumns() > lastKnownScreenSize.getColumns() ||
nextPosition.getRow() + expectedDecoratedSize.getRows() > lastKnownScreenSize.getRows()) {
nextPosition = TerminalPosition.OFFSET_1x1;
}
window.setPosition(nextPosition);
}
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:25,代码来源:DefaultWindowManager.java
示例3: setComponent
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public void setComponent(Component component) {
Component oldComponent = this.component;
if(oldComponent == component) {
return;
}
if(oldComponent != null) {
removeComponent(oldComponent);
}
if(component != null) {
this.component = component;
component.onAdded(this);
component.setPosition(TerminalPosition.TOP_LEFT_CORNER);
invalidate();
}
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:17,代码来源:AbstractComposite.java
示例4: updateScreen
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public synchronized void updateScreen() throws IOException {
TerminalSize minimumTerminalSize = TerminalSize.ZERO;
for(Window window: windows) {
if(window.getHints().contains(Window.Hint.FULL_SCREEN) ||
window.getHints().contains(Window.Hint.FIT_TERMINAL_WINDOW)) {
//Don't take full screen windows or auto-sized windows into account
continue;
}
TerminalPosition lastPosition = window.getPosition();
minimumTerminalSize = minimumTerminalSize.max(
//Add position to size to get the bottom-right corner of the window
window.getPreferredSize().withRelative(lastPosition.getColumn(), lastPosition.getRow()));
}
virtualScreen.setMinimumSize(minimumTerminalSize);
super.updateScreen();
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:18,代码来源:MultiWindowTextGUI.java
示例5: ScreenResizeTest
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
public ScreenResizeTest(String[] args) throws InterruptedException, IOException {
screen = new TestTerminalFactory(args).createScreen();
screen.startScreen();
screen.setCursorPosition(new TerminalPosition(0, 0));
putStrings("Initial setup, please resize the window");
long now = System.currentTimeMillis();
while(System.currentTimeMillis() - now < 20 * 1000) {
screen.pollInput();
if(screen.doResizeIfNecessary() != null) {
putStrings("Size: " + screen.getTerminalSize().getColumns() + "x" + screen.getTerminalSize().getRows());
}
Thread.sleep(1);
}
screen.stopScreen();
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:18,代码来源:ScreenResizeTest.java
示例6: getCursorPosition
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
public static TerminalPosition getCursorPosition(List<Character> currentMatching) {
if (currentMatching.isEmpty()) {
return null;
}
if (currentMatching.get(0) != KeyDecodingProfile.ESC_CODE) {
return null;
}
String asString = "";
for (int i = 1; i < currentMatching.size(); i++) {
asString += currentMatching.get(i);
}
Matcher matcher = REPORT_CURSOR_PATTERN.matcher(asString);
if (!matcher.matches()) {
return null;
}
return new TerminalPosition(Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(1)));
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:22,代码来源:ScreenInfoCharacterPattern.java
示例7: drawLine0
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
private void drawLine0(TerminalPosition start, int deltaX, int deltaY, boolean leftToRight, TextCharacter character) {
int x = start.getColumn();
int y = start.getRow();
int deltaYx2 = deltaY * 2;
int deltaYx2MinusDeltaXx2 = deltaYx2 - (deltaX * 2);
int errorTerm = deltaYx2 - deltaX;
callback.onPoint(x, y, character);
while(deltaX-- > 0) {
if(errorTerm >= 0) {
y++;
errorTerm += deltaYx2MinusDeltaXx2;
}
else {
errorTerm += deltaYx2;
}
x += leftToRight ? 1 : -1;
callback.onPoint(x, y, character);
}
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:20,代码来源:DefaultShapeRenderer.java
示例8: drawLine1
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
private void drawLine1(TerminalPosition start, int deltaX, int deltaY, boolean leftToRight, TextCharacter character) {
int x = start.getColumn();
int y = start.getRow();
int deltaXx2 = deltaX * 2;
int deltaXx2MinusDeltaYx2 = deltaXx2 - (deltaY * 2);
int errorTerm = deltaXx2 - deltaY;
callback.onPoint(x, y, character);
while(deltaY-- > 0) {
if(errorTerm >= 0) {
x += leftToRight ? 1 : -1;
errorTerm += deltaXx2MinusDeltaYx2;
}
else {
errorTerm += deltaXx2;
}
y++;
callback.onPoint(x, y, character);
}
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:20,代码来源:DefaultShapeRenderer.java
示例9: readInput
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
private KeyStroke readInput(boolean blocking) throws IOException {
synchronized(readMutex) {
if(!keyQueue.isEmpty())
return keyQueue.poll();
KeyStroke key = inputDecoder.getNextCharacter(blocking);
if (key != null && key.getKeyType() == KeyType.CursorLocation) {
TerminalPosition reportedTerminalPosition = inputDecoder.getLastReportedTerminalPosition();
if (reportedTerminalPosition != null)
onResized(reportedTerminalPosition.getColumn(), reportedTerminalPosition.getRow());
return pollInput();
} else {
return key;
}
}
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:18,代码来源:StreamBasedTerminal.java
示例10: drawTable
import com.googlecode.lanterna.TerminalPosition; //导入依赖的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++;
}
}
}
开发者ID:null-dev,项目名称:SpeedCD,代码行数:39,代码来源:FileTable.java
示例11: AbstractComponent
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
public AbstractComponent() {
size = TerminalSize.ZERO;
position = TerminalPosition.TOP_LEFT_CORNER;
explicitPreferredSize = null;
layoutData = null;
invalid = true;
parent = null;
renderer = null; //Will be set on the first call to getRenderer()
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:10,代码来源:AbstractComponent.java
示例12: toBasePane
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public TerminalPosition toBasePane(TerminalPosition position) {
Container parent = getParent();
if(parent == null) {
return null;
}
return parent.toBasePane(getPosition().withRelative(position));
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:9,代码来源:AbstractComponent.java
示例13: correctCursor
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
private void correctCursor() {
this.cursorPosition =
new TerminalPosition(
Math.min(cursorPosition.getColumn(), size.getColumns() - 1),
Math.min(cursorPosition.getRow(), size.getRows() - 1));
this.cursorPosition =
new TerminalPosition(
Math.max(cursorPosition.getColumn(), 0),
Math.max(cursorPosition.getRow(), 0));
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:11,代码来源:VirtualTerminal.java
示例14: VirtualScreenTest
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
public VirtualScreenTest(String[] args) throws InterruptedException, IOException {
Screen screen = new TestTerminalFactory(args).createScreen();
screen = new VirtualScreen(screen);
screen.startScreen();
TextGraphics textGraphics = screen.newTextGraphics();
textGraphics.setBackgroundColor(TextColor.ANSI.GREEN);
textGraphics.fillTriangle(new TerminalPosition(40, 0), new TerminalPosition(25,19), new TerminalPosition(65, 19), ' ');
textGraphics.setBackgroundColor(TextColor.ANSI.RED);
textGraphics.drawRectangle(TerminalPosition.TOP_LEFT_CORNER, screen.getTerminalSize(), ' ');
screen.refresh();
while(true) {
KeyStroke keyStroke = screen.pollInput();
if(keyStroke != null) {
if(keyStroke.getKeyType() == KeyType.Escape) {
break;
}
}
else if(screen.doResizeIfNecessary() != null) {
screen.refresh();
}
else {
Thread.sleep(1);
}
}
screen.stopScreen();
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:29,代码来源:VirtualScreenTest.java
示例15: getLine
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
private List<TextCharacter> getLine(TerminalSize terminalSize, TerminalPosition position) {
while(position.getRow() >= lineBuffer.size()) {
newLine();
}
int lineIndex = Math.min(terminalSize.getRows(), lineBuffer.size()) - 1 - position.getRow();
List<TextCharacter> line = lineBuffer.get(lineIndex);
while(line.size() <= position.getColumn()) {
line.add(fillCharacter);
}
return line;
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:12,代码来源:TextBuffer.java
示例16: setCharacter
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public TextGraphics setCharacter(int columnIndex, int rowIndex, TextCharacter textCharacter) {
TerminalSize size = getSize();
if(columnIndex < 0 || columnIndex >= size.getColumns() ||
rowIndex < 0 || rowIndex >= size.getRows()) {
return this;
}
virtualTerminal.setCursorAndPutCharacter(new TerminalPosition(columnIndex, rowIndex), textCharacter);
return this;
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:11,代码来源:VirtualTerminalTextGraphics.java
示例17: toGlobal
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public TerminalPosition toGlobal(TerminalPosition localPosition) {
if(localPosition == null) {
return null;
}
return lastKnownPosition.withRelative(contentOffset.withRelative(localPosition));
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:8,代码来源:AbstractWindow.java
示例18: getInteractableAt
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
public synchronized Interactable getInteractableAt(TerminalPosition position) {
if(position.getRow() >= lookupMap.length) {
return null;
}
else if(position.getColumn() >= lookupMap[0].length) {
return null;
}
else if(lookupMap[position.getRow()][position.getColumn()] == -1) {
return null;
}
return interactables.get(lookupMap[position.getRow()][position.getColumn()]);
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:13,代码来源:InteractableLookupMap.java
示例19: MultiWindowTextGUI
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
private MultiWindowTextGUI(
TextGUIThreadFactory guiThreadFactory,
VirtualScreen screen,
WindowManager windowManager,
WindowPostRenderer postRenderer,
Component background) {
super(guiThreadFactory, screen);
if(windowManager == null) {
throw new IllegalArgumentException("Creating a window-based TextGUI requires a WindowManager");
}
if(background == null) {
//Use a sensible default instead of throwing
background = new EmptySpace(TextColor.ANSI.BLUE);
}
this.virtualScreen = screen;
this.windowManager = windowManager;
this.backgroundPane = new AbstractBasePane() {
@Override
public TextGUI getTextGUI() {
return MultiWindowTextGUI.this;
}
@Override
public TerminalPosition toGlobal(TerminalPosition localPosition) {
return localPosition;
}
public TerminalPosition fromGlobal(TerminalPosition globalPosition) {
return globalPosition;
}
};
this.backgroundPane.setComponent(background);
this.windows = new ArrayList<Window>();
this.postRenderer = postRenderer;
this.eofWhenNoWindows = false;
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:38,代码来源:MultiWindowTextGUI.java
示例20: getCursorPosition
import com.googlecode.lanterna.TerminalPosition; //导入依赖的package包/类
@Override
public synchronized TerminalPosition getCursorPosition() {
Window activeWindow = getActiveWindow();
if(activeWindow != null) {
return activeWindow.toGlobal(activeWindow.getCursorPosition());
}
else {
return backgroundPane.getCursorPosition();
}
}
开发者ID:Truth0906,项目名称:lanterna,代码行数:11,代码来源:MultiWindowTextGUI.java
注:本文中的com.googlecode.lanterna.TerminalPosition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论