Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gui.controls.ControlMap.java

Here you can find all the information about the file org.dgpf.gui.controls.ControlMap.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Alexander Podlich
 * 
 * E-Mail           : podlich@student.uni-kassel.de
 * Creation Date    : 04.07.2006 15:39:44
 * Original Filename: org.dgpf.gui.controls.DGPFControlMap.java
 * Version          : 1.0
 * Last modification: 04.07.2006
 * Last modified by : Alexander Podlich
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" 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.
 */


package org.dgpf.gui.controls;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Map;

import javax.swing.JComponent;
import javax.swing.JPanel;

import org.dgpf.gui.InternalFrame;
import org.dgpf.gui.components.BorderedPanel;
import org.dgpf.gui.utils.Layout;
import org.dgpf.search.api.SearchState;
import org.sfc.collections.Collections;
import org.sfc.meta.PropertyPort;

/**
 * This class makes it possible to get the right JComponent for a property.
 * 
 * @author Alexander Podlich
 */

public class ControlMap
  {

  /**
   * This hash map contains the objects of the gui elements.
   */

  private Map<PropertyPort, Object> m_map;

  /**
   * Default constructor.
   */

  public ControlMap()
    {
    this.m_map = Collections.create_map(-1);
    }

  /**
   * The update method.
   * 
   * @param p_pPort
   *          The PropertyPort
   * @param p_searchState
   *          The search state to display.
   */

  public void update(PropertyPort p_pPort, SearchState<?> p_searchState)
    {
    Object l_object;
    IControl[] l_controlArray;

    l_object = this.m_map.get(p_pPort);
    if(l_object != null)
      {
      if(l_object instanceof IControl)
        {
        ((IControl) l_object).update(p_pPort, p_searchState, -1);
        }
      else
        {
        if(l_object instanceof IControl[])
          {
          l_controlArray = ((IControl[]) l_object);
          for(int i = (l_controlArray.length - 1); i >= 0; i--)
            {
            l_controlArray[i].update(p_pPort, p_searchState, i);
            }
          }
        }
      }
    }

  /**
   * The create method.
   * 
   * @param p_frame
   *          is the <code>DGPFInternalFrame</code> this
   *          <code>Component</code> belongs to.
   * @param p_pPort
   *          The PropertyPort.
   * @param p_searchState
   *          The search state to display.
   * @return A JComponent to be added to the owning control.
   */

  public JComponent create(InternalFrame p_frame, PropertyPort p_pPort,
      SearchState<?> p_searchState)
    {
    IControl l_dgpfControl;
    IControl[] l_dgpfControlOfArray;
    JPanel l_panelBox, l_panel;

    if(p_pPort.is_array())
      {
      int l_count = p_pPort.get_count(p_searchState);
      l_dgpfControlOfArray = new IControl[l_count];

      for(int l_i = 0; l_i < l_count; ++l_i)
        {
        l_dgpfControlOfArray[l_i] = FactoryMap.INSTANCE.create(p_frame,
            p_pPort);
        }

      l_panelBox = new JPanel(new GridBagLayout());

      for(int l_i = 0; l_i < l_dgpfControlOfArray.length; ++l_i)
        {
        l_panel = new BorderedPanel(String.valueOf(l_i));
        l_panel.setLayout(new GridBagLayout());
        Layout.set_constraints(l_panel, l_dgpfControlOfArray[l_i].get(),
            1.0, 1.0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.LINE_START, GridBagConstraints.REMAINDER,
            new Insets(3, 3, 3, 3));
        Layout.set_constraints(l_panelBox, l_panel, 1.0, 1.0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START,
            GridBagConstraints.REMAINDER, new Insets(3, 3, 3, 3));
        }

      this.m_map.put(p_pPort, l_dgpfControlOfArray);
      return l_panelBox;
      }

    l_dgpfControl = FactoryMap.INSTANCE.create(p_frame, p_pPort);
    this.m_map.put(p_pPort, l_dgpfControl);
    return l_dgpfControl.get();
    }
  }

File Information:

file name:ControlMap.java
package:org.dgpf.gui.controls
qualified name:org.dgpf.gui.controls.ControlMap.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gui/controls/ControlMap.java
size:4.429 KB (4536 B)
uploaded: 2015-07-22 04:10:58 GMT+0000
last update: 2006-09-24 23:47:04 GMT+0000
last access: 2017-11-20 19:03:20 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-20 19:03:20 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo