Package de.gurkenlabs.litiengine.gui
Class ListField
java.lang.Object
de.gurkenlabs.litiengine.gui.GuiComponent
de.gurkenlabs.litiengine.gui.ListField
- All Implemented Interfaces:
IRenderable
,Tweenable
,java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.awt.event.MouseWheelListener
,java.util.EventListener
public class ListField
extends GuiComponent
The Class ListField.
Field Summary
Constructor Summary
Constructors Constructor Description ListField(double x, double y, double width, double height, java.lang.Object[][] content, int shownRows, int shownColumns)
Creates a 2D vertical list field.ListField(double x, double y, double width, double height, java.lang.Object[] content, int shownRows)
Creates a vertical list field.Method Summary
Modifier and Type Method Description void
deselect()
Resets the ListField's selection tonull
.Spritesheet
getButtonSprite()
java.util.List<java.util.function.IntConsumer>
getChangeConsumer()
java.lang.Object[][]
getContent()
Spritesheet
getEntrySprite()
int
getHorizontalLowerBound()
HorizontalSlider
getHorizontalSlider()
java.util.List<ImageComponent>
getListEntry(int column)
Returns all list items of a specified column.ImageComponent
getListEntry(int column, int row)
Returns item at a specified column and row.int
getMaxRows()
Returns the number of rows of the tallest column.int
getNumberOfShownColumns()
int
getNumberOfShownRows()
ImageComponent
getSelectedComponent()
java.lang.Object
getSelectedObject()
int
getSelectionColumn()
Returns the selected column.int
getSelectionRow()
Returns the selected row.int
getVerticalLowerBound()
VerticalSlider
getVerticalSlider()
boolean
isArrowKeyNavigation()
boolean
isEntireColumnSelected()
boolean
isEntireRowSelected()
boolean
isSliderInside()
Verify if sliders are set to be inside the ListField.void
onChange(java.util.function.IntConsumer c)
void
refresh()
void
render(java.awt.Graphics2D g)
Renders the visual contents of this instance onto the provided graphics context.void
setArrowKeyNavigation(boolean arrowKeyNavigation)
void
setButtonSprite(Spritesheet buttonSprite)
void
setEntrySprite(Spritesheet entrySprite)
void
setForwardMouseEvents(int column, boolean forwardMouseEvents)
void
setHorizontalLowerBound(int lowerBound)
void
setSelectEntireColumn(boolean selectEntireColumn)
If set to true, selecting a element will show a selection of the entire column on which that element is on.void
setSelectEntireRow(boolean selectEntireRow)
If set to true, selecting a element will show a selection of the entire row on which that element is on.void
setSelection(int column, int row)
void
setSliderInside(boolean sliderInside)
If set to true, the sliders of this ListField will be displayed within its boundaries.void
setVerticalLowerBound(int lowerBound)
void
slideDown()
Slides the ListField down by one row.void
slideUp()
Slides the ListField up by one row.Methods inherited from class de.gurkenlabs.litiengine.gui.GuiComponent
drawTextShadow, getAppearance, getAppearanceDisabled, getAppearanceHovered, getBoundingBox, getClickConsumer, getComponentId, getComponents, getCurrentAppearance, getFont, getHeight, getHoverConsumer, getHoverSound, getLocation, getMouseDraggedConsumer, getMouseEnterConsumer, getMouseLeaveConsumer, getMouseMovedConsumer, getMousePressedConsumer, getMouseReleasedConsumer, getMouseWheelConsumer, getName, getShape, getTag, getText, getTextAlign, getTextAngle, getTextShadowColor, getTextShadowStroke, getTextToRender, getTextValign, getTextX, getTextY, getTweenValues, getWidth, getX, getY, hasAutomaticLineBreaks, hasTextAntialiasing, initializeComponents, isEnabled, isForwardMouseEvents, isHovered, isPressed, isSelected, isSuspended, isVisible, mouseClicked, mouseDragged, mouseEntered, mouseEventShouldBeForwarded, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, onClicked, onHovered, onMouseDragged, onMouseEnter, onMouseLeave, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelScrolled, onTextChanged, prepare, setAutomaticLineBreaks, setDimension, setEnabled, setFont, setFontSize, setForwardMouseEvents, setHeight, setHovered, setHoverSound, setLocation, setLocation, setName, setSelected, setTag, setText, setTextAlign, setTextAngle, setTextAntialiasing, setTextShadow, setTextShadowColor, setTextShadowStroke, setTextValign, setTextX, setTextY, setTweenValues, setVisible, setWidth, setX, setY, suspend, toggleSelection, toggleSuspension
Constructor Details
ListField
public ListField(double x, double y, double width, double height, java.lang.Object[] content, int shownRows)Creates a vertical list field.
The content of this list field can only be accessed through the first column (column 0).
Examples:content[0][0] - ok
content[0][1] - ok
content[0][8] - ok
content[1][5] - NOK
content[2][0] - NOK- Parameters:
x
- The x-coordinate of the ListField.y
- The y-coordinate of the ListField.width
- The width of the ListField.height
- The height of the ListField.content
- The 1 dimension array to show in the ListField.shownRows
- The number of rows/elements to display before the user needs to scroll for more possible rows/elements.- See Also:
ListField(double, double, double, double, Object[], int)
ListField
public ListField(double x, double y, double width, double height, java.lang.Object[][] content, int shownRows, int shownColumns)Creates a 2D vertical list field.
The given content should be arranged as columns of elements.
Examples:content[0][0] - column 0, row 0
content[0][1] - column 0, row 1
content[2][8] - column 2, row 8- Parameters:
x
- The x-coordinate of the ListField.y
- The y-coordinate of the ListField.width
- The width of the ListField.height
- The height of the ListField.content
- The 2 dimension array to show in the ListField.shownRows
- The number of rows to display before the user needs to scroll for more possible rows.shownColumns
- The number of columns to display before the user needs to scroll for more possible columns.
Method Details
deselect
public void deselect()Resets the ListField's selection tonull
.
The ListField will then show no selection.getButtonSprite
getChangeConsumer
public java.util.List<java.util.function.IntConsumer> getChangeConsumer()getContent
public java.lang.Object[][] getContent()getEntrySprite
getHorizontalLowerBound
public int getHorizontalLowerBound()getHorizontalSlider
getListEntry
Returns all list items of a specified column.- Parameters:
column
- the column- Returns:
- a list of items
getListEntry
Returns item at a specified column and row.- Parameters:
column
- the columnrow
- the row- Returns:
- ImageComponent at [column,row]
getMaxRows
public int getMaxRows()Returns the number of rows of the tallest column.- Returns:
- int representing the length of the tallest column
getNumberOfShownRows
public int getNumberOfShownRows()getNumberOfShownColumns
public int getNumberOfShownColumns()getSelectedComponent
getSelectedObject
public java.lang.Object getSelectedObject()getSelectionColumn
public int getSelectionColumn()Returns the selected column.- Returns:
- number of the column; -1 if isEntireRowSelected() is true
getSelectionRow
public int getSelectionRow()Returns the selected row.- Returns:
- number of the row
getVerticalLowerBound
public int getVerticalLowerBound()getVerticalSlider
isArrowKeyNavigation
public boolean isArrowKeyNavigation()onChange
public void onChange(java.util.function.IntConsumer c)refresh
public void refresh()render
public void render(java.awt.Graphics2D g)Description copied from interface:IRenderable
Renders the visual contents of this instance onto the provided graphics context.If an
Entity
implements this interface, this method will be called right after the entity was rendered from the environment. Allowing for a custom rendering mechanism.This interface can be implemented in general by anything that should be rendered to the game's screen.
- Specified by:
render
in interfaceIRenderable
- Overrides:
render
in classGuiComponent
- Parameters:
g
- The current graphics object onto which this instance will render its visual contents.- See Also:
RenderEngine.renderEntity(Graphics2D, de.gurkenlabs.litiengine.entities.IEntity)
setArrowKeyNavigation
public void setArrowKeyNavigation(boolean arrowKeyNavigation)setButtonSprite
setEntrySprite
setForwardMouseEvents
public void setForwardMouseEvents(int column, boolean forwardMouseEvents)setHorizontalLowerBound
public void setHorizontalLowerBound(int lowerBound)setSelection
public void setSelection(int column, int row)setSelectEntireColumn
public void setSelectEntireColumn(boolean selectEntireColumn)If set to true, selecting a element will show a selection of the entire column on which that element is on. Without taking account of its row.
Set to false as default.- Parameters:
selectEntireColumn
- a boolean
setSliderInside
public void setSliderInside(boolean sliderInside)If set to true, the sliders of this ListField will be displayed within its boundaries. This is necessary, for example, when a ListField covers an entire screen.
Set to false as default.- Parameters:
sliderInside
- a boolean
setSelectEntireRow
public void setSelectEntireRow(boolean selectEntireRow)If set to true, selecting a element will show a selection of the entire row on which that element is on. Without taking account of its column.
Set to false as default.- Parameters:
selectEntireRow
- a boolean
setVerticalLowerBound
public void setVerticalLowerBound(int lowerBound)isEntireColumnSelected
public boolean isEntireColumnSelected()- Returns:
- true if selection is set to select the entire column; false otherwise
isEntireRowSelected
public boolean isEntireRowSelected()- Returns:
- true if selection is set to select the entire row; false otherwise
isSliderInside
public boolean isSliderInside()Verify if sliders are set to be inside the ListField.- Returns:
- true if slider is set to be inside the ListField; false otherwise
slideUp
public void slideUp()Slides the ListField up by one row.slideDown
public void slideDown()Slides the ListField down by one row.