/*
 * SGFigureDialog.java
 *
 * Created on 2004/06/09, 15:19
 */

package jp.riken.brain.ni.samuraigraph.base;

import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;

/**
 *
 * @author  kuromaru
 */
public class SGFigureDialog extends SGPropertyDialog
{

	/**
	 * 
	 */
	public static final String TITLE = "Figure Dialog";

    
    /** Creates new form SGFigureDialog */
    public SGFigureDialog(java.awt.Frame parent, boolean modal)
    {
        super(parent, modal);
        initComponents();
        this.initProperty();
    }
    
        
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        mFigurePanel = new javax.swing.JPanel();
        mWidthLabel = new javax.swing.JLabel();
        mHeightLabel = new javax.swing.JLabel();
        mWidthSpinner = new jp.riken.brain.ni.samuraigraph.base.SGSpinner();
        mHeightSpinner = new jp.riken.brain.ni.samuraigraph.base.SGSpinner();
        mLocationLabel = new javax.swing.JLabel();
        mSizeLabel = new javax.swing.JLabel();
        mXLabel = new javax.swing.JLabel();
        mXSpinner = new jp.riken.brain.ni.samuraigraph.base.SGSpinner();
        mYLabel = new javax.swing.JLabel();
        mYSpinner = new jp.riken.brain.ni.samuraigraph.base.SGSpinner();
        mSpaceLabel = new javax.swing.JLabel();
        mSpaceLineAndScaleLabel = new javax.swing.JLabel();
        mSpaceScaleAndTitleLabel = new javax.swing.JLabel();
        mSpaceLineAndScaleSpinner = new jp.riken.brain.ni.samuraigraph.base.SGSpinner();
        mSpaceScaleAndTitleSpinner = new jp.riken.brain.ni.samuraigraph.base.SGSpinner();
        mBackgroundColorLabel = new javax.swing.JLabel();
        mBackgroundColorButton = new javax.swing.JButton();
        mLegendVisibleCheckBox = new javax.swing.JCheckBox();
        mLegendVisibleLabel = new javax.swing.JLabel();
        mLocationSeparator = new javax.swing.JSeparator();
        mSizeSeparator = new javax.swing.JSeparator();
        mSpaceSeparator = new javax.swing.JSeparator();
        mColorSeparator = new javax.swing.JSeparator();
        mLeftSpaceLabel = new javax.swing.JLabel();
        mRightSpaceLabel = new javax.swing.JLabel();
        mTransparentCheckBox = new javax.swing.JCheckBox();
        mButtonPanel = new javax.swing.JPanel();
        mOKButton = new javax.swing.JButton();
        mCancelButton = new javax.swing.JButton();
        mPreviewButton = new javax.swing.JButton();

        getContentPane().setLayout(new java.awt.GridBagLayout());

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        mFigurePanel.setLayout(new java.awt.GridBagLayout());

        mFigurePanel.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
        mWidthLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mWidthLabel.setText("Width");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
        mFigurePanel.add(mWidthLabel, gridBagConstraints);

        mHeightLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mHeightLabel.setText("Height");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 20, 5, 5);
        mFigurePanel.add(mHeightLabel, gridBagConstraints);

        mWidthSpinner.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mWidthSpinner, gridBagConstraints);

        mHeightSpinner.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mHeightSpinner, gridBagConstraints);

        mLocationLabel.setFont(new java.awt.Font("Dialog", 3, 12));
        mLocationLabel.setText("Location");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(10, 5, 5, 5);
        mFigurePanel.add(mLocationLabel, gridBagConstraints);

        mSizeLabel.setFont(new java.awt.Font("Dialog", 3, 12));
        mSizeLabel.setText("Size");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mSizeLabel, gridBagConstraints);

        mXLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mXLabel.setText("X");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
        mFigurePanel.add(mXLabel, gridBagConstraints);

        mXSpinner.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mXSpinner, gridBagConstraints);

        mYLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mYLabel.setText("Y");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 20, 5, 5);
        mFigurePanel.add(mYLabel, gridBagConstraints);

        mYSpinner.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mYSpinner, gridBagConstraints);

        mSpaceLabel.setFont(new java.awt.Font("Dialog", 3, 12));
        mSpaceLabel.setText("Space");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mSpaceLabel, gridBagConstraints);

        mSpaceLineAndScaleLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mSpaceLineAndScaleLabel.setText("to Scale");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
        mFigurePanel.add(mSpaceLineAndScaleLabel, gridBagConstraints);

        mSpaceScaleAndTitleLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mSpaceScaleAndTitleLabel.setText("to Title");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 20, 5, 5);
        mFigurePanel.add(mSpaceScaleAndTitleLabel, gridBagConstraints);

        mSpaceLineAndScaleSpinner.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mSpaceLineAndScaleSpinner, gridBagConstraints);

        mSpaceScaleAndTitleSpinner.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mSpaceScaleAndTitleSpinner, gridBagConstraints);

        mBackgroundColorLabel.setFont(new java.awt.Font("Dialog", 3, 12));
        mBackgroundColorLabel.setText("Color");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mBackgroundColorLabel, gridBagConstraints);

        mBackgroundColorButton.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        mFigurePanel.add(mBackgroundColorButton, gridBagConstraints);

        mLegendVisibleCheckBox.setFont(new java.awt.Font("Dialog", 0, 12));
        mLegendVisibleCheckBox.setText("Visible");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mLegendVisibleCheckBox, gridBagConstraints);

        mLegendVisibleLabel.setFont(new java.awt.Font("Dialog", 3, 12));
        mLegendVisibleLabel.setText("Legend ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mFigurePanel.add(mLegendVisibleLabel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(10, 60, 0, 0);
        mFigurePanel.add(mLocationSeparator, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 35, 0, 0);
        mFigurePanel.add(mSizeSeparator, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 48, 0, 0);
        mFigurePanel.add(mSpaceSeparator, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(0, 45, 0, 0);
        mFigurePanel.add(mColorSeparator, gridBagConstraints);

        mLeftSpaceLabel.setText("    ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
        mFigurePanel.add(mLeftSpaceLabel, gridBagConstraints);

        mRightSpaceLabel.setText("    ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
        mFigurePanel.add(mRightSpaceLabel, gridBagConstraints);

        mTransparentCheckBox.setFont(new java.awt.Font("Dialog", 0, 12));
        mTransparentCheckBox.setText("Transparency");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
        mFigurePanel.add(mTransparentCheckBox, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        getContentPane().add(mFigurePanel, gridBagConstraints);

        mOKButton.setFont(new java.awt.Font("MS Sans Serif", 1, 12));
        mOKButton.setText("OK");
        mButtonPanel.add(mOKButton);

        mCancelButton.setFont(new java.awt.Font("MS Sans Serif", 1, 12));
        mCancelButton.setText("Cancel");
        mButtonPanel.add(mCancelButton);

        mPreviewButton.setFont(new java.awt.Font("MS Sans Serif", 1, 12));
        mPreviewButton.setText("Preview");
        mButtonPanel.add(mPreviewButton);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        getContentPane().add(mButtonPanel, gridBagConstraints);

        pack();
    }//GEN-END:initComponents

    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        // ここに処理コードを追加:
    }//GEN-LAST:event_closeDialog
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new SGFigureDialog(new javax.swing.JFrame(), true).show();
    }
    
    // 変数宣言 - 編集不可//GEN-BEGIN:variables
    private javax.swing.JButton mBackgroundColorButton;
    private javax.swing.JLabel mBackgroundColorLabel;
    private javax.swing.JPanel mButtonPanel;
    private javax.swing.JButton mCancelButton;
    private javax.swing.JSeparator mColorSeparator;
    private javax.swing.JPanel mFigurePanel;
    private javax.swing.JLabel mHeightLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mHeightSpinner;
    private javax.swing.JLabel mLeftSpaceLabel;
    private javax.swing.JCheckBox mLegendVisibleCheckBox;
    private javax.swing.JLabel mLegendVisibleLabel;
    private javax.swing.JLabel mLocationLabel;
    private javax.swing.JSeparator mLocationSeparator;
    private javax.swing.JButton mOKButton;
    private javax.swing.JButton mPreviewButton;
    private javax.swing.JLabel mRightSpaceLabel;
    private javax.swing.JLabel mSizeLabel;
    private javax.swing.JSeparator mSizeSeparator;
    private javax.swing.JLabel mSpaceLabel;
    private javax.swing.JLabel mSpaceLineAndScaleLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mSpaceLineAndScaleSpinner;
    private javax.swing.JLabel mSpaceScaleAndTitleLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mSpaceScaleAndTitleSpinner;
    private javax.swing.JSeparator mSpaceSeparator;
    private javax.swing.JCheckBox mTransparentCheckBox;
    private javax.swing.JLabel mWidthLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mWidthSpinner;
    private javax.swing.JLabel mXLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mXSpinner;
    private javax.swing.JLabel mYLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mYSpinner;
    // 変数宣言の終わり//GEN-END:variables
    



	/**
	 * 
	 */
	private boolean initProperty()
	{

		// set the title
		this.setTitle( SGFigureDialog.TITLE );


		//
		// スピナーモデルの設定
		//

		this.mXSpinner.setDigitForRoundingOut(-2);
		this.mXSpinner.initProperties(
			new SpinnerNumberModel( 0.0, -50.0, 50.0, 1.0 ),
			SGSpinner.SPINNER_UNIT_CM	);
		this.mXSpinner.setMinimumFractionDigits(1);
		this.mXSpinner.setMaximumFractionDigits(1);
//		this.mXSpinner.setMaximumFractionDigits(2);

		this.mYSpinner.setDigitForRoundingOut(-2);
		this.mYSpinner.initProperties(
			new SpinnerNumberModel( 0.0, -50.0, 50.0, 1.0 ),
			SGSpinner.SPINNER_UNIT_CM	);
		this.mYSpinner.setMinimumFractionDigits(1);
		this.mYSpinner.setMaximumFractionDigits(1);
//		this.mYSpinner.setMaximumFractionDigits(2);

		this.mWidthSpinner.setDigitForRoundingOut(-2);
		this.mWidthSpinner.initProperties(
			new SpinnerNumberModel( 10.0, 1.0, 50.0, 1.0 ),
			SGSpinner.SPINNER_UNIT_CM	);
		this.mWidthSpinner.setMinimumFractionDigits(1);
		this.mWidthSpinner.setMaximumFractionDigits(1);
//		this.mWidthSpinner.setMaximumFractionDigits(2);

		this.mHeightSpinner.setDigitForRoundingOut(-2);
		this.mHeightSpinner.initProperties(
			new SpinnerNumberModel( 10.0, 1.0, 50.0, 1.0 ),
			SGSpinner.SPINNER_UNIT_CM	);
		this.mHeightSpinner.setMinimumFractionDigits(1);
		this.mHeightSpinner.setMaximumFractionDigits(1);
//		this.mHeightSpinner.setMaximumFractionDigits(2);

		this.mSpaceLineAndScaleSpinner.initProperties(
			new SpinnerNumberModel( 0.0, 0.0, 5.0, 0.01 ),
			SGSpinner.SPINNER_UNIT_CM );

		this.mSpaceScaleAndTitleSpinner.initProperties(
			new SpinnerNumberModel( 0.0, 0.0, 5.0, 0.01 ),
			SGSpinner.SPINNER_UNIT_CM );


		// 色属性変更ボタンにアクションリスナを追加
		this.mBackgroundColorButton.addActionListener(this);

		// フォーカスされた色属性ボタンの初期化
		this.mFocusedColorSetButton = this.mBackgroundColorButton;


		//
		this.mTransparentCheckBox.addActionListener(this);


		return true;
	}




	/**
	 * 
	 */
	public void actionPerformed( final ActionEvent e )
	{
		super.actionPerformed(e);

		Object source = e.getSource();
		if( source.equals(this.mTransparentCheckBox) )
		{
			this.mBackgroundColorButton.setEnabled(
				!this.mTransparentCheckBox.isSelected());
		}

	}



    
   	/**
	 * 
	 */
	public Number getFigureX()
	{
		return this.mXSpinner.getNumber();
	}

	/**
	 * 
	 */
	public Number getFigureY()
	{
		return this.mYSpinner.getNumber();
	}

	/**
	 * 
	 */
	public Number getFigureWidth()
	{
		return this.mWidthSpinner.getNumber();
	}

	/**
	 * 
	 */
	public Number getFigureHeight()
	{
		return this.mHeightSpinner.getNumber();
	}

	/**
	 * 
	 */
	public Number getSpaceLineAndNumber()
	{
		return this.mSpaceLineAndScaleSpinner.getNumber();
	}

	/**
	 * 
	 */
	public Number getSpaceNumberAndTitle()
	{
		return this.mSpaceScaleAndTitleSpinner.getNumber();
	}

	/**
	 * 
	 */
	public Color getFigureBackgroundColor()
	{
		return this.mBackgroundColorButton.getBackground();
	}

	/**
	 * 
	 * @return
	 */
	public boolean getFigureTransparentFlag()
	{
		return this.mTransparentCheckBox.isSelected();
	}

	/**
	 * 
	 */
	public boolean getFigureLegendVisible()
	{
		return this.mLegendVisibleCheckBox.isSelected();
	}




	/**
	 * 
	 */
	public boolean setFigureX( final float x )
	{
		this.mXSpinner.setValue( new Double( x ) );
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureY( final float y )
	{
		this.mYSpinner.setValue( new Double( y ) );
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureWidth( final float w )
	{
		this.mWidthSpinner.setValue( new Double( w ) );
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureHeight( final float h )
	{
		this.mHeightSpinner.setValue( new Double( h ) );
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureSpaceLineAndNumber( final float space )
	{
		this.mSpaceLineAndScaleSpinner.setValue( new Double( space ) );
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureSpaceNumberAndTitle( final float space )
	{
		this.mSpaceScaleAndTitleSpinner.setValue( new Double( space ) );
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureBackgroundColor( final Color cl )
	{
		this.mBackgroundColorButton.setBackground( cl );
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureTransparentFlag( final boolean b )
	{
		this.mTransparentCheckBox.setSelected(b);
		return true;
	}

	/**
	 * 
	 */
	public boolean setFigureLegendVisible( final boolean flag )
	{
		this.mLegendVisibleCheckBox.setSelected(flag);
		return true;
	}



	/**
	 * 
	 */
	public boolean setListener( final SGFigure listener )
	{
		this.mOKButton.addActionListener(listener);
		this.mCancelButton.addActionListener(listener);
		this.mPreviewButton.addActionListener(listener);

		final ArrayList sList = this.getSpinnerList();
		for( int ii=0; ii<sList.size(); ii++ )
		{
			SGSpinner spinner = (SGSpinner)sList.get(ii);
			spinner.getFormattedTextField().addActionListener( listener );
		}


		//
		this.addWindowListener(listener);

		return true;
	}



	/**
	 * 
	 */
	public ArrayList getColorSelectionComponentList()
	{
		final ArrayList list = new ArrayList();
			
		list.add( this.mBackgroundColorButton );

		return list;
	}


	/**
	 * 
	 */
	public ArrayList getActiveComponentList()
	{
		final ArrayList list = this.getActiveComponentListFromSpinners();
		return list;
	}


	/**
	 * 
	 */
	public ArrayList getSpinnerList()
	{
		ArrayList list = new ArrayList();

		list.add( this.mXSpinner );
		list.add( this.mYSpinner );
		list.add( this.mWidthSpinner );
		list.add( this.mHeightSpinner );
		list.add( this.mSpaceLineAndScaleSpinner );
		list.add( this.mSpaceScaleAndTitleSpinner );

		return list;
	}


	/**
	 * 
	 */
	public SGFigure.FigureProperties getProperties()
	{
		SGFigure.FigureProperties p
			= new SGFigure.FigureProperties();

		// x
		final Number x = this.getFigureX();
		if( x==null )
		{
			SGUtility.showIllegalInputErrorMessageDialog( this );
			return null;
		}
		else
		{
			p.x = x.floatValue()/SGConstants.CM_POINT_RATIO;
		}


		// y
		final Number y = this.getFigureY();
		if( y==null )
		{
			SGUtility.showIllegalInputErrorMessageDialog( this );
			return null;
		}
		else
		{
			p.y = y.floatValue()/SGConstants.CM_POINT_RATIO;
		}


		// width
		final Number w = this.getFigureWidth();
		if( w==null )
		{
			SGUtility.showIllegalInputErrorMessageDialog( this );
			return null;
		}
		else
		{
			p.width = w.floatValue()/SGConstants.CM_POINT_RATIO;
		}


		// height
		final Number h = this.getFigureHeight();
		if( h==null )
		{
			SGUtility.showIllegalInputErrorMessageDialog( this );
			return null;
		}
		else
		{
			p.height = h.floatValue()/SGConstants.CM_POINT_RATIO;
		}



		// space
		final Number spaceLN = this.getSpaceLineAndNumber();
		if( spaceLN==null )
		{
			SGUtility.showIllegalInputErrorMessageDialog( this );
			return null;
		}
		else
		{
			p.spaceLineAndNumber = spaceLN.floatValue()/SGConstants.CM_POINT_RATIO;
		}

		final Number spaceNT = this.getSpaceNumberAndTitle();
		if( spaceNT==null )
		{
			SGUtility.showIllegalInputErrorMessageDialog( this );
			return null;
		}
		else
		{
			p.spaceNumberAndTitle = spaceNT.floatValue()/SGConstants.CM_POINT_RATIO;
		}


		// legend
		p.legendVisible = this.getFigureLegendVisible();


		// background color
		p.bgColor = this.getFigureBackgroundColor();


		// transparency
		p.transparent = this.getFigureTransparentFlag();


		return p;
	}

}
