/*******************************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.report.model.script;

import org.mozilla.javascript.ScriptableObject;

/**
 * Represents the scriptable object for <code>ColorHandle</code>.
 */

public class NativeColor extends ScriptableObject
{

	/**
	 * The class name of this native color object.
	 */

	public static final String CLASS_NAME = "Color"; //$NON-NLS-1$

	/**
	 * The color object of this native object holds.
	 */

	private Color color = null;

	/**
	 * The zero-argument constructor used by Rhino runtime to create instances
	 */

	public NativeColor()
	{}

    /**
     * JavaScript function that is the constructor .
     * 
     * @param color a color instance
     */
    
    
	public void jsConstructor( Object color )
	{
		assert ( color instanceof Color );
		this.color = (Color) color;
	}
	
	/**
	 * JavaScript function to return the transparent property of the color.
	 * 
	 * @return whether the color property value is set to the CSS transparent
	 *         value.
	 */

	public boolean jsGet_transparent( )
	{
		return color.isTranparent( );
	}

	/**
	 * JavaScript function to return the rgb value of the color.
	 * 
	 * @return rgb value of the color.
	 */

	public Integer jsGet_rgb( )
	{
		return new Integer( color.getRGB( ) );
	}

	/**
	 * JavaScript function to return the css value of the color.
	 * 
	 * @return the color value in the form that can be set in CSS: either a CSS
	 *         color name or an RBG value
	 */

	public String jsGet_cssValue( )
	{
		return color.getCssValue( );
	}

	/**
	 * JavaScript function to return the value of the color.
	 * 
	 * @return the css color name or as a CSS RGB string if
	 *         set as RGB
	 */

	public String jsGet_value( )
	{
		return color.getValue( );
	}

    
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.mozilla.javascript.Scriptable#getClassName()
	 */

	public String getClassName( )
	{
		return CLASS_NAME;
	}
}