~gephi.team/gephi/0.8.1

« back to all changes in this revision

Viewing changes to RankingAPI/src/org/gephi/ranking/api/Transformer.java

  • Committer: Mathieu Bastian
  • Date: 2011-07-19 04:14:33 UTC
  • Revision ID: git-v1:fc8aece8315f8e214fdb55d8cd035682fd1ca44b
Major refactoring of the Ranking modules, and creation of SPIs for ranking builders and transformers. Creation of a RankingPlugin module with new ranking and transformers implementations. Simplification of the RankingAPI module and fit to conventions. Update of the DesktopRanking module with cleaner code and introduction of a RankingUIController and RankingUIModel to manage states. Deletion of the RankingResult mechanism and introduction of RankingEvent and RankingListener interfaces to manages ranking events. Documentation of the API and SPI, ready to be declared stable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
You should have received a copy of the GNU Affero General Public License
19
19
along with Gephi.  If not, see <http://www.gnu.org/licenses/>.
20
 
*/
 
20
 */
21
21
package org.gephi.ranking.api;
22
22
 
23
23
/**
24
 
 *
 
24
 * Transformers role is to transform nodes/edges numerical attributes 
 
25
 * to visual signs (e.g. color or sizes). It uses a normalized real number
 
26
 * between zero and one to output a meaningful value.
 
27
 * <p>
 
28
 * Transformers can be applied to a subset of values using lower/bound filter
 
29
 * values.
 
30
 * <p>
 
31
 * Default transformers implemented in the RankingPlugin:
 
32
 * <ul><li><b>RENDERABLE_COLOR:</b> Sets node/edge color</li>
 
33
 * <li><b>RENDERABLE_SIZE:</b> Sets node/edge size. For edges, the size is the weight.</li>
 
34
 * <li><b>LABEL_COLOR:</b> Sets label color.</li>
 
35
 * <li><b>LABEL_SIZE:</b> Sets label size. Note this is a multiplier.</li>
 
36
 * 
 
37
 * @see Ranking
25
38
 * @author Mathieu Bastian
26
39
 */
27
40
public interface Transformer<Target> {
28
41
 
 
42
    public static final String RENDERABLE_COLOR = "renderable_color";
 
43
    public static final String RENDERABLE_SIZE = "renderable_size";
 
44
    public static final String LABEL_COLOR = "label_color";
 
45
    public static final String LABEL_SIZE = "label_size";
 
46
 
 
47
    /**
 
48
     * Sets the lower filter bound. Values lower than this value won't be
 
49
     * transformed. By default the bound is set to zero, so no filtering.
 
50
     * @param lowerBound the lower bound filter value
 
51
     */
29
52
    public void setLowerBound(float lowerBound);
30
53
 
 
54
    /**
 
55
     * Sets the upper filter bound. Values upper than this value won't be
 
56
     * transformed. By default the bound is set to one, so no filtering.
 
57
     * @param upperBound the upper bound filter value
 
58
     */
31
59
    public void setUpperBound(float upperBound);
32
60
 
 
61
    /**
 
62
     * Returns the lower bound filter value. By default it's set to zero, so
 
63
     * filtering is disabled.
 
64
     * @return the lower bound filter value
 
65
     */
33
66
    public float getLowerBound();
34
67
 
 
68
    /**
 
69
     * Returns the upper bound filter value. By default it's set to one, so
 
70
     * filtering is disabled.
 
71
     * @return the upper bound filter value
 
72
     */
35
73
    public float getUpperBound();
36
74
 
 
75
    /**
 
76
     * Returns <code>true</code> if <code>value</code> is within the lower and
 
77
     * the upper bound. Typically, this is called before <code>transform()</code>
 
78
     * to know if a value can be processed. By default, this always returns <code>
 
79
     * true</code>, as lower bound is set ot zero and upper bound to one.
 
80
     * @param value the value to test if in bounds
 
81
     * @return <code>true</code> if value superior or equal to lowerBound and
 
82
     * value inferior or equal to upperBound, <code>false</code> otherwise
 
83
     * 
 
84
     */
37
85
    public boolean isInBounds(float value);
38
86
 
 
87
    /**
 
88
     * Transforms <code>target</code> with <code>normalizedValue</code> between
 
89
     * zero and one. The method also returns the transformed value, like the color
 
90
     * for instance for a color transformer.
 
91
     * @param target            the object to transform
 
92
     * @param normalizedValue   the ranking normalized value
 
93
     * @return                  the transformed value, or <code>null</code>
 
94
     */
39
95
    public Object transform(Target target, float normalizedValue);
40
 
 
41
 
    public void setInterpolator(Interpolator interpolator);
42
96
}