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/>.
21
21
package org.gephi.ranking.api;
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.
28
* Transformers can be applied to a subset of values using lower/bound filter
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>
25
38
* @author Mathieu Bastian
27
40
public interface Transformer<Target> {
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";
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
29
52
public void setLowerBound(float lowerBound);
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
31
59
public void setUpperBound(float upperBound);
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
33
66
public float getLowerBound();
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
35
73
public float getUpperBound();
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
37
85
public boolean isInBounds(float value);
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>
39
95
public Object transform(Target target, float normalizedValue);
41
public void setInterpolator(Interpolator interpolator);