/*
 * Copyright (C) 2016 team-cachebox.de
 *
 * Licensed under the : GNU General Public License (GPL);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.gnu.org/licenses/gpl.html
 *
 * 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.
 */
package de.longri.cachebox3.gui.widgets;

import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisTable;

/**
 * Created by Longri on 07.09.2016.
 */
public class Stars extends VisTable {

    public Stars(int value) {

        Skin skin = VisUI.getSkin();
        Drawable star1 = value >= 2 ? skin.getDrawable("star") : value >= 1 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
        Drawable star2 = value >= 4 ? skin.getDrawable("star") : value >= 3 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
        Drawable star3 = value >= 6 ? skin.getDrawable("star") : value >= 5 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
        Drawable star4 = value >= 8 ? skin.getDrawable("star") : value >= 7 ? skin.getDrawable("star_half") : skin.getDrawable("star0");
        Drawable star5 = value == 10 ? skin.getDrawable("star") : value >= 9 ? skin.getDrawable("star_half") : skin.getDrawable("star0");

        this.add(new Image(star1));
        this.add(new Image(star2));
        this.add(new Image(star3));
        this.add(new Image(star4));
        this.add(new Image(star5));

        this.pack();
        this.layout();
    }
}

@@ -946,32 +946,522 @@
    p
-ublic Stars(int value) %7B
+rivate final Image image1, image2, image3, image4, image5;%0A%0A    public Stars(int value) %7B%0A%0A        this.add(image1 = new Image());%0A        this.add(image2 = new Image());%0A        this.add(image3 = new Image());%0A        this.add(image4 = new Image());%0A        this.add(image5 = new Image());%0A%0A        setValue(value);%0A    %7D%0A%0A    public void setValue(int value) %7B%0A%0A        if (value %3C 0 %7C%7C value %3E 10) %7B%0A            throw new RuntimeException(%22value must between 0-10! it was:%22 + Integer.toString(value));%0A        %7D%0A
 %0A%0A  
@@ -2194,34 +2194,31 @@
     
-this.add(new Image(
+setImage(image1, 
 star1)
-)
 ;%0A  
@@ -2227,34 +2227,31 @@
     
-this.add(new Image(
+setImage(image2, 
 star2)
-)
 ;%0A  
@@ -2260,34 +2260,31 @@
     
-this.add(new Image(
+setImage(image3, 
 star3)
-)
 ;%0A  
@@ -2293,34 +2293,31 @@
     
-this.add(new Image(
+setImage(image4, 
 star4)
-)
 ;%0A  
@@ -2326,34 +2326,31 @@
     
-this.add(new Image(
+setImage(image5, 
 star5)
-)
 ;%0A%0A 
@@ -2397,11 +2397,183 @@
 );%0A    %7D
+%0A%0A    private void setImage(Image image, Drawable drawable) %7B%0A        image.setDrawable(drawable);%0A        image.setSize(image.getPrefWidth(), image.getPrefHeight());%0A    %7D
 %0A%7D%0A

make Stars widget adjustable