Search in sources :

Example 71 with Box

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

the class PaintJobTest method setUp.

public void setUp() throws Exception {
    bufferedImageCache = new SimpleCache<Panel, BufferedImage>();
    pool = new BufferedImagePool(1);
    Context.instance().bufferedImageCache = bufferedImageCache;
    Context.instance().bufferedImagePool = pool;
    job = new PaintJob(new Box(100, 200, 300, 400), Colors.TRANSPARENT);
    panel = new MockProp();
    style = panel.style;
    graphics = new MockGraphics();
}
Also used : Panel(limelight.ui.Panel) BufferedImagePool(limelight.ui.BufferedImagePool) Box(limelight.util.Box) BufferedImage(java.awt.image.BufferedImage)

Example 72 with Box

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

the class PaintJobTest method testPaintRoot.

public void testPaintRoot() throws Exception {
    panel.setLocation(1, 2);
    panel.setSize(1000, 1000);
    job.substituteGraphics(graphics);
    job.paint(panel);
    assertEquals(new Box(-99, -198, 1000, 1000), graphics.subGraphics.get(0).clip);
}
Also used : Box(limelight.util.Box)

Example 73 with Box

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

the class PaintJobTest method testPaintingChildren.

public void testPaintingChildren() throws Exception {
    MockProp child = new MockProp();
    panel.add(child);
    panel.childConsumableBounds = new Box(12, 34, 56, 78);
    child.setLocation(123, 456);
    child.setSize(100, 200);
    MockGraphics graphics = new MockGraphics();
    job.paintChildren(panel, graphics);
    assertEquals(new Box(12, 34, 56, 78), graphics.clippedRectangle);
    assertEquals(new Box(123, 456, 100, 200), graphics.subGraphics.get(0).clip);
}
Also used : Box(limelight.util.Box)

Example 74 with Box

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

the class StaticFillStrategyValueTest method setUp.

public void setUp() throws Exception {
    attribute = new StaticFillStrategyValue();
    graphics = new MockGraphics();
    clip = new Box(0, 0, 60, 60);
    graphics.clip = clip;
}
Also used : MockGraphics(limelight.ui.MockGraphics) Box(limelight.util.Box)

Example 75 with Box

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

the class GradientPainter method paint.

public void paint(Graphics2D graphics, PaintablePanel panel) {
    Style style = panel.getStyle();
    Box r = panel.getBorderedBounds();
    Color color1 = style.getCompiledBackgroundColor().getColor();
    Color color2 = style.getCompiledSecondaryBackgroundColor().getColor();
    int angle = style.getCompiledGradientAngle().getDegrees();
    double penetration = style.getCompiledGradientPenetration().getPercentage();
    boolean cyclic = style.getCompiledCyclicGradient().isOn();
    int x1, y1, x2, y2;
    if (angle == 90) {
        x1 = x2 = r.width / 2;
        y1 = r.height;
        y2 = 0;
    } else if (angle == 270) {
        x1 = x2 = r.width / 2;
        y1 = 0;
        y2 = r.height;
    } else if (angle == 0) {
        y1 = y2 = r.height / 2;
        x1 = 0;
        x2 = r.width;
    } else if (angle == 180) {
        y1 = y2 = r.height / 2;
        x1 = r.width;
        x2 = 0;
    } else {
        double radians = Math.toRadians(angle);
        double x = Math.cos(radians);
        double y = Math.sin(radians);
        double a = y / x;
        double dx = Math.abs(r.height / a);
        double dy = Math.abs(r.width * a);
        if (x > 0) {
            x1 = (int) (r.width / 2 - dx / 2);
            x1 = Math.max(x1, 0);
            x2 = (int) (r.width / 2 + dx / 2);
            x2 = Math.min(x2, r.width);
        } else {
            x2 = (int) (r.width / 2 - dx / 2);
            x2 = Math.max(x2, 0);
            x1 = (int) (r.width / 2 + dx / 2);
            x1 = Math.min(x1, r.width);
        }
        if (y >= 0) {
            y1 = (int) (r.height / 2 + dy / 2);
            y1 = Math.min(r.height, y1);
            y2 = (int) (r.height / 2 - dy / 2);
            y2 = Math.max(0, y2);
        } else {
            y2 = (int) (r.height / 2 + dy / 2);
            y2 = Math.min(r.height, y2);
            y1 = (int) (r.height / 2 - dy / 2);
            y1 = Math.max(0, y1);
        }
    }
    int x3 = x1 + (int) ((x2 - x1) * penetration * 0.01);
    int y3 = y1 + (int) ((y2 - y1) * penetration * 0.01);
    graphics.setPaint(new GradientPaint(x1, y1, color1, x3, y3, color2, cyclic));
    Border border = panel.getBorderShaper();
    Shape insideBorder = border.getShapeInsideBorder();
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics.fill(insideBorder);
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
Also used : Style(limelight.styles.Style) Box(limelight.util.Box)

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