Ignore:
Timestamp:
2016-06-17T02:58:36+02:00 (8 years ago)
Author:
Don-vip
Message:
  • remove duplicated code
  • fix various sonar warnings
  • add some javadoc and unit tests
Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r10405 r10409  
    141141    // The only events that may move/resize this map view are window movements or changes to the map view size.
    142142    // We can clean this up more by only recalculating the state on repaint.
    143     private final HierarchyListener hierarchyListener = new HierarchyListener() {
     143    private final transient HierarchyListener hierarchyListener = new HierarchyListener() {
    144144        @Override
    145145        public void hierarchyChanged(HierarchyEvent e) {
     
    151151    };
    152152
    153     private final ComponentAdapter componentListener = new ComponentAdapter() {
     153    private final transient ComponentAdapter componentListener = new ComponentAdapter() {
    154154        @Override
    155155        public void componentShown(ComponentEvent e) {
     
    170170     * The current state (scale, center, ...) of this map view.
    171171     */
    172     private MapViewState state;
     172    private transient MapViewState state;
    173173
    174174    /**
  • trunk/src/org/openstreetmap/josm/gui/util/GuiSizesHelper.java

    r10392 r10409  
    33
    44import java.awt.Dimension;
    5 import java.awt.HeadlessException;
     5import java.awt.GraphicsEnvironment;
    66import java.awt.Toolkit;
    77
     
    2020    }
    2121
    22 
    2322    /** cache value for screen resolution */
    2423    private static float screenDPI = -1;
    2524
    26     /** Request the screen resolution (cached)
     25    /**
     26     * Request the screen resolution (cached)
    2727     * @return screen resolution in DPI
    2828     */
     
    3535                        screenDPI = 96f * scalePref;
    3636                    } else {
    37                         try {
     37                        if (!GraphicsEnvironment.isHeadless()) {
    3838                            screenDPI = Toolkit.getDefaultToolkit().getScreenResolution();
    39                         } catch (HeadlessException e) {
     39                        } else {
    4040                            screenDPI = 96;
    4141                        }
     
    5353     */
    5454    public static float getPixelDensity() {
    55         float pixelPerInch = getScreenDPI();
    56         return pixelPerInch / 96f;
     55        return getScreenDPI() / 96f;
    5756    }
    5857
     
    7271    public static int getSizeDpiAdjusted(int size) {
    7372        if (size <= 0) return size;
    74         float pixelPerInch = getScreenDPI();
    75         return Math.round(size * pixelPerInch / 96);
     73        return Math.round(size * getScreenDPI() / 96);
    7674    }
    7775
     
    8381    public static float getSizeDpiAdjusted(float size) {
    8482        if (size <= 0f) return size;
    85         float pixelPerInch = getScreenDPI();
    86         return size * pixelPerInch / 96;
     83        return size * getScreenDPI() / 96;
    8784    }
    8885
     
    9491    public static double getSizeDpiAdjusted(double size) {
    9592        if (size <= 0d) return size;
    96         float pixelPerInch = getScreenDPI();
    97         return size * pixelPerInch / 96;
     93        return size * getScreenDPI() / 96;
    9894    }
    9995
     
    105101    public static Dimension getDimensionDpiAdjusted(Dimension dim) {
    106102        float pixelPerInch = getScreenDPI();
    107         int width = dim.width, height = dim.height;
     103        int width = dim.width;
     104        int height = dim.height;
    108105        if (dim.width > 0) {
    109106            width = Math.round(dim.width * pixelPerInch / 96);
Note: See TracChangeset for help on using the changeset viewer.