View | Details | Raw Unified | Return to bug 59995
Collapse All | Expand All

(-)src/core/org/apache/jmeter/JMeter.java (-2 / +2 lines)
Lines 318-325 Link Here
318
    public JMeter() {
318
    public JMeter() {
319
        super();
319
        super();
320
    }
320
    }
321
321
    
322
323
    /**
322
    /**
324
     * Starts up JMeter in GUI mode
323
     * Starts up JMeter in GUI mode
325
     */
324
     */
Lines 339-344 Link Here
339
            log.warn("Could not set LAF to:"+jMeterLaf, ex);
338
            log.warn("Could not set LAF to:"+jMeterLaf, ex);
340
        }
339
        }
341
        splash.setProgress(10);
340
        splash.setProgress(10);
341
        JMeterUtils.applyHiDPIOnFonts();
342
        PluginManager.install(this, true);
342
        PluginManager.install(this, true);
343
343
344
        JMeterTreeModel treeModel = new JMeterTreeModel();
344
        JMeterTreeModel treeModel = new JMeterTreeModel();
(-)src/core/org/apache/jmeter/gui/action/ActionNames.java (+2 lines)
Lines 104-109 Link Here
104
    public static final String RUN_TG           = "run_tg"; // $NON-NLS-1$
104
    public static final String RUN_TG           = "run_tg"; // $NON-NLS-1$
105
    public static final String RUN_TG_NO_TIMERS = "run_tg_no_timers"; // $NON-NLS-1$
105
    public static final String RUN_TG_NO_TIMERS = "run_tg_no_timers"; // $NON-NLS-1$
106
    public static final String VALIDATE_TG      = "validate_tg"; //$NON-NLS-1$
106
    public static final String VALIDATE_TG      = "validate_tg"; //$NON-NLS-1$
107
    public static final String ZOOM_IN          = "zoom_in"; //$NON-NLS-1$
108
    public static final String ZOOM_OUT         = "zoom_out"; //$NON-NLS-1$
107
109
108
    // Prevent instantiation
110
    // Prevent instantiation
109
    private ActionNames() {}
111
    private ActionNames() {}
