source: branches/MetisMQI/src/main/java/weka/datagenerators/ClusterDefinition.java

Last change on this file was 29, checked in by gnappo, 15 years ago

Taggata versione per la demo e aggiunto branch.

File size: 3.9 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 * ClusterDefinition.java
19 * Copyright (C) 2005 University of Waikato, Hamilton, New Zealand
20 *
21 */
22
23package weka.datagenerators;
24
25import weka.core.OptionHandler;
26import weka.core.RevisionHandler;
27import weka.core.Utils;
28
29import java.io.Serializable;
30import java.util.Enumeration;
31
32/**
33 * Ancestor to all ClusterDefinitions, i.e., subclasses that handle their
34 * own parameters that the cluster generator only passes on.
35 *
36 *
37 * @author FracPete (fracpete at waikato dot ac dot nz)
38 * @version $Revision: 1.5 $
39 */
40
41public abstract class ClusterDefinition
42  implements Serializable, OptionHandler, RevisionHandler {
43
44  /** for serialization */
45  private static final long serialVersionUID = -5950001207047429961L;
46
47  /** the parent of the cluster */
48  protected ClusterGenerator m_Parent;
49
50  /**
51   * initializes the cluster, without a parent cluster (necessary for GOE)
52   */
53  public ClusterDefinition() {
54    this(null);
55  }
56
57  /**
58   * initializes the cluster
59   *
60   * @param parent    the datagenerator this cluster belongs to
61   */
62  public ClusterDefinition(ClusterGenerator parent) {
63    m_Parent = parent;
64
65    try {
66      setDefaults();
67    }
68    catch (Exception e) {
69      e.printStackTrace();
70    }
71  }
72
73  /**
74   * sets the default values
75   *
76   * @throws Exception if setting of defaults fails
77   */
78  protected abstract void setDefaults() throws Exception;
79
80  /**
81   * Returns a string describing this data generator.
82   *
83   * @return a description of the data generator suitable for
84   * displaying in the explorer/experimenter gui
85   */
86  public String globalInfo() {
87    return "Contains informations about a certain cluster of a cluster generator.";
88  }
89
90  /**
91   * Returns an enumeration describing the available options.
92   *
93   * @return an enumeration of all the available options
94   */
95  public abstract Enumeration listOptions();
96
97  /**
98   * Parses a list of options for this object. <p/>
99   *
100   * For list of valid options see class description.<p/>
101   *
102   * @param options the list of options as an array of strings
103   * @throws Exception if an option is not supported
104   */
105  public abstract void setOptions(String[] options) throws Exception;
106
107  /**
108   * Gets the current settings of the datagenerator BIRCHCluster.
109   *
110   * @return an array of strings suitable for passing to setOptions
111   */
112  public abstract String[] getOptions();
113
114  /**
115   * returns the parent datagenerator this cluster belongs to
116   *
117   * @return the parent this cluster belongs to
118   */
119  public ClusterGenerator getParent() {
120    return m_Parent;
121  }
122
123  /**
124   * sets the parent datagenerator this cluster belongs to
125   *
126   * @param parent the parent datagenerator
127   */
128  public void setParent(ClusterGenerator parent) {
129    m_Parent = parent;
130  }
131 
132  /**
133   * Returns the tip text for this property
134   *
135   * @return tip text for this property suitable for
136   * displaying in the explorer/experimenter gui
137   */
138  public String parentTipText() {
139    return "The cluster generator this object belongs to.";
140  }
141
142  /**
143   * returns a string representation of the cluster
144   *
145   * @return the cluster definition as string
146   */
147  public String toString() {
148    return this.getClass().getName() + ": " + Utils.joinOptions(getOptions());
149  }
150}
Note: See TracBrowser for help on using the repository browser.