Search in sources :

Example 6 with StyledText

use of limelight.ui.text.StyledText in project limelight by slagyr.

the class TextPanelTest method styledInheritsFromDefault.

@Test
public void styledInheritsFromDefault() {
    createStyles();
    parent.setSize(200, 100);
    panel.setText("<size_only_style>This some text</size_only_style>", parent);
    panel.buildLines();
    List<TextLayout> lines = panel.getLines();
    assertEquals(1, lines.size());
    String onlyLine = lines.get(0).toString();
    assertSubString("name=" + defaultFontFace, onlyLine);
    assertSubString("size=" + "25", onlyLine);
    assertSubString("style=" + defaultFontStyle, onlyLine);
    StyledText first = panel.getTextChunks().get(0);
    assertEquals(defaultTextColor, first.getColor());
}
Also used : StyledText(limelight.ui.text.StyledText) TextLayout(java.awt.font.TextLayout) Test(org.junit.Test)

Example 7 with StyledText

use of limelight.ui.text.StyledText in project limelight by slagyr.

the class TextPanelTest method textColor.

@Test
public void textColor() throws Exception {
    createStyles();
    panel.setText("text <my_other_style>here</my_other_style> man", parent);
    panel.buildLines();
    StyledText first = panel.getTextChunks().get(0);
    assertEquals(defaultTextColor, first.getColor());
    StyledText second = panel.getTextChunks().get(1);
    assertEquals(new Color(0x0000FF), second.getColor());
    StyledText third = panel.getTextChunks().get(2);
    assertEquals(defaultTextColor, third.getColor());
}
Also used : StyledText(limelight.ui.text.StyledText) Test(org.junit.Test)

Aggregations

StyledText (limelight.ui.text.StyledText)7 Test (org.junit.Test)5 TextLayout (java.awt.font.TextLayout)2 AttributedString (java.text.AttributedString)2 RichStyle (limelight.styles.RichStyle)1 StyledTextParser (limelight.ui.text.StyledTextParser)1