(int display)
| 129 | |
| 130 | |
| 131 | private int displayDensityImpl(int display) { |
| 132 | GraphicsConfiguration graphicsConfig = null; |
| 133 | |
| 134 | if (display == -1) { // the default display |
| 135 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
| 136 | graphicsConfig = ge.getDefaultScreenDevice().getDefaultConfiguration(); |
| 137 | |
| 138 | } else if (display == SPAN) { |
| 139 | // walk through all displays, go with lowest common denominator |
| 140 | for (int i = 0; i < displayDevices.length; i++) { |
| 141 | if (displayDensityImpl(i) == 1) { |
| 142 | return 1; |
| 143 | } |
| 144 | } |
| 145 | return 2; // everyone is density 2 |
| 146 | |
| 147 | } else if (display <= displayDevices.length) { |
| 148 | graphicsConfig = displayDevices[display - 1].getDefaultConfiguration(); |
| 149 | } |
| 150 | |
| 151 | if (graphicsConfig == null) { |
| 152 | System.err.println("Display " + display + " does not exist, " + |
| 153 | "returning 1 for displayDensity(" + display + ")"); |
| 154 | return 1; // not the end of the world, so don't throw a RuntimeException |
| 155 | |
| 156 | } else { |
| 157 | AffineTransform tx = graphicsConfig.getDefaultTransform(); |
| 158 | return (int) Math.round(tx.getScaleX()); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | |
| 163 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
no test coverage detected