TextGUIElement
Border
, Container
, Interactable
AbstractBasePane.ContentHolder
, AbstractBorder
, AbstractComponent
, AbstractComposite
, AbstractInteractableComponent
, AbstractListBox
, ActionListBox
, AnimatedLabel
, Button
, CheckBox
, CheckBoxList
, ComboBox
, EmptySpace
, GUIBackdrop
, Label
, Panel
, ProgressBar
, RadioBoxList
, ScrollBar
, Separator
, Table
, TextBox
public interface Component extends TextGUIElement
AbstractComponent
or another one of the sub-classes instead to avoid implementing most
of the methods in this interface.Modifier and Type | Method | Description |
---|---|---|
Component |
addTo(Panel panel) |
Same as calling
panel.addComponent(thisComponent) |
BasePane |
getBasePane() |
Returns the BasePane that this container belongs to.
|
LayoutData |
getLayoutData() |
Returns the layout data associated with this component.
|
Container |
getParent() |
Returns the container which is holding this container, or
null if it's not assigned to anything. |
TerminalPosition |
getPosition() |
Returns the top-left corner of this component, measured from its parent.
|
TerminalSize |
getPreferredSize() |
Returns the ideal size this component would like to have, in order to draw itself properly.
|
ComponentRenderer<? extends Component> |
getRenderer() |
Returns the renderer used to draw this component and measure its preferred size.
|
TerminalSize |
getSize() |
Returns how large this component is.
|
TextGUI |
getTextGUI() |
Returns the TextGUI that this component is currently part of.
|
Theme |
getTheme() |
Returns the
Theme this component should be rendered using. |
ThemeDefinition |
getThemeDefinition() |
Returns the
ThemeDefinition defined in the current Theme for this component class. |
boolean |
hasParent(Container parent) |
Returns
true if the supplied Container is either the direct or indirect Parent of this component. |
void |
invalidate() |
Marks the component as invalid and requiring to be re-drawn at next opportunity.
|
boolean |
isInside(Container container) |
Returns true if this component is inside of the specified Container.
|
void |
onAdded(Container container) |
Called by the GUI system when you add a component to a container; DO NOT CALL THIS YOURSELF!
|
void |
onRemoved(Container container) |
Called by the GUI system when you remove a component from a container; DO NOT CALL THIS YOURSELF!
|
Component |
setLayoutData(LayoutData data) |
Sets optional layout data associated with this component.
|
Component |
setPosition(TerminalPosition position) |
This method will be called by the layout manager when it has decided where the component is to be located.
|
Component |
setPreferredSize(TerminalSize explicitPreferredSize) |
Overrides the components preferred size calculation and makes the
getPreferredSize() always return the
value passed in here. |
Component |
setSize(TerminalSize size) |
This method will be called by the layout manager when it has decided how large the component will be.
|
Component |
setTheme(Theme theme) |
Overrides the
Theme this component will use so rather than deriving the theme from either the window or
the GUI system, it will always return this theme. |
TerminalPosition |
toBasePane(TerminalPosition position) |
Translates a position local to the container to the base pane's coordinate space.
|
TerminalPosition |
toGlobal(TerminalPosition position) |
Translates a position local to the container to global coordinate space.
|
Border |
withBorder(Border border) |
Takes a border object and moves this component inside it and then returns it again.
|
draw, isInvalid
TerminalPosition getPosition()
Component setPosition(TerminalPosition position)
position
- Top-left position of the component, relative to its parentTerminalSize getSize()
Component setSize(TerminalSize size)
size
- Current size of the componentTerminalSize getPreferredSize()
Component setPreferredSize(TerminalSize explicitPreferredSize)
getPreferredSize()
always return the
value passed in here. If you call this will null
, it will re-enable the preferred size calculation again.
Please note that using this method on components that are not designed to work with arbitrary sizes make have
unexpected behaviour.explicitPreferredSize
- Preferred size we want to use for this componentComponent setLayoutData(LayoutData data)
data
- Layout data associated with this componentLayoutData getLayoutData()
Container getParent()
null
if it's not assigned to anything.boolean hasParent(Container parent)
true
if the supplied Container is either the direct or indirect Parent of this component.parent
- Container to test if it's the parent or grand-parent of this componenttrue
if the container is either the direct or indirect parent of this component, otherwise false
TextGUI getTextGUI()
Theme getTheme()
Theme
this component should be rendered using. The default implementation through
AbstractComponent
will retrieve this from the Window
the component belongs to, or return the
default theme if the component has not been added to a window yet. You can override the theme this component is
assigned to by calling setTheme(Theme)
.Theme
for this componentThemeDefinition getThemeDefinition()
ThemeDefinition
defined in the current Theme
for this component class. The is the
same as calling:
component.getTheme().getThemeDefinition(ComponentClassType.class); // i.e button.getTheme().getThemeDefinition(Button.class);
ThemeDefinition
defined in the current Theme
for this component classComponent setTheme(Theme theme)
Theme
this component will use so rather than deriving the theme from either the window or
the GUI system, it will always return this theme. If you call this with null
, it remove the override and
the next call to getTheme()
will again try to derive the theme by looking at the window or the GUI
system.theme
- Theme
to assign to this component, or null
to use whatever the window usesboolean isInside(Container container)
getParent()
is not the same instance as container
, but if this
method returns true, you can be sure that this component is not a direct child.container
- Container to test if this component is insidecontainer
ComponentRenderer<? extends Component> getRenderer()
void invalidate()
Border withBorder(Border border)
container.addComponent(new Button("Test").withBorder(Borders.singleLine()));
border
- Border to wrap the component withTerminalPosition toBasePane(TerminalPosition position)
null
.position
- Position to translate (relative to the container's top-left corner)null
if the component is an orphanTerminalPosition toGlobal(TerminalPosition position)
null
.position
- Position to translate (relative to the container's top-left corner)null
if the component is an orphanBasePane getBasePane()
null
if noneComponent addTo(Panel panel)
panel.addComponent(thisComponent)
panel
- Panel to add this component tovoid onAdded(Container container)
container
- Container that this component was just added tovoid onRemoved(Container container)
container
- Container that this component was just removed fromCopyright © 2020. All rights reserved.