Java Code Examples for com.googlecode.lanterna.TerminalSize#ZERO
The following examples show how to use
com.googlecode.lanterna.TerminalSize#ZERO .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GridLayout.java From lanterna with GNU Lesser General Public License v3.0 | 6 votes |
@Override public TerminalSize getPreferredSize(List<Component> components) { TerminalSize preferredSize = TerminalSize.ZERO; if(components.isEmpty()) { return preferredSize.withRelative( leftMarginSize + rightMarginSize, topMarginSize + bottomMarginSize); } Component[][] table = buildTable(components); table = eliminateUnusedRowsAndColumns(table); //Figure out each column first, this can be done independently of the row heights int preferredWidth = 0; int preferredHeight = 0; for(int width: getPreferredColumnWidths(table)) { preferredWidth += width; } for(int height: getPreferredRowHeights(table)) { preferredHeight += height; } preferredSize = preferredSize.withRelative(preferredWidth, preferredHeight); preferredSize = preferredSize.withRelativeColumns(leftMarginSize + rightMarginSize + (table[0].length - 1) * horizontalSpacing); preferredSize = preferredSize.withRelativeRows(topMarginSize + bottomMarginSize + (table.length - 1) * verticalSpacing); return preferredSize; }
Example 2
Source File: MultiWindowTextGUI.java From lanterna with GNU Lesser General Public License v3.0 | 6 votes |
@Override public synchronized void updateScreen() throws IOException { if (getScreen() instanceof VirtualScreen) { // If the user has passed in a virtual screen, we should calculate the minimum size required and tell it. // Previously the constructor always wrapped the screen in a VirtualScreen, but now we need to check. TerminalSize minimumTerminalSize = TerminalSize.ZERO; for (Window window : windows) { if (window.isVisible()) { if (window.getHints().contains(Window.Hint.FULL_SCREEN) || window.getHints().contains(Window.Hint.FIT_TERMINAL_WINDOW) || window.getHints().contains(Window.Hint.EXPANDED)) { //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.getDecoratedSize().withRelative( Math.max(lastPosition.getColumn(), 0), Math.max(lastPosition.getRow(), 0))); } } ((VirtualScreen) getScreen()).setMinimumSize(minimumTerminalSize); } super.updateScreen(); }
Example 3
Source File: Label.java From lanterna with GNU Lesser General Public License v3.0 | 6 votes |
/** * Returns the area, in terminal columns and rows, required to fully draw the lines passed in. * @param lines Lines to measure the size of * @param currentBounds Optional (can pass {@code null}) terminal size to use for storing the output values. If the * method is called many times and always returning the same value, passing in an external * reference of this size will avoid creating new {@code TerminalSize} objects every time * @return Size that is required to draw the lines */ protected TerminalSize getBounds(String[] lines, TerminalSize currentBounds) { if(currentBounds == null) { currentBounds = TerminalSize.ZERO; } currentBounds = currentBounds.withRows(lines.length); if(labelWidth == null || labelWidth == 0) { int preferredWidth = 0; for(String line : lines) { int lineWidth = TerminalTextUtils.getColumnWidth(line); if(preferredWidth < lineWidth) { preferredWidth = lineWidth; } } currentBounds = currentBounds.withColumns(preferredWidth); } else { List<String> wordWrapped = TerminalTextUtils.getWordWrappedText(labelWidth, lines); currentBounds = currentBounds.withColumns(labelWidth).withRows(wordWrapped.size()); } return currentBounds; }
Example 4
Source File: AnimatedLabel.java From lanterna with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates a new animated label, initially set to one frame. You will need to add more frames and call * {@code startAnimation()} for this to start moving. * * @param firstFrameText The content of the label at the first frame */ public AnimatedLabel(String firstFrameText) { super(firstFrameText); frames = new ArrayList<>(); currentFrame = 0; combinedMaximumPreferredSize = TerminalSize.ZERO; String[] lines = splitIntoMultipleLines(firstFrameText); frames.add(lines); ensurePreferredSize(lines); }
Example 5
Source File: AbstractComponent.java From lanterna with GNU Lesser General Public License v3.0 | 5 votes |
/** * Default constructor */ public AbstractComponent() { size = TerminalSize.ZERO; position = TerminalPosition.TOP_LEFT_CORNER; explicitPreferredSize = null; layoutData = null; visible = true; invalid = true; parent = null; overrideRenderer = null; themeRenderer = null; themeRenderersTheme = null; defaultRenderer = null; }
Example 6
Source File: DefaultTableHeaderRenderer.java From lanterna with GNU Lesser General Public License v3.0 | 5 votes |
@Override public TerminalSize getPreferredSize(Table<V> table, String label, int columnIndex) { if(label == null) { return TerminalSize.ZERO; } return new TerminalSize(TerminalTextUtils.getColumnWidth(label), 1); }
Example 7
Source File: AbsoluteLayout.java From lanterna with GNU Lesser General Public License v3.0 | 5 votes |
@Override public TerminalSize getPreferredSize(List<Component> components) { TerminalSize size = TerminalSize.ZERO; for(Component component: components) { size = size.max( new TerminalSize( component.getPosition().getColumn() + component.getSize().getColumns(), component.getPosition().getRow() + component.getSize().getRows())); } return size; }
Example 8
Source File: Label.java From lanterna with GNU Lesser General Public License v3.0 | 5 votes |
/** * Main constructor, creates a new Label displaying a specific text. * @param text Text the label will display */ public Label(String text) { this.lines = null; this.labelSize = TerminalSize.ZERO; this.labelWidth = 0; this.foregroundColor = null; this.backgroundColor = null; this.additionalStyles = EnumSet.noneOf(SGR.class); setText(text); }
Example 9
Source File: InteractableLookupMap.java From lanterna with GNU Lesser General Public License v3.0 | 4 votes |
TerminalSize getSize() { if (lookupMap.length==0) { return TerminalSize.ZERO; } return new TerminalSize(lookupMap[0].length, lookupMap.length); }