1 /******************************************************************************* 2 * Copyright (c) 2000, 2007 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jface.text.source; 15 16 import org.eclipse.swt.graphics.GC; 17 import org.eclipse.swt.graphics.Rectangle; 18 import org.eclipse.swt.widgets.Canvas; 19 20 /** 21 * Extension interface for {@link org.eclipse.jface.text.source.IAnnotationAccess}. 22 * <p> 23 * This interface replaces the methods of <code>IAnnotationAccess</code>. 24 * </p> 25 * <p> 26 * This interface provides 27 * </p> 28 * <ul> 29 * <li>a label for the annotation type of a given annotation</li> 30 * <li>the paint layer of a given annotation</li> 31 * <li>means to paint a given annotation</li> 32 * <li>information about the type hierarchy of the annotation type of a given annotation</li> 33 * </ul> 34 * 35 * @see org.eclipse.jface.text.source.IAnnotationAccess 36 * @since 3.0 37 */ 38 public interface IAnnotationAccessExtension { 39 40 /** 41 * The default annotation layer. 42 */ 43 static final int DEFAULT_LAYER= IAnnotationPresentation.DEFAULT_LAYER; 44 45 /** 46 * Returns the label for the given annotation's type. 47 * 48 * @param annotation the annotation 49 * @return the label the given annotation's type or <code>null</code> if no such label exists 50 */ getTypeLabel(Annotation annotation)51 String getTypeLabel(Annotation annotation); 52 53 /** 54 * Returns the layer for given annotation. Annotations are considered 55 * being located at layers and are considered being painted starting with 56 * layer 0 upwards. Thus an annotation at layer 5 will be drawn on top of 57 * all co-located annotations at the layers 4 - 0. 58 * 59 * @param annotation the annotation 60 * @return the layer of the given annotation 61 */ getLayer(Annotation annotation)62 int getLayer(Annotation annotation); 63 64 /** 65 * Draws a graphical representation of the given annotation within the given bounds. 66 * <p> 67 * <em>Note that this method is not used when drawing annotations on the editor's 68 * text widget. This is handled trough a {@link org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy}.</em> 69 * </p> 70 * @param annotation the given annotation 71 * @param gc the drawing GC 72 * @param canvas the canvas to draw on 73 * @param bounds the bounds inside the canvas to draw on 74 */ paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds)75 void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds); 76 77 /** 78 * Returns <code>true</code> if painting <code>annotation</code> will produce something 79 * meaningful, <code>false</code> if not. E.g. if no image is available. 80 * <p> 81 * <em>Note that this method is not used when drawing annotations on the editor's 82 * text widget. This is handled trough a {@link org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy}.</em> 83 * </p> 84 * @param annotation the annotation to check whether it can be painted 85 * @return <code>true</code> if painting <code>annotation</code> will succeed 86 */ isPaintable(Annotation annotation)87 boolean isPaintable(Annotation annotation); 88 89 /** 90 * Returns <code>true</code> if the given annotation is of the given type 91 * or <code>false</code> otherwise. 92 * 93 * @param annotationType the annotation type 94 * @param potentialSupertype the potential super annotation type 95 * @return <code>true</code> if annotation type is a sub-type of the potential annotation super type 96 */ isSubtype(Object annotationType, Object potentialSupertype)97 boolean isSubtype(Object annotationType, Object potentialSupertype); 98 99 /** 100 * Returns the list of super types for the given annotation type. This does not include the type 101 * itself. The index in the array of super types indicates the length of the path in the hierarchy 102 * graph to the given annotation type. 103 * 104 * @param annotationType the annotation type to check 105 * @return the super types for the given annotation type 106 */ getSupertypes(Object annotationType)107 Object[] getSupertypes(Object annotationType); 108 } 109