Class Card
Card invoice = new Card(new Label("Three items, due on Friday.").setWrap(true))
.setTitle("Harbor Lane Supplies")
.setSubtitle("Invoice 1042")
.setHeaderSuffix(new Label("$1,240.00").setStrong(true))
.setFooter(new Button("Approve"));
Looks. Card.Style.ELEVATED, the default, lifts the card by the theme's
Elevation.RAISED shadow, with a hairline round it on a dark palette, where a shadow on a
dark ground does not show; Card.Style.OUTLINED draws a line round it and no shadow;
Card.Style.FILLED sets it apart by tone alone; Card.Style.PLAIN draws nothing of its own,
and its parts stand on the page. Card.Orientation.HORIZONTAL puts the media
in a column at the leading side, beside the header and the content, with the footer across the
whole card under both. The media is laid out as Card.MediaFit says, and may be an
Icon, which the card draws itself, tinted with the accent when it is tintable.
Height. Given more height than it measures, as cards side by side in a row are, the card gives the extra to its content and keeps its footer at the bottom, so footers line up.
A card that is clicked. With onActivate(Runnable) the card is activated by a
click anywhere outside its footer, and by Enter or Space while it holds the keyboard; the
footer's actions are clicked as the buttons they are, and a press in the footer between them
does nothing. A card with no footer is one click as a whole. The part of the card that is
clicked takes the keyboard as one stop, shows the pointer's hover and press over itself alone,
and is drawn apart from the footer by a line. It holds no control of its own: a widget that takes
the keyboard (a button, a field, a check box) is refused in the media, the header and the
content of a card that is activated, with an IllegalArgumentException from the setter or
from onActivate; one that arrives later, inside a content the application changes, is
logged once and answers nothing, and every press and key there stays the card's. Moved to the
footer, taken out of the card, or left in a card that is no longer clicked, it answers again as
it did, and the card keeps no hold on it. Actions go in the footer. A card that is not activated
takes any widget in any part.
To a reader. A card with a title is a group named by its title, whose title is a
heading; a card with none is transparent, as a Surface is, so a chart in a card is the
chart. A card that is activated is a button named by its title and described by its subtitle,
and what else is inside the part that is clicked is not read: a fact a reader needs from the
content (an amount, a state) is said with Widget.setAccessibleDescription(String) on the card,
which lands on that button, as Widget.setAccessibleName(String) does. With a footer, the
button and the footer's actions are held in a group named by the title. An activated card with
no title has no name unless the application gives it one.
Reading right to left the header's leading part, the horizontal media column and the rounded corners of a covering picture are on the right, and the footer's actions sit at the left.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow the media is laid out.static enumWhere the media goes.static enumHow the card is set apart from what is around it. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Widget<?> The area carries a caption bound to an activated card, and its name and description.Takes the media away, assetMedia(null)would: that call does not compile, becausenullfits more than one of the overloads.Takes the subtitle away, assetSubtitle(null)would: that call does not compile, becausenullfits more than one of the overloads.Takes the title away, assetTitle(null)would: that call does not compile, becausenullfits more than one of the overloads.@Nullable Widget<?> content()footer()protected voidhandleUserChange(Change.Aspect aspect) Runs this widget's application handler for a change it has just announced.@Nullable Widget<?> @Nullable Widget<?> boolean@Nullable Widget<?> media()floatmediaFit()@Nullable Iconprotected voidA group named by the title, when there is a title and the card is not activated, or when it is activated and has a footer, whose actions the group holds beside the area's button; and nothing otherwise, the card's node being its area's button or none.onActivate(@Nullable Runnable handler) Makes the card activated by a click outside its footer, by Enter or Space while it holds the keyboard, and by a reader's press;nullmakes it a plain card again.protected voidonLayout()Containers position children here (measure +Widget.layoutBox(float, float, float, float)per child).protected SizeonMeasure(Constraints constraints) Reports the size this widget wants withinconstraints.protected voidWidget's own background/content, in local coordinates.protected voidonPaintOverlay(Canvas canvas) The edge, over a picture that covers the card, and the line above an activated card's footer.protected floatHow far beyond this widget's bounds its painting may reach, in logical points: its own painting and any descendant no ancestor clips (a drop shadow, a glow, a child positioned outside the parent's box).protected booleanThe fill and the shadow are background to the parts, and say nothing of themselves: a card with no title and no handler is not in the accessible tree.setContent(@Nullable Widget<?> newContent) Sets what the card holds under its header: one widget, a column for several.Sets the footer's actions, which sit at the card's trailing edge and wrap to another line on a narrow card; the ones it had go back to the application.setHeaderPrefix(@Nullable Widget<?> newPrefix) Sets the part before the title, spanning its two lines: an avatar, an icon.setHeaderSuffix(@Nullable Widget<?> newSuffix) Sets the part after the title, spanning its two lines: a badge, an amount.Sets an icon as the media, drawn by the card as authored.setMedia(@Nullable Icon icon, Icon.Mirroring mirroring) Sets an icon as the media, saying whether its drawing turns around when the card reads right to left.Sets the media: a picture, a video, an avatar, any widget.setMediaAspectRatio(float widthOverHeight) Sets the media's width over its height where it stretches across a vertical card (Card.MediaFit.STRETCHandCard.MediaFit.COVER); 16 to 9 by default.setMediaFit(Card.MediaFit fit) Sets how the media is laid out (defaultCard.MediaFit.NATURAL).setOrientation(Card.Orientation newOrientation) Sets where the media goes (defaultCard.Orientation.VERTICAL).setStyle(Card.Style newStyle) Sets how the card is set apart (defaultCard.Style.ELEVATED).setSubtitle(@Nullable String newSubtitle) Sets a fixed subtitle: one line, or as many assetSubtitleLines(int)allows, muted, under the title.setSubtitle(@Nullable I18nString newSubtitle) Sets a subtitle that follows the UI language.setSubtitleLines(int lines) Lets the subtitle break across up tolineslines, assetTitleLines(int)does the title; 1, the default, keeps it on one line.Sets a fixed title: one line, or as many assetTitleLines(int)allows, strong, ending with an ellipsis where it does not fit.setTitle(@Nullable I18nString newTitle) Sets a title that follows the UI language.setTitleLines(int lines) Lets the title break across up tolineslines, the last ending with an ellipsis when more of it remains; 1, the default, keeps it on one line.style()@Nullable Stringsubtitle()int@Nullable Stringtitle()intMethods inherited from class limn.scene.Widget
acceptsTextInput, accessibleLabelAccessKey, accessibleLabelText, add, add, announceChange, backdropReach, baselineOffset, baselineOffsetOf, caretRect, children, clipboard, clipHeight, clipsChildren, clipWidth, clipX, clipY, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedBackward, focusArrivedByTraversal, height, hitTest, hitTestChild, id, imageCursor, inheritanceHost, invalidate, invalidate, invalidateAccessible, isEnabled, isFocusable, isFocused, isRightToLeft, isSelfEnabled, isShowing, isVisible, isVisibleByItsOwnFlag, layoutBox, layoutDirection, locale, localToScene, localToSceneBounds, markNeedsContainedLayout, markNeedsLayout, markNeedsLayoutInPlace, maxHeight, maxWidth, measure, minHeight, minWidth, moveChild, moveChild, moveChild, neutralBase, notifyChange, notifyTextEdit, observeChanges, onAccessibilityAction, onAccessibilityChild, onAccessibilityChildAction, onAccessibilityChildIdentity, onAttached, onCanEdit, onCharTyped, onDetached, onDragExit, onDragOver, onDragStart, onDrop, onEdit, onFocusGained, onFocusLost, onHitTest, onKeyEvent, onMouseEvent, onPreedit, onSyntheticAction, overlayPassesPointer, paintChildren, paintsFromBackdrop, paintWidget, parent, remove, remove, requestFocus, requestFocus, revealInView, revealInView, runHandler, scene, sceneNanos, sceneToLocal, self, setAccessibleDescribedBy, setAccessibleDescription, setAccessibleDescription, setAccessibleIgnored, setAccessibleLabelledBy, setAccessibleName, setAccessibleName, setAccessibleRole, setControlSize, setCursor, setEnabled, setFocusable, setId, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setPresentedElsewhere, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, tooltipSource, width, x, y
-
Constructor Details
-
Card
public Card()An empty card; every part is set afterwards. -
Card
A card holdingcontent, every other part unset.- Parameters:
content- what the card holds
-
-
Method Details
-
setMedia
Sets the media: a picture, a video, an avatar, any widget. It is laid out in the boxCard.MediaFitgives it and told nothing else, so anImageViewthat should crop is givenImageView.Fit.COVERby the caller.nulltakes it away, and so does an icon set in its place. UI thread only.- Parameters:
newMedia- the media, ornull- Returns:
- this card
- Throws:
IllegalArgumentException- whennewMediais already in another container or holds this card, or when the card is activated and it takes the keyboard or holds a widget that does; the card is then left as it was
-
setMedia
Sets an icon as the media, drawn by the card as authored. A tintable icon is drawn in the accent. The icon is decoration to a reader, as a button's is. UI thread only.- Parameters:
icon- the icon, ornullto take the media away- Returns:
- this card
-
setMedia
Sets an icon as the media, saying whether its drawing turns around when the card reads right to left. UI thread only.- Parameters:
icon- the icon, ornullto take the media awaymirroring-Icon.Mirroring.NEVERunless the glyph means a direction- Returns:
- this card
-
clearMedia
Takes the media away, assetMedia(null)would: that call does not compile, becausenullfits more than one of the overloads.- Returns:
- this card
-
media
- Returns:
- the media widget, or
nullwhen there is none or the media is an icon
-
mediaIcon
- Returns:
- the icon drawn as the media, or
null
-
setHeaderPrefix
Sets the part before the title, spanning its two lines: an avatar, an icon. UI thread only.- Parameters:
newPrefix- the part, ornullto take it away- Returns:
- this card
- Throws:
IllegalArgumentException- when the part is already in another container or holds this card, or when the card is activated and it takes the keyboard or holds a widget that does; the card is then left as it was
-
headerPrefix
- Returns:
- the part before the title, or
null
-
setTitle
Sets a fixed title: one line, or as many assetTitleLines(int)allows, strong, ending with an ellipsis where it does not fit.- Parameters:
newTitle- the title, ornullto take it away- Returns:
- this card
-
setTitle
Sets a title that follows the UI language. It names the card to a reader. UI thread only.- Parameters:
newTitle- the title, ornullto take it away- Returns:
- this card
-
clearTitle
Takes the title away, assetTitle(null)would: that call does not compile, becausenullfits more than one of the overloads.- Returns:
- this card
-
title
- Returns:
- the title, resolved in this card's own language, or
null
-
setSubtitle
Sets a fixed subtitle: one line, or as many assetSubtitleLines(int)allows, muted, under the title.- Parameters:
newSubtitle- the subtitle, ornullto take it away- Returns:
- this card
-
setSubtitle
Sets a subtitle that follows the UI language. Without a title it is drawn where the title would be, muted, and names nothing. An activated card's subtitle is its description to a reader. UI thread only.- Parameters:
newSubtitle- the subtitle, ornullto take it away- Returns:
- this card
-
clearSubtitle
Takes the subtitle away, assetSubtitle(null)would: that call does not compile, becausenullfits more than one of the overloads.- Returns:
- this card
-
subtitle
- Returns:
- the subtitle, resolved in this card's own language, or
null
-
setTitleLines
Lets the title break across up tolineslines, the last ending with an ellipsis when more of it remains; 1, the default, keeps it on one line. A long name then reads whole on a narrow card instead of being cut after a few letters. The header grows to the lines the title takes, and a reader still hears the whole title. UI thread only.- Parameters:
lines- the most lines, 1 or more- Returns:
- this card
- Throws:
IllegalArgumentException- whenlinesis below 1
-
titleLines
public int titleLines()- Returns:
- the most lines the title breaks across; see
setTitleLines(int)
-
setSubtitleLines
Lets the subtitle break across up tolineslines, assetTitleLines(int)does the title; 1, the default, keeps it on one line. UI thread only.- Parameters:
lines- the most lines, 1 or more- Returns:
- this card
- Throws:
IllegalArgumentException- whenlinesis below 1
-
subtitleLines
public int subtitleLines()- Returns:
- the most lines the subtitle breaks across; see
setSubtitleLines(int)
-
setHeaderSuffix
Sets the part after the title, spanning its two lines: a badge, an amount. UI thread only.- Parameters:
newSuffix- the part, ornullto take it away- Returns:
- this card
- Throws:
IllegalArgumentException- when the part is already in another container or holds this card, or when the card is activated and it takes the keyboard or holds a widget that does; the card is then left as it was
-
headerSuffix
- Returns:
- the part after the title, or
null
-
setContent
Sets what the card holds under its header: one widget, a column for several. It takes the height the card is given beyond what it measures. UI thread only.- Parameters:
newContent- the content, ornullto take it away- Returns:
- this card
- Throws:
IllegalArgumentException- when the content is already in another container or holds this card, or when the card is activated and it takes the keyboard or holds a widget that does; the card is then left as it was
-
content
- Returns:
- the content, or
null
-
setStyle
Sets how the card is set apart (defaultCard.Style.ELEVATED). UI thread only.- Parameters:
newStyle- the style- Returns:
- this card
-
style
- Returns:
- how the card is set apart
-
setOrientation
Sets where the media goes (defaultCard.Orientation.VERTICAL). UI thread only.- Parameters:
newOrientation- the orientation- Returns:
- this card
-
orientation
- Returns:
- where the media goes
-
setMediaFit
Sets how the media is laid out (defaultCard.MediaFit.NATURAL). UI thread only.- Parameters:
fit- the fit- Returns:
- this card
-
mediaFit
- Returns:
- how the media is laid out
-
setMediaAspectRatio
Sets the media's width over its height where it stretches across a vertical card (Card.MediaFit.STRETCHandCard.MediaFit.COVER); 16 to 9 by default. UI thread only.- Parameters:
widthOverHeight- the ratio, above zero- Returns:
- this card
- Throws:
IllegalArgumentException- when not above zero or not finite
-
mediaAspectRatio
public float mediaAspectRatio()- Returns:
- the media's width over its height where it stretches across a vertical card
-
onActivate
Makes the card activated by a click outside its footer, by Enter or Space while it holds the keyboard, and by a reader's press;nullmakes it a plain card again. A press is announced to the watchers asINVOKEDfirst. Not called while the card is disabled. UI thread only.- Parameters:
handler- the handler, ornullto clear the slot- Returns:
- this card
- Throws:
IllegalStateException- if a handler is already registeredIllegalArgumentException- when the media, the header or the content holds a widget that takes the keyboard
-
isActivatable
public boolean isActivatable()- Returns:
- whether the card is activated by a click: whether
onActivate(java.lang.Runnable)holds a handler
-
handleUserChange
Description copied from class:WidgetRuns this widget's application handler for a change it has just announced. Called byWidget.runHandler(limn.scene.Change), and so byWidget.notifyChange(limn.scene.Change), only for aUSERorigin and after every watcher has run.A component overrides it once and switches on the aspect, reading its own accessors for the payload: a slider passes
value(), a combo boxselectedIndex(), a text fieldtext(). A component with no handler does not override it.An override that does not recognise the aspect must call
super, because a subclass of a component that has a handler inherits that component's dispatch through this method: aSearchFieldthat overrode this for its own aspect and did not chain would silently deleteTextField's. The ordering lives in the base class, this is the one link in it a subclass can break, and the contract test drives every subclass through its parent's gestures to catch one that does.- Overrides:
handleUserChangein classWidget<Card>- Parameters:
aspect- what changed; the origin isUSERor this is not called
-
onMeasure
Description copied from class:WidgetReports the size this widget wants withinconstraints. Called once per layout pass, and the result is cached against the constraints and the resolved axes (size step, layout direction, locale), so it must be a pure function of them and of this widget's own state.Resolve the
ControlSizeand theLayoutDirectiononce each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, andI18n.locale()answers it wherever text is resolved. -
onLayout
protected void onLayout()Description copied from class:WidgetContainers position children here (measure +Widget.layoutBox(float, float, float, float)per child). -
paintOutset
protected float paintOutset()Description copied from class:WidgetHow far beyond this widget's bounds its painting may reach, in logical points: its own painting and any descendant no ancestor clips (a drop shadow, a glow, a child positioned outside the parent's box). Partial rendering uses it both ways:Widget.invalidate()damage grows by it, and a repaint pass skips this subtree only when bounds + outset miss the pass region; painting farther than declared leaves stale pixels.The work is divided by who knows the number. A widget declares what it paints itself outside its box:
Label's icon overhang, the focus ringButton,CheckboxandRadioButtondraw outside theirs. A widget that lays out children and does not clip them declares how far they may paint past it, because a ring on a child at its edge hangs past it too, and a pass landing only in that band would otherwise skip it and never reach the child. Every layout the toolkit ships does that by default with the reach the theme gives a focus ring, and takes another number through its publicpaintOverflow, which sets what this hook answers; a layout an application writes inherits both by extendinglimn.scene.layout.Container, and one that extends this class directly overrides this hook itself. A widget that clips its children declares only its own painting, since the clip bounds theirs.Asked of every widget a repaint pass considers, and on every
invalidate(), so an override answers in constant time without allocating: a number held or looked up, never a walk over the children. Default0: everything stays inside the bounds, which is true for most leaves.- Overrides:
paintOutsetin classWidget<Card>
-
paintsDecoration
protected boolean paintsDecoration()The fill and the shadow are background to the parts, and say nothing of themselves: a card with no title and no handler is not in the accessible tree.- Overrides:
paintsDecorationin classWidget<Card>- Returns:
true, always
-
onPaint
Description copied from class:WidgetWidget's own background/content, in local coordinates. -
onPaintOverlay
The edge, over a picture that covers the card, and the line above an activated card's footer.- Overrides:
onPaintOverlayin classWidget<Card>
-
onAccessibility
A group named by the title, when there is a title and the card is not activated, or when it is activated and has a footer, whose actions the group holds beside the area's button; and nothing otherwise, the card's node being its area's button or none.- Overrides:
onAccessibilityin classWidget<Card>- Parameters:
a- the node being described; write into it, and never keep it
-
accessibleLabelTarget
The area carries a caption bound to an activated card, and its name and description.- Overrides:
accessibleLabelTargetin classWidget<Card>- Returns:
- the widget that carries a label bound to this one;
thisby default - See Also:
-