Search in sources :

Example 16 with Box

use of limelight.util.Box in project limelight by slagyr.

the class NinePatchTest method itIsInitializedWithAnImage.

@Test
public void itIsInitializedWithAnImage() throws Exception {
    NinePatch.Info info = NinePatch.Info.inspect(image);
    assertEquals(new Box(1, 1, 3, 11), info.topLeftBounds);
    assertEquals(new Box(4, 1, 5, 11), info.topMiddleBounds);
    assertEquals(new Box(9, 1, 7, 11), info.topRightBounds);
    assertEquals(new Box(1, 12, 3, 13), info.middleLeftBounds);
    assertEquals(new Box(4, 12, 5, 13), info.middleMiddleBounds);
    assertEquals(new Box(9, 12, 7, 13), info.middleRightBounds);
    assertEquals(new Box(1, 25, 3, 17), info.bottomLeftBounds);
    assertEquals(new Box(4, 25, 5, 17), info.bottomMiddleBounds);
    assertEquals(new Box(9, 25, 7, 17), info.bottomRightBounds);
}
Also used : Box(limelight.util.Box) Test(org.junit.Test)

Example 17 with Box

use of limelight.util.Box in project limelight by slagyr.

the class BorderPainterTest method setUp.

public void setUp() throws Exception {
    panel = new MockProp();
    style = panel.getStyle();
    border = new Box(5, 5, 100, 100);
    panel.boxInsideMargins = border;
    painter = BorderPainter.instance;
    graphics = new MockGraphics();
}
Also used : MockGraphics(limelight.ui.MockGraphics) MockProp(limelight.ui.model.MockProp) Box(limelight.util.Box)

Example 18 with Box

use of limelight.util.Box in project limelight by slagyr.

the class BorderTest method setUp.

public void setUp() {
    style = new FlatStyle();
    insideMargin = new Box(0, 0, 100, 200);
}
Also used : FlatStyle(limelight.styles.FlatStyle) Box(limelight.util.Box)

Example 19 with Box

use of limelight.util.Box in project limelight by slagyr.

the class InputPanelLayout method doExpansion.

@Override
public void doExpansion(Panel thePanel) {
    PanelBase panel = (PanelBase) thePanel;
    Box bounds = panel.getParent().getChildConsumableBounds();
    panel.setLocation(bounds.x, bounds.y);
    panel.setSize(bounds.width, bounds.height);
}
Also used : PanelBase(limelight.ui.model.PanelBase) Box(limelight.util.Box)

Example 20 with Box

use of limelight.util.Box in project limelight by slagyr.

the class PropPanelLayout method snapToSize.

public void snapToSize(PropPanel panel) {
    if (// can happen if removed from tree
    panel.getParent() == null)
        return;
    Box maxArea = panel.getParent().getChildConsumableBounds();
    Style style = panel.getStyle();
    if (style.getCompiledWidth() instanceof AutoDimensionValue && style.getCompiledHeight() instanceof GreedyDimensionValue)
        throw new LimelightException("A greedy height is not allowed with auto width.");
    int newWidth = style.getCompiledWidth().calculateDimension(maxArea.width, style.getCompiledMinWidth(), style.getCompiledMaxWidth(), panel.greediness.width);
    int newHeight = style.getCompiledHeight().calculateDimension(maxArea.height, style.getCompiledMinHeight(), style.getCompiledMaxHeight(), panel.greediness.height);
    // TODO MDM - Hacky Hack!!!!  More thought needs to go into the way layouts are down and how greedy fits into it all
    //    if(topLevel && style.getCompiledWidth() instanceof GreedyDimensionValue && panel.getWidth() > newWidth)
    //      newWidth = panel.getWidth();
    //    if(topLevel && style.getCompiledHeight() instanceof GreedyDimensionValue && panel.getHeight() > newHeight)
    //      newHeight = panel.getHeight();
    panel.setSize(newWidth, newHeight);
    panel.resetPendingSizeChange();
}
Also used : Style(limelight.styles.Style) Box(limelight.util.Box) AutoDimensionValue(limelight.styles.values.AutoDimensionValue) GreedyDimensionValue(limelight.styles.values.GreedyDimensionValue) LimelightException(limelight.LimelightException)

Aggregations

Box (limelight.util.Box)80 Test (org.junit.Test)31 MockGraphics (limelight.ui.MockGraphics)11 Before (org.junit.Before)6 AffineTransform (java.awt.geom.AffineTransform)5 Style (limelight.styles.Style)3 TextLocation (limelight.ui.text.TextLocation)3 TypedLayout (limelight.ui.text.TypedLayout)3 BufferedImage (java.awt.image.BufferedImage)2 Panel (limelight.ui.Panel)2 TextLayout (java.awt.font.TextLayout)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LimelightException (limelight.LimelightException)1 FlatStyle (limelight.styles.FlatStyle)1 StringValue (limelight.styles.abstrstyling.StringValue)1 AutoDimensionValue (limelight.styles.values.AutoDimensionValue)1 GreedyDimensionValue (limelight.styles.values.GreedyDimensionValue)1 BufferedImagePool (limelight.ui.BufferedImagePool)1 MockPanel (limelight.ui.MockPanel)1