/*
 * Created on 2004/06/11
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package jp.riken.brain.ni.samuraigraph.figure.java2d;

import java.util.*;
import java.io.*;
import jp.riken.brain.ni.samuraigraph.base.*;
import jp.riken.brain.ni.samuraigraph.data.*;
import jp.riken.brain.ni.samuraigraph.figure.*;


/**
 * @author kuromaru
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public abstract class SGElementGroupSetInFigureElement extends SGElementGroupSet
{

	/**
	 *
	 */
	protected String mName = null;


	/**
	 * 
	 */
	public SGElementGroupSetInFigureElement()
	{
		super();
	}


	/**
	 *
	 */
	public boolean setName( final String name )
	{
		mName = name;
		return true;
	}


	/**
	 * 
	 */
	public String getName()
	{
		return mName;
	}


	/**
	 * 
	 */
	public boolean writePropertyOfData( final Writer writer ) throws IOException
	{

		// name of data
		SGUtilityText.writeStringPropertyLine( writer, SGIGraphElement.PF_DATA_NAME, this.mName );

		return true;
	}




	/**
	 * 
	 */
	public SGProperties getProperties()
	{
		ElementGroupSetPropertiesInFigureElement ep = new ElementGroupSetPropertiesInFigureElement();
		if( this.getProperties(ep) == false )
		{
			return null;
		}

		return ep;
	}


	/**
	 * 
	 */
	public boolean getProperties( final SGProperties p )
	{
		if( ( p instanceof ElementGroupSetPropertiesInFigureElement ) == false ) return false;

		if( super.getProperties(p) == false ) return false;

		ElementGroupSetPropertiesInFigureElement ep = (ElementGroupSetPropertiesInFigureElement)p;

		ep.name = new String( this.mName );

		return true;
	}



	/**
	 * 
	 */
	public boolean setProperties( final SGProperties p )
	{
		if( ( p instanceof ElementGroupSetPropertiesInFigureElement ) == false ) return false;

		if( super.setProperties(p) == false ) return false;

		ElementGroupSetPropertiesInFigureElement ep = (ElementGroupSetPropertiesInFigureElement)p;

		this.mName = new String( ep.name );

		return true;
	}



	/**
	 * 
	 */
	public boolean readProperties( final BufferedReader br, final SGProperties prop )
		throws IOException
	{
		if( br==null || prop==null )
		{
			return false;
		}

		if( super.readProperties(br,prop) == false )
		{
			return false;
		}

		if( ( prop instanceof ElementGroupSetPropertiesInFigureElement ) == false )
		{
			return false;
		}

		ElementGroupSetPropertiesInFigureElement p = (ElementGroupSetPropertiesInFigureElement)prop;

		String line = null;

		// name of data
		if( ( line = SGUtilityText.readLine(br) ) == null )
		{
			return false;
		}
//System.out.println(line);
		String name = SGUtilityText.getStringPropertyFromLine(line,SGIGraphElement.PF_DATA_NAME);
		if( name == null )
		{
			return false;
		}
		p.name = name;

		return true;

	}




	/**
	 * 
	 */
	public static class ElementGroupSetPropertiesInFigureElement
		extends ElementGroupSetProperties
	{

		String name;


		/**
		 * 
		 *
		 */
		public ElementGroupSetPropertiesInFigureElement()
		{
			super();
		}



		/**
		 * 
		 */
		public boolean equals( final Object obj )
		{

			if( ( obj instanceof ElementGroupSetPropertiesInFigureElement ) == false )
			{
				return false;
			}

			if( super.equals(obj) == false ) return false;

			ElementGroupSetPropertiesInFigureElement p = (ElementGroupSetPropertiesInFigureElement)obj;

			if( p.name.equals(this.name) == false ) return false;

			return true;

		}


		/**
		 * 
		 */
		public String toString()
		{
			String str = new String("[");
			str += super.toString();
			str += new String("name="+name+", ");
			str += new String("]");

			return str;
		}
		
	}




}
