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 import com.google.common.base.Functions;
16
17 import edu.uci.ics.jung.visualization.util.VertexShapeFactory;
18
19
20
21
22
23
24
25 public abstract class AbstractVertexShapeTransformer<V> implements SettableVertexShapeTransformer<V>
26 {
27 protected Function<? super V,Integer> vsf;
28 protected Function<? super V,Float> varf;
29 protected VertexShapeFactory<V> factory;
30 public final static int DEFAULT_SIZE = 8;
31 public final static float DEFAULT_ASPECT_RATIO = 1.0f;
32
33 public AbstractVertexShapeTransformer(Function<? super V,Integer> vsf, Function<? super V,Float> varf)
34 {
35 this.vsf = vsf;
36 this.varf = varf;
37 factory = new VertexShapeFactory<V>(vsf, varf);
38 }
39
40 public AbstractVertexShapeTransformer()
41 {
42 this(Functions.constant(DEFAULT_SIZE),
43 Functions.constant(DEFAULT_ASPECT_RATIO));
44 }
45
46 public void setSizeTransformer(Function<V,Integer> vsf)
47 {
48 this.vsf = vsf;
49 factory = new VertexShapeFactory<V>(vsf, varf);
50 }
51
52 public void setAspectRatioTransformer(Function<V,Float> varf)
53 {
54 this.varf = varf;
55 factory = new VertexShapeFactory<V>(vsf, varf);
56 }
57 }