Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gui.charts.descriptors.PortDescriptorBase.java

Here you can find all the information about the file org.dgpf.gui.charts.descriptors.PortDescriptorBase.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    : 22.07.2006 15:34:38
 * Original Filename: org.dgpf.gui.components.PortDescriptor.java
 * Version          : 1.0
 * Last modification: 22.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.charts.descriptors;

import org.dgpf.search.api.SearchState;
import org.sfc.meta.PropertyPort;

/**
 * Saves the property port, the index (if property port is an array,
 * otherwise index is -1) and the name of the property.
 * 
 * @author Alexander Podlich
 */

public abstract class PortDescriptorBase implements
    Comparable<PortDescriptorBase>
  {

  /**
   * The property port.
   */

  final PropertyPort<?> m_pPort;

  /**
   * The index of the property
   */

  final int             m_index;

  /**
   * The name of the property
   */

  final String          m_name;

  /**
   * Constructor.
   * 
   * @param p_port
   *          The property port.
   * @param p_name
   *          The name of the property.
   */

  public PortDescriptorBase(PropertyPort<?> p_port, String p_name)
    {
    this.m_pPort = p_port;
    this.m_index = -1;
    this.m_name = p_name;
    }

  /**
   * Constructor.
   * 
   * @param p_port
   *          The property port.
   * @param p_index
   *          The index of the property.
   * @param p_name
   *          The name of the property.
   */

  public PortDescriptorBase(PropertyPort<?> p_port, int p_index,
      String p_name)
    {
    this.m_pPort = p_port;
    this.m_index = p_index;
    this.m_name = this.createName(p_name, p_index);
    }

  /**
   * Create the name internally.
   * 
   * @param p_name
   *          The translated name.
   * @param p_index
   *          The index.
   * @return The name to use.
   */

  String createName(String p_name, int p_index)
    {
    return p_name + " [" + p_index + "]";
    }

  /**
   * Obtain the value of the property refered to by this descriptor.
   * 
   * @param p_searchState
   *          The state object to obtain the property value from.
   * @return The value wanted.
   */

  public abstract double get(final SearchState<?> p_searchState);

  /**
   * Gets the string representation of the pPort.
   * 
   * @return The name of the property.
   */

  @Override
  public final String toString()
    {
    return this.m_name;
    }

  /**
   * Return the property port.
   * 
   * @return The property port.
   */

  public PropertyPort<?> getPropertyPort()
    {
    return this.m_pPort;
    }

  /**
   * Return the index.
   * 
   * @return The property port.
   */

  public int getIndex()
    {
    return this.m_index;
    }

  /**
   * @param p_pd
   *          The other port descriptor
   * @return Returns <code>1</code> if other port descriptor has a
   *         alphabetically smaller toString() value. <code>-1</code> if
   *         other other port descriptor has a alphabetically bigger
   *         toString() value.
   */

  public int compareTo(PortDescriptorBase p_pd)
    {
    if(this.toString().compareTo(p_pd.toString()) == 0)
      {
      int l_myHash = this.hashCode();
      int l_oHash = p_pd.hashCode();

      if(l_myHash < l_oHash)
        {
        return 1;
        }
      else
        if(l_myHash > l_oHash)
          {
          return -1;
          }
        else
          {
          return 0;
          }
      }
    return this.toString().compareTo(p_pd.toString());
    }

  }

File Information:

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