/*******************************************************************************
 *  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.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.enums.EnumCompoundGraphicType;
import cdac.medinfo.sdk.dcm30_04.enums.EnumCompoundGraphicUnits;
import cdac.medinfo.sdk.dcm30_04.enums.EnumGraphicFilled;
import cdac.medinfo.sdk.dcm30_04.enums.EnumShowTickLabel;
import cdac.medinfo.sdk.dcm30_04.enums.EnumTickAlignment;
import cdac.medinfo.sdk.dcm30_04.enums.EnumTickLabelAlignment;
import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidItemException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ValidationException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;

/**
* This item class contains the methods to set, get and validate the attribute present in Compound Graphic Sequence.
 */

public class CompoundGraphicSequenceItem extends Item  
{

	private static final long serialVersionUID = 1L;


	/**
	 * This constructor creates the item with default TransferSyntax 
	 */
	CompoundGraphicSequenceItem()
	{
		super();
	}


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

	/**
	 * This constructor creates CompoundGraphicSequenceItem with specified TransferSyntax and
	 * specified DictionaryReader
	 * @param objTransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 * @param objDictionaryReader specifies the DICOM Dictionary reader to be used 
	 */
	CompoundGraphicSequenceItem(ITransferSyntax objTransferSyntax, IDictionaryReader objDictionaryReader)
	{
		super(objTransferSyntax,objDictionaryReader);
	}
	
	LineStyleSequenceMacro  objLineStyleSequenceMacro = null;
	TextStyleSequenceMacro objTextStyleSequenceMacro = null;
	FillStyleSequenceMacro objFillStyleSequenceMacro = null;

	/**
	 * Validates all the attributes in Compound Graphic Sequence Item that are present in the DataSet
	 * @return boolean - Success -true, Failure - false
	 * @throws InvalidItemException throws InvalidItemException If Mandatory or Conditional element fails.
	 */
	public boolean validateForModule()  throws InvalidItemException
	{
		try
		{
			if(!contains(0x0070,0x0226))
				throw new MandatoryMissingException("0070,0226");
			if(!contains(0x0070,0x0282))
				throw new MandatoryMissingException("0070,0282");
			if(!contains(0x0070,0x0020))
				throw new MandatoryMissingException("0070,0020");
			if(!contains(0x0070,0x0021))
				throw new MandatoryMissingException("0070,0021");
			if(!contains(0x0070,0x0022))
				throw new MandatoryMissingException("0070,0022");
			if(!contains(0x0070,0x0294))
				throw new MandatoryMissingException("0070,0294");
			
			
			if(contains(0x0070,0x0230) || 
					(contains(0x0070,0x0294) && (getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.CUTLINE) || getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.INFINITELINE))) )
				if(!contains(0x0070,0x0273))
					throw new ConditionFailedException("0x0070,0x0273");
			
