Decoratable

A component that paints through the decoration its modifier declares: what every decoration modifier and every DecorationModifierNode target.

The library writes decoration; the component stores it and applies it, as it applies its Border:

  • paint answers decoration.paint(this, g) { super.paint(it) };

  • paintBorder paints the border at Decoration.localLayoutBounds;

  • both getInsets overloads answer through Decoration.insets;

  • contains answers Decoration.contains;

  • isOpaque answers super.isOpaque() && decoration.isOpaque(this), and the component paints its background inside Decoration.localLayoutBounds where super.isOpaque();

  • repaint(long, int, int, int, int) answers decoration.repaint(this, tm, x, y, width, height);

  • paintImmediately(int, int, int, int) answers decoration.paintImmediately(this, x, y, w, h) { x, y, w, h -> super.paintImmediately(x, y, w, h) };

  • a component with children also answers isPaintingOrigin with Decoration.isDecorated, as JLayer does, so a repaint a child records is painted through its decoration.

Its size getters answer as for any Swing component: a size worked out from its content includes getInsets(), and a set size answers as set. A Foundation container gives it all its paint outsets. Any other parent gives it only the part of its decoration its PaintOutsets value leaves in layout, none by default, and clips the rest at its bounds.

Properties

Link copied to clipboard
abstract var decoration: Decoration

The decoration this component paints through; Decoration.None until the library writes one.

Functions

Link copied to clipboard
open override fun onDeclaredNodesChanged(componentNode: SwingComponentNode<*>, nodes: List<SwingModifier.Node>)

Gathers the decoration the nodes declare and writes it to decoration. Not to be overridden.