View Javadoc

1   /*
2    * @(#)$Id: ArrowDescriptor.java 760 2009-08-25 20:10:41Z kurmannu $
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.descriptor;
28  
29  import java.awt.Graphics2D;
30  import java.awt.RenderingHints;
31  
32  import org.sigtec.ink.Note;
33  import org.ximtec.igesture.core.DigitalDescriptor;
34  
35  
36  /**
37   * @version 1.0 Nov 2006
38   * @author Ueli Kurmann, igesture@uelikurmann.ch
39   * @author Beat Signer, signer@inf.ethz.ch
40   */
41  public class ArrowDescriptor extends DigitalDescriptor {
42  
43     private static final int SPACE = 20;
44  
45  
46     public ArrowDescriptor() {
47        super();
48     }
49  
50  
51     @Override
52     public void getDigitalObject(Graphics2D graphic, Note note) {
53        int x1 = (int)note.getBounds2D().getMinX();
54        int x2 = (int)note.getBounds2D().getMaxX();
55        int y = (int)((note.getBounds2D().getMinY() + note.getBounds2D().getMaxY()) / 2);
56        int diff = (int)((note.getBounds2D().getMinY() - note.getBounds2D()
57              .getMaxY()) / 2);
58        graphic.setRenderingHint(RenderingHints.KEY_RENDERING,
59              RenderingHints.VALUE_RENDER_QUALITY);
60        graphic.drawLine(x1, y, x2, y);
61        graphic.drawLine(x2, y, x2 - SPACE, y - diff);
62        graphic.drawLine(x2, y, x2 - SPACE, y + diff);
63     } // getDigitalObject
64  
65  
66    @Override
67    public String getName() {
68      return this.getClass().getSimpleName();
69    }
70  
71  }