All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gwt.material.design.client.ui.MaterialProgress Maven / Gradle / Ivy

There is a newer version: 2.8.3
Show newest version
/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 - 2017 GwtMaterialDesign
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package gwt.material.design.client.ui;

import com.google.gwt.dom.client.Style.Unit;
import gwt.material.design.client.base.HasType;
import gwt.material.design.client.base.mixin.ColorsMixin;
import gwt.material.design.client.base.mixin.CssTypeMixin;
import gwt.material.design.client.constants.Color;
import gwt.material.design.client.constants.CssName;
import gwt.material.design.client.constants.ProgressType;
import gwt.material.design.client.ui.html.Div;

//@formatter:off

/**
 * Material Progress indicator to define intermediate and determinate progress bars
 * 

UiBinder Usage:

*

*

 * {@code
 * // INDETERMINATE Type
 * 
 *
 * // DETERMINATE Type
 * 
 * }
 * 
* * @author kevzlou7979 * @see Material Progress * @see Material Design Specification */ public class MaterialProgress extends Div implements HasType { private double percent = 0; private Div fillContainer = new Div(); private ColorsMixin
fillColorMixin; private CssTypeMixin typeMixin; public MaterialProgress() { super(CssName.PROGRESS); getElement().getStyle().setMargin(0, Unit.PX); add(fillContainer); setType(ProgressType.INDETERMINATE); } public MaterialProgress(ProgressType type) { this(); setType(type); } public MaterialProgress(ProgressType type, Double percent) { this(type); setPercent(percent); } @Override public void setType(ProgressType type) { getTypeMixin().setType(type); } @Override public ProgressType getType() { return getTypeMixin().getType(); } /** * Get progress width as percent unit */ public double getPercent() { return percent; } /** * Set progress width as percent unit. * If percent is greater than 100 then reset the progress in the maximum value (100%) * If percent is less than 0 then reset the progress in the minimum value (0%) */ public void setPercent(double percent) { if (percent > 100) { percent = 100; } if (percent < 0) { percent = 0; } this.percent = percent; fillContainer.getElement().getStyle().setWidth(percent, Unit.PCT); } /** * Get the progress bar color. */ public Color getColor() { return getFillColorMixin().getBackgroundColor(); } /** * Set the color of the progress bar. * * @param color String value of the color. */ public void setColor(Color color) { getFillColorMixin().setBackgroundColor(color); } public Div getFillContainer() { return fillContainer; } protected ColorsMixin
getFillColorMixin() { if (fillColorMixin == null) { fillColorMixin = new ColorsMixin<>(fillContainer); } return fillColorMixin; } protected CssTypeMixin getTypeMixin() { if (typeMixin == null) { typeMixin = new CssTypeMixin<>(this, fillContainer); } return typeMixin; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy