gwt.material.design.client.base.helper.ColorHelper Java Examples

The following examples show how to use gwt.material.design.client.base.helper.ColorHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PathStylerMixin.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void setup(MaterialPathAnimator animator) {
    animator.setAnimateOnStartCallback(() -> {
        Scheduler.get().scheduleDeferred(() -> {
            Element bridgeElement = getBridgeElement();
            if (bridgeElement != null) {
                if (shadow != null) {
                    bridgeElement.addClassName("z-depth-" + shadow);
                }

                if (backgroundColor != null) {
                    setStyleProperty("background", ColorHelper.setupComputedBackgroundColor(backgroundColor));
                }

                if (properties != null) {
                    for (PathStyleProperty property : properties) {
                        bridgeElement.getStyle().setProperty(property.getProperty(), property.getValue());
                    }
                }
            }
        });
    });
}
 
Example #2
Source File: MaterialCircularProgressTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void checkProperties(MaterialCircularProgress circularProgress) {
    // Size
    circularProgress.setSize(200);
    assertEquals(200.0, circularProgress.getSize());
    // Thickness
    circularProgress.setThickness(20);
    assertEquals(20, circularProgress.getThickness());
    // Start Angle
    circularProgress.setStartAngle(Math.PI / 2);
    assertEquals(Math.PI / 2, circularProgress.getStartAngle());
    // Fill Color
    circularProgress.setFillColor(Color.RED);
    assertEquals(Color.RED, circularProgress.getFillColor());
    assertNotNull(ColorHelper.setupComputedBackgroundColor(circularProgress.getFillColor()));
    // Empty Fill Color
    circularProgress.setEmptyFillColor(Color.RED_LIGHTEN_2);
    assertEquals(Color.RED_LIGHTEN_2, circularProgress.getEmptyFillColor());
    assertNotNull(ColorHelper.setupComputedBackgroundColor(circularProgress.getEmptyFillColor()));
    // Reverse
    circularProgress.setReverse(true);
    assertTrue(circularProgress.isReverse());
}
 
Example #3
Source File: SignaturePadView.java    From gwt-material-demo with Apache License 2.0 5 votes vote down vote up
protected void chooseColor(MaterialColumn widget) {
    Color color = widget.getBackgroundColor();
    if (color != null) {
        signaturePad.setPenColor(ColorHelper.setupComputedBackgroundColor(color));
    }
    colorSelected.setText("Pen Color : " + color.name());
    colorSelected.setTextColor(color);
}
 
Example #4
Source File: JsCircularProgressOptions.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@JsOverlay
public static final JsCircularProgressOptions create() {
    JsCircularProgressOptions options = new JsCircularProgressOptions();
    options.value = 0.0;
    options.size = 100;
    options.thickness = 8;
    options.startAngle = Math.PI;
    options.fill = ColorHelper.setupComputedBackgroundColor(Color.BLUE);
    options.emptyFill = ColorHelper.setupComputedBackgroundColor(Color.GREY_LIGHTEN_2);
    options.reverse = false;
    return options;
}
 
Example #5
Source File: MaterialCutOut.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the computed background color, based on the backgroundColor CSS
 * class.
 */
protected void setupComputedBackgroundColor() {
    // temp is just a widget created to evaluate the computed background
    // color
    MaterialWidget temp = new MaterialWidget(Document.get().createDivElement());
    temp.setBackgroundColor(backgroundColor);

    // setting a style to make it invisible for the user
    Style style = temp.getElement().getStyle();
    style.setPosition(Position.FIXED);
    style.setWidth(1, Unit.PX);
    style.setHeight(1, Unit.PX);
    style.setLeft(-10, Unit.PX);
    style.setTop(-10, Unit.PX);
    style.setZIndex(-10000);

    // adding it to the body (on Chrome the component must be added to the
    // DOM before getting computed values).
    String computed = ColorHelper.setupComputedBackgroundColor(backgroundColor);

    // convert rgb to rgba, considering the opacity field
    if (opacity < 1 && computed.startsWith("rgb(")) {
        computed = computed.replace("rgb(", "rgba(").replace(")", ", " + opacity + ")");
    }

    computedBackgroundColor = computed;
}
 
Example #6
Source File: ColorHelperTest.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
public void testFromStyleName() {
    assertEquals(Color.PINK_LIGHTEN_1,
        ColorHelper.fromStyleName("pink lighten-1", Color.class, Color.DEFAULT));
}
 
Example #7
Source File: MaterialCircularProgress.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
/**
 * Set the fillColor of the circular progress
 */
public void setFillColor(Color fillColor) {
    this.fillColor = fillColor;
    options.fill = ColorHelper.setupComputedBackgroundColor(fillColor);
}
 
Example #8
Source File: MaterialCircularProgress.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
/**
 * Set the empty fill color of the circular progress
 */
public void setEmptyFillColor(Color emptyFillColor) {
    this.emptyFillColor = emptyFillColor;
    options.emptyFill = ColorHelper.setupComputedBackgroundColor(emptyFillColor);
}
 
Example #9
Source File: MaterialBubble.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
@Override
public void setBackgroundColor(Color bgColor) {
    super.setBackgroundColor(bgColor);
    options.color = ColorHelper.setupComputedBackgroundColor(bgColor);
    reload();
}