(-)src/core/org/apache/jmeter/gui/action/LookAndFeelCommand.java (-13 / +1 lines)
Lines 18-26 Link Here
18
18
19
package org.apache.jmeter.gui.action;
19
package org.apache.jmeter.gui.action;
20
20
21
import java.awt.Dialog;
22
import java.awt.Frame;
23
import java.awt.Window;
24
import java.awt.event.ActionEvent;
21
import java.awt.event.ActionEvent;
25
import java.util.ArrayList;
22
import java.util.ArrayList;
26
import java.util.HashSet;
23
import java.util.HashSet;
Lines 29-35 Link Here
29
import java.util.Set;
26
import java.util.Set;
30
import java.util.prefs.Preferences;
27
import java.util.prefs.Preferences;
31
28
32
import javax.swing.SwingUtilities;
33
import javax.swing.UIManager;
29
import javax.swing.UIManager;
34
30
35
import org.apache.jmeter.gui.util.JMeterMenuBar;
31
import org.apache.jmeter.gui.util.JMeterMenuBar;
Lines 130-144 Link Here
130
        try {
126
        try {
131
            String className = ev.getActionCommand().substring(ActionNames.LAF_PREFIX.length()).replace('/', '.');
127
            String className = ev.getActionCommand().substring(ActionNames.LAF_PREFIX.length()).replace('/', '.');
132
            UIManager.setLookAndFeel(className);
128
            UIManager.setLookAndFeel(className);
133
            for (Window w : Window.getWindows()) {
129
            JMeterUtils.refreshUI();
134
                SwingUtilities.updateComponentTreeUI(w);
135
                if (w.isDisplayable() &&
136
                    (w instanceof Frame ? !((Frame)w).isResizable() :
137
                    w instanceof Dialog ? !((Dialog)w).isResizable() :
138
                    true)) {
139
                    w.pack();
140
                }
141
            }
142
            PREFS.put(USER_PREFS_KEY, className);
130
            PREFS.put(USER_PREFS_KEY, className);
143
        } catch (javax.swing.UnsupportedLookAndFeelException | InstantiationException | ClassNotFoundException | IllegalAccessException e) {
131
        } catch (javax.swing.UnsupportedLookAndFeelException | InstantiationException | ClassNotFoundException | IllegalAccessException e) {
144
            JMeterUtils.reportErrorToUser("Look and Feel unavailable:" + e.toString());
132
            JMeterUtils.reportErrorToUser("Look and Feel unavailable:" + e.toString());
(-)src/core/org/apache/jmeter/gui/action/ZoomInOut.java (+60 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.gui.action;
20
21
import java.awt.event.ActionEvent;
22
import java.util.HashSet;
23
import java.util.Set;
24
25
import org.apache.jmeter.util.JMeterUtils;
26
27
/**
28
 * Zoom IN/OUT
29
 */
30
public class ZoomInOut extends AbstractAction {
31
    private static final Set<String> commands = new HashSet<>();
32
33
    private static final float ZOOM_SCALE = JMeterUtils.getPropDefault("zoom_scale", 1.1f);
34
35
    static {
36
        commands.add(ActionNames.ZOOM_IN);
37
        commands.add(ActionNames.ZOOM_OUT);
38
    }
39
40
    /**
41
     * @see org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest#doActionAfterCheck(ActionEvent)
42
     */
43
    @Override
44
    public void doAction(ActionEvent e) {
45
        final String actionCommand = e.getActionCommand();
46
        if (actionCommand.equals(ActionNames.ZOOM_IN)) {
47
            JMeterUtils.applyScaleOnFonts(ZOOM_SCALE);
48
        } else if (actionCommand.equals(ActionNames.ZOOM_OUT)) {
49
            JMeterUtils.applyScaleOnFonts(1/ZOOM_SCALE);
50
        }
51
    }
52
53
    /**
54
     * @see org.apache.jmeter.gui.action.Command#getActionNames()
55
     */
56
    @Override
57
    public Set<String> getActionNames() {
58
        return commands;
59
    }
60
}
(-)src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java (+5 lines)
Lines 346-351 Link Here
346
        JMenuItem expand = makeMenuItemRes("menu_expand_all", ActionNames.EXPAND_ALL, KeyStrokes.EXPAND_ALL); //$NON-NLS-1$
346
        JMenuItem expand = makeMenuItemRes("menu_expand_all", ActionNames.EXPAND_ALL, KeyStrokes.EXPAND_ALL); //$NON-NLS-1$
347
        optionsMenu.add(expand);
347
        optionsMenu.add(expand);
348
348
349
        JMenuItem zoomIn = makeMenuItemRes("menu_zoom_in", ActionNames.ZOOM_IN); //$NON-NLS-1$
350
        optionsMenu.add(zoomIn);
351
        JMenuItem zoomOut = makeMenuItemRes("menu_zoom_out", ActionNames.ZOOM_OUT); //$NON-NLS-1$
352
        optionsMenu.add(zoomOut);
353
349
        addPluginsMenuItems(optionsMenu, menuCreators, MENU_LOCATION.OPTIONS);
354
        addPluginsMenuItems(optionsMenu, menuCreators, MENU_LOCATION.OPTIONS);
350
    }
355
    }
351
356
(-)src/core/org/apache/jmeter/resources/messages.properties (+2 lines)
Lines 668-673 Link Here
668
menu_threads=Threads (Users)
668
menu_threads=Threads (Users)
669
menu_timer=Timer
669
menu_timer=Timer
670
menu_toolbar=Toolbar
670
menu_toolbar=Toolbar
671
menu_zoom_in=Zoom In
672
menu_zoom_out=Zoom Out
671
metadata=MetaData
673
metadata=MetaData
672
method=Method\:
674
method=Method\:
673
mimetype=Mimetype
675
mimetype=Mimetype
(-)src/core/org/apache/jmeter/resources/messages_fr.properties (+2 lines)
Lines 658-663 Link Here
658
menu_threads=Moteurs d'utilisateurs
658
menu_threads=Moteurs d'utilisateurs
659
menu_timer=Compteurs de temps
659
menu_timer=Compteurs de temps
660
menu_toolbar=Barre d'outils
660
menu_toolbar=Barre d'outils
661
menu_zoom_in=Agrandir
662
menu_zoom_out=R\u00E9duire
661
metadata=M\u00E9ta-donn\u00E9es
663
metadata=M\u00E9ta-donn\u00E9es
662
method=M\u00E9thode \:
664
method=M\u00E9thode \:
663
mimetype=Type MIME
665
mimetype=Type MIME
(-)src/core/org/apache/jmeter/util/JMeterUtils.java (+51 lines)
Lines 18-24 Link Here
18
18
19
package org.apache.jmeter.util;
19
package org.apache.jmeter.util;
20
20
21
import java.awt.Dialog;
22
import java.awt.Font;
23
import java.awt.Frame;
21
import java.awt.HeadlessException;
24
import java.awt.HeadlessException;
25
import java.awt.Window;
22
import java.io.BufferedReader;
26
import java.io.BufferedReader;
23
import java.io.File;
27
import java.io.File;
24
import java.io.FileInputStream;
28
import java.io.FileInputStream;
Lines 35-40 Link Here
35
import java.util.MissingResourceException;
39
import java.util.MissingResourceException;
36
import java.util.Properties;
40
import java.util.Properties;
37
import java.util.ResourceBundle;
41
import java.util.ResourceBundle;
42
import java.util.Set;
38
import java.util.Vector;
43
import java.util.Vector;
39
import java.util.concurrent.ThreadLocalRandom;
44
import java.util.concurrent.ThreadLocalRandom;
40
45
Lines 42-47 Link Here
42
import javax.swing.JOptionPane;
47
import javax.swing.JOptionPane;
43
import javax.swing.JTable;
48
import javax.swing.JTable;
44
import javax.swing.SwingUtilities;
49
import javax.swing.SwingUtilities;
50
import javax.swing.UIManager;
45
51
46
import org.apache.commons.io.IOUtils;
52
import org.apache.commons.io.IOUtils;
47
import org.apache.jmeter.gui.GuiPackage;
53
import org.apache.jmeter.gui.GuiPackage;
Lines 1144-1147 Link Here
1144
        return delimiterValue;
1150
        return delimiterValue;
1145
    }
