~ubuntu-branches/ubuntu/precise/weka/precise

« back to all changes in this revision

Viewing changes to weka/datagenerators/ClusterDefinition.java

  • Committer: Bazaar Package Importer
  • Author(s): Soeren Sonnenburg
  • Date: 2008-02-24 09:18:45 UTC
  • Revision ID: james.westby@ubuntu.com-20080224091845-1l8zy6fm6xipbzsr
Tags: upstream-3.5.7+tut1
ImportĀ upstreamĀ versionĀ 3.5.7+tut1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
23
package weka.datagenerators;
 
24
 
 
25
import weka.core.OptionHandler;
 
26
import weka.core.Utils;
 
27
 
 
28
import java.io.Serializable;
 
29
import java.util.Enumeration;
 
30
 
 
31
/**
 
32
 * Ancestor to all ClusterDefinitions, i.e., subclasses that handle their
 
33
 * own parameters that the cluster generator only passes on.
 
34
 *
 
35
 *
 
36
 * @author FracPete (fracpete at waikato dot ac dot nz)
 
37
 * @version $Revision: 1.4 $
 
38
 */
 
39
 
 
40
public abstract class ClusterDefinition
 
41
  implements Serializable, OptionHandler {
 
42
 
 
43
  /** for serialization */
 
44
  private static final long serialVersionUID = -5950001207047429961L;
 
45
 
 
46
  /** the parent of the cluster */
 
47
  protected ClusterGenerator m_Parent;
 
48
 
 
49
  /**
 
50
   * initializes the cluster, without a parent cluster (necessary for GOE)
 
51
   */
 
52
  public ClusterDefinition() {
 
53
    this(null);
 
54
  }
 
55
 
 
56
  /**
 
57
   * initializes the cluster
 
58
   *
 
59
   * @param parent    the datagenerator this cluster belongs to
 
60
   */
 
61
  public ClusterDefinition(ClusterGenerator parent) {
 
62
    m_Parent = parent;
 
63
 
 
64
    try {
 
65
      setDefaults();
 
66
    }
 
67
    catch (Exception e) {
 
68
      e.printStackTrace();
 
69
    }
 
70
  }
 
71
 
 
72
  /**
 
73
   * sets the default values
 
74
   * 
 
75
   * @throws Exception if setting of defaults fails
 
76
   */
 
77
  protected abstract void setDefaults() throws Exception;
 
78
 
 
79
  /**
 
80
   * Returns a string describing this data generator.
 
81
   *
 
82
   * @return a description of the data generator suitable for
 
83
   * displaying in the explorer/experimenter gui
 
84
   */
 
85
  public String globalInfo() {
 
86
    return "Contains informations about a certain cluster of a cluster generator.";
 
87
  }
 
88
 
 
89
  /**
 
90
   * Returns an enumeration describing the available options.
 
91
   *
 
92
   * @return an enumeration of all the available options
 
93
   */
 
94
  public abstract Enumeration listOptions();
 
95
 
 
96
  /**
 
97
   * Parses a list of options for this object. <p/>
 
98
   *
 
99
   * For list of valid options see class description.<p/>
 
100
   *
 
101
   * @param options the list of options as an array of strings
 
102
   * @throws Exception if an option is not supported
 
103
   */
 
104
  public abstract void setOptions(String[] options) throws Exception;
 
105
 
 
106
  /**
 
107
   * Gets the current settings of the datagenerator BIRCHCluster.
 
108
   *
 
109
   * @return an array of strings suitable for passing to setOptions
 
110
   */
 
111
  public abstract String[] getOptions();
 
112
 
 
113
  /**
 
114
   * returns the parent datagenerator this cluster belongs to
 
115
   * 
 
116
   * @return the parent this cluster belongs to
 
117
   */
 
118
  public ClusterGenerator getParent() {
 
119
    return m_Parent;
 
120
  }
 
121
 
 
122
  /**
 
123
   * sets the parent datagenerator this cluster belongs to
 
124
   * 
 
125
   * @param parent the parent datagenerator
 
126
   */
 
127
  public void setParent(ClusterGenerator parent) {
 
128
    m_Parent = parent;
 
129
  }
 
130
  
 
131
  /**
 
132
   * Returns the tip text for this property
 
133
   * 
 
134
   * @return tip text for this property suitable for
 
135
   * displaying in the explorer/experimenter gui
 
136
   */
 
137
  public String parentTipText() {
 
138
    return "The cluster generator this object belongs to.";
 
139
  }
 
140
 
 
141
  /**
 
142
   * returns a string representation of the cluster
 
143
   * 
 
144
   * @return the cluster definition as string
 
145
   */
 
146
  public String toString() {
 
147
    return this.getClass().getName() + ": " + Utils.joinOptions(getOptions());
 
148
  }
 
149
}