webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java
changeset 95 36ace6ba1dc1
parent 82 9ac7acee7d9f
child 96 2eeaa41236c3
     1.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java	Sun Sep 13 16:48:54 2009 +0200
     1.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Games.java	Fri Sep 18 23:28:13 2009 +0200
     1.3 @@ -29,6 +29,7 @@
     1.4  import cz.xelfi.quoridor.IllegalPositionException;
     1.5  import cz.xelfi.quoridor.webidor.*;
     1.6  import cz.xelfi.quoridor.Move;
     1.7 +import java.awt.Image;
     1.8  import java.io.BufferedReader;
     1.9  import java.io.BufferedWriter;
    1.10  import java.io.File;
    1.11 @@ -118,6 +119,17 @@
    1.12  
    1.13      @GET
    1.14      @Path("{id}")
    1.15 +    @Produces("image/png")
    1.16 +    public Image getBoardImage(@PathParam("id") String id) {
    1.17 +        Game g = findGame(id);
    1.18 +        if (g == null) {
    1.19 +            throw new IllegalArgumentException("Unknown game " + id);
    1.20 +        }
    1.21 +        return BoardImage.draw(g.getBoard());
    1.22 +    }
    1.23 +
    1.24 +    @GET
    1.25 +    @Path("{id}")
    1.26      @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
    1.27      public Game getBoardInfo(@PathParam("id") String id) {
    1.28          Game g = findGame(id);