/*******************************************************************************
 * 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>DimensionHandle</code>.
 */

public class NativeDimension extends ScriptableObject
{

	/**
	 * The class name of the native dimension property.
	 */

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

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

	private Dimension dimension = null;

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

	public NativeDimension( )
	{}

	public void jsConstructor( Object dimension )
	{
		assert dimension instanceof Dimension;
		this.dimension = (Dimension) dimension;
	}

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

	public String getClassName( )
	{
		return CLASS_NAME;
	}

	/**
	 * Returns the CSS-compatible dimension value.
	 * 
	 * @return the CSS-compatible dimension value.
	 */

	public String jsGet_value( )
	{
		return this.dimension.getValue( );
	}

	/**
	 * Returns the units portion of a dimension
	 * 
	 * @return the units portion of a dimension
	 */

	public String jsGet_units( )
	{
		return this.dimension.getUnits( );
	}

	/**
	 * Returns the measure portion of a dimension
	 * 
	 * @return the measure portion of a dimension
	 */

	public Double jsGet_measure( )
	{
		return new Double( this.dimension.getMeasure( ) );
	}
}