this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

clean up thumbnail rendering code

+13 -13
+9 -10
src/main/java/app/pane/explorer/Item.java
··· 41 41 42 42 import app.SwingUtils; 43 43 import assets.AssetHandle; 44 + import util.Logger; 44 45 45 46 abstract class Item extends JPanel 46 47 { 47 - static final int PADDING = 2; 48 - static final int SIZE = AssetHandle.THUMBNAIL_WIDTH + (4 + PADDING) * 2; 48 + static final int PADDING = 3; 49 + static final int SIZE = AssetHandle.THUMBNAIL_WIDTH + PADDING * 2; 49 50 50 51 final Explorer explorer; 51 52 final String name; ··· 69 70 setLayout(null); 70 71 setPreferredSize(new Dimension(SIZE, SIZE)); 71 72 setOpaque(false); 72 - setBorder(BorderFactory.createEmptyBorder(4 + PADDING, 4 + PADDING, 4 + PADDING, 4 + PADDING)); 73 + setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING)); 73 74 74 75 var adapter = new MouseAdapter() { 75 76 @Override ··· 195 196 renameField = new JTextField(currentName); 196 197 renameField.setHorizontalAlignment(JTextField.CENTER); 197 198 renameField.selectAll(); 198 - renameField.setFont(renameField.getFont().deriveFont(12f)); 199 + renameField.setFont(renameField.getFont().deriveFont(11f)); 199 200 renameField.setBorder(null); 200 201 renameField.setMargin(new Insets(0, 0, 0, 0)); 201 202 ··· 310 311 311 312 // Icon 312 313 if (icon != null) { 313 - int iconW = Math.min(icon.getIconWidth(), AssetHandle.THUMBNAIL_WIDTH); 314 - int iconH = Math.min(icon.getIconHeight(), AssetHandle.THUMBNAIL_HEIGHT); 314 + int iconW = icon.getIconWidth(); 315 + int iconH = icon.getIconHeight(); 315 316 int iconX = x + (w - iconW) / 2; 316 317 int iconY = y + (iconAreaH - iconH) / 2; 317 318 318 319 if (checkerboard) 319 320 paintCheckerboard(g2, iconX, iconY, iconW, iconH); 320 321 321 - Graphics2D clipped = (Graphics2D) g2.create(iconX, iconY, iconW, iconH); 322 - icon.paintIcon(this, clipped, 0, 0); 323 - clipped.dispose(); 322 + icon.paintIcon(this, g2, iconX, iconY); 324 323 } 325 324 326 325 // Name label with ellipsis (hidden during inline rename) 327 326 if (renameField == null) { 328 327 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); 329 328 g2.setColor(UIManager.getColor("Label.foreground")); 330 - g2.setFont(getFont().deriveFont(12f)); 329 + g2.setFont(getFont().deriveFont(11f)); 331 330 FontMetrics fm = g2.getFontMetrics(); 332 331 333 332 String displayText = name;
+4 -3
src/main/java/assets/AssetHandle.java
··· 18 18 19 19 public class AssetHandle extends File 20 20 { 21 - public static final int THUMBNAIL_WIDTH = 80; 22 - public static final int THUMBNAIL_HEIGHT = 50; 21 + public static final int THUMBNAIL_WIDTH = 74; 22 + public static final int THUMBNAIL_HEIGHT = 60; 23 23 24 24 public static final DataFlavor FLAVOUR; 25 25 static { ··· 142 142 int srcH = src.getHeight(null); 143 143 144 144 int dstW, dstH; 145 - boolean scalingUp = maxW > srcW || maxH > srcH; 145 + boolean scalingUp = srcW <= maxW && srcH <= maxH; 146 146 if (scalingUp) { 147 147 // Integer scaling with nearest neighbour 148 148 int scale = Math.max(1, Math.min(maxW / srcW, maxH / srcH)); ··· 163 163 : RenderingHints.VALUE_INTERPOLATION_BILINEAR); 164 164 g.drawImage(src, 0, 0, dstW, dstH, null); 165 165 g.dispose(); 166 + assert bi.getWidth() <= maxW && bi.getHeight() <= maxH; 166 167 return bi; 167 168 } 168 169