2 * Jexer - Java Text User Interface
4 * The MIT License (MIT)
6 * Copyright (C) 2019 Kevin Lamonte
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
29 package jexer
.backend
;
31 import jexer
.bits
.Cell
;
32 import jexer
.bits
.CellAttributes
;
35 * Drawing operations API.
37 public interface Screen
{
40 * Set drawing offset for x.
42 * @param offsetX new drawing offset
44 public void setOffsetX(final int offsetX
);
47 * Set drawing offset for y.
49 * @param offsetY new drawing offset
51 public void setOffsetY(final int offsetY
);
54 * Get right drawing clipping boundary.
56 * @return drawing boundary
58 public int getClipRight();
61 * Set right drawing clipping boundary.
63 * @param clipRight new boundary
65 public void setClipRight(final int clipRight
);
68 * Get bottom drawing clipping boundary.
70 * @return drawing boundary
72 public int getClipBottom();
75 * Set bottom drawing clipping boundary.
77 * @param clipBottom new boundary
79 public void setClipBottom(final int clipBottom
);
82 * Get left drawing clipping boundary.
84 * @return drawing boundary
86 public int getClipLeft();
89 * Set left drawing clipping boundary.
91 * @param clipLeft new boundary
93 public void setClipLeft(final int clipLeft
);
96 * Get top drawing clipping boundary.
98 * @return drawing boundary
100 public int getClipTop();
103 * Set top drawing clipping boundary.
105 * @param clipTop new boundary
107 public void setClipTop(final int clipTop
);
112 * @return if true, the logical screen is not in sync with the physical
115 public boolean isDirty();
118 * Get the attributes at one location.
120 * @param x column coordinate. 0 is the left-most column.
121 * @param y row coordinate. 0 is the top-most row.
122 * @return attributes at (x, y)
124 public CellAttributes
getAttrXY(final int x
, final int y
);
127 * Get the cell at one location.
129 * @param x column coordinate. 0 is the left-most column.
130 * @param y row coordinate. 0 is the top-most row.
131 * @return the character + attributes
133 public Cell
getCharXY(final int x
, final int y
);
136 * Set the attributes at one location.
138 * @param x column coordinate. 0 is the left-most column.
139 * @param y row coordinate. 0 is the top-most row.
140 * @param attr attributes to use (bold, foreColor, backColor)
142 public void putAttrXY(final int x
, final int y
,
143 final CellAttributes attr
);
146 * Set the attributes at one location.
148 * @param x column coordinate. 0 is the left-most column.
149 * @param y row coordinate. 0 is the top-most row.
150 * @param attr attributes to use (bold, foreColor, backColor)
151 * @param clip if true, honor clipping/offset
153 public void putAttrXY(final int x
, final int y
,
154 final CellAttributes attr
, final boolean clip
);
157 * Fill the entire screen with one character with attributes.
159 * @param ch character to draw
160 * @param attr attributes to use (bold, foreColor, backColor)
162 public void putAll(final char ch
, final CellAttributes attr
);
165 * Render one character with attributes.
167 * @param x column coordinate. 0 is the left-most column.
168 * @param y row coordinate. 0 is the top-most row.
169 * @param ch character + attributes to draw
171 public void putCharXY(final int x
, final int y
, final Cell ch
);
174 * Render one character with attributes.
176 * @param x column coordinate. 0 is the left-most column.
177 * @param y row coordinate. 0 is the top-most row.
178 * @param ch character to draw
179 * @param attr attributes to use (bold, foreColor, backColor)
181 public void putCharXY(final int x
, final int y
, final char ch
,
182 final CellAttributes attr
);
185 * Render one character without changing the underlying attributes.
187 * @param x column coordinate. 0 is the left-most column.
188 * @param y row coordinate. 0 is the top-most row.
189 * @param ch character to draw
191 public void putCharXY(final int x
, final int y
, final char ch
);
194 * Render a string. Does not wrap if the string exceeds the line.
196 * @param x column coordinate. 0 is the left-most column.
197 * @param y row coordinate. 0 is the top-most row.
198 * @param str string to draw
199 * @param attr attributes to use (bold, foreColor, backColor)
201 public void putStringXY(final int x
, final int y
, final String str
,
202 final CellAttributes attr
);
205 * Render a string without changing the underlying attribute. Does not
206 * wrap if the string exceeds the line.
208 * @param x column coordinate. 0 is the left-most column.
209 * @param y row coordinate. 0 is the top-most row.
210 * @param str string to draw
212 public void putStringXY(final int x
, final int y
, final String str
);
215 * Draw a vertical line from (x, y) to (x, y + n).
217 * @param x column coordinate. 0 is the left-most column.
218 * @param y row coordinate. 0 is the top-most row.
219 * @param n number of characters to draw
220 * @param ch character to draw
221 * @param attr attributes to use (bold, foreColor, backColor)
223 public void vLineXY(final int x
, final int y
, final int n
,
224 final char ch
, final CellAttributes attr
);
227 * Draw a horizontal line from (x, y) to (x + n, y).
229 * @param x column coordinate. 0 is the left-most column.
230 * @param y row coordinate. 0 is the top-most row.
231 * @param n number of characters to draw
232 * @param ch character to draw
233 * @param attr attributes to use (bold, foreColor, backColor)
235 public void hLineXY(final int x
, final int y
, final int n
,
236 final char ch
, final CellAttributes attr
);
239 * Change the width. Everything on-screen will be destroyed and must be
242 * @param width new screen width
244 public void setWidth(final int width
);
247 * Change the height. Everything on-screen will be destroyed and must be
250 * @param height new screen height
252 public void setHeight(final int height
);
255 * Change the width and height. Everything on-screen will be destroyed
256 * and must be redrawn.
258 * @param width new screen width
259 * @param height new screen height
261 public void setDimensions(final int width
, final int height
);
266 * @return current screen height
268 public int getHeight();
273 * @return current screen width
275 public int getWidth();
278 * Reset screen to not-bold, white-on-black. Also flushes the offset and
284 * Flush the offset and clip variables.
286 public void resetClipping();
289 * Clear the logical screen.
294 * Draw a box with a border and empty background.
296 * @param left left column of box. 0 is the left-most row.
297 * @param top top row of the box. 0 is the top-most row.
298 * @param right right column of box
299 * @param bottom bottom row of the box
300 * @param border attributes to use for the border
301 * @param background attributes to use for the background
303 public void drawBox(final int left
, final int top
,
304 final int right
, final int bottom
,
305 final CellAttributes border
, final CellAttributes background
);
308 * Draw a box with a border and empty background.
310 * @param left left column of box. 0 is the left-most row.
311 * @param top top row of the box. 0 is the top-most row.
312 * @param right right column of box
313 * @param bottom bottom row of the box
314 * @param border attributes to use for the border
315 * @param background attributes to use for the background
316 * @param borderType if 1, draw a single-line border; if 2, draw a
317 * double-line border; if 3, draw double-line top/bottom edges and
318 * single-line left/right edges (like Qmodem)
319 * @param shadow if true, draw a "shadow" on the box
321 public void drawBox(final int left
, final int top
,
322 final int right
, final int bottom
,
323 final CellAttributes border
, final CellAttributes background
,
324 final int borderType
, final boolean shadow
);
329 * @param left left column of box. 0 is the left-most row.
330 * @param top top row of the box. 0 is the top-most row.
331 * @param right right column of box
332 * @param bottom bottom row of the box
334 public void drawBoxShadow(final int left
, final int top
,
335 final int right
, final int bottom
);
338 * Clear the physical screen.
340 public void clearPhysical();
343 * Unset every image cell on one row of the physical screen, forcing
344 * images on that row to be redrawn.
346 * @param y row coordinate. 0 is the top-most row.
348 public void unsetImageRow(final int y
);
351 * Classes must provide an implementation to push the logical screen to
352 * the physical device.
354 public void flushPhysical();
357 * Put the cursor at (x,y).
359 * @param visible if true, the cursor should be visible
360 * @param x column coordinate to put the cursor on
361 * @param y row coordinate to put the cursor on
363 public void putCursor(final boolean visible
, final int x
, final int y
);
368 public void hideCursor();
371 * Get the cursor visibility.
373 * @return true if the cursor is visible
375 public boolean isCursorVisible();
378 * Get the cursor X position.
380 * @return the cursor x column position
382 public int getCursorX();
385 * Get the cursor Y position.
387 * @return the cursor y row position
389 public int getCursorY();
392 * Set the window title.
394 * @param title the new title
396 public void setTitle(final String title
);
399 * Get the width of a character cell in pixels.
401 * @return the width in pixels of a character cell
403 public int getTextWidth();
406 * Get the height of a character cell in pixels.
408 * @return the height in pixels of a character cell
410 public int getTextHeight();