Mercurial > projects > dwt-addons
diff dwtx/jface/text/source/AnnotationPainter.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 7926b636c282 |
children |
line wrap: on
line diff
--- a/dwtx/jface/text/source/AnnotationPainter.d Wed Aug 27 14:49:30 2008 +0200 +++ b/dwtx/jface/text/source/AnnotationPainter.d Mon Sep 08 00:51:37 2008 +0200 @@ -74,20 +74,10 @@ import dwtx.jface.text.source.OverviewRuler; // packageimport import dwtx.jface.text.source.OverviewRulerHoverManager; // packageimport - import dwt.dwthelper.utils; - - import dwtx.dwtxhelper.Collection; - - - - - - - - - +import tango.text.convert.Format; +import tango.io.Stdout; import dwt.DWT; import dwt.DWTException; @@ -222,11 +212,11 @@ int leftX= left.x; // compute (number of point) * 2 - int length= ((2 * peaks) + 1) * 2; - if (length < 0) + int length_= ((2 * peaks) + 1) * 2; + if (length_ < 0) return new int[0]; - int[] coordinates= new int[length]; + int[] coordinates= new int[length_]; // cache peeks' y-coordinates int top= left.y + Math.min(baseline + 1, lineHeight - HEIGHT - 1); @@ -242,8 +232,8 @@ } // the last down flank is missing - coordinates[length-2]= Math.min(Math.max(0, right.x - 1), left.x + (WIDTH * peaks)); - coordinates[length-1]= bottom; + coordinates[length_-2]= Math.min(Math.max(0, right.x - 1), left.x + (WIDTH * peaks)); + coordinates[length_-1]= bottom; return coordinates; } @@ -342,7 +332,14 @@ * Implementation of <code>IRegion</code> that can be reused * by setting the offset and the length. */ - private static class ReusableRegion : Position , IRegion {} + private static class ReusableRegion : Position , IRegion { + public override int getOffset(){ + return super.getOffset(); + } + public override int getLength(){ + return super.getLength(); + } + } /** * Tells whether this class is in debug mode. @@ -362,7 +359,18 @@ * The squiggly painter strategy. * @since 3.0 */ - private static const IDrawingStrategy SQUIGGLES_STRATEGY= new SquigglesStrategy(); + private static IDrawingStrategy SQUIGGLES_STRATEGY_; + private static IDrawingStrategy SQUIGGLES_STRATEGY(){ + if( SQUIGGLES_STRATEGY_ is null ){ + synchronized( AnnotationPainter.classinfo ){ + if( SQUIGGLES_STRATEGY_ is null ){ + SQUIGGLES_STRATEGY_ = new SquigglesStrategy(); + } + } + } + return SQUIGGLES_STRATEGY_; + } + /** * This strategy is used to mark the <code>null</code> value in the chache @@ -370,25 +378,65 @@ * * @since 3.4 */ - private static const IDrawingStrategy NULL_STRATEGY= new NullStrategy(); + private static IDrawingStrategy NULL_STRATEGY_; + private static IDrawingStrategy NULL_STRATEGY(){ + if( NULL_STRATEGY_ is null ){ + synchronized( AnnotationPainter.classinfo ){ + if( NULL_STRATEGY_ is null ){ + NULL_STRATEGY_= new NullStrategy(); + } + } + } + return NULL_STRATEGY_; + } /** * The squiggles painter id. * @since 3.0 */ - private static const Object SQUIGGLES= new Object(); + private static Object SQUIGGLES_; + private static Object SQUIGGLES(){ + if( SQUIGGLES_ is null ){ + synchronized( AnnotationPainter.classinfo ){ + if( SQUIGGLES_ is null ){ + SQUIGGLES_= new Object(); + } + } + } + return SQUIGGLES_; + } /** * The squiggly painter strategy. * * @since 3.4 */ - private static const ITextStyleStrategy HIGHLIGHTING_STRATEGY= new HighlightingStrategy(); + private static ITextStyleStrategy HIGHLIGHTING_STRATEGY_; + private static ITextStyleStrategy HIGHLIGHTING_STRATEGY(){ + if( HIGHLIGHTING_STRATEGY_ is null ){ + synchronized( AnnotationPainter.classinfo ){ + if( HIGHLIGHTING_STRATEGY_ is null ){ + HIGHLIGHTING_STRATEGY_= new HighlightingStrategy(); + } + } + } + return HIGHLIGHTING_STRATEGY_; + } /** * The highlighting text style strategy id. * * @since 3.4 */ - private static const Object HIGHLIGHTING= new Object(); + private static Object HIGHLIGHTING_; + private static Object HIGHLIGHTING(){ + if( HIGHLIGHTING_ is null ){ + synchronized( AnnotationPainter.classinfo ){ + if( HIGHLIGHTING_ is null ){ + HIGHLIGHTING_= new Object(); + } + } + } + return HIGHLIGHTING_; + } /** * The presentation information (decoration) for an annotation. Each such @@ -431,34 +479,34 @@ * The map with decorations * @since 3.0 */ - private Map fDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767 + private Map fDecorationsMap; // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767 /** * The map with of highlighted decorations. * @since 3.0 */ - private Map fHighlightedDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767 + private Map fHighlightedDecorationsMap; /** * Mutex for highlighted decorations map. * @since 3.0 */ - private Object fDecorationMapLock= new Object(); + private Object fDecorationMapLock; /** * Mutex for for decorations map. * @since 3.0 */ - private Object fHighlightedDecorationsMapLock= new Object(); + private Object fHighlightedDecorationsMapLock; /** * Maps an annotation type to its registered color. * * @see #setAnnotationTypeColor(Object, Color) */ - private Map fAnnotationType2Color= new HashMap(); + private Map fAnnotationType2Color; /** * Cache that maps the annotation type to its color. * @since 3.4 */ - private Map fCachedAnnotationType2Color= new HashMap(); + private Map fCachedAnnotationType2Color; /** * The range in which the current highlight annotations can be found. * @since 3.0 @@ -497,25 +545,25 @@ * @see #addAnnotationType(Object, Object) * @since 3.0 */ - private Map fAnnotationType2PaintingStrategyId= new HashMap(); + private Map fAnnotationType2PaintingStrategyId; /** * Maps annotation types to painting strategy identifiers. * @since 3.4 */ - private Map fCachedAnnotationType2PaintingStrategy= new HashMap(); + private Map fCachedAnnotationType2PaintingStrategy; /** * Maps painting strategy identifiers to painting strategies. * * @since 3.0 */ - private Map fPaintingStrategyId2PaintingStrategy= new HashMap(); + private Map fPaintingStrategyId2PaintingStrategy; /** * Reuse this region for performance reasons. * @since 3.3 */ - private ReusableRegion fReusableRegion= new ReusableRegion(); + private ReusableRegion fReusableRegion; /** * Creates a new annotation painter for the given source viewer and with the @@ -526,13 +574,24 @@ * @param access the annotation access for this painter */ public this(ISourceViewer sourceViewer, IAnnotationAccess access) { + fDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767 + fHighlightedDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767 + fDecorationMapLock= new Object(); + fHighlightedDecorationsMapLock= new Object(); + fAnnotationType2Color= new HashMap(); + fCachedAnnotationType2Color= new HashMap(); + fReusableRegion= new ReusableRegion(); + fAnnotationType2PaintingStrategyId= new HashMap(); + fCachedAnnotationType2PaintingStrategy= new HashMap(); + fPaintingStrategyId2PaintingStrategy= new HashMap(); + fSourceViewer= sourceViewer; fAnnotationAccess= access; fTextWidget= sourceViewer.getTextWidget(); // default drawing strategies: squiggles were the only decoration style before version 3.0 - fPaintingStrategyId2PaintingStrategy.put(SQUIGGLES, SQUIGGLES_STRATEGY); - fPaintingStrategyId2PaintingStrategy.put(HIGHLIGHTING, HIGHLIGHTING_STRATEGY); + fPaintingStrategyId2PaintingStrategy.put(SQUIGGLES, cast(Object)SQUIGGLES_STRATEGY); + fPaintingStrategyId2PaintingStrategy.put(HIGHLIGHTING, cast(Object)HIGHLIGHTING_STRATEGY); } /** @@ -909,7 +968,7 @@ if (paintingStrategy is null || cast(NullStrategy)paintingStrategy ) return null; - Color color= getColor(type); + Color color= getColor(stringcast(type)); if (color is null) return null; @@ -954,7 +1013,7 @@ if ( cast(IAnnotationAccessExtension)fAnnotationAccess ) { IAnnotationAccessExtension ext = cast(IAnnotationAccessExtension) fAnnotationAccess; - Object[] sts = ext.getSupertypes(type); + Object[] sts = ext.getSupertypes(stringcast(type)); for (int i= 0; i < sts.length; i++) { strategy= fPaintingStrategyId2PaintingStrategy.get(fAnnotationType2PaintingStrategyId.get(sts[i])); if (strategy !is null) { @@ -964,7 +1023,7 @@ } } - fCachedAnnotationType2PaintingStrategy.put(type, NULL_STRATEGY); + fCachedAnnotationType2PaintingStrategy.put(type, cast(Object)NULL_STRATEGY); return null; } @@ -1032,7 +1091,7 @@ if ( cast(ITextViewerExtension2)fSourceViewer ) { if (DEBUG) - System.out_.println("AP: invalidating offset: " + r.getOffset() + ", length= " + r.getLength()); //$NON-NLS-1$ //$NON-NLS-2$ + System.out_.println(Format("AP: invalidating offset: {}, length= {}", r.getOffset(), r.getLength())); //$NON-NLS-1$ //$NON-NLS-2$ (cast(ITextViewerExtension2)fSourceViewer).invalidateTextPresentation(r.getOffset(), r.getLength()); @@ -1058,7 +1117,7 @@ IRegion region= tp.getExtent(); if (DEBUG) - System.out_.println("AP: applying text presentation offset: " + region.getOffset() + ", length= " + region.getLength()); //$NON-NLS-1$ //$NON-NLS-2$ + System.out_.println(Format("AP: applying text presentation offset: {}, length= {}", region.getOffset(), region.getLength())); //$NON-NLS-1$ //$NON-NLS-2$ for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) { @@ -1146,7 +1205,7 @@ // changes any more. If the document gets modified between // now and running the posted runnable, the position information // is not accurate any longer. - textWidgetDisplay.asyncExec( dgRunnable( (Event event_){ + textWidgetDisplay.asyncExec( dgRunnable( (AnnotationModelEvent event_){ if (fTextWidget !is null && !fTextWidget.isDisposed()) updatePainting(event_); }, event )); @@ -1227,8 +1286,8 @@ // don't permit null as null is used to signal that an annotation type is not // registered with a specific strategy, and that its annotation hierarchy should be searched if (id is null) - throw new IllegalArgumentException(); - fPaintingStrategyId2PaintingStrategy.put(id, strategy); + throw new IllegalArgumentException(null); + fPaintingStrategyId2PaintingStrategy.put(id, cast(Object)strategy); fCachedAnnotationType2PaintingStrategy.clear(); } @@ -1249,8 +1308,8 @@ // don't permit null as null is used to signal that an annotation type is not // registered with a specific strategy, and that its annotation hierarchy should be searched if (id is null) - throw new IllegalArgumentException(); - fPaintingStrategyId2PaintingStrategy.put(id, strategy); + throw new IllegalArgumentException(null); + fPaintingStrategyId2PaintingStrategy.put(id, cast(Object)strategy); fCachedAnnotationType2PaintingStrategy.clear(); } @@ -1450,7 +1509,7 @@ // ensure sized appropriately for (int i= toBeDrawn.size(); i <= pp.fLayer; i++) toBeDrawn.add(new LinkedList()); - (cast(List) toBeDrawn.get(pp.fLayer)).add(entry); + (cast(List) toBeDrawn.get(pp.fLayer)).add(cast(Object)entry); } } IDocument document= fSourceViewer.getDocument();