1
2
3
4
5
6
7
8
9
10
11
12 package edu.uci.ics.jung.visualization.decorators;
13
14 import java.awt.Shape;
15
16 import com.google.common.base.Function;
17
18 import edu.uci.ics.jung.graph.Graph;
19 import edu.uci.ics.jung.graph.util.Context;
20 import edu.uci.ics.jung.graph.util.EdgeType;
21 import edu.uci.ics.jung.visualization.util.ArrowFactory;
22
23
24
25
26
27
28
29 public class DirectionalEdgeArrowTransformer<V,E> implements Function<Context<Graph<V,E>,E>,Shape> {
30 protected Shape undirected_arrow;
31 protected Shape directed_arrow;
32
33 public DirectionalEdgeArrowTransformer(int length, int width, int notch_depth)
34 {
35 directed_arrow = ArrowFactory.getNotchedArrow(width, length, notch_depth);
36 undirected_arrow = ArrowFactory.getWedgeArrow(width, length);
37 }
38
39
40
41
42 public Shape apply(Context<Graph<V,E>,E> context)
43 {
44 if (context.graph.getEdgeType(context.element) == EdgeType.DIRECTED)
45 return directed_arrow;
46 else
47 return undirected_arrow;
48 }
49
50 }