1
2
3
4
5
6
7
8
9
10
11
12 package edu.uci.ics.jung.visualization.decorators;
13
14 import com.google.common.base.Function;
15
16 import edu.uci.ics.jung.graph.Graph;
17 import edu.uci.ics.jung.graph.util.Context;
18 import edu.uci.ics.jung.graph.util.EdgeType;
19
20
21
22
23
24
25
26 public class ConstantDirectionalEdgeValueTransformer<V,E> implements Function<Context<Graph<V,E>,E>,Number>
27 {
28 protected Double undirected_value;
29 protected Double directed_value;
30
31
32
33
34
35
36 public ConstantDirectionalEdgeValueTransformer(double undirected, double directed)
37 {
38 this.undirected_value = new Double(undirected);
39 this.directed_value = new Double(directed);
40 }
41
42 public Number apply(Context<Graph<V,E>,E> context) {
43 Graph<V,E> graph = context.graph;
44 E e = context.element;
45 if (graph.getEdgeType(e) == EdgeType.DIRECTED)
46 return directed_value;
47 else
48 return undirected_value;
49 }
50
51
52
53
54
55 public void setUndirectedValue(double value)
56 {
57 this.undirected_value = value;
58 }
59
60
61
62
63
64 public void setDirectedValue(double value)
65 {
66 this.directed_value = value;
67 }
68 }