Skip to main content
summaryrefslogtreecommitdiffstats
blob: 6986aecbcaa2a1baf2498f1162e9e46969adae5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.jface.text.source;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;

/**
 * Extension interface for <code>IAnnotationAccess</code>.
 * Allows to get a label for the annotation's type.
 * </code>.
 * 
 * @since 3.0
 */
public interface IAnnotationAccessExtension {
	
	/**
	 * The default annotation layer.
	 */
	static final int DEFAULT_LAYER= IAnnotationPresentation.DEFAULT_LAYER;

	/**
	 * Returns the label for the given annotation's type.
	 * 
	 * @param annotation the annotation
	 * @return the label the given annotation's type or <code>null</code> if no such label exists
	 */
	String getTypeLabel(Annotation annotation);
	
	/**
	 * Returns the layer for given annotation. Annotations are considered
	 * being located at layers and are considered being painted starting with
	 * layer 0 upwards. Thus an annotation at layer 5 will be drawn on top of
	 * all co-located annotations at the layers 4 - 0.
	 * 
	 * @param annotation the annotation
	 * @return the layer of the given annotation
	 */
	int getLayer(Annotation annotation);
	
	/**
	 * Draws a graphical representation of the given annotation within the given bounds.
	 * 
	 * @param annotation the given annotation
	 * @param gc the drawing GC
	 * @param canvas the canvas to draw on
	 * @param bounds the bounds inside the canvas to draw on
	 */
	void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds);
	
	/**
	 * Returns <code>true</code> if painting <code>annotation</code> will produce something
	 * meaningful, <code>false</code> if not. E.g. if no image is available.
	 * 
	 * @param annotation the annotation to check for paintability
	 * @return <code>true</code> if painting <code>annotation</code> will succeed
	 */
	boolean isPaintable(Annotation annotation);
	
	/**
	 * Returns <code>true</code> if the given annotation is of the given type
	 * or <code>false</code> otherwise.
	 * 
	 * @param annotationType the annotation type
	 * @param potentialSupertype the potential super annotation type
	 * @return <code>true</code> if annotation type is a subtype of the potential annotation super type
	 */
	boolean isSubtype(Object annotationType, Object potentialSupertype);
	
	/**
	 * Returns the list of super types for the given annotation type. This does not include the type 
	 * itself. The index in the array of super types indicates the length of the path in the hierarchy
	 * graph to the given annotation type.
	 * 
	 * @param annotationType the annotation type to check
	 * @return the super types for the given annotation type
	 */
	Object[] getSupertypes(Object annotationType);
}

Back to the top