From 7d4c2c58d6dc4a8d7111521cc097189ef121e7d0 Mon Sep 17 00:00:00 2001 From: Sebastian Schulz Date: Mon, 22 Nov 2021 11:17:24 +0100 Subject: [PATCH 1/2] Remove method from interface ILayer and update all places accordingly --- .../context/internal/ContextExportWizard.java | 4 +- .../internal/provider/GlyphBuilder.java | 136 ++++-------------- .../ui/operations/example/FeaturesInView.java | 41 +++--- .../org/locationtech/udig/project/ILayer.java | 8 -- .../project/internal/render/impl/Styling.java | 119 +++++++-------- 5 files changed, 113 insertions(+), 195 deletions(-) diff --git a/plugins/org.locationtech.udig.context/src/org/locationtech/udig/context/internal/ContextExportWizard.java b/plugins/org.locationtech.udig.context/src/org/locationtech/udig/context/internal/ContextExportWizard.java index 0f8e359ac5..3890790228 100644 --- a/plugins/org.locationtech.udig.context/src/org/locationtech/udig/context/internal/ContextExportWizard.java +++ b/plugins/org.locationtech.udig.context/src/org/locationtech/udig/context/internal/ContextExportWizard.java @@ -91,9 +91,9 @@ static void writeContext(IMap map, BufferedWriter out) throws IOException { append(2, out, ""); //$NON-NLS-1$ for (ILayer layer : map.getMapLayers()) { try { - if (layer.isType(Layer.class)) { + if (layer.hasResource(Layer.class)) { writeLayer(layer, out); - } else if (layer.isType(WFSDataStore.class)) { + } else if (layer.hasResource(WFSDataStore.class)) { writeFeatureType(layer, out); } else { // n/a diff --git a/plugins/org.locationtech.udig.project.edit/src/org/locationtech/udig/project/internal/provider/GlyphBuilder.java b/plugins/org.locationtech.udig.project.edit/src/org/locationtech/udig/project/internal/provider/GlyphBuilder.java index 610a9a0ca4..86ead8bec5 100644 --- a/plugins/org.locationtech.udig.project.edit/src/org/locationtech/udig/project/internal/provider/GlyphBuilder.java +++ b/plugins/org.locationtech.udig.project.edit/src/org/locationtech/udig/project/internal/provider/GlyphBuilder.java @@ -1,7 +1,7 @@ -/* - * uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004, Refractions Research Inc. +/** + * uDig - User Friendly Desktop Internet GIS client + * http://udig.refractions.net + * (C) 2004, Refractions Research Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -43,19 +43,21 @@ */ public class GlyphBuilder { - public static ImageDescriptor createImageDescriptor( final RenderedImage image ) { - return new ImageDescriptor(){ + public static ImageDescriptor createImageDescriptor(final RenderedImage image) { + return new ImageDescriptor() { + @Override public ImageData getImageData() { return createImageData(image); } }; } - /** Create a buffered image that can be be coverted to SWTland later */ - public static BufferedImage createBufferedImage( int w, int h ) { + + /** Create a buffered image that can be be converted to SWTland later */ + public static BufferedImage createBufferedImage(int w, int h) { return new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR_PRE); } - public static Image createSWTImage( RenderedImage image ) { - // Rectangle size = new Rectangle(0, 0, image.getWidth(), image.getHeight()); + + public static Image createSWTImage(RenderedImage image) { ImageData data = createImageData(image); return new org.eclipse.swt.graphics.Image(Display.getDefault(), data); @@ -63,7 +65,7 @@ public static Image createSWTImage( RenderedImage image ) { public static final int TRANSPARENT = 0x220000 | 0x2200 | 0x22; - public static ImageData createImageData( RenderedImage image ) { + public static ImageData createImageData(RenderedImage image) { ImageData swtdata = null; int width = image.getWidth(); int height = image.getHeight(); @@ -78,21 +80,17 @@ public static ImageData createImageData( RenderedImage image ) { byte blueT = (byte) ((TRANSPARENT) & 0xFF); byte greenT = (byte) ((TRANSPARENT >> 8) & 0xFF); byte redT = (byte) ((TRANSPARENT >> 16) & 0xFF); - // System.out.println("red="+redT+"blue"+blueT+"green"+greenT); - // System.out.println("Transparent"+TRANSPARENT); - // awtImage2.getRGB(); Raster raster = image.getData(); - int[] awtdata = raster.getPixels(0, 0, width, height, new int[width * height * 3]);// raster.getNumBands()]); + int[] awtdata = raster.getPixels(0, 0, width, height, new int[width * height * 3]); int step = swtdata.depth / 8; byte[] data = swtdata.data; int baseindex = 0; - // System.out.println( "AWT size:" + awtdata.length ); - for( int y = 0; y < height; y++ ) { + for (int y = 0; y < height; y++) { int idx = ((0 + y) * swtdata.bytesPerLine) + (0 * step); - for( int x = 0; x < width; x++ ) { + for (int x = 0; x < width; x++) { baseindex = (x + (y * width)) * 4; if (awtdata[baseindex + 3] == 0) { @@ -108,13 +106,14 @@ public static ImageData createImageData( RenderedImage image ) { } return swtdata; } - public ImageDescriptor createWMSGylph( Layer target ) { - if (target.isType(WebMapServer.class)) + + public ImageDescriptor createWMSGylph(Layer target) { + if (target.hasResource(WebMapServer.class)) return null; try { WebMapServer wms = target.getResource(WebMapServer.class, null); - org.geotools.ows.wms.Layer layer = target.getResource( - org.geotools.ows.wms.Layer.class, null); + org.geotools.ows.wms.Layer layer = target.getResource(org.geotools.ows.wms.Layer.class, + null); if (wms.getCapabilities().getRequest().getGetLegendGraphic() != null) { @@ -122,8 +121,8 @@ public ImageDescriptor createWMSGylph( Layer target ) { request.setLayer(layer.getName()); String desiredFormat = null; - List formats = wms.getCapabilities().getRequest() - .getGetLegendGraphic().getFormats(); + List formats = wms.getCapabilities().getRequest().getGetLegendGraphic() + .getFormats(); if (formats.contains("image/png")) { //$NON-NLS-1$ desiredFormat = "image/png"; //$NON-NLS-1$ } @@ -141,13 +140,9 @@ public ImageDescriptor createWMSGylph( Layer target ) { // darn } return null; - /* - * BufferedImage image = createBufferedImage( target, 16, 16); Graphics2D g2 = (Graphics2D) - * image.getGraphics(); g2.setColor(Color.GREEN); g2.fillRect(1, 1, 14, 14); - * g2.setColor(Color.BLACK); g2.drawRect(0, 0, 15, 15); return createImageDescriptor(image); - */ } - private SimpleFeature sampleFeature( Layer layer ) { + + private SimpleFeature sampleFeature(Layer layer) { FeatureIterator reader = null; try { reader = layer.getResource(FeatureSource.class, null).getFeatures().features(); @@ -163,7 +158,7 @@ private SimpleFeature sampleFeature( Layer layer ) { } } - public Image createGlyph( Layer layer, Style styleObject ) { + public Image createGlyph(Layer layer, Style styleObject) { int width = 16; int height = 16; @@ -172,93 +167,20 @@ public Image createGlyph( Layer layer, Style styleObject ) { ViewportGraphics graphics = Drawing.createGraphics(new GC(image), Display.getDefault(), new Dimension(width - 1, width - 1)); graphics.clearRect(0, 0, width, height); - // graphics.clearRect(0,0,16,16); AffineTransform transform = Drawing.worldToScreenTransform(feature.getBounds(), new Rectangle(1, 0, width - 1, width - 1)); - // Drawing.createGraphics(image.createGraphics()); Drawing.create().drawFeature(graphics, feature, transform, styleObject); - // return createSWTImage(image); return image; - // StyleImpl imp = (StyleImpl) styleObject; - // FeatureTypeStyle style = imp.getFeatureTypeStyles()[0]; - // Rule rule = style.getRules()[0]; - // Symbolizer symbolizer = rule.getSymbolizers()[0]; - // SimpleFeature feature = sampleFeature( layer ); - // - // if (symbolizer instanceof LineSymbolizer) { - // try { - // LineSymbolizer line = (LineSymbolizer) symbolizer; - // Stroke stroke = line.getStroke(); - // Color color = stroke.getColor(feature); - // - // BufferedImage image = createBufferedImage( layer, 16, 16); - // Graphics2D g2 = (Graphics2D) image.getGraphics(); - // g2.setColor(color); - // g2.drawArc(4, 4, 24, 24, 90, 90); - // g2.drawLine(0, 2, 11, 11); - // g2.drawLine(11, 11, 15, 8); - // - // g2.setColor(Color.BLACK); - // g2.drawRect(0, 0, 15, 15); - // return createImageDescriptor(image); - // } catch (Exception e) { - // BufferedImage image = createBufferedImage(16, 16); - // Graphics2D g2 = (Graphics2D) image.getGraphics(); - // g2.setColor(Color.BLACK); - // g2.drawArc(4, 4, 24, 24, 90, 90); - // g2.drawLine(0, 2, 11, 11); - // g2.drawLine(11, 11, 15, 8); - // - // g2.setColor(Color.BLACK); - // g2.drawRect(0, 0, 15, 15); - // return createImageDescriptor(image); - // } - // } else if (symbolizer instanceof PolygonSymbolizer) { - // try { - // PolygonSymbolizer poly = (PolygonSymbolizer) symbolizer; - // Stroke stroke = poly.getStroke(); - // Color color = stroke.getColor(feature); - // Fill fill = poly.getFill(); - // Paint fillColor = (Paint) fill.getColor().getValue(feature); - // - // BufferedImage image = createBufferedImage( layer, 16, 16); - // Graphics2D g2 = (Graphics2D) image.getGraphics(); - // g2.setPaint(fillColor); - // g2.fillArc(4, 4, 24, 24, 90, 90); - // g2.setPaint(color); - // g2.drawArc(4, 4, 24, 24, 90, 90); - // - // g2.setColor(Color.BLACK); - // g2.drawRect(0, 0, 16, 16); - // return createImageDescriptor(image); - // } catch (Exception e) { - // BufferedImage image = createBufferedImage( layer, 16, 16); - // Graphics2D g2 = (Graphics2D) image.getGraphics(); - // - // g2.setColor(Color.BLACK); - // g2.drawRect(2, 2, 11, 11); - // g2.setColor(Color.BLUE); - // g2.fillRect(3, 3, 10, 10); - // - // g2.setColor(Color.BLACK); - // g2.drawRect(0, 0, 15, 15); - // return createImageDescriptor(image); - // } - // } - // return null; } - public Object createGlyph( Layer layer ) { + + public Object createGlyph(Layer layer) { try { ImageDescriptor glyph; - if (layer.isType(WebMapServer.class)) { + if (layer.hasResource(WebMapServer.class)) { glyph = createWMSGylph(layer); if (glyph != null) return glyph; } - /* - * // This so does not work right now if (layer.getStyle() != null) { glyph = - * createGylph( layer, layer.getStyle() ); if( glyph != null ) return glyph; } - */ } catch (Throwable t) { t.printStackTrace(); } diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/operations/example/FeaturesInView.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/operations/example/FeaturesInView.java index 010e1b10d9..7d031a6336 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/operations/example/FeaturesInView.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/operations/example/FeaturesInView.java @@ -1,7 +1,7 @@ -/* - * uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004, Refractions Research Inc. +/** + * uDig - User Friendly Desktop Internet GIS client + * http://udig.refractions.net + * (C) 2004, Refractions Research Inc. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -29,7 +29,7 @@ /** * Counts all the features that are within the current view. - * + * * @author jeichar * @since 1.0 */ @@ -39,23 +39,25 @@ public class FeaturesInView implements IOp { * @see org.locationtech.udig.ui.operations.IOp#op(org.eclipse.swt.widgets.Display, * java.lang.Object, org.eclipse.core.runtime.IProgressMonitor) */ - public void op( final Display display, Object target, IProgressMonitor monitor ) + @Override + public void op(final Display display, Object target, IProgressMonitor monitor) throws Exception { IMap map = (IMap) target; Exception e = null; int featureCount = 0; - for( ILayer layer : map.getMapLayers() ) { - if (layer.isType(FeatureSource.class) && layer.isVisible()) { + for (ILayer layer : map.getMapLayers()) { + if (layer.hasResource(FeatureSource.class) && layer.isVisible()) { try { - FeatureSource source = layer.getResource(FeatureSource.class, monitor); + FeatureSource source = layer + .getResource(FeatureSource.class, monitor); Filter filter = layer.createBBoxFilter(map.getViewportModel().getBounds(), monitor); - FeatureCollection results = source.getFeatures(new Query(layer.getSchema() - .getName().getLocalPart(), filter)); + FeatureCollection results = source + .getFeatures( + new Query(layer.getSchema().getName().getLocalPart(), filter)); int count = results.size(); - // FeatureReader reader=results.reader() if (count > 0) { featureCount += count; } @@ -69,17 +71,16 @@ public void op( final Display display, Object target, IProgressMonitor monitor ) final Exception exception = e; final int finalCount = featureCount; - display.asyncExec(new Runnable(){ + display.asyncExec(new Runnable() { + @Override public void run() { if (exception == null) - MessageDialog.openInformation(display.getActiveShell(), - Messages.FeaturesInView_0, - Messages.FeaturesInView_1 + finalCount); + MessageDialog.openInformation(display.getActiveShell(), + Messages.FeaturesInView_0, Messages.FeaturesInView_1 + finalCount); else - MessageDialog.openInformation(display.getActiveShell(), - Messages.FeaturesInView_0, - MessageFormat.format(Messages.FeaturesInView_3, new Object[] {finalCount}) - ); + MessageDialog.openInformation(display.getActiveShell(), + Messages.FeaturesInView_0, MessageFormat.format( + Messages.FeaturesInView_3, new Object[] { finalCount })); } }); } diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/ILayer.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/ILayer.java index 5b2085aff4..1c95bb02e5 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/ILayer.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/ILayer.java @@ -142,14 +142,6 @@ public interface ILayer extends ILegendItem, Comparable { */ public boolean hasResource(Class resourceType); - /** - * @see #hasResource(Class) - * - * @deprecated use {@link #hasResource(Class)} - */ - @Deprecated - public boolean isType(Class resourceType); - /** * Returns a real resource that one of the GeoResources can resolved to. *

diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/Styling.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/Styling.java index aedc79cc24..b170c966fc 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/Styling.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/Styling.java @@ -1,4 +1,5 @@ -/* uDig - User Friendly Desktop Internet GIS client +/** + * uDig - User Friendly Desktop Internet GIS client * http://udig.refractions.net * (C) 2004-2012, Refractions Research Inc. * @@ -19,14 +20,9 @@ import java.util.List; import java.util.Map; -import org.locationtech.udig.project.internal.Layer; -import org.locationtech.udig.project.internal.Messages; -import org.locationtech.udig.project.internal.ProjectPlugin; -import org.locationtech.udig.ui.graphics.SLDs; -import org.opengis.style.SemanticType; +import org.geotools.feature.NameImpl; import org.geotools.ows.wms.StyleImpl; import org.geotools.ows.wms.WebMapServer; -import org.geotools.feature.NameImpl; import org.geotools.styling.FeatureTypeStyle; import org.geotools.styling.LineSymbolizer; import org.geotools.styling.PointSymbolizer; @@ -34,10 +30,15 @@ import org.geotools.styling.RasterSymbolizer; import org.geotools.styling.Style; import org.geotools.styling.StyleBuilder; +import org.locationtech.udig.project.internal.Layer; +import org.locationtech.udig.project.internal.Messages; +import org.locationtech.udig.project.internal.ProjectPlugin; +import org.locationtech.udig.ui.graphics.SLDs; +import org.opengis.style.SemanticType; /** * A utility class for obtaining precanned or random styles - * + * * @author Jesse Eichar * @version $Revision: 1.9 $ */ @@ -46,39 +47,39 @@ public class Styling { /** A map of default styles. */ public static final Map STYLES; static { - Map styles = new HashMap(); - styles.put(Messages.Styling_blueLine, Integer.valueOf(0)); - styles.put(Messages.Styling_greenLine, Integer.valueOf(1)); - styles.put(Messages.Styling_blackLine, Integer.valueOf(2)); - styles.put(Messages.Styling_blackLine_blueFill, Integer.valueOf(3)); - styles.put(Messages.Styling_blackLine_greenFill, Integer.valueOf(4)); - styles.put(Messages.Styling_blackLine_semitransparentBlueFill, Integer.valueOf(5)); - styles.put(Messages.Styling_blackLine_semitransparentYellowFill, Integer.valueOf(6)); - styles.put(Messages.Styling_pointStyle, Integer.valueOf(7)); + Map styles = new HashMap<>(); + styles.put(Messages.Styling_blueLine, Integer.valueOf(0)); + styles.put(Messages.Styling_greenLine, Integer.valueOf(1)); + styles.put(Messages.Styling_blackLine, Integer.valueOf(2)); + styles.put(Messages.Styling_blackLine_blueFill, Integer.valueOf(3)); + styles.put(Messages.Styling_blackLine_greenFill, Integer.valueOf(4)); + styles.put(Messages.Styling_blackLine_semitransparentBlueFill, Integer.valueOf(5)); + styles.put(Messages.Styling_blackLine_semitransparentYellowFill, Integer.valueOf(6)); + styles.put(Messages.Styling_pointStyle, Integer.valueOf(7)); STYLES = Collections.unmodifiableMap(styles); } /** - * Returns a Style object give a style name and a feature typename. - * + * Returns a Style object give a style name and a feature type name. + * * @param styleName The name of the style to creates. The list of name can be obtained from * {@link #getStyleNames(Layer)} * @param typeName the TypeName of the feature type the style will style. - * @return a Style object give a style name and a feature typename. + * @return a Style object give a style name and a feature type name. */ - public static Style getStyle( String styleName, String typeName ) { + public static Style getStyle(String styleName, String typeName) { return getStyle(((Integer) STYLES.get(styleName)).intValue(), typeName); } /** - * Returns a Style object given a value from {@link #STYLES}and the feature typename. - * + * Returns a Style object given a value from {@link #STYLES}and the feature type name. + * * @param index a value from {@link #STYLES} * @param typeName the TypeName of the feature type the style will style. - * @return a Style object given a value from {@link #STYLES}and the feature typename + * @return a Style object given a value from {@link #STYLES}and the feature type name */ - public static Style getStyle( int index, String typeName ) { - switch( index ) { + public static Style getStyle(int index, String typeName) { + switch (index) { case 0: return createLineStyle(typeName, Color.BLUE); case 1: @@ -103,22 +104,22 @@ public static Style getStyle( int index, String typeName ) { /** * Returns a simple style to use in default cases. - * + * * @param typeName the TypeName of the feature type the style will style. * @return a simple style to use in default cases. */ - public static Style createLineStyle( String typeName ) { + public static Style createLineStyle(String typeName) { return createLineStyle(typeName, Color.blue); } /** * Returns a simple style to use in default cases. - * + * * @param typeName the TypeName of the feature type the style will style. * @param color the color of the style * @return a simple style to use in default cases. */ - public static Style createLineStyle( String typeName, Color color ) { + public static Style createLineStyle(String typeName, Color color) { StyleBuilder sb = new StyleBuilder(); Style linestyle = sb.createStyle(); @@ -126,100 +127,102 @@ public static Style createLineStyle( String typeName, Color color ) { linestyle.featureTypeStyles().add(sb.createFeatureTypeStyle(line)); FeatureTypeStyle fts = linestyle.featureTypeStyles().get(0); - fts.setName(Messages.Styling_name); //tag as simple + fts.setName(Messages.Styling_name); // tag as simple fts.featureTypeNames().add(new NameImpl(SLDs.GENERIC_FEATURE_TYPENAME)); - + fts.semanticTypeIdentifiers().clear(); - fts.semanticTypeIdentifiers().add(new SemanticType("generic:geometry")); //$NON-NLS-1$ - fts.semanticTypeIdentifiers().add(new SemanticType("simple")); //$NON-NLS-1$ - + fts.semanticTypeIdentifiers().add(new SemanticType("generic:geometry")); //$NON-NLS-1$ + fts.semanticTypeIdentifiers().add(new SemanticType("simple")); //$NON-NLS-1$ + return linestyle; } /** * Returns a simple style to use in default cases. - * + * * @param typeName the TypeName of the feature type the style will style. * @return a simple style to use in default cases. */ - public static Style createPolyStyle( String typeName ) { + public static Style createPolyStyle(String typeName) { return createPolyStyle(typeName, Color.BLACK, Color.GREEN); } /** * Returns a simple style to use in default cases. - * + * * @param typeName the TypeName of the feature type the style will style. * @param line the color of the outlines. * @param fill The color of the fills * @return a simple style to use in default cases. */ - public static Style createPolyStyle( String typeName, Color line, Color fill ) { + public static Style createPolyStyle(String typeName, Color line, Color fill) { StyleBuilder sb = new StyleBuilder(); Style polystyle = sb.createStyle(); PolygonSymbolizer poly = sb.createPolygonSymbolizer(fill, line, 1); polystyle.featureTypeStyles().add(sb.createFeatureTypeStyle(poly)); - polystyle.featureTypeStyles().get(0).featureTypeNames().add(new NameImpl(SLDs.GENERIC_FEATURE_TYPENAME)); + polystyle.featureTypeStyles().get(0).featureTypeNames() + .add(new NameImpl(SLDs.GENERIC_FEATURE_TYPENAME)); return polystyle; } /** * Returns a simple style to use in default cases. - * + * * @param typeName the TypeName of the feature type the style will style. * @return a simple style to use in default cases. */ - public static Style createPointStyle( String typeName ) { + public static Style createPointStyle(String typeName) { StyleBuilder sb = new StyleBuilder(); Style pointstyle = sb.createStyle(); PointSymbolizer point = sb.createPointSymbolizer(sb.createGraphic()); pointstyle.featureTypeStyles().add(sb.createFeatureTypeStyle(point)); - pointstyle.featureTypeStyles().get(0).featureTypeNames().add(new NameImpl(SLDs.GENERIC_FEATURE_TYPENAME) ); + pointstyle.featureTypeStyles().get(0).featureTypeNames() + .add(new NameImpl(SLDs.GENERIC_FEATURE_TYPENAME)); return pointstyle; } /** * Returns a simple style to use in default cases. - * + * * @param typeName the TypeName of the feature type the style will style. * @return as simple style to use in default cases. */ - public static Style createRasterStyle( String typeName ) { + public static Style createRasterStyle(String typeName) { StyleBuilder sb = new StyleBuilder(); Style rasterstyle = sb.createStyle(); RasterSymbolizer raster = sb.createRasterSymbolizer(); rasterstyle.featureTypeStyles().add(sb.createFeatureTypeStyle(raster)); - rasterstyle.featureTypeStyles().get(0).featureTypeNames().add(new NameImpl(SLDs.GENERIC_FEATURE_TYPENAME)); + rasterstyle.featureTypeStyles().get(0).featureTypeNames() + .add(new NameImpl(SLDs.GENERIC_FEATURE_TYPENAME)); return rasterstyle; } /** * Returns a list of style names that can be used on the given layer. - * + * * @param currentLayer The layer to finds styles for. * @return a list of style names that can be used on the given layer. */ - @SuppressWarnings("unchecked") - public static Collection getStyleNames( Layer currentLayer ) { - // URI id=currentLayer.getID(); - // if( id.containsKey(WMSRegistryEntry.GET_CAPABILITIES_URL) ){ - if (currentLayer.isType(WebMapServer.class)) { // checking for wms + public static Collection getStyleNames(Layer currentLayer) { + if (currentLayer.hasResource(WebMapServer.class)) { // checking for WMS - List l = new LinkedList(); + List l = new LinkedList<>(); try { - for (Iterator iterator = currentLayer.getResource(org.geotools.ows.wms.Layer.class, null).getStyles().iterator(); iterator.hasNext();) { - StyleImpl style = (StyleImpl) iterator.next(); - l.add(style.getName()); - } + for (Iterator iterator = currentLayer + .getResource(org.geotools.ows.wms.Layer.class, null).getStyles() + .iterator(); iterator.hasNext();) { + StyleImpl style = iterator.next(); + l.add(style.getName()); + } } catch (IOException e) { ProjectPlugin.log(null, e); } - l.add(Messages.Styling_default); + l.add(Messages.Styling_default); return l; } From 997ac3dcb1002f1388f108d2ea22ab5699470d08 Mon Sep 17 00:00:00 2001 From: Sebastian Schulz Date: Mon, 22 Nov 2021 11:51:07 +0100 Subject: [PATCH 2/2] Fix compile issue --- .../udig/project/internal/LayerDecorator.java | 9 -- .../udig/project/internal/impl/LayerImpl.java | 116 ++++++++++-------- 2 files changed, 65 insertions(+), 60 deletions(-) diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/LayerDecorator.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/LayerDecorator.java index a0619b4070..306e6f9371 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/LayerDecorator.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/LayerDecorator.java @@ -890,15 +890,6 @@ public void setMaxScaleDenominator(double value) { layer.setMaxScaleDenominator(value); } - /** - * @deprecated - */ - @Deprecated - @Override - public boolean isType(Class resourceType) { - return layer.hasResource(resourceType); - } - @Override public boolean hasResource(Class resourceType) { return layer.hasResource(resourceType); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java index cc778e9edf..835373c7ca 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java @@ -168,9 +168,9 @@ public class LayerImpl extends EObjectImpl implements Layer { protected static final int ZORDER_EDEFAULT = 0; /** - * The cached value of the '{@link #getZorder() Zorder}' attribute. - * + * * @see #getZorder() * @generated * @ordered @@ -242,7 +242,6 @@ private void raiseEvents(Notification msg) { } } - @SuppressWarnings("unchecked") private void registerWithContainers(Notification msg) { // register itself with container objects switch (msg.getEventType()) { @@ -343,7 +342,7 @@ public void changed(FeatureEvent featureEvent) { CopyOnWriteArraySet listeners = new CopyOnWriteArraySet<>(); /** - * Ensures that a warning about georesources not found is only logged once + * Ensures that a warning about GeoResources not found is only logged once */ private volatile boolean warned = false; @@ -358,7 +357,7 @@ public void changed(FeatureEvent featureEvent) { private final Lock geoResourceCacheLock = new UDIGDisplaySafeLock(); /** - * indicates whether or not the CRS is a known CRS (the georesources return null when asked for + * indicates whether or not the CRS is a known CRS (the GeoResources return null when asked for * a CRS). If null then it has not been computed yet. if false and crsLoader !=null then it is * being computed. */ @@ -366,7 +365,7 @@ public void changed(FeatureEvent featureEvent) { /** * Used in {@link #isUnknownCRS()} to lazily compute the CRS. If null and unknownCRS is null - * then the crs has not been computed. if not null then the computatin is taking place. + * then the CRS has not been computed. if not null then the computation is taking place. */ private volatile ISafeRunnable crsLoader; @@ -389,19 +388,11 @@ protected void finalize() throws Throwable { CatalogPlugin.removeListener(this); } - /* - * @see - * org.locationtech.udig.project.Layer#addListener(org.locationtech.udig.project.LayerListener) - */ @Override public void addListener(final ILayerListener listener) { listeners.add(listener); } - /* - * @see - * org.locationtech.udig.project.Layer#removeListener(org.locationtech.udig.project.LayerListener) - */ @Override public void removeListener(final ILayerListener listener) { listeners.remove(listener); @@ -428,6 +419,7 @@ protected void zorderNotify(int old, int current) { /** * + * * @generated */ @Override @@ -437,6 +429,7 @@ protected EClass eStaticClass() { /** * + * * @generated */ @Override @@ -448,6 +441,7 @@ public ContextModel getContextModel() { /** * + * * @generated */ public NotificationChain basicSetContextModel(ContextModel newContextModel, @@ -459,6 +453,7 @@ public NotificationChain basicSetContextModel(ContextModel newContextModel, /** * + * * @generated */ @Override @@ -501,7 +496,6 @@ public int getZorder() { * @generated NOT */ @Override - @SuppressWarnings("unchecked") public void setZorder(int newZorder) { if (getContextModel() == null || getMapInternal().getLayersInternal() == null) { return; @@ -518,6 +512,7 @@ public void setZorder(int newZorder) { /** * + * * @generated */ @Override @@ -527,6 +522,7 @@ public String getName() { /** * + * * @generated */ @Override @@ -540,6 +536,7 @@ public void setName(String newName) { /** * + * * @generated */ @Override @@ -549,6 +546,7 @@ public URL getID() { /** * + * * @generated */ @Override @@ -603,6 +601,7 @@ public ID getResourceID() { /** * + * * @generated */ @Override @@ -612,6 +611,7 @@ public boolean isVisible() { /** * + * * @generated */ @Override @@ -636,7 +636,7 @@ public void setVisible(boolean newVisible) { * New implementation of the method: *

* getGeoResource() is a blocking method but it must not block UI thread. With this purpose the - * new imlementation is done to avoid UI thread blocking because of synchronization. * * @uml.property name="geoResources" @@ -739,13 +739,14 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { private boolean assertNotInDisplayAccess() { if (Display.getCurrent() != null) { - // ProjectPlugin.log("getGeoResources was called in display Thread", new Exception("JUST A WARNING NOT CRITICAL")); //$NON-NLS-1$ //$NON-NLS-2$ + // ProjectPlugin.log("getGeoResources was called in display Thread", new Exception("JUST + // A WARNING NOT CRITICAL")); //$NON-NLS-1$ //$NON-NLS-2$ } return true; } /** - * will be returned by getGeoResources and getGeoResource in the real connection is broken. + * Will be returned by getGeoResources and getGeoResource in the real connection is broken. */ static public final EList NULL; static { @@ -825,6 +826,7 @@ public void setCatalogRef(CatalogRef newCatalogRef) { /** * + * * @generated */ public void setCatalogRefGen(CatalogRef newCatalogRef) { @@ -837,6 +839,7 @@ public void setCatalogRefGen(CatalogRef newCatalogRef) { /** * + * * @generated */ @Override @@ -846,6 +849,7 @@ public StyleBlackboard getStyleBlackboard() { /** * + * * @generated */ public NotificationChain basicSetStyleBlackboard(StyleBlackboard newStyleBlackboard, @@ -892,6 +896,7 @@ public void setStyleBlackboard(StyleBlackboard newStyleBlackboard) { /** * + * * @generated */ @Override @@ -901,6 +906,7 @@ public Filter getFilter() { /** * + * * @generated */ @Override @@ -989,15 +995,6 @@ public IGeoResource findGeoResource(Class resourceType) { return null; } - /** - * @deprecated - */ - @Deprecated - @Override - public boolean isType(Class resourceType) { - return hasResource(resourceType); - } - @Override public boolean hasResource(Class resourceType) { for (IGeoResource resource : getGeoResources()) { @@ -1009,6 +1006,7 @@ public boolean hasResource(Class resourceType) { /** * + * * @generated */ @Override @@ -1018,6 +1016,7 @@ public ImageDescriptor getIcon() { /** * please use getIcon + * * @deprecated * @generated NOT */ @@ -1027,8 +1026,8 @@ public ImageDescriptor getGlyph() { } /** - * - * + * + * * @generated */ @Override @@ -1042,6 +1041,7 @@ public void setIcon(ImageDescriptor newIcon) { /** * please use setIcon + * * @deprecated * @generated NOT */ @@ -1112,9 +1112,9 @@ public Query getQuery(boolean selection) { private volatile int status; /** - * The default value of the '{@link #getName() Name}' attribute. - * + * * @see #getName() * @generated * @ordered @@ -1152,9 +1152,9 @@ public Query getQuery(boolean selection) { protected volatile CatalogRef catalogRef = new CatalogRef(this); /** - * The default value of the '{@link #getID() ID}' attribute. - * + * The default value of the '{@link #getID() ID}' attribute. * + * * @see #getID() * @generated * @ordered @@ -1222,9 +1222,9 @@ public Query getQuery(boolean selection) { protected volatile EList geoResources = null; /** - * The default value of the '{@link #getCRS() CRS}' attribute. - * + * The default value of the '{@link #getCRS() CRS}' attribute. * + * * @see #getCRS() * @generated * @ordered @@ -1352,9 +1352,9 @@ public Query getQuery(boolean selection) { protected EMap interactionMap; /** - * The default value of the '{@link #isShown() Shown}' attribute. - * - * + * The default value of the '{@link #isShown() Shown}' attribute. + * * @see #isShown() * @generated * @ordered @@ -1362,9 +1362,9 @@ public Query getQuery(boolean selection) { protected static final boolean SHOWN_EDEFAULT = false; /** - * The cached value of the '{@link #isShown() Shown}' attribute. - * - * + * The cached value of the '{@link #isShown() Shown}' attribute. + * * @see #isShown() * @generated * @ordered @@ -1372,9 +1372,9 @@ public Query getQuery(boolean selection) { protected boolean shown = SHOWN_EDEFAULT; /** - * The default value of the '{@link #getIcon() Icon}' attribute. - * - * + * The default value of the '{@link #getIcon() Icon}' attribute. + * * @see #getIcon() * @generated * @ordered @@ -1382,9 +1382,9 @@ public Query getQuery(boolean selection) { protected static final ImageDescriptor ICON_EDEFAULT = null; /** - * The cached value of the '{@link #getIcon() Icon}' attribute. - * + * The cached value of the '{@link #getIcon() Icon}' attribute. * + * * @see #getIcon() * @generated * @ordered @@ -1519,6 +1519,7 @@ public void setCRS(CoordinateReferenceSystem newCRS) { /** * + * * @generated */ public void setCRSGen(CoordinateReferenceSystem newCRS) { @@ -1544,6 +1545,7 @@ public IBlackboard getBlackboard() { /** * + * * @generated */ @Override @@ -1553,6 +1555,7 @@ public ColourScheme getColourScheme() { /** * + * * @generated */ @Override @@ -1566,6 +1569,7 @@ public void setColourScheme(ColourScheme newColourScheme) { /** * + * * @generated */ @Override @@ -1575,6 +1579,7 @@ public Color getDefaultColor() { /** * + * * @generated */ @Override @@ -1686,6 +1691,7 @@ public double getMaxScaleDenominator() { /** * + * * @generated */ @Override @@ -1700,6 +1706,7 @@ public void setMaxScaleDenominator(double newMaxScaleDenominator) { /** * + * * @generated */ @Override @@ -1714,8 +1721,8 @@ public Map getInteractionMap() { } /** - * - * + * + * * @generated */ @Override @@ -1724,8 +1731,8 @@ public boolean isShown() { } /** - * - * + * + * * @generated */ @Override @@ -1815,6 +1822,7 @@ public CoordinateReferenceSystem getCRS(IProgressMonitor monitor) { /** * + * * @generated */ @Override @@ -1831,6 +1839,7 @@ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, /** * + * * @generated */ @Override @@ -1850,6 +1859,7 @@ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, /** * + * * @generated */ @Override @@ -1864,6 +1874,7 @@ public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs /** * + * * @generated */ @Override @@ -1920,6 +1931,7 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) { /** * + * * @generated */ @SuppressWarnings("unchecked") @@ -1991,6 +2003,7 @@ public void eSet(int featureID, Object newValue) { /** * + * * @generated */ @Override @@ -2059,6 +2072,7 @@ public void eUnset(int featureID) { /** * + * * @generated */ @Override @@ -2228,7 +2242,7 @@ public ReferencedEnvelope getBounds(IProgressMonitor monitor, CoordinateReferenc private ReferencedEnvelope obtainBoundsFromResources(IProgressMonitor monitor) { ReferencedEnvelope result = null; for (IGeoResource resource : getGeoResources()) { - //IGeoResourceInfo info = resource.getInfo(monitor); + // IGeoResourceInfo info = resource.getInfo(monitor); IGeoResourceInfo info = getInfo(resource, monitor); Envelope tmp = null; if (info != null)