Search in sources :

Example 6 with Style

use of limelight.styles.Style 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)

Example 7 with Style

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

the class PropPanelLayout method collapseAutoDimensions.

private void collapseAutoDimensions(PropPanel panel, Dimension consumedDimensions) {
    Style style = panel.getStyle();
    int width = style.getCompiledWidth().collapseExcess(panel.getWidth(), consumedDimensions.width + horizontalInsets(panel), style.getCompiledMinWidth(), style.getCompiledMaxWidth());
    int height = style.getCompiledHeight().collapseExcess(panel.getHeight(), consumedDimensions.height + verticalInsets(panel), style.getCompiledMinHeight(), style.getCompiledMaxHeight());
    panel.setSize(width, height);
}
Also used : Style(limelight.styles.Style)

Example 8 with Style

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

the class ImagePanelLayout method handleAutoDimensions.

private void handleAutoDimensions(ImagePanel panel, Dimension size) {
    Style style = panel.getStyle();
    boolean autoWidth = style.getCompiledWidth() instanceof AutoDimensionValue;
    boolean autoHeight = style.getCompiledHeight() instanceof AutoDimensionValue;
    if (autoWidth && autoHeight) {
        size.width = (int) (panel.getRotatedWidth() + 0.5);
        size.height = (int) (panel.getRotatedHeight() + 0.5);
    } else if (autoWidth) {
        double ratio = size.height / panel.getRotatedHeight();
        size.width = (int) (panel.getRotatedWidth() * ratio + 0.5);
    } else if (autoHeight) {
        double ratio = size.width / panel.getRotatedWidth();
        size.height = (int) (panel.getRotatedHeight() * ratio + 0.5);
    }
}
Also used : Style(limelight.styles.Style) AutoDimensionValue(limelight.styles.values.AutoDimensionValue)

Example 9 with Style

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

the class PaintJob method applyAlphaCompositeFor.

public void applyAlphaCompositeFor(Panel panel, Graphics2D graphics) {
    Style style = panel.getStyle();
    double alphaPercentage = style.getCompiledTransparency().getPercentage();
    if (alphaPercentage > 0) {
        float alpha = (float) (1.0f - (alphaPercentage / 100.0f));
        Composite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
        graphics.setComposite(alphaComposite);
    }
}
Also used : Style(limelight.styles.Style)

Example 10 with Style

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

the class TextPanelTest method observerAddedForLineStyling.

@Test
public void observerAddedForLineStyling() throws Exception {
    panel.setText("some text", parent);
    panel.buildLines();
    Style style = panel.getTextChunks().get(0).getStyle();
    assertEquals(true, style.hasObserver(panel));
}
Also used : RichStyle(limelight.styles.RichStyle) Style(limelight.styles.Style) Test(org.junit.Test)

Aggregations

Style (limelight.styles.Style)14 RichStyle (limelight.styles.RichStyle)4 Test (org.junit.Test)4 Box (limelight.util.Box)3 AutoDimensionValue (limelight.styles.values.AutoDimensionValue)2 IOException (java.io.IOException)1 LimelightException (limelight.LimelightException)1 StringValue (limelight.styles.abstrstyling.StringValue)1 GreedyDimensionValue (limelight.styles.values.GreedyDimensionValue)1 Pen (limelight.ui.Pen)1 ImageCache (limelight.ui.model.ImageCache)1 Scene (limelight.ui.model.Scene)1 TypedLayout (limelight.ui.text.TypedLayout)1