@Override public int getLayer(Annotation annotation) { if (annotation instanceof IAnnotationPresentation) { IAnnotationPresentation presentation = (IAnnotationPresentation) annotation; return presentation.getLayer(); } AnnotationPreference preference = getAnnotationPreference(annotation); if (preference != null) return preference.getPresentationLayer(); // backward compatibility, ignore exceptions, just return default layer try { Method method = annotation.getClass().getMethod("getLayer"); // $NON-NLS-1$ Integer result = (Integer) method.invoke(annotation); return result.intValue(); } catch (SecurityException x) { } catch (IllegalArgumentException x) { } catch (NoSuchMethodException x) { } catch (IllegalAccessException x) { } catch (InvocationTargetException x) { } return IAnnotationAccessExtension.DEFAULT_LAYER; }
@Override public void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds) { if (annotation instanceof IAnnotationPresentation) { IAnnotationPresentation presentation = (IAnnotationPresentation) annotation; presentation.paint(gc, canvas, bounds); return; } AnnotationPreference preference = getAnnotationPreference(annotation); if (preference != null) { Object type = getType(annotation); String annotationType = (type == null ? null : type.toString()); Image image = getImage(annotation, preference, annotationType); if (image != null) { ImageUtilities.drawImage(image, gc, canvas, bounds, SWT.CENTER, SWT.TOP); return; } } // backward compatibility, ignore exceptions, just don't paint try { Method method = annotation .getClass() .getMethod( "paint", new Class[] {GC.class, Canvas.class, Rectangle.class}); // $NON-NLS-1$ method.invoke(annotation, new Object[] {gc, canvas, bounds}); } catch (SecurityException x) { } catch (IllegalArgumentException x) { } catch (NoSuchMethodException x) { } catch (IllegalAccessException x) { } catch (InvocationTargetException x) { } }