/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * 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 cdac.medinfo.sdk.dcm30_04.baselibs;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;

/**
* This item class contains the methods to set, get and validate the attribute present in Luminance ResponseSequence.
 */

public class LuminanceResponseSequenceItem extends Item
{

	private static final long serialVersionUID = 1L;
	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax 
	 */
	LuminanceResponseSequenceItem()
	{
		super();
	}


	/**
	 * This constructor creates the item and internal code sequence macro with specified TransferSyntax 
	 * and default DictionaryReader
	 * @param objITransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 */
	LuminanceResponseSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

	/**
	 * This constructor creates LuminanceResponseSequenceItem with specified TransferSyntax and
	 * specified DictionaryReader
	 * @param objTransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 * @param objDictionaryReader specifies the DICOM Dictionary reader to be used 
	 */
	LuminanceResponseSequenceItem(ITransferSyntax objTransferSyntax, IDictionaryReader objDictionaryReader)
	{
		super(objTransferSyntax,objDictionaryReader);
	}


	/**
	 * Sets a LuminanceValue
	 * Luminance in candelas per square meter (cd/m2) at the measurement location.
	 * @param arrLuminanceValue pair of floating point numbers
	 */
	public void setLuminanceValue(float[] arrLuminanceValue)
	{
		/* Accept the LuminanceValue in short format of type FL.
		 * Luminance in candelas per square meter (cd/m2) at the measurement location.
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0028,0x701F, arrLuminanceValue,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0028,0x701F,DicomConstants.DCM_DT_FL, arrLuminanceValue);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves LuminanceValue.
	 * @return float[] - Float array of Luminance Value.
	 */
	public float[] getLuminanceValue()
	{
		Object objValue = getValue(0x0028,0x701F);
		if(objValue != null)
			return (float[])objValue;
		return null;
	}

	/**
	 * Sets a CIExyWhitePoint
	 * White Point at the measurement location,
	 * The white point is recorded as a CIE xy chromaticity with two dimensionless floating point values 
	 * where the first is the x value and the second is the y value.
	 * @param arrLuminanceValue pair of floating point numbers
	 */
	public void setCIExyWhitePoint(float[] arrCIExyWhitePoint)
	{
		/* Accept the CIExyWhitePoint in short format of type FL.
		 * White Point at the measurement location,
		 * The white point is recorded as a CIE xy chromaticity with two dimensionless floating point values 
		 * where the first is the x value and the second is the y value.
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0028,0x7018, arrCIExyWhitePoint,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0028,0x7018,DicomConstants.DCM_DT_FL, arrCIExyWhitePoint);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves CIExyWhitePoint.
	 * @return float[] - Float array of CIExy White Point.
	 */
	public float[] getCIExyWhitePoint()
	{
		Object objValue = getValue(0x0028,0x7018);
		if(objValue != null)
			return (float[])objValue;
		return null;
	}
}
