Style.Composite composite = (Style.Composite)style; buffer.append("[["); if (composite.getUnderline() == Boolean.TRUE) { buffer.append('u'); if (composite.getBold() == Boolean.TRUE) { buffer.append('b'); if (composite.getForeground() != null) { buffer.append(COLOR_MAP.get(composite.getForeground())); if (composite.getBackground() != null) { buffer.append(COLOR_MAP.get(composite.getBackground()));
public Style.Composite leaveStyle() { if (stack == null || stack.isEmpty()) { throw new IllegalStateException("Cannot leave non existing style"); } Style.Composite last = stack.removeLast(); if (stack.size() > 0) { // Compute merged Style.Composite merged = getMerged(); // Compute diff with removed Boolean bold = foo(last.getBold(), merged.getBold()); Boolean underline = foo(last.getUnderline(), merged.getUnderline()); Boolean blink = foo(last.getBlink(), merged.getBlink()); // For now we assume that black is the default background color // and white is the default foreground color Color fg = foo(last.getForeground(), merged.getForeground(), Color.def); Color bg = foo(last.getBackground(), merged.getBackground(), Color.def); // Style.Composite bilto = Style.style(bold, underline, blink, fg, bg); // append(bilto); } else { append(Style.reset); } return last; }
table.add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("NAME", "LEVEL"));
header.style(Decoration.bold.fg(Color.black).bg(Color.white)); header.add(new LabelElement("ID")); header.add(new LabelElement("NAME"));
new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add( "ID", "NAME",
bold((Boolean)attributes.get("bold")). underline((Boolean)attributes.get("underline")). blink((Boolean)attributes.get("blink")); if (attributes.containsKey("fg")) { style = style.foreground((Color)attributes.get("fg")); style = style.foreground((Color)attributes.get("foreground")); style = style.background((Color)attributes.get("bg")); style = style.background((Color)attributes.get("background"));
bold((Boolean)attributes.get("bold")). underline((Boolean)attributes.get("underline")). blink((Boolean)attributes.get("blink")); if (attributes.containsKey("fg")) { style = style.foreground((Color)attributes.get("fg")); style = style.foreground((Color)attributes.get("foreground")); style = style.background((Color)attributes.get("bg")); style = style.background((Color)attributes.get("background"));
bold((Boolean)attributes.get("bold")). underline((Boolean)attributes.get("underline")). blink((Boolean)attributes.get("blink")); if (attributes.containsKey("fg")) { style = style.foreground((Color)attributes.get("fg")); style = style.foreground((Color)attributes.get("foreground")); style = style.background((Color)attributes.get("bg")); style = style.background((Color)attributes.get("background"));
new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add( "ID", "NAME",
overflow(Overflow.HIDDEN). rightCellPadding(1). add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("NAME", "TYPE", "DESCRIPTION")); for (MBeanAttributeInfo attributeInfo : info.getAttributes()) { attributes.row(attributeInfo.getName(), attributeInfo.getType(), attributeInfo.getDescription());
overflow(Overflow.HIDDEN). rightCellPadding(1). add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("NAME", "TYPE", "DESCRIPTION")); for (MBeanAttributeInfo attributeInfo : info.getAttributes()) { attributes.row(attributeInfo.getName(), attributeInfo.getType(), attributeInfo.getDescription());
header.style(Decoration.bold.fg(Color.black).bg(Color.white)); for (String s : bilto) { header.add(s);
header.style(Decoration.bold.fg(Color.black).bg(Color.white)); for (String s : bilto) { header.add(s);
header.style(Decoration.bold.fg(Color.black).bg(Color.white)); for (String s : bilto) { header.add(new LabelElement(s));
style(Decoration.bold.fg(Color.black).bg(Color.white)). add("NAME", "CLASSNAME", "MXBEAN", "DESCRIPTION") );
header.style(Decoration.bold.fg(Color.black).bg(Color.white)); header.add(new LabelElement("NAME")); header.add(new LabelElement("LEVEL"));
style(Decoration.bold.fg(Color.black).bg(Color.white)). add("NAME", "CLASSNAME", "MXBEAN", "DESCRIPTION") );
table.add(new RowElement().style(Decoration.bold.fg(Color.black).bg(Color.white)).add("NAME", "LEVEL"));
public void write(Style style) throws IOException { if (style == Style.reset) { termIO.resetAttributes(); termIO.write(""); } else { // if (style instanceof Style.Composite) { Style.Composite composite = (Style.Composite)style; if (composite.getBold() != null) { termIO.setBold(composite.getBold()); } if (composite.getUnderline() != null) { termIO.setUnderlined(composite.getUnderline()); } if (composite.getBlink() != null) { termIO.setBlink(composite.getBlink()); } Color fg = composite.getForeground(); if (fg != null) { termIO.setForegroundColor(30 + fg.code); } Color bg = composite.getBackground(); if (bg != null) { termIO.setBackgroundColor(30 + bg.code); } } else { termIO.resetAttributes(); } } }
public void write(Style style) throws IOException { if (style == Style.reset) { termIO.resetAttributes(); termIO.write(""); } else { // if (style instanceof Style.Composite) { Style.Composite composite = (Style.Composite)style; if (composite.getBold() != null) { termIO.setBold(composite.getBold()); } if (composite.getUnderline() != null) { termIO.setUnderlined(composite.getUnderline()); } if (composite.getBlink() != null) { termIO.setBlink(composite.getBlink()); } Color fg = composite.getForeground(); if (fg != null) { termIO.setForegroundColor(30 + fg.code); } Color bg = composite.getBackground(); if (bg != null) { termIO.setBackgroundColor(30 + bg.code); } } else { termIO.resetAttributes(); } } }