Search in sources :

Example 1 with MockGraphics

use of limelight.ui.MockGraphics in project limelight by slagyr.

the class TextPanelSelectionPainterTest method setUp.

@Before
public void setUp() {
    assumeTrue(TestUtil.notHeadless());
    container = new limelight.ui.model.text.MockTextContainer();
    container.bounds = new Box(0, 0, 150, 28);
    model = new limelight.ui.model.text.MultiLineTextModel(container);
    model.setTypedLayoutFactory(MockTypedLayoutFactory.instance);
    model.setText("Some Text");
    model.setCaretLocation(TextLocation.at(0, 4));
    graphics = new MockGraphics();
    container.cursorOn = true;
    painter = TextPanelSelectionPainter.instance;
    model.startSelection(TextLocation.at(0, 6));
}
Also used : MockGraphics(limelight.ui.MockGraphics) Box(limelight.util.Box) Before(org.junit.Before)

Example 2 with MockGraphics

use of limelight.ui.MockGraphics in project limelight by slagyr.

the class ScrollBarPainterTest method shouldPaintTallSliderVertically.

@Test
public void shouldPaintTallSliderVertically() throws Exception {
    setUpVertically();
    scrollBar.configure(90, 100);
    painter.paintOn(graphics, scrollBar);
    MockGraphics.DrawnImage outsideSliderCap = graphics.drawnImages.get(12);
    MockGraphics.DrawnImage insideSliderCap = graphics.drawnImages.get(13);
    assertEquals(5, outsideSliderCap.y);
    assertEquals(53, insideSliderCap.y);
    MockGraphics fillerGraphics = graphics.subGraphics.get(0);
    assertEquals(13, fillerGraphics.clip.y);
    assertEquals(-5, fillerGraphics.drawnImages.get(0).y);
    assertEquals(12, fillerGraphics.drawnImages.get(1).y);
    assertEquals(29, fillerGraphics.drawnImages.get(2).y);
}
Also used : MockGraphics(limelight.ui.MockGraphics) Test(org.junit.Test)

Example 3 with MockGraphics

use of limelight.ui.MockGraphics in project limelight by slagyr.

the class ScrollBarPainterTest method setUpVertically.

private void setUpVertically() {
    scrollBar = new ScrollBarPanel(ScrollBarPanel.VERTICAL);
    scrollBar.setSize(15, 100);
    scrollBar.setValue(0);
    scrollBar.configure(1, 100);
    graphics = new MockGraphics();
    images = ScrollBarPainter.verticalImages;
}
Also used : MockGraphics(limelight.ui.MockGraphics) ScrollBarPanel(limelight.ui.model.inputs.ScrollBarPanel)

Example 4 with MockGraphics

use of limelight.ui.MockGraphics in project limelight by slagyr.

the class ScrollBarPainterTest method shouldPaintWideSliderHorizontally.

@Test
public void shouldPaintWideSliderHorizontally() throws Exception {
    setUpHorizontally();
    scrollBar.configure(90, 100);
    //    System.err.println("scrollBar.getSliderSize() = " + scrollBar.getSliderSize());
    //    scrollBar.getSliderSize() = 56
    painter.paintOn(graphics, scrollBar);
    MockGraphics.DrawnImage outsideSliderCap = graphics.drawnImages.get(12);
    MockGraphics.DrawnImage insideSliderCap = graphics.drawnImages.get(13);
    assertEquals(5, outsideSliderCap.x);
    assertEquals(53, insideSliderCap.x);
    MockGraphics fillerGraphics = graphics.subGraphics.get(0);
    assertEquals(13, fillerGraphics.clip.x);
    assertEquals(-5, fillerGraphics.drawnImages.get(0).x);
    assertEquals(12, fillerGraphics.drawnImages.get(1).x);
    assertEquals(29, fillerGraphics.drawnImages.get(2).x);
}
Also used : MockGraphics(limelight.ui.MockGraphics) Test(org.junit.Test)

Example 5 with MockGraphics

use of limelight.ui.MockGraphics in project limelight by slagyr.

the class NinePatchTest method itDrawsAnImageStretchedInBothDimensions.

@Test
public void itDrawsAnImageStretchedInBothDimensions() throws Exception {
    NinePatch patch = NinePatch.load(image);
    MockGraphics graphics = new MockGraphics();
    patch.draw(graphics, 0, 0, 100, 100);
    assertEquals(9, graphics.drawnImages.size());
    // top left
    checkDrawnImage(graphics.drawnImages.get(0), new Rectangle(1, 1, 3, 11), new Rectangle(0, 0, 3, 11));
    // top middle
    checkDrawnImage(graphics.drawnImages.get(1), new Rectangle(4, 1, 5, 11), new Rectangle(3, 0, 90, 11));
    // top right
    checkDrawnImage(graphics.drawnImages.get(2), new Rectangle(9, 1, 7, 11), new Rectangle(93, 0, 7, 11));
    // middle left
    checkDrawnImage(graphics.drawnImages.get(3), new Rectangle(1, 12, 3, 13), new Rectangle(0, 11, 3, 72));
    // middle middle
    checkDrawnImage(graphics.drawnImages.get(4), new Rectangle(4, 12, 5, 13), new Rectangle(3, 11, 90, 72));
    // middle right
    checkDrawnImage(graphics.drawnImages.get(5), new Rectangle(9, 12, 7, 13), new Rectangle(93, 11, 7, 72));
    // bottom left
    checkDrawnImage(graphics.drawnImages.get(6), new Rectangle(1, 25, 3, 17), new Rectangle(0, 83, 3, 17));
    // bottom middle
    checkDrawnImage(graphics.drawnImages.get(7), new Rectangle(4, 25, 5, 17), new Rectangle(3, 83, 90, 17));
    // bottom right
    checkDrawnImage(graphics.drawnImages.get(8), new Rectangle(9, 25, 7, 17), new Rectangle(93, 83, 7, 17));
}
Also used : MockGraphics(limelight.ui.MockGraphics) Test(org.junit.Test)

Aggregations

MockGraphics (limelight.ui.MockGraphics)24 Box (limelight.util.Box)11 Test (org.junit.Test)6 Before (org.junit.Before)5 FakePropProxy (limelight.model.api.FakePropProxy)3 MockProp (limelight.ui.model.MockProp)3 PropPanel (limelight.ui.model.PropPanel)3 FakeScene (limelight.ui.model.FakeScene)2 MockStage (limelight.ui.model.MockStage)2 ScrollBarPanel (limelight.ui.model.inputs.ScrollBarPanel)2 Pen (limelight.ui.Pen)1 MockDrawable (limelight.ui.model.MockDrawable)1 MockTextModel (limelight.ui.model.inputs.MockTextModel)1 TextBoxPanel (limelight.ui.model.inputs.TextBoxPanel)1