			if(contains(0x0070,0x0294) && (getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.CUTLINE) || getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.INFINITELINE) || getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.CROSSHAIR)) )
				if(!contains(0x0070,0x0261))
					throw new ConditionFailedException("0x0070,0x0261");
			
			if(contains(0x0070,0x0294) && getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.CROSSHAIR) )
				if(!contains(0x0070,0x0262))
					throw new ConditionFailedException("0x0070,0x0262");
			
			if(contains(0x0070,0x0294) && getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.AXIS) )
				if(contains(0x0070,0x0287))
					getMajorTicksSequence().validateForModule();

			if(contains(0x0070,0x0294) && (getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.RULER) || getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.AXIS) || getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.CROSSHAIR)) ){
				if(!contains(0x0070,0x0274))
					throw new ConditionFailedException("0x0070,0x0274");
				if(!contains(0x0070,0x0279))
					throw new ConditionFailedException("0x0070,0x0279");
				if(!contains(0x0070,0x0278))
					throw new ConditionFailedException("0x0070,0x0278");
			}
		
			if(contains(0x0070,0x0294) && (getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.RECTANGLE) || getDataForTag(0x0070, 0x0294).getValue().equals(EnumCompoundGraphicType.ELLIPSE)) )
					if(!contains(0x0070,0x0024))
						throw new ConditionFailedException("0x0070,0x0024");
		}
		catch(MandatoryMissingException me)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(me.getMessage());
			}
			throw new InvalidItemException(this.getClass().getSimpleName(),me);
		}
		catch(ConditionFailedException ce)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(ce.getMessage());
			}
			throw new ValidationException(this.getClass().getSimpleName(),ce); 
		}
		return true;
	}
	
	/**
	 * This method returns the Line Style Sequence Macro with proper initialization.
	 * @return - instance of {@link LineStyleSequenceMacro} 
	 */
	public LineStyleSequenceMacro getLineStyleSequenceMacro()
	{
		if(objLineStyleSequenceMacro == null)
		{
			objLineStyleSequenceMacro = new LineStyleSequenceMacro(this);
		}
		return objLineStyleSequenceMacro;
	}
	
	/**
	 * This method returns the Text Style Sequence Macro with proper initialization.
	 * @return - instance of {@link TextStyleSequenceMacro} 
	 */
	public TextStyleSequenceMacro getTextStyleSequenceMacro()
	{
		if(objTextStyleSequenceMacro == null)
		{
			objTextStyleSequenceMacro = new TextStyleSequenceMacro(this);
		}
		return objTextStyleSequenceMacro;
	}
	
	/**
	 * This method returns the Fill Style Sequence Macro with proper initialization.
	 * @return - instance of {@link FillStyleSequenceMacro} 
	 */
	public FillStyleSequenceMacro getFillStyleSequenceMacro()
	{
		if(objFillStyleSequenceMacro == null)
		{
			objFillStyleSequenceMacro = new FillStyleSequenceMacro(this);
		}
		return objFillStyleSequenceMacro;
	}
	
	/**
	 * Sets Compound Graphic Instance ID.
	 * A number that identifies the Compound Graphic described in this Item. 
	 * The value shall be unique within this SOP instance.
	 * @param iCompoundGraphicInstanceID long value of Compound Graphic Instance ID.
	 */
	public void setCompoundGraphicInstanceID(int iCompoundGraphicInstanceID)
	{
		/* Accept the Compound Graphic Instance ID of type UL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0226, iCompoundGraphicInstanceID,objIDictionaryReader);
		else
			objIDataElement = new ExplicitDE(0x0070,0x0226,DicomConstants.DCM_DT_UL, iCompoundGraphicInstanceID);
		//Add the DataElement to the Item
		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Compound Graphic Instance ID.
	 * A number that identifies the Compound Graphic described in this Item. 
	 * The value shall be unique within this SOP instance.
	 * @return long - value of Compound Graphic Instance ID.
	 */
	public int getCompoundGraphicInstanceID()
	{
		Object objValue = getValue(0x0070,0x0226);
		if(objValue != null)
			return Integer.parseInt(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets Compound Graphic Units.
	 * Type of dimension used in attributes for the Compound Graphic when specifying distances and locations.
	 * Defined Terms:
	 * 1) PIXEL.
	 * 2) DISPLAY.
	 * @param enumCompoundGraphicUnits enum value of Compound Graphic Units.
	 */
	public void setCompoundGraphicUnits(EnumCompoundGraphicUnits enumCompoundGraphicUnits)
	{
		/* Accept the Compound Graphic Units in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0070,0x0282, enumCompoundGraphicUnits.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0282,DicomConstants.DCM_DT_CS, enumCompoundGraphicUnits.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return Compound Graphic Units. 
	 * Type of dimension used in attributes for the Compound Graphic when specifying distances and locations.
	 * @return String - value of Compound Graphic Units.
	 */
	public String getCompoundGraphicUnits()
	{
		Object objValue = getValue(0x0070,0x0282);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Graphic Dimensions
	 * @param shGraphicDimensions short value of Graphic Dimensions
	 */
	public void setGraphicDimensions(short shGraphicDimensions)
	{
		/* Accept the Graphic Dimensions of type US.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0020,shGraphicDimensions,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0020,DicomConstants.DCM_DT_US, shGraphicDimensions);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Graphic Dimensions
	 * @return short - short value of Graphic Dimensions
	 */
	public short getGraphicDimensions()
	{
		Object objValue = getValue(0x0070,0x0020);
		if(objValue != null)
			return Short.parseShort(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets Number of Graphic Points
	 * @param shNumberofGraphicPoints short value of Number of Graphic Points
	 */
	public void setNumberofGraphicPoints(short shNumberofGraphicPoints)
	{
		/* Accept the Number of Graphic Points of type US.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0021,shNumberofGraphicPoints,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0021,DicomConstants.DCM_DT_US, shNumberofGraphicPoints);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Number of Graphic Points
	 * @return short - short value of Number of Graphic Points
	 */
	public short getNumberofGraphicPoints()
	{
		Object objValue = getValue(0x0070,0x0021);
		if(objValue != null)
			return Short.parseShort(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets the Graphic Data.
	 * Numerical data Items that specify this Compound Graphic (points, vectors and scalars).
	 * @param fGraphicData Float value of Graphic Data
	 */
	public void setGraphicData( float fGraphicData)
	{
		/*
		 * Accept the Graphic Data in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0022, fGraphicData,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0022,DicomConstants.DCM_DT_FL, fGraphicData);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Graphic Data.
	 * Numerical data Items that specify this Compound Graphic (points, vectors and scalars).
	 * @return float - Float value of the Graphic Data
	 */
	public float getGraphicData()
	{
		Object objValue = getValue(0x0070,0x0022);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets type of Compound Graphic.
	 * Defined Terms:
	 * 1) MULTILINE.
	 * 2) INFINITELINE.
	 * 3) CUTLINE
	 * 4) RANGELINE.
	 * 5) RULER.
	 * 6) AXIS.
	 * 7) CROSSHAIR.
	 * 8) ARROW.
	 * 9) RECTANGLE.
	 * 10) ELLIPSE.
	 * @param enumCompoundGraphicType enum value of Compound Graphic Type.
	 */
	public void setCompoundGraphicType(EnumCompoundGraphicType enumCompoundGraphicType)
	{
		/* Accept the Setup Device Type in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0070,0x0294, enumCompoundGraphicType.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0294,DicomConstants.DCM_DT_CS, enumCompoundGraphicType.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return type of Compound Graphic. 
	 * @return String - value of Compound Graphic Type.
	 */
	public String getCompoundGraphicType()
	{
		Object objValue = getValue(0x0070,0x0294);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	
	/**
	 * Sets the Rotation Angle.
	 * The rotation of this Compound Graphic in degrees. 
	 * Value shall be in degrees,between 0 and 360.
	 * @param dblRotationAngle Double value of Rotation Angle
	 */
	public void setRotationAngle(double dblRotationAngle)
	{
		/*Accept the Rotation Angle in double format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0070,0x0230, dblRotationAngle,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0230,DicomConstants.DCM_DT_FD, dblRotationAngle);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Rotation Angle.
	 * The rotation of this Compound Graphic in degrees. 
	 * Value shall be in degrees,between 0 and 360.
	 * @return double - double value of Rotation Angle
	 */
	public double getRotationAngle()
	{
		Object objValue = getValue(0x0070,0x0230);
		if(objValue != null)
			return Double.parseDouble(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets the Rotation Point.
	 * The rotation point of this Compound Graphic.
	 * @param fRotationPoint Float value of the Rotation Point
	 */
	public void setRotationPoint( float fRotationPoint)
	{
		/*
		 * Accept the Rotation Point in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0273, fRotationPoint,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0273,DicomConstants.DCM_DT_FL, fRotationPoint);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Rotation Point.
	 * The rotation point of this Compound Graphic.
	 * @return float - Float value of the Rotation Point
	 */
	public float getRotationPoint()
	{
		Object objValue = getValue(0x0070,0x0273);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets the Gap Length.
	 * @param fGapLength Float value of the Gap Length
	 */
	public void setGapLength( float fGapLength)
	{
		/*
		 * Accept the Gap Length in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0261, fGapLength,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0261,DicomConstants.DCM_DT_FL, fGapLength);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Gap Length.
	 * @return float - Float value of the Gap Length
	 */
	public float getGapLength()
	{
		Object objValue = getValue(0x0070,0x0261);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	/**
	 * Sets the Diameter of Visibility.
	 * @param fDiameterofVisibility Float value of the Diameter of Visibility
	 */
	public void setDiameterofVisibility( float fDiameterofVisibility)
	{
		/*
		 * Accept the Diameter of Visibility in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0262, fDiameterofVisibility,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0262,DicomConstants.DCM_DT_FL, fDiameterofVisibility);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the Diameter of Visibility.
	 * @return float - Float value of the Diameter of Visibility
	 */
	public float getDiameterofVisibility()
	{
		Object objValue = getValue(0x0070,0x0262);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	
	
	/**
	 * Retrieves pre-initialized object of Major Ticks Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return MajorTicksSequence - instance of MajorTicksSequence. 
	 */
	public MajorTicksSequence getMajorTicksSequence()
	{
		MajorTicksSequence objMajorTicksSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0070, 0x0287);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objMajorTicksSequence = (MajorTicksSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objMajorTicksSequence = (MajorTicksSequence)objDicomV3Factory.createSequence(0x0070, 0x0287, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0070, 0x0287, objMajorTicksSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0070, 0x0287, DicomConstants.DCM_DT_SQ, objMajorTicksSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objMajorTicksSequence;
	}
	
	
	/**
	 * Sets Tick Alignment.
	 * The alignment of the ticks with respect to the line.
	 * Defined Terms:
	 * 1) BOTTOM.
	 * 2) CENTER.
	 * 3) TOP.
	 * @param enumTickAlignment enum value of Tick Alignment.
	 */
	public void setTickAlignment(EnumTickAlignment enumTickAlignment)
	{
		/* Accept the Tick Alignment in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0070,0x0274, enumTickAlignment.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0274,DicomConstants.DCM_DT_CS, enumTickAlignment.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return type of Tick Alignment. 
	 * The alignment of the ticks with respect to the line.
	 * @return String - value of Tick Alignment.
	 */
	public String getTickAlignment()
	{
		Object objValue = getValue(0x0070,0x0274);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Tick Label Alignment.
	 * The alignment of the label with respect to the tick.
	 * Defined Terms:
	 * 1) BOTTOM.
	 * 2) TOP.
	 * @param enumTickLabelAlignment enum value of Tick Label Alignment.
	 */
	public void setTickLabelAlignment(EnumTickLabelAlignment enumTickLabelAlignment)
	{
		/* Accept the Tick Label Alignment in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0070,0x0279, enumTickLabelAlignment.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0279,DicomConstants.DCM_DT_CS, enumTickLabelAlignment.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return type of Tick Label Alignment. 
	 * The alignment of the label with respect to the tick.
	 * @return String - value of Tick Label Alignment.
	 */
	public String getTickLabelAlignment()
	{
		Object objValue = getValue(0x0070,0x0279);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets Show Tick Label.
	 * Indicates whether the tick label should be initially visible.
	 * Defined Terms:
	 * 1) Y.
	 * 2) N.
	 * @param enumShowTickLabel enum value of Show Tick Label.
	 */
	public void setShowTickLabel(EnumShowTickLabel enumShowTickLabel)
	{
		/* Accept the Show Tick Label in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0070,0x0278, enumShowTickLabel.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0278,DicomConstants.DCM_DT_CS, enumShowTickLabel.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return type of Show Tick Label. 
	 * Indicates whether the tick label should be initially visible.
	 * @return String - value of Show Tick Label.
	 */
	public String getShowTickLabel()
	{
		Object objValue = getValue(0x0070,0x0278);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Graphic Filled.
	 * Indicates whether or not the Compound Graphics is displayed as filled.
	 * Defined Terms:
	 * 1) Y.
	 * 2) N.
	 * @param enumGraphicFilled enum value of Graphic Filled.
	 */
	public void setGraphicFilled(EnumGraphicFilled enumGraphicFilled)
	{
		/* Accept the Graphic Filled in String format of type CS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0070,0x0024, enumGraphicFilled.getValue(),getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0070,0x0024,DicomConstants.DCM_DT_CS, enumGraphicFilled.getValue());

		addDataElement(objIDataElement);


	}

	/**
	 * Return type of Graphic Filled. 
	 * Indicates whether or not the Compound Graphics is displayed as filled.
	 * @return String - value of Graphic Filled.
	 */
	public String getGraphicFilled()
	{
		Object objValue = getValue(0x0070,0x0024);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Graphic Group ID.
	 * A number that defines the corresponding group object in the Graphic GroupSequence (0070,0234).
	 * @param iGraphicGroupID long value of Graphic Group ID.
	 */
	public void setGraphicGroupID(int iGraphicGroupID)
	{
		/* Accept the Graphic Group ID of type UL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0070,0x0295, iGraphicGroupID,objIDictionaryReader);
		else
			objIDataElement = new ExplicitDE(0x0070,0x0295,DicomConstants.DCM_DT_UL, iGraphicGroupID);
		//Add the DataElement to the Item
		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Graphic Group ID.
	 * A number that defines the corresponding group object in the Graphic GroupSequence (0070,0234).
	 * @return long - value of Graphic Group ID.
	 */
	public int getGraphicGroupID()
	{
		Object objValue = getValue(0x0070,0x0295);
		if(objValue != null)
			return Integer.parseInt(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}

	
}
