public class StyledPanel extends Panel implements Element, StyledRenderable
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
StyledPanel()
Creates a styled panel without class selector.
|
Modifier and Type | Method and Description |
---|---|
void |
addClassSelector(java.lang.String classSelector)
Adds a class selector.
|
boolean |
contains(int x,
int y)
Gets whether or not a location (x,y) is in the panel's bounds.
|
java.lang.String |
getAttribute(java.lang.String attribute)
Gets the value of an attribute.
|
Element |
getChild(int index)
Gets the child element at an index.
|
int |
getChildrenCount()
Gets the number of children of this element.
|
Element[] |
getChildrenElements()
Gets the children elements.
|
StyledDesktop |
getDesktop()
Gets the desktop on which the panel is shown.
|
Element |
getParentElement()
Gets the parent element.
|
Style |
getStyle()
Gets the current style of the renderable.
|
boolean |
hasClassSelector(java.lang.String classSelector)
Gets whether or not the element has the given class selector.
|
boolean |
isInState(State state)
Gets whether or not the element is in the given state.
|
boolean |
isTransparent()
Gets whether this panel is transparent or not.
|
void |
mergeStyle(Style style)
Merges a style with the style of this renderable.
|
void |
removeAllClassSelectors()
Removes all the class selectors.
|
void |
removeClassSelector(java.lang.String classSelector)
Removes a class selector.
|
void |
removeInstanceStyle()
Removes the style specific to this renderable.
|
void |
render(GraphicsContext g)
Renders the renderable on the given graphics context.
|
void |
renderContent(GraphicsContext g,
Style style,
Rectangle bounds)
Renders the content of the renderable without the border, margin and padding specified in the style.
|
void |
setClassSelectors(java.lang.String classSelector)
Sets the class selectors.
|
void |
setWidget(Widget widget)
Attach the specified widget to this panel.
|
void |
show(Desktop desktop)
Deprecated.
Use
showAdjustingToChild(Desktop) instead. |
void |
show(Desktop desktop,
boolean fill)
Deprecated.
Use
showAdjustingToChild(Desktop) or showFullScreen(Desktop) instead. |
void |
showAdjustingToChild(Desktop desktop)
Requests the panel to be shown on the specified desktop.
|
void |
showFullScreen(Desktop desktop)
Requests the panel to be shown on the specified desktop.
|
void |
showUsingBounds(Desktop desktop)
Requests the panel to be shown on the specified desktop.
|
protected void |
updateStyle()
Updates the style of the widget.
|
protected boolean |
updateStyleOnly()
Update widget style without repainting it.
|
void |
validate()
Lays out all the hierarchy of this panel.
|
void |
validate(int widthHint,
int heightHint)
Lays out all the hierarchy of this panel.
|
Rectangle |
validateContent(Style style,
Rectangle bounds)
Gets the content size of the renderable without the border, margin and padding specified in the style.
|
becameActive, becameInactive, getEventHandler, getFocus, getHeight, getPreferredHeight, getPreferredWidth, getWidget, getWidgetAt, getWidth, getX, getY, handleEvent, hide, hideNotify, invalidate, isActive, isAdjustedToChild, isPacked, isShown, isValid, repaint, repaint, revalidate, setBounds, setEventHandler, setFocus, setLocation, setPacked, setPreferredSize, setSize, showInternal, showNotify
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEventHandler, getHeight, getWidth, getX, getY, handleEvent, hideNotify, isShown, repaint, repaint, setEventHandler, showNotify
public boolean isTransparent()
Panel
By default, a panel is transparent.
A transparent panel means that it will not repaint ALL the rectangular zone defined by its bounds. Then each time it needs to be repainted, its parent (recursively if also transparent) will be repainted within the bounds of the panel.
Each time a non-transparent panel needs to be repainted, it is the only one to be repainted.
isTransparent
in class Panel
true
if this panel is transparent, false
otherwise.Panel.contains(int, int)
public boolean contains(int x, int y)
Panel
The given location is considered here as a relative location to the desktop.
contains
in class Panel
x
- x coordinate.y
- y coordinate.true
if the (x,y) location is in the panel bounds, false
otherwise.Panel.isTransparent()
public void setWidget(@Nullable Widget widget) throws java.lang.IllegalArgumentException
If there is already a widget on this panel, the former is detached from the latter.
If the specified widget is null
, the panel does not hold a widget anymore.
The panel is also ask to be revalidated if shown.
If the given widget is not an element, an IllegalArgumentException
is thrown.
setWidget
in class Panel
widget
- the widget to set.java.lang.IllegalArgumentException
- if the given widget is not an element.Element
,
StyledWidget
,
StyledComposite
@Deprecated public void show(@Nullable Desktop desktop) throws java.lang.NullPointerException
showAdjustingToChild(Desktop)
instead.
Identical to calling Panel.show(Desktop, boolean)
without filling the desktop.
If the given desktop is not a styled desktop, an IllegalArgumentException
is thrown.
show
in class Panel
desktop
- the desktopjava.lang.IllegalArgumentException
- if the given desktop is not an element.java.lang.NullPointerException
- if desktop
is null
.StyledDesktop
@Deprecated public void show(@Nullable Desktop desktop, boolean fill) throws java.lang.NullPointerException
showAdjustingToChild(Desktop)
or showFullScreen(Desktop)
instead.
If fill
is true
, it is fitted to desktop size and it will be declared as not be packed.
If fill
is false
and no size has been set, it will be declared as packed.
If the desktop is shown, the panel is automatically validated.
The panel is added to the list of panels known by the desktop.
Special cases:
If the given desktop is not a styled desktop, an IllegalArgumentException
is thrown.
show
in class Panel
desktop
- the desktop.fill
- true
to fit the panel to the desktop size, false
otherwise.java.lang.IllegalArgumentException
- if the given desktop is not an element.java.lang.NullPointerException
- if desktop
is null
.StyledDesktop
public void showFullScreen(@Nullable Desktop desktop) throws java.lang.NullPointerException
The panel is fitted to desktop size.
If the desktop is shown, the panel is automatically validated.
The panel is added to the list of panels known by the desktop.
If the panel is already shown on another desktop, it is hidden on this desktop before being shown on the new
If the given desktop is not a styled desktop, an IllegalArgumentException
is thrown.
showFullScreen
in class Panel
desktop
- the desktopjava.lang.IllegalArgumentException
- if the given desktop is not an element.java.lang.NullPointerException
- if the given desktop is null
.StyledDesktop
public void showAdjustingToChild(@Nullable Desktop desktop) throws java.lang.NullPointerException
The panel is fitted to its child widget size. Its location is set according to its style alignment.
If the desktop is shown, the panel is automatically validated.
The panel is added to the list of panels known by the desktop.
If the panel is already shown on another desktop, it is hidden on this desktop before being shown on the new
If the given desktop is not a styled desktop, an IllegalArgumentException
is thrown.
showAdjustingToChild
in class Panel
desktop
- the desktopjava.lang.NullPointerException
- if the given desktop is null
.java.lang.IllegalArgumentException
- if the given desktop is not an element.StyledDesktop
,
Style.getAlignment()
,
Panel.hide()
,
Panel.isShown()
,
Panel.revalidate()
public void showUsingBounds(@Nullable Desktop desktop) throws java.lang.NullPointerException
The bounds of the panel remains unchanged and must be set with Panel.setBounds(int, int, int, int)
before.
If the desktop is shown, the panel is automatically validated.
The panel is added to the list of panels known by the desktop.
If the panel is already shown on another desktop, it is hidden on this desktop before being shown on the new
If the given desktop is not a styled desktop, an IllegalArgumentException
is thrown.
showUsingBounds
in class Panel
desktop
- the desktopjava.lang.IllegalArgumentException
- if the given desktop is not an element.java.lang.NullPointerException
- if the given desktop is null
.StyledDesktop
@Nullable public StyledDesktop getDesktop()
Panel
null
if the panel is not shown.getDesktop
in class Panel
null
.Panel.isShown()
@Nullable public Element getParentElement()
Element
getParentElement
in interface Element
public Element[] getChildrenElements()
Element
Returns an empty array if no children.
getChildrenElements
in interface Element
Element.EMPTY_ELEMENT_ARRAY
public Element getChild(int index)
Element
public int getChildrenCount()
Element
getChildrenCount
in interface Element
public void mergeStyle(Style style)
StyledRenderable
Equivalent to StyleHelper.getStylesheet().addRule(new InstanceSelector(renderable), style);
mergeStyle
in interface StyledRenderable
style
- the style to merge.StyledRenderable.removeInstanceStyle()
,
InstanceSelector
public void removeInstanceStyle()
StyledRenderable
Equivalent to StyleHelper.getStylesheet().removeRule(new InstanceSelector(renderable));
removeInstanceStyle
in interface StyledRenderable
StyledRenderable.mergeStyle(Style)
,
InstanceSelector
public Style getStyle()
StyledRenderable
The style is retrieved from the global stylesheet: StyleHelper.getStylesheet().getStyle(renderable);
getStyle
in interface StyledRenderable
Stylesheet.getStyle(ej.style.Element)
protected void updateStyle()
protected boolean updateStyleOnly()
true
if the style has been updated, false
otherwise.public void render(GraphicsContext g)
Renderable
render
in interface Renderable
render
in class Panel
g
- the graphics context to be used to draw the renderable.public void renderContent(GraphicsContext g, Style style, Rectangle bounds)
StyledRenderable
The given graphics context is translated and clipped according to the given bounds (the border, margin and padding are applied on this graphics context before).
renderContent
in interface StyledRenderable
g
- the graphics context where to render the content of the renderable.style
- the style to use.bounds
- the remaining size to render the content.Outline.apply(GraphicsContext, Rectangle)
,
Border.apply(GraphicsContext, Rectangle, int)
,
StyleHelper.renderWithoutContent(GraphicsContext, Rectangle, Style)
public void validate()
Panel
Nothing is done if the panel is already valid.
The panel is repainted if it is shown on a desktop.
If the panel is declared as packed, it is resized to the preferred size of its widgets, otherwise its widgets fill its size.
validate
in class Panel
Panel.isPacked()
,
Panel.isValid()
public void validate(int widthHint, int heightHint)
Panel
After this call the preferred size will have been established. The parameters defines the maximum size available
for this panel, or MWT.NONE
if there is no constraint.
public Rectangle validateContent(Style style, Rectangle bounds)
StyledRenderable
validateContent
in interface StyledRenderable
style
- the style to use.bounds
- the bounds available for the content. A width or a height equals to MWT.NONE
means no
constraint on this dimension.public boolean hasClassSelector(java.lang.String classSelector)
Element
hasClassSelector
in interface Element
classSelector
- the class selector to check.true
if the element has the given class selector, false
otherwise.public void addClassSelector(java.lang.String classSelector)
StyledRenderable
addClassSelector
in interface StyledRenderable
classSelector
- the class selector to add.public void removeClassSelector(java.lang.String classSelector)
StyledRenderable
removeClassSelector
in interface StyledRenderable
classSelector
- the class selector to remove.public void setClassSelectors(java.lang.String classSelector)
StyledRenderable
The given string is a space separated list of class selectors.
If there is already some class selectors, they are removed.
setClassSelectors
in interface StyledRenderable
classSelector
- the class selectors list to split.public void removeAllClassSelectors()
StyledRenderable
removeAllClassSelectors
in interface StyledRenderable
public boolean isInState(State state)
Element
@Nullable public java.lang.String getAttribute(java.lang.String attribute)
Element
getAttribute
in interface Element
attribute
- the attribute to search.null
if the attribute does not exist.