Package jsynoptic.builtin.ui

Source Code of jsynoptic.builtin.ui.PlotPropertiesPanel

/* ========================
* 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: PlotPropertiesPanel.java,v 1.11 2008/11/27 10:53:15 ogor Exp $
*
* Changes
* -------
* 27 juin 2005 : Initial public release (CC);
*
*/
package jsynoptic.builtin.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;

import jsynoptic.builtin.Plot;
import jsynoptic.builtin.Plot.PlotPropertiesNames;

import simtools.ui.JPropertiesPanel;
import simtools.ui.MenuResourceBundle;
import simtools.ui.ResourceFinder;

/**
* A panel to display/edit plot properties
*
* @author cazenave_c
*/
public class PlotPropertiesPanel extends JPropertiesPanel{

  protected JTextField tftitle;
 
  protected JCheckBox cblegend, cbCurveInformation;
  protected JPanel plotPropertiesPane, curvePane, limitPane, axisPane;
 
  protected static MenuResourceBundle  resources = (MenuResourceBundle)ResourceFinder.get(Plot.class);
 
  protected int curvesSize;
  protected CurvePropertiesPanel curvProp;
  protected LimitPropertiesPanel limitProp;
 
  protected AxePropertiesPanel[] axeprop;

  public PlotPropertiesPanel(int curvesSize, String shapeName) {
    super(shapeName);
    this.curvesSize=curvesSize;
    createContent();
  }
 
