1
2
3
4
5
6
7 package org.utgenome.gwt.utgb.server.app;
8
9 import java.awt.Graphics2D;
10 import java.awt.image.BufferedImage;
11 import java.io.IOException;
12
13 import javax.imageio.ImageIO;
14 import javax.servlet.ServletException;
15 import javax.servlet.http.HttpServletRequest;
16 import javax.servlet.http.HttpServletResponse;
17
18 import org.utgenome.gwt.utgb.server.WebTrackBase;
19 import org.utgenome.gwt.utgb.server.util.graphic.GraphicUtil;
20 import org.xerial.util.log.Logger;
21
22
23
24
25
26 public class Transparent extends WebTrackBase {
27 private static final long serialVersionUID = 1L;
28 private static Logger _logger = Logger.getLogger(Transparent.class);
29
30 public String color = "000000";
31 public float opacity = 0.1f;
32
33 public Transparent() {
34 }
35
36 @Override
37 public void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
38
39 final int w = 1;
40 BufferedImage b = new BufferedImage(w, w, BufferedImage.TYPE_INT_ARGB);
41 Graphics2D g = b.createGraphics();
42
43 g.setColor(GraphicUtil.parseColor(color, (int) (255 * opacity)));
44 g.fillRect(0, 0, w, w);
45 response.setContentType("image/png");
46 ImageIO.write(b, "png", response.getOutputStream());
47
48 }
49
50 }