Search in sources :

Example 6 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class StyledTextTest method shouldBuildFont.

@Test
public void shouldBuildFont() throws Exception {
    styledText = new StyledText("Blah");
    styledText.setupStyles(new HashMap<String, RichStyle>(), new RichStyle(), new MockStyleObserver());
    styledText.getStyle().setFontFace("Courier");
    styledText.getStyle().setFontStyle("plain");
    styledText.getStyle().setFontSize(12);
    Font font = styledText.getFont();
    assertEquals("Courier", font.getName());
    assertEquals(12, font.getSize());
    assertEquals(true, font.isPlain());
}
Also used : RichStyle(limelight.styles.RichStyle) Test(org.junit.Test)

Example 7 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class StyledTextTest method shouldNotBuildStylesMoreThanOnce.

@Test
public void shouldNotBuildStylesMoreThanOnce() throws Exception {
    makeSampleStyles();
    StyleObserver observer = new MockStyleObserver();
    styledText = new StyledText("Some Text", "fizz", "bang");
    styledText.setupStyles(styles, defaultStyle, observer);
    styledText.setupStyles(styles, defaultStyle, observer);
    RichStyle style = styledText.getStyle();
    assertEquals(3, style.getExtentions().size());
    assertEquals(1, style.getObservers().size());
}
Also used : RichStyle(limelight.styles.RichStyle) StyleObserver(limelight.styles.StyleObserver) Test(org.junit.Test)

Example 8 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class StyledTextTest method shouldTeardownStyles.

@Test
public void shouldTeardownStyles() throws Exception {
    makeSampleStyles();
    styledText = new StyledText("Some Text", "fizz", "bang");
    styledText.setupStyles(styles, defaultStyle, new MockStyleObserver());
    styledText.teardownStyles();
    RichStyle style = styledText.getStyle();
    assertEquals(false, style1.hasObserver(style));
    assertEquals(false, style2.hasObserver(style));
    assertEquals(false, defaultStyle.hasObserver(style));
}
Also used : RichStyle(limelight.styles.RichStyle) Test(org.junit.Test)

Example 9 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class BuiltInStyles method buildDropDownPopupListItemHover.

private static RichStyle buildDropDownPopupListItemHover() {
    RichStyle style = new RichStyle();
    style.setTextColor("white");
    style.setBackgroundColor("#bbd453");
    style.setSecondaryBackgroundColor("#9fb454");
    style.setGradientAngle(270);
    style.setGradient("on");
    return style;
}
Also used : RichStyle(limelight.styles.RichStyle)

Example 10 with RichStyle

use of limelight.styles.RichStyle in project limelight by slagyr.

the class TextPanel method buildLines.

public synchronized void buildLines() {
    consumableArea = panel.getChildConsumableBounds();
    lines = new LinkedList<TextLayout>();
    if (text != null && text.length() > 0) {
        StyledTextParser parser = new StyledTextParser();
        textChunks = parser.parse(text);
        final Scene root = getRoot();
        if (// TODO MDM - It happens.... but how?  Ah!  Need to acquire tree lock when removing panels.
        root != null) {
            Map<String, RichStyle> styleMap = root.getStyles();
            for (StyledText styledText : textChunks) styledText.setupStyles(styleMap, getStyle(), this);
            // TODO MDM StyleObservers may cause a memory leak.  Styles keep track of panels that are no longer used?
            addLines();
        }
    }
}
Also used : StyledText(limelight.ui.text.StyledText) RichStyle(limelight.styles.RichStyle) StyledTextParser(limelight.ui.text.StyledTextParser) AttributedString(java.text.AttributedString) TextLayout(java.awt.font.TextLayout)

Aggregations

RichStyle (limelight.styles.RichStyle)21 Test (org.junit.Test)9 Scene (limelight.ui.model.Scene)3 HashMap (java.util.HashMap)2 StyleObserver (limelight.styles.StyleObserver)2 Opts (limelight.util.Opts)2 TextLayout (java.awt.font.TextLayout)1 AttributedString (java.text.AttributedString)1 Matcher (java.util.regex.Matcher)1 LimelightException (limelight.LimelightException)1 FakeScene (limelight.ui.model.FakeScene)1 MockStage (limelight.ui.model.MockStage)1 StyledText (limelight.ui.text.StyledText)1 StyledTextParser (limelight.ui.text.StyledTextParser)1