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

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

import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.ArrayList;

import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.JTextComponent;

import jp.riken.brain.ni.samuraigraph.base.SGFigure;
import jp.riken.brain.ni.samuraigraph.base.SGIFigureDialogObserver;
import jp.riken.brain.ni.samuraigraph.base.SGIPropertyDialogObserver;
import jp.riken.brain.ni.samuraigraph.base.SGPropertyDialog;
import jp.riken.brain.ni.samuraigraph.base.SGTwoAxesRadioButtonManager;
import jp.riken.brain.ni.samuraigraph.base.SGUtilityText;



/**
 *
 * @author  kuromaru
 */
public class SGXYFigureDialog extends SGPropertyDialog
	implements SGILineConstants
{

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

    
    /** Creates new form SGFigureDialog */
    public SGXYFigureDialog(java.awt.Frame parent, boolean modal)
    {
        super(parent, modal);
        initComponents();
        this.initProperty();
		this.initialize();
    }
    
        
    /** 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;

        mGridLabel = new javax.swing.JLabel();
        mGridDialogButton = new javax.swing.JButton();
        mButtonPanel = new javax.swing.JPanel();
        mOKButton = new javax.swing.JButton();
        mCancelButton = new javax.swing.JButton();
        mPreviewButton = new javax.swing.JButton();
        mTabbedPane = new javax.swing.JTabbedPane();
        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 jp.riken.brain.ni.samuraigraph.base.SGColorSelectionButton();
        mLegendVisibleCheckBox = new jp.riken.brain.ni.samuraigraph.base.SGCheckBox();
        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 jp.riken.brain.ni.samuraigraph.base.SGCheckBox();
        mGridPanel = new javax.swing.JPanel();
        mInnerGridPanel = new javax.swing.JPanel();
        mLineLabel = new javax.swing.JLabel();
        mLineSeparator = new javax.swing.JSeparator();
        mGridVisibleCheckBox = new jp.riken.brain.ni.samuraigraph.base.SGCheckBox();
        mLocationLabel1 = new javax.swing.JLabel();
        mLocationSeparator1 = new javax.swing.JSeparator();
        mStepXValueLabel = new javax.swing.JLabel();
        mStepXValueTextField = new jp.riken.brain.ni.samuraigraph.base.SGTextField();
        mBaseXValueLabel = new javax.swing.JLabel();
        mBaseXValueTextField = new jp.riken.brain.ni.samuraigraph.base.SGTextField();
        mStepYValueLabel = new javax.swing.JLabel();
        mStepYValueTextField = new jp.riken.brain.ni.samuraigraph.base.SGTextField();
        mBaseYValueLabel = new javax.swing.JLabel();
        mBaseYValueTextField = new jp.riken.brain.ni.samuraigraph.base.SGTextField();
        mLineTypeLabel = new javax.swing.JLabel();
        mLineTypeComboBox = new javax.swing.JComboBox();
        mLineWidthLabel = new javax.swing.JLabel();
        mLineWidthSpinner = new jp.riken.brain.ni.samuraigraph.base.SGSpinner();
        mLineColorLabel = new javax.swing.JLabel();
        mLineColorButton = new jp.riken.brain.ni.samuraigraph.base.SGColorSelectionButton();
        mAutoCheckBox = new jp.riken.brain.ni.samuraigraph.base.SGCheckBox();
        mAxisPanel = new javax.swing.JPanel();
        mLeftTopRadioButton = new javax.swing.JRadioButton();
        mLeftBottomRadioButton = new javax.swing.JRadioButton();
        mRightTopRadioButton = new javax.swing.JRadioButton();
        mRightBottomRadioButton = new javax.swing.JRadioButton();
        mScaleReferenceLabel2 = new javax.swing.JLabel();
        mScaleReferenceLabel1 = new javax.swing.JLabel();

        mGridLabel.setFont(new java.awt.Font("Dialog", 3, 12));
        mGridLabel.setText("Grid ");
        mGridDialogButton.setFont(new java.awt.Font("Dialog", 0, 12));
        mGridDialogButton.setText("Show Dialog");

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

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

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

        mPreviewButton.setFont(new java.awt.Font("Dialog", 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);

        mTabbedPane.setFont(new java.awt.Font("Dialog", 1, 12));
        mFigurePanel.setLayout(new java.awt.GridBagLayout());

        mFigurePanel.setFont(new java.awt.Font("Dialog", 0, 12));
        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.setFont(new java.awt.Font("Dialog", 0, 12));
        mWidthSpinner.setPreferredSize(new java.awt.Dimension(75, 22));
        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.setFont(new java.awt.Font("Dialog", 0, 12));
        mHeightSpinner.setPreferredSize(new java.awt.Dimension(75, 22));
        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.setFont(new java.awt.Font("Dialog", 0, 12));
        mXSpinner.setPreferredSize(new java.awt.Dimension(75, 22));
        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.setFont(new java.awt.Font("Dialog", 0, 12));
        mYSpinner.setPreferredSize(new java.awt.Dimension(75, 22));
        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.setFont(new java.awt.Font("Dialog", 0, 12));
        mSpaceLineAndScaleSpinner.setPreferredSize(new java.awt.Dimension(75, 22));
        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.setFont(new java.awt.Font("Dialog", 0, 12));
        mSpaceScaleAndTitleSpinner.setPreferredSize(new java.awt.Dimension(75, 22));
        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(5, 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(5, 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(5, 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);

        mTabbedPane.addTab("Figure", mFigurePanel);

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

        mGridPanel.setFont(new java.awt.Font("Dialog", 0, 12));
        mInnerGridPanel.setLayout(new java.awt.GridBagLayout());

        mInnerGridPanel.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
        mLineLabel.setFont(new java.awt.Font("Dialog", 3, 12));
        mLineLabel.setText("Line");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(8, 10, 0, 5);
        mInnerGridPanel.add(mLineLabel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(8, 40, 0, 10);
        mInnerGridPanel.add(mLineSeparator, gridBagConstraints);

        mGridVisibleCheckBox.setFont(new java.awt.Font("Dialog", 0, 12));
        mGridVisibleCheckBox.setText("Visible");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
        mInnerGridPanel.add(mGridVisibleCheckBox, gridBagConstraints);

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

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(10, 65, 5, 10);
        mInnerGridPanel.add(mLocationSeparator1, gridBagConstraints);

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

        mStepXValueTextField.setColumns(6);
        mStepXValueTextField.setFont(new java.awt.Font("Dialog", 0, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mInnerGridPanel.add(mStepXValueTextField, gridBagConstraints);

        mBaseXValueLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mBaseXValueLabel.setText("Base X");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mInnerGridPanel.add(mBaseXValueLabel, gridBagConstraints);

        mBaseXValueTextField.setColumns(6);
        mBaseXValueTextField.setFont(new java.awt.Font("Dialog", 0, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 10);
        mInnerGridPanel.add(mBaseXValueTextField, gridBagConstraints);

        mStepYValueLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mStepYValueLabel.setText("Step Y");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
        mInnerGridPanel.add(mStepYValueLabel, gridBagConstraints);

        mStepYValueTextField.setColumns(6);
        mStepYValueTextField.setFont(new java.awt.Font("Dialog", 0, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mInnerGridPanel.add(mStepYValueTextField, gridBagConstraints);

        mBaseYValueLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mBaseYValueLabel.setText("Base Y");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mInnerGridPanel.add(mBaseYValueLabel, gridBagConstraints);

        mBaseYValueTextField.setColumns(6);
        mBaseYValueTextField.setFont(new java.awt.Font("Dialog", 0, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 10);
        mInnerGridPanel.add(mBaseYValueTextField, gridBagConstraints);

        mLineTypeLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mLineTypeLabel.setText("Type");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 10, 5);
        mInnerGridPanel.add(mLineTypeLabel, gridBagConstraints);

        mLineTypeComboBox.setFont(new java.awt.Font("Dialog", 0, 12));
        mLineTypeComboBox.setPreferredSize(new java.awt.Dimension(140, 22));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 10, 5);
        mInnerGridPanel.add(mLineTypeComboBox, gridBagConstraints);

        mLineWidthLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mLineWidthLabel.setText("Width");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 10, 5);
        mInnerGridPanel.add(mLineWidthLabel, gridBagConstraints);

        mLineWidthSpinner.setFont(new java.awt.Font("Dialog", 0, 12));
        mLineWidthSpinner.setPreferredSize(new java.awt.Dimension(75, 22));
        mLineWidthSpinner.setMinimumSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 10, 5);
        mInnerGridPanel.add(mLineWidthSpinner, gridBagConstraints);

        mLineColorLabel.setFont(new java.awt.Font("Dialog", 0, 12));
        mLineColorLabel.setText("Color");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 20, 10, 5);
        mInnerGridPanel.add(mLineColorLabel, gridBagConstraints);

        mLineColorButton.setPreferredSize(new java.awt.Dimension(65, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 10, 5);
        mInnerGridPanel.add(mLineColorButton, gridBagConstraints);

        mAutoCheckBox.setFont(new java.awt.Font("Dialog", 0, 12));
        mAutoCheckBox.setText("Auto");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 5);
        mInnerGridPanel.add(mAutoCheckBox, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
        mGridPanel.add(mInnerGridPanel, gridBagConstraints);

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

        mLeftTopRadioButton.setFont(new java.awt.Font("Dialog", 1, 12));
        mLeftTopRadioButton.setText("Left/Top");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        mAxisPanel.add(mLeftTopRadioButton, gridBagConstraints);

        mLeftBottomRadioButton.setFont(new java.awt.Font("Dialog", 1, 12));
        mLeftBottomRadioButton.setText("Left/Bottom");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        mAxisPanel.add(mLeftBottomRadioButton, gridBagConstraints);

        mRightTopRadioButton.setFont(new java.awt.Font("Dialog", 1, 12));
        mRightTopRadioButton.setText("Right/Top");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        mAxisPanel.add(mRightTopRadioButton, gridBagConstraints);

        mRightBottomRadioButton.setFont(new java.awt.Font("Dialog", 1, 12));
        mRightBottomRadioButton.setText("Right/Bottom");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        mAxisPanel.add(mRightBottomRadioButton, gridBagConstraints);

        mScaleReferenceLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
        mScaleReferenceLabel2.setText("(Value <-> Scale)");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
        mAxisPanel.add(mScaleReferenceLabel2, gridBagConstraints);

        mScaleReferenceLabel1.setFont(new java.awt.Font("Dialog", 1, 12));
        mScaleReferenceLabel1.setText("Scale Reference");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.ipadx = 7;
        mAxisPanel.add(mScaleReferenceLabel1, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        mGridPanel.add(mAxisPanel, gridBagConstraints);

        mTabbedPane.addTab("Grid", mGridPanel);

        getContentPane().add(mTabbedPane, new java.awt.GridBagConstraints());

        pack();
    }//GEN-END:initComponents
    
    
    // 変数宣言 - 編集不可//GEN-BEGIN:variables
    private jp.riken.brain.ni.samuraigraph.base.SGCheckBox mAutoCheckBox;
    private javax.swing.JPanel mAxisPanel;
    private jp.riken.brain.ni.samuraigraph.base.SGColorSelectionButton mBackgroundColorButton;
    private javax.swing.JLabel mBackgroundColorLabel;
    private javax.swing.JLabel mBaseXValueLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGTextField mBaseXValueTextField;
    private javax.swing.JLabel mBaseYValueLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGTextField mBaseYValueTextField;
    private javax.swing.JPanel mButtonPanel;
    private javax.swing.JButton mCancelButton;
    private javax.swing.JSeparator mColorSeparator;
    private javax.swing.JPanel mFigurePanel;
    private javax.swing.JButton mGridDialogButton;
    private javax.swing.JLabel mGridLabel;
    private javax.swing.JPanel mGridPanel;
    private jp.riken.brain.ni.samuraigraph.base.SGCheckBox mGridVisibleCheckBox;
    private javax.swing.JLabel mHeightLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mHeightSpinner;
    private javax.swing.JPanel mInnerGridPanel;
    private javax.swing.JRadioButton mLeftBottomRadioButton;
    private javax.swing.JLabel mLeftSpaceLabel;
    private javax.swing.JRadioButton mLeftTopRadioButton;
    private jp.riken.brain.ni.samuraigraph.base.SGCheckBox mLegendVisibleCheckBox;
    private javax.swing.JLabel mLegendVisibleLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGColorSelectionButton mLineColorButton;
    private javax.swing.JLabel mLineColorLabel;
    private javax.swing.JLabel mLineLabel;
    private javax.swing.JSeparator mLineSeparator;
    private javax.swing.JComboBox mLineTypeComboBox;
    private javax.swing.JLabel mLineTypeLabel;
    private javax.swing.JLabel mLineWidthLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGSpinner mLineWidthSpinner;
    private javax.swing.JLabel mLocationLabel;
    private javax.swing.JLabel mLocationLabel1;
    private javax.swing.JSeparator mLocationSeparator;
    private javax.swing.JSeparator mLocationSeparator1;
    private javax.swing.JButton mOKButton;
    private javax.swing.JButton mPreviewButton;
    private javax.swing.JRadioButton mRightBottomRadioButton;
    private javax.swing.JLabel mRightSpaceLabel;
    private javax.swing.JRadioButton mRightTopRadioButton;
    private javax.swing.JLabel mScaleReferenceLabel1;
    private javax.swing.JLabel mScaleReferenceLabel2;
    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.JLabel mStepXValueLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGTextField mStepXValueTextField;
    private javax.swing.JLabel mStepYValueLabel;
    private jp.riken.brain.ni.samuraigraph.base.SGTextField mStepYValueTextField;
    private javax.swing.JTabbedPane mTabbedPane;
    private jp.riken.brain.ni.samuraigraph.base.SGCheckBox 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
    


	public static final String SHOW_GRID_DIALOG = "Show Dialog";


	/**
	 * 
	 */
	private SGTwoAxesRadioButtonManager mAxesButtonGroup = null;


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

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


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

//		final int order = SGFigure.MINIMAL_LENGTH_ORDER -1;
		final int digits = - SGFigure.MINIMAL_LENGTH_ORDER;

//		this.mXSpinner.setDigitForRoundingOut(order);
		this.mXSpinner.initProperties(
			new SpinnerNumberModel( 0.0, -50.0, 150.0, 1.0 ),
			cm, digits, digits );
//		this.mXSpinner.setMinimumFractionDigits(digits);
//		this.mXSpinner.setMaximumFractionDigits(digits);

//		this.mYSpinner.setDigitForRoundingOut(order);
		this.mYSpinner.initProperties(
			new SpinnerNumberModel( 0.0, -50.0, 150.0, 1.0 ),
			cm, digits, digits );
//		this.mYSpinner.setMinimumFractionDigits(digits);
//		this.mYSpinner.setMaximumFractionDigits(digits);

//		this.mWidthSpinner.setDigitForRoundingOut(order);
		this.mWidthSpinner.initProperties(
			new SpinnerNumberModel( 10.0, 1.0, 50.0, 1.0 ),
			cm, digits, digits );
//		this.mWidthSpinner.setMinimumFractionDigits(digits);
//		this.mWidthSpinner.setMaximumFractionDigits(digits);

//		this.mHeightSpinner.setDigitForRoundingOut(order);
		this.mHeightSpinner.initProperties(
			new SpinnerNumberModel( 10.0, 1.0, 50.0, 1.0 ),
			cm, digits, digits );
//		this.mHeightSpinner.setMinimumFractionDigits(digits);
//		this.mHeightSpinner.setMaximumFractionDigits(digits);

		this.mSpaceLineAndScaleSpinner.initProperties(
			new SpinnerNumberModel( 0.0, 0.0, 5.0, 0.10 ),
			cm, 1, 2 );

		this.mSpaceScaleAndTitleSpinner.initProperties(
			new SpinnerNumberModel( 0.0, 0.0, 5.0, 0.10 ),
			cm, 1, 2 );


		// set the combo box
		{
			JComboBox cb = this.mLineTypeComboBox;
			final String array[] = {
				LINE_NAME_SOLID,
				LINE_NAME_BROKEN,
				LINE_NAME_DOT,
				LINE_NAME_DASHED,
				LINE_NAME_DOUBLE_DASHED
			};
			for(int ii=0 ; ii<array.length ; ii++)
			{
				cb.addItem( array[ii] );
			}
		}


		this.pack();

		
		this.mAxesButtonGroup = new SGTwoAxesRadioButtonManager(
			this.mLeftBottomRadioButton, this.mLeftTopRadioButton,
			this.mRightBottomRadioButton, this.mRightTopRadioButton,
			new JRadioButton() );

		
		// set spinner model
		this.mLineWidthSpinner.initProperties(
			getLineWidthSpinnerNumberModel(),
			pt, 1, 2 );


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

		//
		this.mTransparentCheckBox.addActionListener(this);
		this.mLegendVisibleCheckBox.addActionListener(this);


		// set action listeners
		this.mGridVisibleCheckBox.addActionListener(this);
		this.mAutoCheckBox.addActionListener(this);

		{
			this.mOKButton.addActionListener(this);
			this.mCancelButton.addActionListener(this);
			this.mPreviewButton.addActionListener(this);
		}

		return true;
	}




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

		Object source = e.getSource();
		if( source.equals( this.mTransparentCheckBox ) )
		{
			this.setFigureTransparent( this.isFigureTransparent() );
		}
		else if( source.equals( this.mLegendVisibleCheckBox ) )
		{
		}
		else if( source.equals( this.mGridDialogButton ) )
		{
			this.mColorDialog.setVisible(false);
		}
		else if( source.equals( this.mGridVisibleCheckBox ) )
		{
			this.setGridVisible( this.mGridVisibleCheckBox.getSelected() );
		}
		else if( source.equals( this.mAutoCheckBox ) )
		{
			this.setAutoFlag( this.mAutoCheckBox.getSelected() );
		}

	}


    
   	/**
	 * 
	 */
	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.getColor();
	}

	/**
	 * 
	 * @return
	 */
	public Boolean isFigureTransparent()
	{
		return this.mTransparentCheckBox.getSelected();
	}

	/**
	 * 
	 */
	public Boolean getFigureLegendVisible()
	{
		return this.mLegendVisibleCheckBox.getSelected();
	}




	/**
	 * 
	 */
	public boolean setFigureX( final Object value )
	{
		return this.setValue( this.mXSpinner, value );
	}

	/**
	 * 
	 */
	public boolean setFigureY( final Object value )
	{
		return this.setValue( this.mYSpinner, value );
	}

	/**
	 * 
	 */
	public boolean setFigureWidth( final Object value )
	{
		return this.setValue( this.mWidthSpinner, value );
	}

	/**
	 * 
	 */
	public boolean setFigureHeight( final Object value )
	{
		return this.setValue( this.mHeightSpinner, value );
	}

	/**
	 * 
	 */
	public boolean setFigureSpaceLineAndNumber( final Object value )
	{
		return this.setValue( this.mSpaceLineAndScaleSpinner, value );
	}

	/**
	 * 
	 */
	public boolean setFigureSpaceNumberAndTitle( final Object value )
	{
		return this.setValue( this.mSpaceScaleAndTitleSpinner, value );
	}

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

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


	/**
	 * 
	 * @param transparent
	 * @return
	 */
	private boolean setBackgroundComponentsEnabled( final Boolean transparent )
	{
		boolean b = true;
		if( transparent!=null )
		{
			b = !transparent.booleanValue();
		}
		
		this.mBackgroundColorButton.setEnabled(b);

		return true;
	}


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



	/**
	 * 
	 * @param b
	 */
	public void setGridVisible( final Boolean b )
	{
		this.mGridVisibleCheckBox.setSelected(b);
		this.setGridComponentsEnabled(b);
	}



	private void setGridComponentsEnabled( final Boolean flag )
	{
		boolean b = false;
		if( flag!=null )
		{
			b = flag.booleanValue();
		}
		this.setGridComponentsEnabled(b);
	}

	private void setGridComponentsEnabled( final boolean b )
	{
		Component[] array =
		{
			this.mScaleReferenceLabel1,
			this.mScaleReferenceLabel2,
			this.mLeftBottomRadioButton,
			this.mLeftTopRadioButton,
			this.mRightBottomRadioButton,
			this.mRightTopRadioButton,
			this.mLocationLabel1,
			this.mLineLabel,
			this.mAutoCheckBox,
			this.mLineWidthLabel,
			this.mLineWidthSpinner,
			this.mLineTypeLabel,
			this.mLineTypeComboBox,
			this.mLineColorLabel,
			this.mLineColorButton
		};
		
		for( int ii=0; ii<array.length; ii++ )
		{
			array[ii].setEnabled(b);
		}

		this.setScaleComponentsEnabled(b);
	}


	/**
	 * 
	 * @param b
	 */
	public void setAutoFlag( final Boolean b )
	{
		this.mAutoCheckBox.setSelected(b);
		this.setScaleComponentsEditable(b);
		this.setScaleComponentsEnabled(b);
	}


	private void setScaleComponentsEnabled( final Boolean auto )
	{
		boolean b;
		if( auto==null )
		{
			b = true;
		}
		else
		{
			final boolean fAuto = auto.booleanValue();

			Boolean gridVisible = this.getGridVisible();
			boolean gVisible;
			if( gridVisible==null )
			{
				gVisible = false;
			}
			else
			{
				gVisible = gridVisible.booleanValue();
			}

			b = !fAuto & gVisible;
		}

		this.setScaleComponentsEnabled(b);
	}


	private void setScaleComponentsEnabled( final boolean b )
	{
		Component[] array =
		{
			this.mBaseXValueLabel,
			this.mBaseXValueTextField,
			this.mBaseYValueLabel,
			this.mBaseYValueTextField,
			this.mStepXValueLabel,
			this.mStepXValueTextField,
			this.mStepYValueLabel,
			this.mStepYValueTextField
		};

		for( int ii=0; ii<array.length; ii++ )
		{
			array[ii].setEnabled(b);
		}
	}



	private void setScaleComponentsEditable( final Boolean auto )
	{
		boolean flag = true;
		if( auto!=null )
		{
			flag = !auto.booleanValue();
		}
		
		this.setScaleComponentsEditable(flag);
	}


	private void setScaleComponentsEditable( final boolean b )
	{
		JTextComponent[] array =
		{
			this.mBaseXValueTextField,
			this.mBaseYValueTextField,
			this.mStepXValueTextField,
			this.mStepYValueTextField
		};

		for( int ii=0; ii<array.length; ii++ )
		{
			array[ii].setEditable(b);
		}
	}



	/**
	 * 
	 */
	public boolean setLineType( final Integer type )
	{
		if( type!=null )
		{
			final String typeName = SGDrawingElementLine.getLineTypeName( type.intValue() );
			this.mLineTypeComboBox.setSelectedItem(typeName);
		}
		else
		{
			this.mLineTypeComboBox.setSelectedItem( null );
		}

		return true;
	}


	/**
	 * 
	 * @return
	 */
	public Boolean getGridVisible()
	{
		return this.mGridVisibleCheckBox.getSelected();
	}


	/**
	 * 
	 */
	public int getLineType()
	{
		final String typeName = (String)this.mLineTypeComboBox.getSelectedItem();
		final Integer num = SGDrawingElementLine.getLineTypeFromName(typeName);
		if( num==null )
		{
			return -1;
		}
		else
		{
			return num.intValue();
		}
	}


	/**
	 * 
	 */
	public boolean setLineWidth( final Object obj )
	{
		return this.setValue( this.mLineWidthSpinner, obj );
	}


	/**
	 * 
	 */
	public Number getLineWidth()
	{
		return this.mLineWidthSpinner.getNumber();
	}


	/**
	 * 
	 */
	public boolean setLineColor( final Color cl )
	{
		this.mLineColorButton.setColor( cl );
		return true;
	}


	/**
	 * 
	 */
	public Color getLineColor()
	{
		return this.mLineColorButton.getColor();
	}


	/**
	 * 
	 * @return
	 */
	public Boolean getAutoFlag()
	{
		return this.mAutoCheckBox.getSelected();
	}
	

    
	/**
	 * 
	 */
	public Number getBaseXValue()
	{
		String str = this.mBaseXValueTextField.getText();
		Number d = SGUtilityText.getDouble(str);
		return d;
	}


	/**
	 * 
	 */
	public Number getBaseYValue()
	{
		String str = this.mBaseYValueTextField.getText();
		Number d = SGUtilityText.getDouble(str);
		return d;
	}


	/**
	 * 
	 */
	public Number getStepXValue()
	{
		String str = this.mStepXValueTextField.getText();
		Number d = SGUtilityText.getDouble(str);
		return d;
	}


	/**
	 * 
	 */
	public Number getStepYValue()
	{
		String str = this.mStepYValueTextField.getText();
		Number d = SGUtilityText.getDouble(str);
		return d;
	}


	/**
	 * 
	 * @param value
	 */
	public void setBaseXValue( final Object value )
	{
		this.setValue( this.mBaseXValueTextField, value );
	}


	/**
	 * 
	 * @param value
	 */
	public void setStepXValue( final Object value )
	{
		this.setValue( this.mStepXValueTextField, value );
	}


	/**
	 * 
	 * @param value
	 */
	public void setBaseYValue( final Object value )
	{
		this.setValue( this.mBaseYValueTextField, value );
	}


	/**
	 * 
	 * @param value
	 */
	public void setStepYValue( final Object value )
	{
		this.setValue( this.mStepYValueTextField, value );
	}


	/**
	 * 
	 */
	public ArrayList getTextFieldComponentsList()
	{
		final ArrayList list = this.getFormattedTextFieldsListFromSpinners();
		list.addAll( this.getNumberTextFieldList() );
		return list;
	}


	/**
	 * Returns a list of text fields to set number.
	 * @return
	 */
	public ArrayList getNumberTextFieldList()
	{
		ArrayList list = new ArrayList();
		list.add( this.mStepXValueTextField );
		list.add( this.mStepYValueTextField );
		list.add( this.mBaseXValueTextField );
		list.add( this.mBaseYValueTextField );
		return list;
	}


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

		list.add( this.mLineColorButton );
		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 );

		list.add( this.mLineWidthSpinner );
		return list;
	}



	/**
	 * 
	 */
	public boolean setDialogProperty()
	{
		final SGXYFigureDialog dg = (SGXYFigureDialog)this;

		ArrayList list = this.mPropertyDialogObserverList;

		SGIFigureDialogObserver figure0
			= (SGIFigureDialogObserver)list.get(0);

		final float x0 = figure0.getFigureX();
		final float y0 = figure0.getFigureY();
		final float width0 = figure0.getFigureWidth();
		final float height0 = figure0.getFigureHeight();
		final float spaceLN0 = figure0.getSpaceAxisLineAndNumber();
		final float spaceNT0 = figure0.getSpaceNumberAndTitle();
		final boolean legendVisible0 = figure0.isLegendVisible();
		final Color bgColor0 = figure0.getBackgroundColor();
		final boolean transparent0 = figure0.isTransparent();

		Float x = new Float( x0 );
		Float y = new Float( y0 );
		Float width = new Float( width0 );
		Float height = new Float( height0 );
		Float spaceLN = new Float( spaceLN0 );
		Float spaceNT = new Float( spaceNT0 );
		Boolean legendVisible = Boolean.valueOf( legendVisible0 );
		Color bgColor = bgColor0;
		Boolean transparent = Boolean.valueOf( transparent0 );

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final float xValue1 = figure1.getFigureX();
				if( x0!=xValue1 )
				{
					x = null;
					break;
				}
			}

			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final float yValue1 = figure1.getFigureY();
				if( y0!=yValue1 )
				{
					y = null;
					break;
				}
			}

			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final float width1 = figure1.getFigureWidth();
				if( width0!=width1 )
				{
					width = null;
					break;
				}
			}

			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final float height1 = figure1.getFigureHeight();
				if( height0!=height1 )
				{
					height = null;
					break;
				}
			}

			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final float spaceLN1 = figure1.getSpaceAxisLineAndNumber();
				if( spaceLN0!=spaceLN1 )
				{
					spaceLN = null;
					break;
				}
			}

			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final float spaceNT1 = figure1.getSpaceNumberAndTitle();
				if( spaceNT0!=spaceNT1 )
				{
					spaceNT = null;
					break;
				}
			}

			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final boolean legendVisible1 = figure1.isLegendVisible();
				if( legendVisible0!=legendVisible1 )
				{
					legendVisible = null;
					break;
				}
			}
			
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final Color bgColor1 = figure1.getBackgroundColor();
				if( bgColor0.equals(bgColor1) == false )
				{
					bgColor = null;
					break;
				}
			}

			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIFigureDialogObserver figure1
					= (SGIFigureDialogObserver)list.get(ii);

				final boolean transparent1 = figure1.isTransparent();
				if( transparent0!=transparent1 )
				{
					transparent = null;
					break;
				}
			}

		}



		//
		if( x!=null )
		{
			x = new Float( x.floatValue()*CM_POINT_RATIO );
		}
		this.setFigureX( x );

		if( y!=null )
		{
			y = new Float( y.floatValue()*CM_POINT_RATIO );
		}
		this.setFigureY( y );

		if( width!=null )
		{
			width = new Float( width.floatValue()*CM_POINT_RATIO );
		}
		this.setFigureWidth( width );

		if( height!=null )		
		{
			height = new Float( height.floatValue()*CM_POINT_RATIO );
		}
		this.setFigureHeight( height );

		if( spaceLN!=null )
		{
			spaceLN = new Float( spaceLN.floatValue()*CM_POINT_RATIO );
		}
		this.setFigureSpaceLineAndNumber( spaceLN );
		
		if( spaceNT!=null )
		{
			spaceNT = new Float( spaceNT.floatValue()*CM_POINT_RATIO );
		}
		this.setFigureSpaceNumberAndTitle( spaceNT );


		this.setFigureLegendVisible( legendVisible );

		this.setFigureBackgroundColor( bgColor );

		this.setFigureTransparent( transparent );


		if( this.setGridProperty() == false )
		{
			return false;
		}

		this.setColorButtonBorder(true);

		return true;
	}



	private boolean isGridTabEnable()
	{
		return this.mTabbedPane.isEnabledAt(1);
	}


	private void setGridTabEnabled( final boolean enable )
	{
		this.mTabbedPane.setEnabledAt(1,enable);
		if( !enable )
		{
			this.mTabbedPane.setSelectedIndex(0);
		}
	}



	private boolean setGridProperty()
	{

		ArrayList list = this.mPropertyDialogObserverList;

		if( this.mAxesButtonGroup.setRadioButton( list ) == false )
		{
			return false;
		}

		SGIXYFigureDialogObserver grid0
			= (SGIXYFigureDialogObserver)list.get(0);

		final boolean gridVisible0 = grid0.isGridVisible();
		final boolean autoRange0 = grid0.isAutoRange();
		final double stepValueX0 = grid0.getStepValueX();
		final double stepValueY0 = grid0.getStepValueY();
		final double baselineValueX0 = grid0.getBaselineValueX();
		final double baselineValueY0 = grid0.getBaselineValueY();
		final float lineWidth0 = grid0.getLineWidth();
		final int lineType0 = grid0.getLineType();
		final Color color0 = grid0.getColor();

		Boolean gridVisible = Boolean.valueOf( gridVisible0 );
		Boolean autoRange = Boolean.valueOf( autoRange0 );
		Double stepValueX = new Double( stepValueX0 );
		Double stepValueY = new Double( stepValueY0 );
		Double baselineValueX = new Double( baselineValueX0 );
		Double baselineValueY = new Double( baselineValueY0 );
		Float lineWidth = new Float( lineWidth0 );
		Integer lineType = new Integer( lineType0 );
		Color color = color0;


		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final boolean gridVisible1 = grid1.isGridVisible();
				if( gridVisible0!=gridVisible1 )
				{
					gridVisible = null;
					break;
				}
			}
		}


