Package jsynoptic.builtin.ui

Source Code of jsynoptic.builtin.ui.LinePropertiesPanel

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2005, by :
*     Corporate:
*         EADS Astrium SAS
*         EADS CRC
*     Individual:
*         Claude Cazenave
*
* $Id: LinePropertiesPanel.java,v 1.10 2008/07/22 09:25:17 ogor Exp $
*
* Changes
* -------
* 20 jan 2005 : Initial public release (JB);
*
*/
package jsynoptic.builtin.ui;

import java.util.ResourceBundle;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import simtools.ui.GridBagPanel;
import simtools.ui.ResourceFinder;
import jsynoptic.builtin.LinesShape;
import jsynoptic.builtin.LinesShape.LineShapePropertiesNames;

/**
* A JPanel do display and change the properties of the SimpleShape
*/
public class LinePropertiesPanel extends PropertiesPanel1D {
    public static ResourceBundle resources = ResourceFinder.get(LinesShape.class);

    protected JTextArea taPoints;

    protected JLabel lpoints;

    protected JCheckBox cbClose;

    public LinePropertiesPanel(String shapeName) {
        super(true, false, true, true, shapeName);
       
        addOnCurrentRow(createContent(), 2, true, true, true);
    }

    /*
     * (non-Javadoc)
     *
     * @see jsynoptic.builtin.SimpleShape.PropertiesPanel#createContent()
     */
    public JComponent createContent() {
        lpoints = new JLabel(resources.getString("CouplesOfX,YPoints:"));
        taPoints = new JTextArea();
        taPoints.setText("");
        taPoints.setRows(5);
        JScrollPane jscPoints = new JScrollPane(taPoints);
        cbClose = new JCheckBox(resources.getString("CloseLine"), false);
        // Create line panel
        GridBagPanel linePanel = new GridBagPanel(resources.getString("Line"));
        linePanel.addOnCurrentRow(lpoints);
        linePanel.carriageReturn();
        linePanel.addOnCurrentRow(jscPoints, 1, true, true, true);
        linePanel.addOnCurrentRow(cbClose);
        return linePanel;
    }

    public String[] getPropertyNames() {
        if (_propertyNames == null) {
            _propertyNames = new LineShapePropertiesNames().getPropertyNames();
        }
        return _propertyNames;
    }

    /*
     * (non-Javadoc)
     *
     * @see simtools.ui.JPropertiesPanel#getPropertyValue(java.lang.String)
     */
    public Object getPropertyValue(String name) {
        Object res = super.getPropertyValue(name);
        if (name.equalsIgnoreCase("POINTS")) {
            res = taPoints.getText();
        } else if (name.equalsIgnoreCase("CLOSED")) {
            res = new Boolean(cbClose.isSelected());
        }
        return res;
    }

    /*
     * (non-Javadoc)
     *
     * @see simtools.ui.JPropertiesPanel#setPropertyValue(java.lang.String,
     *      java.lang.Object)
     */
    public void setPropertyValue(String name, Object value) {
        super.setPropertyValue(name, value);
        if (name.equalsIgnoreCase("POINTS")) {
            if (value instanceof String) {
                taPoints.setText((String) value);
            }
        } else if (name.equalsIgnoreCase("CLOSED")) {
            if (value instanceof Boolean) {
                cbClose.setSelected(((Boolean) value).booleanValue());
            }
        }
    }
}
TOP

Related Classes of jsynoptic.builtin.ui.LinePropertiesPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.