/** @param gc */ private void paintRanges(GC gc, Rectangle bounds) { // draw a rectangle for each range gc.setAlpha(200); for (RangeAnnotation a : items) { if (a == selectedAnnotation) { continue; } if (a.isDisposed()) continue; int visualLow = toVisualValue(a.getOffset()) + bounds.x; int visualHigh = toVisualValue(a.getLength()) + visualLow; if (visualLow < bounds.x + HANDLE_SIZE) { visualLow = bounds.x + HANDLE_SIZE; } if (visualHigh > bounds.x + bounds.width - HANDLE_SIZE) { visualHigh = bounds.x + bounds.width - HANDLE_SIZE; } Color fg = a.getForeground(); if (a == selectedAnnotation) { fg = gc.getDevice().getSystemColor(SWT.COLOR_WHITE); } if (fg == null) { fg = getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); } Color bg = a.getBackground(); if (bg == null) { bg = getDisplay().getSystemColor(SWT.COLOR_GRAY); } gc.setForeground(fg); gc.setBackground(bg); gc.fillRectangle(visualLow, bounds.y, visualHigh - visualLow, bounds.height - 1); gc.drawRectangle(visualLow, bounds.y, visualHigh - visualLow - 1, bounds.height - 1); } // paint the selected annotation if (selectedAnnotation != null) { RangeAnnotation a = selectedAnnotation; if (a.isDisposed()) return; int visualLow = toVisualValue(a.getOffset()) + bounds.x; int visualHigh = toVisualValue(a.getLength()) + visualLow; if (visualLow < bounds.x + HANDLE_SIZE) { visualLow = bounds.x + HANDLE_SIZE; } if (visualHigh > bounds.x + bounds.width - HANDLE_SIZE) { visualHigh = bounds.x + bounds.width - HANDLE_SIZE; } Color fg = gc.getDevice().getSystemColor(SWT.COLOR_WHITE); if (fg == null) { fg = getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); } Color bg = a.getBackground(); if (bg == null) { bg = getDisplay().getSystemColor(SWT.COLOR_GRAY); } gc.setForeground(fg); gc.setBackground(bg); gc.fillRectangle(visualLow, bounds.y, visualHigh - visualLow, bounds.height - 1); gc.drawRectangle(visualLow, bounds.y, visualHigh - visualLow - 1, bounds.height - 1); } }