1151
    }
1146
1152
1153
    /**
1154
     * Apply HiDPI scale factor on font if HiDPI mode is enabled
1155
     */
1156
    public static void applyHiDPIOnFonts() {
1157
        if (!getHiDPIMode()) {
1158
            return;
1159
        }
1160
        applyScaleOnFonts((float) getHiDPIScaleFactor());
1161
    }
1162
    
1163
    /**
1164
     * Apply HiDPI scale factor on fonts
1165
     * @param scale flot scale to apply
1166
     */
1167
    public static void applyScaleOnFonts(final float scale) {
1168
        SwingUtilities.invokeLater(() -> {
1169
            Set<Object> keySet = UIManager.getLookAndFeelDefaults().keySet();
1170
            Object[] keys = keySet.toArray(new Object[keySet.size()]);
1171
            for (Object key : keys) {
1172
                if (key != null && key.toString().toLowerCase().contains("font")) {
1173
                    Font font = UIManager.getDefaults().getFont(key);
1174
                    if (font != null) {
1175
                        font = font.deriveFont(font.getSize() * scale);
1176
                        UIManager.put(key, font);
1177
                    }
1178
                }
1179
            } 
1180
            JMeterUtils.refreshUI();
1181
        });
1182
    }
1183
    
1184
    /**
1185
     * Refresh UI after LAF change or resizing
1186
     */
1187
    public static final void refreshUI() {
1188
        for (Window w : Window.getWindows()) {
1189
            SwingUtilities.updateComponentTreeUI(w);
1190
            if (w.isDisplayable() &&
1191
                (w instanceof Frame ? !((Frame)w).isResizable() :
1192
                w instanceof Dialog ? !((Dialog)w).isResizable() :
1193
                true)) {
1194
                w.pack();
1195
            }
1196
        }
1197
    }
1147
}
1198
}

Return to bug 59995