本文整理汇总了Java中com.googlecode.lanterna.TerminalSize.getColumns方法的典型用法代码示例。如果您正苦于以下问题:Java TerminalSize.getColumns方法的具体用法?Java TerminalSize.getColumns怎么用?Java TerminalSize.getColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.lanterna.TerminalSize
的用法示例。
在下文中一共展示了TerminalSize.getColumns方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shrinkWidthToFitArea
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private int shrinkWidthToFitArea(TerminalSize area, int[] columnWidths) {
int totalWidth = 0;
for(int width: columnWidths) {
totalWidth += width;
}
if(totalWidth > area.getColumns()) {
int columnOffset = 0;
do {
if(columnWidths[columnOffset] > 0) {
columnWidths[columnOffset]--;
totalWidth--;
}
if(++columnOffset == numberOfColumns) {
columnOffset = 0;
}
}
while(totalWidth > area.getColumns());
}
return totalWidth;
}
示例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: grabExtraHorizontalSpace
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private int grabExtraHorizontalSpace(TerminalSize area, int[] columnWidths, Set<Integer> expandableColumns, int totalWidth) {
for(int columnIndex: expandableColumns) {
columnWidths[columnIndex]++;
totalWidth++;
if(area.getColumns() == totalWidth) {
break;
}
}
return totalWidth;
}
示例6: grabExtraVerticalSpace
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private int grabExtraVerticalSpace(TerminalSize area, int[] rowHeights, Set<Integer> expandableRows, int totalHeight) {
for(int rowIndex: expandableRows) {
rowHeights[rowIndex]++;
totalHeight++;
if(area.getColumns() == totalHeight) {
break;
}
}
return totalHeight;
}
示例7: 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);
}
示例8: 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);
}
示例9: 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();
}
示例10: getLabelShift
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
private int getLabelShift(Button button, TerminalSize size) {
int availableSpace = size.getColumns() - 2;
if(availableSpace <= 0) {
return 0;
}
int labelShift = 0;
if(availableSpace > button.getLabel().length()) {
labelShift = (size.getColumns() - 2 - button.getLabel().length()) / 2;
}
return labelShift;
}
示例11: drawComponent
import com.googlecode.lanterna.TerminalSize; //导入方法依赖的package包/类
@Override
public void drawComponent(TextGUIGraphics graphics) {
TerminalSize area = graphics.getSize();
String absolutePath = directory.getAbsolutePath();
if(area.getColumns() < absolutePath.length()) {
absolutePath = absolutePath.substring(absolutePath.length() - area.getColumns());
absolutePath = "..." + absolutePath.substring(Math.min(absolutePath.length(), 3));
}
setText(absolutePath);
super.drawComponent(graphics);
}
示例12: 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);
}
}
示例13: 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);
}
}
}
示例14: 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);
}
示例15: 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;
}