1   /*
2    *  Copyright (c) 1998-2005, The University of Sheffield.
3    *
4    *  This file is part of GATE (see http://gate.ac.uk/), and is free
5    *  software, licenced under the GNU Library General Public License,
6    *  Version 2, June1991.
7    *
8    *  A copy of this licence is included in the distribution in the file
9    *  licence.html, and is also available at http://gate.ac.uk/gate/licence.html.
10   *
11   *  Valentin Tablan 09/07/2001
12   *
13   *  $Id: AnnotationVisualResource.java,v 1.8 2005/01/11 13:51:31 ian Exp $
14   */
15  package gate.creole;
16  
17  import gate.Annotation;
18  import gate.VisualResource;
19  import gate.util.GateException;
20  
21  /**
22   * Visual Resources that display and/or edit annotations.
23   * This type of resources can be used to either display or edit existing
24   * annotations or to create new annotations.
25   */
26  public interface AnnotationVisualResource extends VisualResource {
27    /**
28     * Called by the GUI when this viewer/editor has to initialise itself for a
29     * specific annotation or text span.
30     * @param target the object which will always be a {@link gate.AnnotationSet}
31     */
32    public void setTarget(Object target);
33  
34  
35    /**
36     * Used when the viewer/editor has to display/edit an existing annotation
37     * @param ann the annotation to be displayed or edited
38     */
39    public void setAnnotation(Annotation ann);
40  
41    /**
42     * Used when the viewer has to create new annotations.
43     * @param startOffset the start offset of the span covered by the new
44     * annotation(s)
45     * @param endOffset the end offset of the span covered by the new
46     * annotation(s)
47     */
48    public void setSpan(Long startOffset, Long endOffset, String annotationType);
49  
50    /**
51     * Called by the GUI when the user has pressed the "OK" button. This should
52     * trigger the saving of the newly created annotation(s)
53     */
54    public void okAction() throws GateException;
55  
56    /**
57     * Called by the GUI when the user has pressed the "Cancel" button. This should
58     * trigger cleaning up action, if the editor has done any changes to the
59     * annotation sets or document or annotation
60     */
61    public void cancelAction() throws GateException;
62  
63  
64    /**
65     * Checks whether this viewer/editor can handle a specific annotation type.
66     */
67    public boolean canDisplayAnnotationType(String annotationType);
68  
69  }//public interface AnnotationVisualResource extends VisualResource