1
2
3
4
5
6
7
8
9
10
11 package edu.uci.ics.jung.visualization.transform.shape;
12
13 import java.awt.Graphics2D;
14 import java.awt.Shape;
15
16 import edu.uci.ics.jung.visualization.transform.BidirectionalTransformer;
17 import edu.uci.ics.jung.visualization.transform.HyperbolicTransformer;
18
19
20
21
22
23
24
25
26
27
28
29
30 public class TransformingFlatnessGraphics extends TransformingGraphics {
31
32 float flatness = 0;
33
34 public TransformingFlatnessGraphics(BidirectionalTransformer transformer) {
35 this(transformer, null);
36 }
37
38 public TransformingFlatnessGraphics(BidirectionalTransformer transformer, Graphics2D delegate) {
39 super(transformer, delegate);
40 }
41
42 public void draw(Shape s, float flatness) {
43 Shape shape = null;
44 if(transformer instanceof ShapeFlatnessTransformer) {
45 shape = ((ShapeFlatnessTransformer)transformer).transform(s, flatness);
46 } else {
47 shape = ((ShapeTransformer)transformer).transform(s);
48 }
49 delegate.draw(shape);
50
51 }
52
53 public void fill(Shape s, float flatness) {
54 Shape shape = null;
55 if(transformer instanceof HyperbolicTransformer) {
56 shape = ((HyperbolicShapeTransformer)transformer).transform(s, flatness);
57 } else {
58 shape = ((ShapeTransformer)transformer).transform(s);
59 }
60 delegate.fill(shape);
61 }
62 }