本文整理汇总了Java中com.googlecode.lanterna.TerminalSize.getRows方法的典型用法代码示例。如果您正苦于以下问题:Java TerminalSize.getRows方法的具体用法?Java TerminalSize.getRows怎么用?Java TerminalSize.getRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.lanterna.TerminalSize
的用法示例。
在下文中一共展示了TerminalSize.getRows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shrinkHeightToFitArea
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private int shrinkHeightToFitArea(TerminalSize area, int[] rowHeights) {
int totalHeight = 0;
for(int height: rowHeights) {
totalHeight += height;
}
if(totalHeight > area.getRows()) {
int rowOffset = 0;
do {
if(rowHeights[rowOffset] > 0) {
rowHeights[rowOffset]--;
totalHeight--;
}
if(++rowOffset == rowHeights.length) {
rowOffset = 0;
}
}
while(totalHeight > area.getRows());
}
return totalHeight;
}
示例2: onAdded
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的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);
}
}
示例3: add
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public void add(Interactable interactable) {
TerminalPosition topLeft = interactable.toBasePane(TerminalPosition.TOP_LEFT_CORNER);
TerminalSize size = interactable.getSize();
interactables.add(interactable);
int index = interactables.size() - 1;
for(int y = topLeft.getRow(); y < topLeft.getRow() + size.getRows(); y++) {
for(int x = topLeft.getColumn(); x < topLeft.getColumn() + size.getColumns(); x++) {
//Make sure it's not outside the map
if(y >= 0 && y < lookupMap.length &&
x >= 0 && x < lookupMap[y].length) {
lookupMap[y][x] = index;
}
}
}
}
示例4: BasicTextImage
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
/**
* Creates a new BasicTextImage by copying a region of a two-dimensional array of TextCharacter:s. If the area to be
* copied to larger than the source array, a filler character is used.
* @param size Size to create the new BasicTextImage as (and size to copy from the array)
* @param toCopy Array to copy initial data from
* @param initialContent Filler character to use if the source array is smaller than the requested size
*/
private BasicTextImage(TerminalSize size, TextCharacter[][] toCopy, TextCharacter initialContent) {
if(size == null || toCopy == null || initialContent == null) {
throw new IllegalArgumentException("Cannot create BasicTextImage with null " +
(size == null ? "size" : (toCopy == null ? "toCopy" : "filler")));
}
this.size = size;
int rows = size.getRows();
int columns = size.getColumns();
buffer = new TextCharacter[rows][];
for(int y = 0; y < rows; y++) {
buffer[y] = new TextCharacter[columns];
for(int x = 0; x < columns; x++) {
if(y < toCopy.length && x < toCopy[y].length) {
buffer[y][x] = toCopy[y][x];
}
else {
buffer[y][x] = initialContent;
}
}
}
}
示例5: getPreferredSizeVertically
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private TerminalSize getPreferredSizeVertically(List<Component> components) {
int maxWidth = 0;
int height = 0;
for(Component component: components) {
TerminalSize preferredSize = component.getPreferredSize();
if(maxWidth < preferredSize.getColumns()) {
maxWidth = preferredSize.getColumns();
}
height += preferredSize.getRows();
}
height += spacing * (components.size() - 1);
return new TerminalSize(maxWidth, height);
}
示例6: getPreferredSizeHorizontally
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private TerminalSize getPreferredSizeHorizontally(List<Component> components) {
int maxHeight = 0;
int width = 0;
for(Component component: components) {
TerminalSize preferredSize = component.getPreferredSize();
if(maxHeight < preferredSize.getRows()) {
maxHeight = preferredSize.getRows();
}
width += preferredSize.getColumns();
}
width += spacing * (components.size() - 1);
return new TerminalSize(width, maxHeight);
}
示例7: InteractableLookupMap
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
public InteractableLookupMap(TerminalSize size) {
lookupMap = new int[size.getRows()][size.getColumns()];
interactables = new ArrayList<Interactable>();
for (int[] aLookupMap : lookupMap) {
Arrays.fill(aLookupMap, -1);
}
}
示例8: fillRectangle
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
@Override
public void fillRectangle(TerminalPosition topLeft, TerminalSize size, TextCharacter character) {
for(int y = 0; y < size.getRows(); y++) {
for(int x = 0; x < size.getColumns(); x++) {
callback.onPoint(topLeft.getColumn() + x, topLeft.getRow() + y, character);
}
}
}
示例9: resize
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
@Override
public BasicTextImage resize(TerminalSize newSize, TextCharacter filler) {
if(newSize == null || filler == null) {
throw new IllegalArgumentException("Cannot resize BasicTextImage with null " +
(newSize == null ? "newSize" : "filler"));
}
if(newSize.getRows() == buffer.length &&
(buffer.length == 0 || newSize.getColumns() == buffer[0].length)) {
return this;
}
return new BasicTextImage(newSize, buffer, filler);
}
示例10: NewSwingTerminalTest
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
/**
* Creates new form NewSwingTerminalTest
*/
public NewSwingTerminalTest() {
initComponents();
final SwingTerminal leftTerminal = new SwingTerminal();
final SwingTerminal rightTerminal = new SwingTerminal();
splitPane.setLeftComponent(leftTerminal);
splitPane.setRightComponent(rightTerminal);
pack();
Timer timer = new Timer(500, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
drawRandomHello(leftTerminal);
drawRandomHello(rightTerminal);
}
private void drawRandomHello(IOSafeTerminal terminal) {
TerminalSize size = terminal.getTerminalSize();
if(size.getColumns() > 6 && size.getRows() > 1) {
int positionX = RANDOM.nextInt(size.getColumns() - 6);
int positionY = RANDOM.nextInt(size.getRows());
terminal.setCursorPosition(positionX, positionY);
terminal.setBackgroundColor(new TextColor.Indexed(RANDOM.nextInt(256)));
terminal.setForegroundColor(new TextColor.Indexed(RANDOM.nextInt(256)));
String hello = "Hello!";
for(int i = 0; i < hello.length(); i++) {
terminal.putCharacter(hello.charAt(i));
}
terminal.flush();
}
}
});
timer.start();
}
示例11: setCharacter
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
@Override
public TextGraphics setCharacter(int columnIndex, int rowIndex, TextCharacter textCharacter) {
TerminalSize writableArea = getSize();
if(columnIndex < 0 || columnIndex >= writableArea.getColumns() ||
rowIndex < 0 || rowIndex >= writableArea.getRows()) {
return this;
}
underlyingTextGraphics.setCharacter(columnIndex + topLeft.getColumn(), rowIndex + topLeft.getRow(), textCharacter);
return this;
}
示例12: resize
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
void resize(TerminalSize newSize) {
if(size.getRows() < newSize.getRows()) {
cursorPosition = cursorPosition.withRelativeRow(newSize.getRows() - size.getRows());
}
this.size = newSize;
updateScrollingController();
correctCursor();
}
示例13: setCharacter
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的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;
}
示例14: onResized
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
@Override
public void onResized(Terminal terminal, TerminalSize newSize) {
try {
terminal.setCursorPosition(0, 0);
String string = newSize.getColumns() + "x" + newSize.getRows() + " ";
char[] chars = string.toCharArray();
for(char c : chars) {
terminal.putCharacter(c);
}
}
catch(IOException e) {
throw new RuntimeException(e);
}
}
示例15: doVerticalLayout
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private void doVerticalLayout(TerminalSize area, List<Component> components) {
int remainingVerticalSpace = area.getRows();
int availableHorizontalSpace = area.getColumns();
for(Component component: components) {
if(remainingVerticalSpace <= 0) {
component.setPosition(TerminalPosition.TOP_LEFT_CORNER);
component.setSize(TerminalSize.ZERO);
}
else {
LinearLayoutData layoutData = (LinearLayoutData)component.getLayoutData();
Alignment alignment = Alignment.Beginning;
if(layoutData != null) {
alignment = layoutData.alignment;
}
TerminalSize preferredSize = component.getPreferredSize();
TerminalSize decidedSize = new TerminalSize(
Math.min(availableHorizontalSpace, preferredSize.getColumns()),
Math.min(remainingVerticalSpace, preferredSize.getRows()));
if(alignment == Alignment.Fill) {
decidedSize = decidedSize.withColumns(availableHorizontalSpace);
alignment = Alignment.Beginning;
}
TerminalPosition position = component.getPosition();
position = position.withRow(area.getRows() - remainingVerticalSpace);
switch(alignment) {
case End:
position = position.withColumn(availableHorizontalSpace - decidedSize.getColumns());
break;
case Center:
position = position.withColumn((availableHorizontalSpace - decidedSize.getColumns()) / 2);
break;
case Beginning:
default:
position = position.withColumn(0);
break;
}
component.setPosition(position);
component.setSize(component.getSize().with(decidedSize));
remainingVerticalSpace -= decidedSize.getRows() + spacing;
}
}
}