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/LayerDecorator.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/LayerDecorator.java index 1613410f7f..e80381c2f9 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 @@ -588,15 +588,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 83d349c982..c56ef66536 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 @@ -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); @@ -505,7 +496,6 @@ public int getZorder() { * @generated NOT */ @Override - @SuppressWarnings("unchecked") public void setZorder(int newZorder) { if (getContextModel() == null || getMapInternal().getLayersInternal() == null) { return; @@ -646,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" @@ -756,7 +746,7 @@ private boolean assertNotInDisplayAccess() { } /** - * 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 { @@ -1005,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()) { 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; }