1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.utgb.server.app;
26
27 import java.awt.Graphics2D;
28 import java.awt.RenderingHints;
29 import java.awt.geom.Ellipse2D;
30 import java.awt.image.BufferedImage;
31 import java.io.IOException;
32
33 import javax.servlet.ServletException;
34 import javax.servlet.http.HttpServletRequest;
35 import javax.servlet.http.HttpServletResponse;
36
37 import org.utgenome.gwt.utgb.server.RequestHandlerBase;
38 import org.utgenome.gwt.utgb.server.util.graphic.GraphicUtil;
39 import org.xerial.util.log.Logger;
40
41
42
43
44
45
46
47 public class RoundCircle extends RequestHandlerBase {
48 private static final long serialVersionUID = 19443895944286732L;
49
50 private static Logger _logger = Logger.getLogger(RoundCircle.class);
51
52 public String color = "666666";
53 public int size = 4;
54 public float opacity = 1f;
55
56 @Override
57 public void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
58 if (size <= 0)
59 size = 1;
60 int canvasSize = size * 2;
61
62 BufferedImage circleImage = GraphicUtil.getTransparentBufferedImage(canvasSize, canvasSize);
63 Graphics2D g = GraphicUtil.getGraphics(circleImage);
64
65 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
66 Ellipse2D circle = new Ellipse2D.Double(0, 0, canvasSize, canvasSize);
67
68 g.setColor(GraphicUtil.parseColor(color, (int) (255 * opacity)));
69 g.fill(circle);
70
71 GraphicUtil.writeImage(circleImage, "png", response);
72 }
73 }