001package gwt.material.design.client.ui;
002
003/*
004 * #%L
005 * GwtMaterial
006 * %%
007 * Copyright (C) 2015 GwtMaterialDesign
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023
024import gwt.material.design.client.base.MaterialWidget;
025import gwt.material.design.client.ui.html.Div;
026
027import com.google.gwt.dom.client.Document;
028
029//@formatter:off
030/**
031* Material Spinner , is a circular loader for gwt material apps
032* <h3>UiBinder Usage:</h3>
033* 
034* <pre>
035* {@code 
036* <m:MaterialSpinner color="red" />
037}
038* </pre>
039* @see <a href="http://gwt-material-demo.herokuapp.com/#loaders">Material Progress</a>
040* @author kevzlou7979
041* @author Ben Dol
042*/
043//@formatter:on
044public class MaterialSpinner extends MaterialWidget {
045
046    private Div circleClipperLeft = new Div();
047    private Div circleClipperRight = new Div();
048    private Div circle1 = new Div();
049    private Div circle2 = new Div();
050    private Div circle3 = new Div();
051    private Div gapPatch = new Div();
052
053    public MaterialSpinner() {
054        super(Document.get().createDivElement(), "spinner-layer");
055        add(circleClipperLeft);
056        circleClipperLeft.add(circle1);
057        add(gapPatch);
058        gapPatch.add(circle2);
059        add(circleClipperRight);
060        circleClipperRight.add(circle3);
061
062        circleClipperLeft.setStyleName("circle-clipper left");
063        gapPatch.setStyleName("gap-patch");
064        circleClipperRight.setStyleName("circle-clipper right");
065
066        circle1.setStyleName("circle");
067        circle2.setStyleName("circle");
068        circle3.setStyleName("circle");
069    }
070
071    public MaterialSpinner(String color) {
072        this();
073        setColor(color);
074    }
075
076    public void setColor(String color) {
077        addStyleName("spinner-" + color);
078    }
079
080}