Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gui.controls.FactoryMap.java

Here you can find all the information about the file org.dgpf.gui.controls.FactoryMap.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    : 06.07.2006 15:44:24
 * Original Filename: org.dgpf.gui.controls.DGPFFactoryMap.java
 * Version          : 1.0
 * Last modification: 06.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.util.Map;

import org.dgpf.gui.InternalFrame;
import org.sfc.collections.Collections;
import org.sfc.meta.BoundedDoubleProperty;
import org.sfc.meta.BoundedIntProperty;
import org.sfc.meta.BoundedLongProperty;
import org.sfc.meta.Property;
import org.sfc.meta.PropertyPort;
import org.sfc.meta.TimeProperty;
import org.sfc.utils.Typesafe;

/**
 * This class contains the factories that create dgpf controls.
 * 
 * @author Alexander Podlich
 */

public final class FactoryMap implements IControlFactory
  {

  /**
   * The shared singleton instance of the factory map.
   */

  public static final FactoryMap            INSTANCE = new FactoryMap();

  /**
   * The internal factory map.
   */

  private final Map<Class, IControlFactory> m_map;

  /**
   * The hidden constructor.
   */

  private FactoryMap()
    {
    super();
    this.m_map = Collections.create_map(-1);

    // for a property, the base class of all properties
    this.m_map.put(Property.classnew IControlFactory()
      {

        public IControl create(InternalFrame p_frame, PropertyPort p_pPort)
          {
          return new PropertyControl(p_frame, p_pPort);
          }

      });

    // for a time property
    this.m_map.put(TimeProperty.classnew IControlFactory()
      {

        public IControl create(InternalFrame p_frame, PropertyPort p_pPort)
          {
          return new TimePropertyControl();
          }

      });

    // for a bounded int property
    this.m_map.put(BoundedIntProperty.classnew IControlFactory()
      {

        public IControl create(InternalFrame p_frame, PropertyPort p_pPort)
          {
          return new BoundedIntPropertyControl(p_frame, p_pPort);
          }

      });

    // for a bounded long property
    this.m_map.put(BoundedLongProperty.classnew IControlFactory()
      {

        public IControl create(InternalFrame p_frame, PropertyPort p_pPort)
          {
          return new BoundedLongPropertyControl(p_frame, p_pPort);
          }

      });

    // for a bounded double property
    this.m_map.put(BoundedDoubleProperty.classnew IControlFactory()
      {

        public IControl create(InternalFrame p_frame, PropertyPort p_pPort)
          {
          return new BoundedDoublePropertyControl(p_frame, p_pPort);
          }

      });

    }

  /**
   * This method creates a IDGPFControl.
   * 
   * @param p_frame
   *          is the <code>DGPFInternalFrame</code> this
   *          <code>Component</code> belongs to.
   * @param p_pPort
   *          The property port.
   * @return The JComponent.
   */

  public IControl create(InternalFrame p_frame, PropertyPort p_pPort)
    {
    Class<?> l_c;
    IControlFactory l_controlFactory;

    for(l_c = Typesafe.cast(p_pPort.get_property().getClass()); l_c != null; l_c = l_c
        .getSuperclass())
      {
      l_controlFactory = this.m_map.get(l_c);
      if(l_controlFactory != null)
        {
        return l_controlFactory.create(p_frame, p_pPort);
        }
      }
    return null;
    }
  }

File Information:

file name:FactoryMap.java
package:org.dgpf.gui.controls
qualified name:org.dgpf.gui.controls.FactoryMap.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gui/controls/FactoryMap.java
size:4.078 KB (4176 B)
uploaded: 2015-07-22 04:10:58 GMT+0000
last update: 2006-09-24 23:47:04 GMT+0000
last access: 2017-11-21 15:47:00 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-21 15:47:00 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo