Package swingtree
Class RenderAs<C extends JComponent,E,T extends E>
java.lang.Object
swingtree.RenderAs<C,E,T>
- Type Parameters:
C- The type of the component which is used to render the cell.E- The type of the value of the cell.T- The type of the value of the cell.
This class models the API of the
CellBuilder which allows you to
specify how a cell should be rendered.
Most likely you will want to call asText(Function)
on this as most cells are rendered as simple texts.
An example would be a combo box containing enum values, which
you don't want to render as the enum name (all capital letters), but rather as a
more human-readable string.-
Method Summary
Modifier and TypeMethodDescriptionas(Configurator<CellConf<C, T>> valueInterpreter) Specify a lambda which receives aCellConfinstance for you to customize its renderer.render(BiConsumer<CellConf<C, T>, Graphics2D> renderer)
-
Method Details
-
as
Specify a lambda which receives aCellConfinstance for you to customize its renderer. This is the most generic way to customize the rendering of a cell, as you can choose between vastly different ways of rendering:.when( MyEnum.class ) .as( cell -> { // do component based rendering: cell.setRenderer( new JLabel( "Hello World" ) ); // or do graphics rendering directly: cell.setRenderer( g -> { // draw something g.drawString( "Hello World", 0, 0 ); }); })- Parameters:
valueInterpreter- A lambda which customizes the provided cell.- Returns:
- The builder API allowing method chaining.
-
asComponent
Specify a lambda which receives aCellConfinstance and return aComponentwhich is then used to render the cell..when( MyEnum.class ) .asComponent( cell -> new JLabel( "Hello World" ) )- Parameters:
renderer- A function which returns aComponentwhich is then used to render the cell.- Returns:
- The builder API allowing method chaining.
-
asText
Specify a lambda which receives aCellConfinstance and return aStringwhich is then used to render the cell..when( MyEnum.class ) .asText( cell -> "Hello World" )- Parameters:
renderer- A function which returns aStringwhich is then used to render the cell.- Returns:
- The builder API allowing method chaining.
-
render
-