comparison dwtx/jface/text/source/AnnotationPainter.d @ 157:7f75eaa8103a

volatile and cast Map.Entry
author Frank Benoit <benoit@tionex.de>
date Mon, 25 Aug 2008 19:06:44 +0200
parents f70d9508c95c
children 25f1f92fa3df
comparison
equal deleted inserted replaced
156:a9566845f1cb 157:7f75eaa8103a
406 /** Indicates whether this painter is active */ 406 /** Indicates whether this painter is active */
407 private bool fIsActive= false; 407 private bool fIsActive= false;
408 /** Indicates whether this painter is managing decorations */ 408 /** Indicates whether this painter is managing decorations */
409 private bool fIsPainting= false; 409 private bool fIsPainting= false;
410 /** Indicates whether this painter is setting its annotation model */ 410 /** Indicates whether this painter is setting its annotation model */
411 private volatile bool fIsSettingModel= false; 411 private /+volatile+/ bool fIsSettingModel= false;
412 /** The associated source viewer */ 412 /** The associated source viewer */
413 private ISourceViewer fSourceViewer; 413 private ISourceViewer fSourceViewer;
414 /** The cached widget of the source viewer */ 414 /** The cached widget of the source viewer */
415 private StyledText fTextWidget; 415 private StyledText fTextWidget;
416 /** The annotation model providing the annotations to be drawn */ 416 /** The annotation model providing the annotations to be drawn */
629 if (DEBUG && event is null) 629 if (DEBUG && event is null)
630 System.out_.println("AP: INTERNAL CHANGE"); //$NON-NLS-1$ 630 System.out_.println("AP: INTERNAL CHANGE"); //$NON-NLS-1$
631 631
632 Iterator iter= decorationsMap.entrySet().iterator(); 632 Iterator iter= decorationsMap.entrySet().iterator();
633 while (iter.hasNext()) { 633 while (iter.hasNext()) {
634 Map.Entry entry= (Map.Entry)iter.next(); 634 Map.Entry entry= cast(Map.Entry)iter.next();
635 Annotation annotation= cast(Annotation)entry.getKey(); 635 Annotation annotation= cast(Annotation)entry.getKey();
636 Decoration decoration= cast(Decoration)entry.getValue(); 636 Decoration decoration= cast(Decoration)entry.getValue();
637 drawDecoration(decoration, null, annotation, clippingRegion, document); 637 drawDecoration(decoration, null, annotation, clippingRegion, document);
638 } 638 }
639 639
1051 System.out_.println("AP: applying text presentation offset: " + region.getOffset() + ", length= " + region.getLength()); //$NON-NLS-1$ //$NON-NLS-2$ 1051 System.out_.println("AP: applying text presentation offset: " + region.getOffset() + ", length= " + region.getLength()); //$NON-NLS-1$ //$NON-NLS-2$
1052 1052
1053 for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) { 1053 for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) {
1054 1054
1055 for (Iterator iter= decorations.iterator(); iter.hasNext();) { 1055 for (Iterator iter= decorations.iterator(); iter.hasNext();) {
1056 Map.Entry entry= (Map.Entry)iter.next(); 1056 Map.Entry entry= cast(Map.Entry)iter.next();
1057 1057
1058 Annotation a= cast(Annotation)entry.getKey(); 1058 Annotation a= cast(Annotation)entry.getKey();
1059 if (a.isMarkedDeleted()) 1059 if (a.isMarkedDeleted())
1060 continue; 1060 continue;
1061 1061
1431 * Create a new list of annotations to be drawn, since removing from decorations is more 1431 * Create a new list of annotations to be drawn, since removing from decorations is more
1432 * expensive. One bucket per drawing layer. Use linked lists as addition is cheap here. 1432 * expensive. One bucket per drawing layer. Use linked lists as addition is cheap here.
1433 */ 1433 */
1434 ArrayList toBeDrawn= new ArrayList(10); 1434 ArrayList toBeDrawn= new ArrayList(10);
1435 for (Iterator e = decorations.iterator(); e.hasNext();) { 1435 for (Iterator e = decorations.iterator(); e.hasNext();) {
1436 Map.Entry entry= (Map.Entry)e.next(); 1436 Map.Entry entry= cast(Map.Entry)e.next();
1437 1437
1438 Annotation a= cast(Annotation)entry.getKey(); 1438 Annotation a= cast(Annotation)entry.getKey();
1439 Decoration pp = cast(Decoration)entry.getValue(); 1439 Decoration pp = cast(Decoration)entry.getValue();
1440 // prune any annotation that is not drawable or does not need drawing 1440 // prune any annotation that is not drawable or does not need drawing
1441 if (!(a.isMarkedDeleted() || skip(a) || !pp.fPosition.overlapsWith(vOffset, vLength))) { 1441 if (!(a.isMarkedDeleted() || skip(a) || !pp.fPosition.overlapsWith(vOffset, vLength))) {
1447 } 1447 }
1448 IDocument document= fSourceViewer.getDocument(); 1448 IDocument document= fSourceViewer.getDocument();
1449 for (Iterator it= toBeDrawn.iterator(); it.hasNext();) { 1449 for (Iterator it= toBeDrawn.iterator(); it.hasNext();) {
1450 List layer= cast(List) it.next(); 1450 List layer= cast(List) it.next();
1451 for (Iterator e = layer.iterator(); e.hasNext();) { 1451 for (Iterator e = layer.iterator(); e.hasNext();) {
1452 Map.Entry entry= (Map.Entry)e.next(); 1452 Map.Entry entry= cast(Map.Entry)e.next();
1453 Annotation a= cast(Annotation)entry.getKey(); 1453 Annotation a= cast(Annotation)entry.getKey();
1454 Decoration pp = cast(Decoration)entry.getValue(); 1454 Decoration pp = cast(Decoration)entry.getValue();
1455 drawDecoration(pp, gc, a, clippingRegion, document); 1455 drawDecoration(pp, gc, a, clippingRegion, document);
1456 } 1456 }
1457 } 1457 }