  protected void createContent(){

    JTabbedPane plotPane = new JTabbedPane();

    // Axis pane
    JPanel axisPaneContainer = new JPanel (new BorderLayout());
    JLabel axisTitle = new JLabel(resources.getStringValue("axisLabel"));
    axisTitle.setFont(new Font("Dialog", Font.PLAIN,18));
    axisPaneContainer.add(axisTitle, BorderLayout.NORTH);
   
    axisPane = new JPanel ();
    axisPane.setLayout(new BoxLayout(axisPane, BoxLayout.Y_AXIS));
    axeprop=new AxePropertiesPanel[4];
   
    axisPane.add(axeprop[0]=new AxePropertiesPanel(resources.getStringValue("primXSection"), "primX", true, null));
    axisPane.add(axeprop[1]=new AxePropertiesPanel(resources.getStringValue("primYSection"), "primY", false, null));
    axisPane.add(axeprop[2]=new AxePropertiesPanel(resources.getStringValue("secXSection"), "secX", false, null));
    axisPane.add(axeprop[3]=new AxePropertiesPanel(resources.getStringValue("secYSection"), "secY", false, null));
    axisPaneContainer.add(axisPane,BorderLayout.CENTER );
   
    JPanel s1 = new JPanel (new BorderLayout());
    s1.add(axisPaneContainer, BorderLayout.NORTH);
    plotPane.addTab(resources.getString("axisLabel"), s1);
 
    // Curves pane
    JPanel curvePaneContainer = new JPanel (new BorderLayout());
    JLabel curveTitle = new JLabel(resources.getStringValue("curveLabel"));
    curveTitle.setFont(new Font("Dialog", Font.PLAIN,18));
    curvePaneContainer.add(curveTitle, BorderLayout.NORTH);
   
    curvePane = new JPanel ();
    curvePane.setLayout(new BoxLayout(curvePane, BoxLayout.Y_AXIS));

    curvProp= createCurvePropertiesPanel()
    curvePane.add(curvProp);
   
    curvePaneContainer.add(curvePane,BorderLayout.CENTER);
   
    JPanel s2 = new JPanel (new BorderLayout());
    s2.add(curvePaneContainer, BorderLayout.NORTH);
    plotPane.addTab(resources.getString("curveLabel"), s2);
   
   
    //  Limit pane
    JPanel limitPaneContainer = new JPanel (new BorderLayout());
    JLabel limitTitle = new JLabel(resources.getStringValue("limitLabel"));
    limitTitle.setFont(new Font("Dialog", Font.PLAIN,18));
    limitPaneContainer.add(limitTitle, BorderLayout.NORTH);
   
    limitPane = new JPanel ();
    limitPane.setLayout(new BoxLayout(limitPane, BoxLayout.Y_AXIS));

    limitProp=new LimitPropertiesPanel(resources);
    limitPane.add(limitProp);
   
    limitPaneContainer.add(limitPane,BorderLayout.CENTER);
   
    JPanel l = new JPanel (new BorderLayout());
    l.add(limitPaneContainer, BorderLayout.NORTH);
    plotPane.addTab(resources.getString("limitLabel"), l);


   
    // Plot settings pane
    JPanel plotSettingsContainer= new JPanel (new BorderLayout());
    JLabel plotTitle = new JLabel(resources.getStringValue("plotLabel"));
    plotTitle.setFont(new Font("Dialog", Font.PLAIN,18));
    plotSettingsContainer.add(plotTitle, BorderLayout.NORTH);
   
    plotPropertiesPane = new JPanel ();
    plotPropertiesPane.setLayout(new BoxLayout(plotPropertiesPane, BoxLayout.Y_AXIS));
    plotPropertiesPane.add(Box.createVerticalStrut(10));
   
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEFT));
    title.add(new JLabel(resources.getStringValue("titleLabel")));
    tftitle = new JTextField(25);
    title.add(tftitle);
    plotPropertiesPane.add(title);
   
   
    plotPropertiesPane.add(Box.createVerticalStrut(10));
    JPanel legend = new JPanel (new FlowLayout(FlowLayout.LEFT));
    cblegend = resources.getCheckBox("legend", null);
    cbCurveInformation = resources.getCheckBox("curveInformation", null);
    legend.add(cblegend);
    legend.add(cbCurveInformation);
    plotPropertiesPane.add(legend);
   
    plotSettingsContainer.add(plotPropertiesPane,BorderLayout.CENTER);
    JPanel s3 = new JPanel (new BorderLayout());
    s3.add(plotSettingsContainer, BorderLayout.NORTH);
   
   
    plotPane.addTab(resources.getString("plotLabel"), s3);
   
   
    this.addOnCurrentRow(plotPane, 1, true, true, true);
  }

  // Properties management
  //----------------------------------------------------------------------
 
  public String[] getPropertyNames(){
    if (_propertyNames==null)
      _propertyNames = new PlotPropertiesNames().getPropertyNames();
    return _propertyNames;
  }
 
  /* (non-Javadoc)
   * @see simtools.util.NamedProperties#getPropertyValue(java.lang.String)
   */
  public Object getPropertyValue(String name) {
    Object res= null;
   
    for(int i=0;i<axeprop.length;i++){
      res=axeprop[i].getPropertyValue(name);
      if(res!=null){
        return res;
      }
    }
    res=curvProp.getPropertyValue(name);
    if(res!=null){
      return res;
    }
    res=limitProp.getPropertyValue(name);
    if(res!=null){
      return res;
    }
    if (name.equalsIgnoreCase("PLOT_TITLE")) {
      if(tftitle.getText().length()>0)
        res=tftitle.getText();
      else
        res=null;
    }
    else if (name.equalsIgnoreCase("PLOT_LEGEND")) {
      res=new Boolean(cblegend.isSelected());
    }
    else if (name.equalsIgnoreCase("PLOT_CURVE_INFORMATION")) {
      res=new Boolean(cbCurveInformation.isSelected());
    }

    return res;
  }
 
 
  protected CurvePropertiesPanel createCurvePropertiesPanel(){
      return  new CurvePropertiesPanel(resources);
  }
 
  /* (non-Javadoc)
   * @see simtools.util.NamedProperties#setPropertyValue(java.lang.String, java.lang.Object)
   */
  public void setPropertyValue(String name, Object value) {

    if (name.equalsIgnoreCase("PLOT_TITLE")){
      if(value instanceof String) {
        tftitle.setText((String) value);
      }
      else{
        tftitle.setText("");
      }
    }
    else if (name.equalsIgnoreCase("PLOT_LEGEND")&& (value instanceof Boolean)) {
      cblegend.setSelected(((Boolean)value).booleanValue());
    }
    else if (name.equalsIgnoreCase("PLOT_CURVE_INFORMATION")&& (value instanceof Boolean)) {
      cbCurveInformation.setSelected(((Boolean)value).booleanValue());
    }
    else{
      for(int i=0;i<axeprop.length;i++){
        axeprop[i].setPropertyValue(name,value);
      }
      curvProp.setPropertyValue(name, value);
      limitProp.setPropertyValue(name, value);
    }
  }
}
TOP

Related Classes of jsynoptic.builtin.ui.PlotPropertiesPanel

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.