// Copyright 2000-2004, FreeHEP.

package hep.graphics.heprep1.ref;

import java.awt.Color;
import java.io.Serializable;

import hep.graphics.heprep1.*;

/**
 *
 * @author M.Donszelmann
 *
 * @version $Id: DefaultHepRepAttValue.java,v 1.1 2004/07/18 08:19:46 duns Exp $
 */

public class DefaultHepRepAttValue implements HepRepAttValue, Serializable {
    public static final String cvsId = "$Id: DefaultHepRepAttValue.java,v 1.1 2004/07/18 08:19:46 duns Exp $";

    private String name, value;
    private int showLabel;
    private Color color;

    public DefaultHepRepAttValue(String name, String value, int showLabel) {
        this.name = name;
        this.value = value;
        this.showLabel = showLabel;
        this.color = null;
    }
    
    public String getName() {
        return name;
    }

    public int showLabel() {
        return showLabel;
    }
    
    public Object getValue() {
        return value;
    }
    
    public String getString() {
        return value;
    }
    
    public long getLong() {
        return Long.parseLong(value);
    }
    
    public int getInteger() {
        return (int)getLong();
    }
    
    public double getDouble() {
        return Double.valueOf(value).doubleValue();
    }
    
    public boolean getBoolean() {
        return Boolean.valueOf(value).booleanValue();
    }
    
    public Color getColor() {
        if (color == null) {
            color = HepRepColor.get(value);
        }
        return color;
    }

    public int getFontStyle() {
        return HepRepFont.getStyle(value);
    }
    
    public String toString() {
        return "AttValue["+getName()+": "+getValue()+"]";
    }
}

