View Javadoc

1   /*
2    * @(#)$Id: DrawEventHandler.java 799 2010-05-04 15:10:56Z bpuype $
3    *
4    * Author       :   Ueli Kurmann, igesture@uelikurmann.ch
5    *
6    * Purpose      : 
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         Reason
13   *
14   * Nov 24, 2006     ukurmann    Initial Release
15   * Mar 24, 2007     bsigner     Cleanup
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  
27  package org.ximtec.igesture.app.showcaseapp.eventhandler;
28  
29  import java.awt.Graphics2D;
30  import java.util.logging.Level;
31  import java.util.logging.Logger;
32  
33  import org.sigtec.ink.Note;
34  import org.ximtec.igesture.app.showcaseapp.Style;
35  import org.ximtec.igesture.core.DigitalDescriptor;
36  import org.ximtec.igesture.core.Result;
37  import org.ximtec.igesture.core.ResultSet;
38  import org.ximtec.igesture.event.GestureAction;
39  
40  
41  /**
42   * @version 1.0 Nov 2006
43   * @author Ueli Kurmann, igesture@uelikurmann.ch
44   * @author Beat Signer, signer@inf.ethz.ch
45   */
46  public class DrawEventHandler implements GestureAction {
47  
48     private static final Logger LOGGER = Logger.getLogger(DrawEventHandler.class
49           .getName());
50  
51     private static final String GESTURE_CLASS_NAME = "Gesture class name = ";
52  
53     private Graphics2D graphic;
54     private Style style;
55  
56  
57     public DrawEventHandler(Graphics2D graphic, Style style) {
58        this.graphic = graphic;
59        this.style = style;
60     }
61  
62  
63     public void actionPerformed(ResultSet resultSet) {
64        Result result = resultSet.getResult();
65        Note note = (Note) resultSet.getGesture().getGesture();
66        LOGGER.log(Level.INFO, GESTURE_CLASS_NAME + result.getGestureClassName());
67        graphic.setStroke(style.getStroke());
68        graphic.setColor(style.getColor());
69        DigitalDescriptor descriptor = result.getGestureClass().getDescriptor(
70              DigitalDescriptor.class);
71        descriptor.getDigitalObject(graphic, note);
72     } // run
73  
74  }