Ignore:
Timestamp:
2014-02-05T23:22:04+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #8234 - remove duplicated/unused icons + javadoc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r6809 r6814  
    2222import java.io.StringReader;
    2323import java.io.UnsupportedEncodingException;
    24 import java.net.MalformedURLException;
    2524import java.net.URI;
    2625import java.net.URL;
     
    360359
    361360    /**
    362      * @see #get(java.lang.String, java.lang.String)
     361     * @param name The icon name (base name with or without '.png' or '.svg' extension)
     362     * @return the requested image or null if the request failed
     363     * @see #get(String, String)
    363364     */
    364365    public static ImageIcon get(String name) {
     
    369370     * Load an image with a given file name, but do not throw an exception
    370371     * when the image cannot be found.
    371      * @see #get(java.lang.String, java.lang.String)
     372     *
     373     * @param subdir subdirectory the image lies in
     374     * @param name The icon name (base name with or without '.png' or '.svg' extension)
     375     * @return the requested image or null if the request failed
     376     * @see #get(String, String)
    372377     */
    373378    public static ImageIcon getIfAvailable(String subdir, String name) {
     
    376381
    377382    /**
    378      * @see #getIfAvailable(java.lang.String, java.lang.String)
     383     * @param name The icon name (base name with or without '.png' or '.svg' extension)
     384     * @return the requested image or null if the request failed
     385     * @see #getIfAvailable(String, String)
    379386     */
    380387    public static ImageIcon getIfAvailable(String name) {
     
    854861     * @param img the image to be rotated.
    855862     * @param rotatedAngle the rotated angle, in degree, clockwise. It could be any double but we
    856      * will mod it with 360 before using it. More over for caching performance, it will be rounded to 
     863     * will mod it with 360 before using it. More over for caching performance, it will be rounded to
    857864     * an entire value between 0 and 360.
    858865     *
     
    863870        return createRotatedImage(img, rotatedAngle, ImageResource.DEFAULT_DIMENSION);
    864871    }
    865    
     872
    866873    /**
    867874     * Creates a rotated version of the input image, scaled to the given dimension.
     
    869876     * @param img the image to be rotated.
    870877     * @param rotatedAngle the rotated angle, in degree, clockwise. It could be any double but we
    871      * will mod it with 360 before using it. More over for caching performance, it will be rounded to 
     878     * will mod it with 360 before using it. More over for caching performance, it will be rounded to
    872879     * an entire value between 0 and 360.
    873880     * @param dimension The requested dimensions. Use (-1,-1) for the original size
     
    878885    public static Image createRotatedImage(Image img, double rotatedAngle, Dimension dimension) {
    879886        CheckParameterUtil.ensureParameterNotNull(img, "img");
    880        
     887
    881888        // convert rotatedAngle to an integer value from 0 to 360
    882889        Long originalAngle = Math.round(rotatedAngle % 360);
     
    884891            originalAngle = 360L;
    885892        }
    886        
     893
    887894        ImageResource imageResource = null;
    888895
     
    892899                ROTATE_CACHE.put(img, cacheByAngle = new HashMap<Long, ImageResource>());
    893900            }
    894            
     901
    895902            imageResource = cacheByAngle.get(originalAngle);
    896            
     903
    897904            if (imageResource == null) {
    898905                // convert originalAngle to a value from 0 to 90
     
    901908                    angle = 90.0;
    902909                }
    903        
     910
    904911                double radian = Math.toRadians(angle);
    905        
     912
    906913                new ImageIcon(img); // load completely
    907914                int iw = img.getWidth(null);
     
    909916                int w;
    910917                int h;
    911        
     918
    912919                if ((originalAngle >= 0 && originalAngle <= 90) || (originalAngle > 180 && originalAngle <= 270)) {
    913920                    w = (int) (iw * Math.sin(DEGREE_90 - radian) + ih * Math.sin(radian));
     
    921928                Graphics g = image.getGraphics();
    922929                Graphics2D g2d = (Graphics2D) g.create();
    923        
     930
    924931                // calculate the center of the icon.
    925932                int cx = iw / 2;
    926933                int cy = ih / 2;
    927        
     934
    928935                // move the graphics center point to the center of the icon.
    929936                g2d.translate(w / 2, h / 2);
    930        
     937
    931938                // rotate the graphics about the center point of the icon
    932939                g2d.rotate(Math.toRadians(originalAngle));
    933        
     940
    934941                g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    935942                g2d.drawImage(img, -cx, -cy, null);
    936        
     943
    937944                g2d.dispose();
    938945                new ImageIcon(image); // load completely
     
    941948        }
    942949    }
    943    
     950
    944951    /**
    945952     * Creates a scaled down version of the input image to fit maximum dimensions. (Keeps aspect ratio)
    946953     *
    947954     * @param img the image to be scaled down.
    948      * @param maxSize the maximum size in pixels (both for width and height) 
     955     * @param maxSize the maximum size in pixels (both for width and height)
    949956     *
    950957     * @return the image after scaling.
Note: See TracChangeset for help on using the changeset viewer.