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 or an animated image on screen.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTImage.ScaleSelections 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.TImage(TWidget parent, int x, int y, int width, int height, Animation animation, int left, int top)Public constructor.TImage(TWidget parent, int x, int y, int width, int height, Animation animation, int left, int top, TAction clickAction)Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Stop the animation on close.voiddraw()Draw the image.intgetColumns()Get the number of text cell columns for this image.java.awt.image.BufferedImagegetImage()Get the raw (unprocessed) image.intgetLeft()Get the left corner to render.intgetRotation()Get the rotation, as degrees.intgetRows()Get the number of text cell rows for this image.doublegetScaleFactor()Get the scale factor.TImage.ScalegetScaleType()Get the scaling strategy.intgetTop()Get the top corner to render.java.awt.image.BufferedImagegetVisibleImage()Get the visible (processed) image.booleanisAntiAlias()Get anti-aliasing value.booleanisEditMenuClear()Check if the clear menu item should be enabled.booleanisEditMenuCopy()Check if the copy menu item should be enabled.booleanisEditMenuCut()Check if the cut menu item should be enabled.booleanisEditMenuPaste()Check if the paste menu item should be enabled.voidonCommand(TCommandEvent command)Handle posted command events.voidonKeypress(TKeypressEvent keypress)Handle keystrokes.voidonMouseDown(TMouseEvent mouse)Handle mouse press events.voidonResize(TResizeEvent event)Handle resize events.voidsetAnimation(Animation animation)Set the image space to an animation, and reprocess to make the visible image.voidsetAntiAlias(boolean antiAlias)Set anti-aliasing.voidsetImage(java.awt.image.BufferedImage image)Set the raw image, and reprocess to make the visible image.voidsetImage(java.awt.image.BufferedImage image, boolean maybeTransparent)Set the raw image, and reprocess to make the visible image.voidsetLeft(int left)Set the left corner to render.voidsetRotation(int rotation)Set the rotation, as degrees clockwise.voidsetScaleFactor(double scaleFactor)Set the scale factor.voidsetScaleType(TImage.Scale scale)Set the scaling strategy.voidsetTop(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, 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, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, drawChildren, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getClipboard, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getCustomMousePointer, getHeight, getLayoutManager, getLocale, getMouseStyle, getParent, getScreen, getTheme, getWidgetUnderMouse, getWidth, getWindow, getX, getY, handleEvent, hasChild, hLineXY, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEchoKeystrokes, isEnabled, isPixelMouse, 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, setCustomMousePointer, setDimensions, setEchoKeystrokes, setEchoKeystrokes, setEnabled, setHeight, setLayoutManager, setLocale, setMouseStyle, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY, 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
-
TImage
public TImage(TWidget parent, int x, int y, int width, int height, Animation animation, 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 imageanimation- the animation 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, Animation animation, 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 imageanimation- the animation 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:
onMouseDownin classTWidget- Parameters:
mouse- mouse button press event
-
onKeypress
public void onKeypress(TKeypressEvent keypress)
Handle keystrokes.- Overrides:
onKeypressin classTWidget- Parameters:
keypress- keystroke event
-
onResize
public void onResize(TResizeEvent event)
Handle resize events.
-
onCommand
public void onCommand(TCommandEvent command)
Handle posted command events.
-
isAntiAlias
public boolean isAntiAlias()
Get anti-aliasing value.- Returns:
- true if anti-aliasing is enabled
-
setAntiAlias
public void setAntiAlias(boolean antiAlias)
Set anti-aliasing.- Parameters:
antiAlias- if true, anti-aliasing will be enabled
-
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
-
setImage
public void setImage(java.awt.image.BufferedImage image, boolean maybeTransparent)Set the raw image, and reprocess to make the visible image.- Parameters:
image- the new imagemaybeTransparent- if false, the image is fully opaque
-
setAnimation
public void setAnimation(Animation animation)
Set the image space to an animation, and reprocess to make the visible image.- Parameters:
animation- the new animation
-
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:
isEditMenuCutin 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:
isEditMenuCopyin 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:
isEditMenuPastein 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:
isEditMenuClearin interfaceEditMenuUser- Returns:
- true if the clear menu item should be enabled
-
-