Package jexer
Class TImage
- java.lang.Object
-
- jexer.TWidget
-
- jexer.TImage
-
- All Implemented Interfaces:
java.lang.Comparable<TWidget>
,EditMenuUser
public class TImage extends TWidget implements EditMenuUser
TImage renders a piece of a bitmap image on screen.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TImage.Scale
Selections for fitting the image to the text cells.
-
Constructor Summary
Constructors Constructor Description TImage(TWidget parent, int x, int y, int width, int height, java.awt.image.BufferedImage image, int left, int top)
Public constructor.TImage(TWidget parent, int x, int y, int width, int height, java.awt.image.BufferedImage image, int left, int top, TAction clickAction)
Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
draw()
Draw the image.int
getColumns()
Get the number of text cell columns for this image.java.awt.image.BufferedImage
getImage()
Get the raw (unprocessed) image.int
getLeft()
Get the left corner to render.int
getRotation()
Get the rotation, as degrees.int
getRows()
Get the number of text cell rows for this image.double
getScaleFactor()
Get the scale factor.TImage.Scale
getScaleType()
Get the scaling strategy.int
getTop()
Get the top corner to render.java.awt.image.BufferedImage
getVisibleImage()
Get the visible (processed) image.boolean
isEditMenuClear()
Check if the clear menu item should be enabled.boolean
isEditMenuCopy()
Check if the copy menu item should be enabled.boolean
isEditMenuCut()
Check if the cut menu item should be enabled.boolean
isEditMenuPaste()
Check if the paste menu item should be enabled.void
onCommand(TCommandEvent command)
Handle posted command events.void
onKeypress(TKeypressEvent keypress)
Handle keystrokes.void
onMouseDown(TMouseEvent mouse)
Handle mouse press events.void
onResize(TResizeEvent event)
Handle resize events.void
setImage(java.awt.image.BufferedImage image)
Set the raw image, and reprocess to make the visible image.void
setLeft(int left)
Set the left corner to render.void
setRotation(int rotation)
Set the rotation, as degrees clockwise.void
setScaleFactor(double scaleFactor)
Set the scale factor.void
setScaleType(TImage.Scale scale)
Set the scaling strategy.void
setTop(int top)
Set the top corner to render.-
Methods inherited from class jexer.TWidget
activate, activate, activate, activateAll, addButton, addCalendar, addCheckBox, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addField, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, close, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getHeight, getLayoutManager, getParent, getScreen, getTheme, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onIdle, onMenu, onMouseDoubleClick, onMouseMotion, onMouseUp, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY
-
-
-
-
Constructor Detail
-
TImage
public TImage(TWidget parent, int x, int y, int width, int height, java.awt.image.BufferedImage image, int left, int top)
Public constructor.- Parameters:
parent
- parent widgetx
- column relative to parenty
- row relative to parentwidth
- number of text cells for width of the imageheight
- number of text cells for height of the imageimage
- the image to displayleft
- left column of the image. 0 is the left-most column.top
- top row of the image. 0 is the top-most row.
-
TImage
public TImage(TWidget parent, int x, int y, int width, int height, java.awt.image.BufferedImage image, int left, int top, TAction clickAction)
Public constructor.- Parameters:
parent
- parent widgetx
- column relative to parenty
- row relative to parentwidth
- number of text cells for width of the imageheight
- number of text cells for height of the imageimage
- the image to displayleft
- left column of the image. 0 is the left-most column.top
- top row of the image. 0 is the top-most row.clickAction
- function to call when mouse is pressed
-
-
Method Detail
-
onMouseDown
public void onMouseDown(TMouseEvent mouse)
Handle mouse press events.- Overrides:
onMouseDown
in classTWidget
- Parameters:
mouse
- mouse button press event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypress
in classTWidget
- Parameters:
keypress
- keystroke event
-
onResize
public void onResize(TResizeEvent event)
Handle resize events.
-
onCommand
public void onCommand(TCommandEvent command)
Handle posted command events.
-
getTop
public int getTop()
Get the top corner to render.- Returns:
- the top row
-
setTop
public void setTop(int top)
Set the top corner to render.- Parameters:
top
- the new top row
-
getLeft
public int getLeft()
Get the left corner to render.- Returns:
- the left column
-
setLeft
public void setLeft(int left)
Set the left corner to render.- Parameters:
left
- the new left column
-
getRows
public int getRows()
Get the number of text cell rows for this image.- Returns:
- the number of rows
-
getColumns
public int getColumns()
Get the number of text cell columns for this image.- Returns:
- the number of columns
-
getImage
public java.awt.image.BufferedImage getImage()
Get the raw (unprocessed) image.- Returns:
- the image
-
setImage
public void setImage(java.awt.image.BufferedImage image)
Set the raw image, and reprocess to make the visible image.- Parameters:
image
- the new image
-
getVisibleImage
public java.awt.image.BufferedImage getVisibleImage()
Get the visible (processed) image.- Returns:
- the image that is currently on screen
-
getScaleType
public TImage.Scale getScaleType()
Get the scaling strategy.- Returns:
- Scale.NONE, Scale.STRETCH, etc.
-
setScaleType
public void setScaleType(TImage.Scale scale)
Set the scaling strategy.- Parameters:
scale
- Scale.NONE, Scale.STRETCH, etc.
-
getScaleFactor
public double getScaleFactor()
Get the scale factor.- Returns:
- the scale factor
-
setScaleFactor
public void setScaleFactor(double scaleFactor)
Set the scale factor. 1.0 means no scaling.- Parameters:
scaleFactor
- the new scale factor
-
getRotation
public int getRotation()
Get the rotation, as degrees.- Returns:
- the rotation in degrees
-
setRotation
public void setRotation(int rotation)
Set the rotation, as degrees clockwise.- Parameters:
rotation
- 0, 90, 180, or 270
-
isEditMenuCut
public boolean isEditMenuCut()
Check if the cut menu item should be enabled.- Specified by:
isEditMenuCut
in interfaceEditMenuUser
- Returns:
- true if the cut menu item should be enabled
-
isEditMenuCopy
public boolean isEditMenuCopy()
Check if the copy menu item should be enabled.- Specified by:
isEditMenuCopy
in interfaceEditMenuUser
- Returns:
- true if the copy menu item should be enabled
-
isEditMenuPaste
public boolean isEditMenuPaste()
Check if the paste menu item should be enabled.- Specified by:
isEditMenuPaste
in interfaceEditMenuUser
- Returns:
- true if the paste menu item should be enabled
-
isEditMenuClear
public boolean isEditMenuClear()
Check if the clear menu item should be enabled.- Specified by:
isEditMenuClear
in interfaceEditMenuUser
- Returns:
- true if the clear menu item should be enabled
-
-