//		// when grid visibility is not common,
//		// set tab disabled
//		this.setGridTabEnabled( (gridVisible!=null) );


		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final boolean autoRange1 = grid1.isAutoRange();
				if( autoRange0!=autoRange1 )
				{
					autoRange = null;
					break;
				}
			}
		}

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final double stepValueX1 = grid1.getStepValueX();
				if( stepValueX0!=stepValueX1 )
				{
					stepValueX = null;
					break;
				}
			}
		}

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final double stepValueY1 = grid1.getStepValueY();
				if( stepValueY0!=stepValueY1 )
				{
					stepValueY = null;
					break;
				}
			}
		}

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final double baselineValueX1 = grid1.getBaselineValueX();
				if( baselineValueX0!=baselineValueX1 )
				{
					baselineValueX = null;
					break;
				}
			}
		}

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final double baselineValueY1 = grid1.getBaselineValueY();
				if( baselineValueY0!=baselineValueY1 )
				{
					baselineValueY = null;
					break;
				}
			}
		}

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final float lineWidth1 = grid1.getLineWidth();
				if( lineWidth0!=lineWidth1 )
				{
					lineWidth = null;
					break;
				}
			}
		}

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final int lineType1 = grid1.getLineType();
				if( lineType0!=lineType1 )
				{
					lineType = null;
					break;
				}
			}
		}

		if( list.size() > 1 )
		{
			for( int ii=1; ii<list.size(); ii++ )
			{
				SGIXYFigureDialogObserver grid1
					= (SGIXYFigureDialogObserver)list.get(ii);
				final Color color1 = grid1.getColor();
				if( color0.equals(color1) == false )
				{
					color = null;
					break;
				}
			}
		}


		this.setAutoFlag( autoRange );
		this.setStepXValue( stepValueX );
		this.setStepYValue( stepValueY );
		this.setBaseXValue( baselineValueX );
		this.setBaseYValue( baselineValueY );
		this.setLineWidth( lineWidth );
		this.setLineType( lineType );
		this.setLineColor( color );

		this.setGridVisible( gridVisible );


		return true;
	}



	/**
	 * 
	 */
	public boolean setPropertiesToListeners( SGIPropertyDialogObserver l )
	{

		SGIXYFigureDialogObserver figure = (SGIXYFigureDialogObserver)l;


		// x
		final Number x = this.getFigureX();
		if( x!=null )
		{
			figure.setFigureX( x.floatValue()/CM_POINT_RATIO );
		}


		// y
		final Number y = this.getFigureY();
		if( y!=null )
		{
			figure.setFigureY( y.floatValue()/CM_POINT_RATIO );
		}

		
		// width
		final Number width = this.getFigureWidth();
		if( width!=null )
		{
			figure.setFigureWidth( width.floatValue()/CM_POINT_RATIO );
		}


		// height
		final Number height = this.getFigureHeight();
		if( height!=null )
		{
			figure.setFigureHeight( height.floatValue()/CM_POINT_RATIO );
		}


		// space line and number
		final Number spaceLN = this.getSpaceLineAndNumber();
		if( spaceLN!=null )
		{
			figure.setSpaceAxisLineAndNumber( spaceLN.floatValue()/CM_POINT_RATIO );
		}


		// space number and title
		final Number spaceNT = this.getSpaceNumberAndTitle();
		if( spaceNT!=null )
		{
			figure.setSpaceNumberAndTitle( spaceNT.floatValue()/CM_POINT_RATIO );
		}


		// transparent
		final Boolean transparent = this.isFigureTransparent();
		if( transparent!=null )
		{
			figure.setTransparent( transparent.booleanValue() );
		}


		// legend visible
		final Boolean legendVisible = this.getFigureLegendVisible();
		if( legendVisible!=null )
		{
			figure.setLegendVisible( legendVisible.booleanValue() );
		}


		// background color
		final Color bgColor = this.getFigureBackgroundColor();
		if( bgColor!=null )
		{
			figure.setBackgroundColor(bgColor);
		}


		// grid properties
		if( this.isGridTabEnable() )
		{
			if( this.setPropertiesToGridListeners( figure ) == false )
			{
				return false;
			}
		}

		return true;
	}



	private boolean setPropertiesToGridListeners( SGIXYFigureDialogObserver l )
	{

		SGIXYFigureDialogObserver grid = (SGIXYFigureDialogObserver)l;

		final int xConfig = this.mAxesButtonGroup.getXAxisConfiguration();
		final int yConfig = this.mAxesButtonGroup.getYAxisConfiguration();
	

		// set the related axes
		if( xConfig!=-1 & yConfig!=-1 )
		{
			grid.setAxisConfiguration( xConfig, yConfig );
		}


		Boolean auto = this.getAutoFlag();
		if( auto!=null )
		{
			if( grid.setAutoRangeFlag( auto.booleanValue() ) == false )
			{
				return false;
			}
		}

		Boolean visible = this.getGridVisible();
		if( visible!=null )
		{
			if( grid.setGridVisible( visible.booleanValue() ) == false )
			{
				return false;
			}
		}

		Number baseX = this.getBaseXValue();
		if( baseX!=null )
		{
			if( grid.setBaselineValueX( baseX.doubleValue() ) == false )
			{
				return false;
			}
		}

		Number baseY = this.getBaseYValue();
		if( baseY!=null )
		{
			if( grid.setBaselineValueY( baseY.doubleValue() ) == false )
			{
				return false;
			}
		}

		Number stepX = this.getStepXValue();
		if( stepX!=null )
		{
			if( grid.setStepValueX( stepX.doubleValue() ) == false )
			{
				return false;
			}
		}

		Number stepY = this.getStepYValue();
		if( stepY!=null )
		{
			if( grid.setStepValueY( stepY.doubleValue() ) == false )
			{
				return false;
			}
		}

		Number lineWidth = this.getLineWidth();
		if( lineWidth!=null )
		{
			if( grid.setLineWidth( lineWidth.floatValue() ) == false )
			{
				return false;
			}
		}
		
		final int type = this.getLineType();
		if( type!=-1 )
		{
			if( grid.setLineType( type ) == false )
			{
				return false;
			}
		}
		
		final Color cl = this.getLineColor();
		if( cl!=null )
		{
			if( grid.setColor( cl ) == false )
			{
				return false;
			}
		}

		return true;
	}



	/**
	 * Check step values.
	 * @return
	 */
	protected boolean hasValidInputValues()
	{
		if( super.hasValidInputValues() == false )
		{
			return false;
		}
		
		Boolean auto = this.getAutoFlag();
		if( auto!=null )
		{
			if( auto.booleanValue() == false )
			{
				Number stepX = this.getStepXValue();
				if( stepX!=null )
				{
					if( stepX.doubleValue() < 0.0 )
					{
						return false;
					}
				}

				Number stepY = this.getStepYValue();
				if( stepY!=null )
				{
					if( stepY.doubleValue() < 0.0 )
					{
						return false;
					}
				}
			}
		}
		
		return true;
	}


}


