1 package edu.uci.ics.jung.visualization;
2
3 import java.awt.Shape;
4 import java.awt.geom.PathIterator;
5 import java.awt.image.BufferedImage;
6
7 import edu.uci.ics.jung.visualization.util.ImageShapeUtils;
8 import junit.framework.TestCase;
9
10 public class TestImageShaper extends TestCase {
11
12 BufferedImage image;
13
14 @Override
15 protected void setUp() throws Exception {
16 super.setUp();
17 int width = 6;
18 int height = 5;
19 image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
20 for(int i=0; i<height; i++) {
21 for(int j=0; j<width; j++) {
22 image.setRGB(j, i, 0x00000000);
23
24
25
26
27 }
28 }
29 image.setRGB(3, 1, 0xffffffff);
30 image.setRGB(4, 1, 0xffffffff);
31 image.setRGB(2, 2, 0xffffffff);
32 image.setRGB(4, 2, 0xffffffff);
33 image.setRGB(1, 3, 0xffffffff);
34 image.setRGB(2, 3, 0xffffffff);
35 image.setRGB(3, 3, 0xffffffff);
36 image.setRGB(4, 3, 0xffffffff);
37 }
38
39 public void testShaper() {
40 Shape shape = ImageShapeUtils.getShape(image, 30);
41
42 float[] seg = new float[6];
43 for (PathIterator i = shape.getPathIterator(null, 1); !i.isDone(); i
44 .next()) {
45 int ret = i.currentSegment(seg);
46
47
48
49
50
51
52
53 }
54 }
55 }