Changeset 16960 in josm for trunk/src/org


Ignore:
Timestamp:
2020-08-29T13:33:25+02:00 (4 years ago)
Author:
simon04
Message:

see #8334 - Add advanced option to scale the table font

Advanced preference keys gui.scale.table.*

Location:
trunk/src/org/openstreetmap/josm
Files:
23 edited

Legend:

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

    r16828 r16960  
    210210        //
    211211        layerList = new LayerList(model);
     212        TableHelper.setFont(layerList, getClass());
    212213        layerList.setSelectionModel(selectionModel);
    213214        layerList.addMouseListener(new PopupMenuHandler());
     
    919920            Icon icon = layer.getIcon();
    920921            if (layerList != null && icon != null) {
    921                 layerList.setRowHeight(idx, Math.max(16, icon.getIconHeight()));
     922                layerList.setRowHeight(idx, Math.max(layerList.getRowHeight(), icon.getIconHeight()));
    922923            }
    923924            selectionModel.setSelectionInterval(idx, idx);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r16598 r16960  
    315315    private void buildTagsTable() {
    316316        // setting up the tags table
     317        TableHelper.setFont(tagTable, getClass());
    317318        tagData.setColumnIdentifiers(new String[]{tr("Key"), tr("Value")});
    318319        tagTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
     
    339340
    340341    private void buildMembershipTable() {
     342        TableHelper.setFont(membershipTable, getClass());
    341343        membershipData.setColumnIdentifiers(new String[]{tr("Member Of"), tr("Role"), tr("Position")});
    342344        membershipTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/SelectionTable.java

    r15048 r16960  
    99import javax.swing.ListSelectionModel;
    1010import javax.swing.SwingUtilities;
     11
     12import org.openstreetmap.josm.gui.util.TableHelper;
    1113
    1214/**
     
    3234
    3335    protected void build() {
     36        TableHelper.setFont(this, getClass());
    3437        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    3538        addMouseListener(new DoubleClickAdapter());
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r16419 r16960  
    5151import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    5252import org.openstreetmap.josm.gui.util.GuiHelper;
     53import org.openstreetmap.josm.gui.util.TableHelper;
    5354import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    5455import org.openstreetmap.josm.gui.widgets.JosmComboBox;
     
    144145        columnmodel = new NamedResultTableColumnModel();
    145146        tblSearchResults = new JTable(model, columnmodel);
     147        TableHelper.setFont(tblSearchResults, DownloadDialog.class);
    146148        tblSearchResults.setSelectionModel(selectionModel);
    147149        JScrollPane scrollPane = new JScrollPane(tblSearchResults);
  • trunk/src/org/openstreetmap/josm/gui/history/NodeListViewer.java

    r16644 r16960  
    1414import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
    1515import org.openstreetmap.josm.data.osm.history.History;
     16import org.openstreetmap.josm.gui.util.TableHelper;
    1617import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    1718
     
    4142        final NodeListTableColumnModel columnModel = new NodeListTableColumnModel();
    4243        final JTable table = new JTable(tableModel, columnModel);
     44        TableHelper.setFont(table, getClass());
    4345        tableModel.addTableModelListener(new ReversedChangeListener(table, columnModel, tr("The nodes of this way are in reverse order")));
    4446        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  • trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListViewer.java

    r16609 r16960  
    1313import org.openstreetmap.josm.data.osm.RelationMemberData;
    1414import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     15import org.openstreetmap.josm.gui.util.TableHelper;
    1516import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    1617
     
    3233        final RelationMemberTableColumnModel columnModel = new RelationMemberTableColumnModel();
    3334        final JTable table = new JTable(tableModel, columnModel);
     35        TableHelper.setFont(table, getClass());
    3436        tableModel.addTableModelListener(new ReversedChangeListener(
    3537                table, columnModel, tr("The members of this relation are in reverse order")));
  • trunk/src/org/openstreetmap/josm/gui/history/TagInfoViewer.java

    r16597 r16960  
    2525import org.openstreetmap.josm.gui.dialogs.properties.HelpTagAction;
    2626import org.openstreetmap.josm.gui.dialogs.properties.TaginfoAction;
     27import org.openstreetmap.josm.gui.util.TableHelper;
    2728import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    2829
     
    6768        TagTableModel tagTableModel = model.getTagTableModel(pointInTime);
    6869        JTable table = new JTable(tagTableModel, new TagTableColumnModel());
     70        TableHelper.setFont(table, getClass());
    6971        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    7072        selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel());
  • trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java

    r16457 r16960  
    3434import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
    3535import org.openstreetmap.josm.gui.util.GuiHelper;
     36import org.openstreetmap.josm.gui.util.TableHelper;
    3637import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    3738import org.openstreetmap.josm.io.XmlWriter;
     
    6970        setShowGrid(false);
    7071        setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
     72        TableHelper.setFont(this, getClass());
    7173        GuiHelper.setBackgroundReadable(this, UIManager.getColor("Button.background"));
    7274        setIntercellSpacing(new Dimension(6, 0));
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java

    r16942 r16960  
    318318            super(model);
    319319            this.content = content;
     320            TableHelper.setFont(this, getClass());
    320321        }
    321322
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/WMTSLayerSelection.java

    r16553 r16960  
    2424
    2525import org.openstreetmap.josm.data.imagery.WMTSTileSource.Layer;
     26import org.openstreetmap.josm.gui.util.TableHelper;
    2627import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    2728import org.openstreetmap.josm.tools.GBC;
     
    9697        list = new JTable(
    9798                new AbstractTableModelExtension(layers));
     99        TableHelper.setFont(list, getClass());
    98100        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    99101        list.setAutoCreateRowSorter(true);
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r16601 r16960  
    338338        iconPathsModel = new IconPathTableModel(selectionModel);
    339339        tblIconPaths = new JTable(iconPathsModel);
     340        TableHelper.setFont(tblIconPaths, getClass());
    340341        tblIconPaths.setSelectionModel(selectionModel);
    341342        tblIconPaths.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AbstractTableListEditor.java

    r16553 r16960  
    2323import javax.swing.table.TableCellEditor;
    2424
     25import org.openstreetmap.josm.gui.util.TableHelper;
    2526import org.openstreetmap.josm.gui.widgets.JosmTextField;
    2627import org.openstreetmap.josm.tools.GBC;
     
    5556        tableModel = newTableModel();
    5657        table = new JTable(tableModel);
     58        TableHelper.setFont(table, PreferencesTable.class);
    5759        setContent(build(), false);
    5860    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ListEditor.java

    r14153 r16960  
    1616import javax.swing.table.AbstractTableModel;
    1717
     18import org.openstreetmap.josm.gui.util.TableHelper;
    1819import org.openstreetmap.josm.gui.widgets.JosmTextField;
    1920import org.openstreetmap.josm.spi.preferences.ListSetting;
     
    5152        p.add(new JLabel(tr("Key: {0}", entry.getKey())), GBC.eol().insets(0, 0, 5, 0));
    5253        JTable table = new JTable(model);
     54        TableHelper.setFont(table, getClass());
    5355        table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    5456        table.setTableHeader(null);
  • trunk/src/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTable.java

    r16846 r16960  
    3131import org.openstreetmap.josm.gui.ExtendedDialog;
    3232import org.openstreetmap.josm.gui.util.GuiHelper;
     33import org.openstreetmap.josm.gui.util.TableHelper;
    3334import org.openstreetmap.josm.gui.widgets.JosmTextField;
    3435import org.openstreetmap.josm.spi.preferences.ListListSetting;
     
    5960        getColumnModel().getColumn(1).setCellEditor(new SettingCellEditor());
    6061
     62        TableHelper.setFont(this, getClass());
    6163        addMouseListener(new MouseAdapter() {
    6264            @Override public void mouseClicked(MouseEvent e) {
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java

    r16625 r16960  
    5353import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
    5454import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
     55import org.openstreetmap.josm.gui.preferences.advanced.PreferencesTable;
    5556import org.openstreetmap.josm.gui.util.GuiHelper;
     57import org.openstreetmap.josm.gui.util.TableHelper;
    5658import org.openstreetmap.josm.gui.widgets.FilterField;
    5759import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    307309
    308310        colors = new JTable(tableModel);
     311        TableHelper.setFont(colors, PreferencesTable.class);
    309312        colors.setAutoCreateRowSorter(true);
    310313        FilterField colorFilter = new FilterField().filter(colors, tableModel);
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CacheSettingsPanel.java

    r16398 r16960  
    4040import org.openstreetmap.josm.gui.layer.WMTSLayer;
    4141import org.openstreetmap.josm.gui.util.GuiHelper;
     42import org.openstreetmap.josm.gui.util.TableHelper;
    4243import org.openstreetmap.josm.gui.widgets.ButtonColumn;
    4344import org.openstreetmap.josm.gui.widgets.JosmTextField;
     
    147148    private static JTable getTableForCache(final CacheAccess<String, BufferedImageCacheEntry> cache, final TableModel tableModel) {
    148149        final JTable ret = new JTable(tableModel);
     150        TableHelper.setFont(ret, CacheSettingsPanel.class);
    149151
    150152        ButtonColumn buttonColumn = new ButtonColumn(
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r15115 r16960  
    4141import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    4242import org.openstreetmap.josm.gui.util.GuiHelper;
     43import org.openstreetmap.josm.gui.util.TableHelper;
    4344import org.openstreetmap.josm.tools.GBC;
    4445import org.openstreetmap.josm.tools.Logging;
     
    198199                }
    199200            };
     201            TableHelper.setFont(list, getClass());
    200202            JScrollPane scroll = new JScrollPane(list);
    201203            add(scroll, GBC.eol().fill(GridBagConstraints.BOTH));
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryProvidersPanel.java

    r16555 r16960  
    6262import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    6363import org.openstreetmap.josm.gui.util.GuiHelper;
     64import org.openstreetmap.josm.gui.util.TableHelper;
    6465import org.openstreetmap.josm.gui.widgets.FilterField;
    6566import org.openstreetmap.josm.gui.widgets.HtmlPanel;
     
    224225            }
    225226        };
     227        TableHelper.setFont(activeTable, getClass());
    226228        activeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    227229
    228230        defaultModel = new ImageryDefaultLayerTableModel();
    229231        defaultTable = new JTable(defaultModel);
     232        TableHelper.setFont(defaultTable, getClass());
    230233        defaultTable.setAutoCreateRowSorter(true);
    231234        defaultFilter = new FilterField().filter(defaultTable, defaultModel);
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeSelectionPanel.java

    r13544 r16960  
    2222import org.openstreetmap.josm.data.projection.Projections;
    2323import org.openstreetmap.josm.gui.preferences.projection.CodeProjectionChoice.CodeComparator;
     24import org.openstreetmap.josm.gui.util.TableHelper;
    2425import org.openstreetmap.josm.gui.widgets.JosmTextField;
    2526import org.openstreetmap.josm.tools.GBC;
     
    9798
    9899        table = new JTable(model);
     100        TableHelper.setFont(table, getClass());
    99101        table.setAutoCreateRowSorter(true);
    100102        JScrollPane scroll = new JScrollPane(table);
  • trunk/src/org/openstreetmap/josm/gui/preferences/shortcut/PrefJPanel.java

    r16913 r16960  
    4141import org.openstreetmap.josm.data.preferences.NamedColorProperty;
    4242import org.openstreetmap.josm.gui.util.GuiHelper;
     43import org.openstreetmap.josm.gui.util.TableHelper;
    4344import org.openstreetmap.josm.gui.widgets.FilterField;
    4445import org.openstreetmap.josm.gui.widgets.JosmComboBox;
     
    194195
    195196        // This is the list of shortcuts:
     197        TableHelper.setFont(shortcutTable, getClass());
    196198        shortcutTable.setModel(model);
    197199        shortcutTable.getSelectionModel().addListSelectionListener(action);
  • trunk/src/org/openstreetmap/josm/gui/util/TableHelper.java

    r16601 r16960  
    33
    44import java.awt.Component;
     5import java.awt.Font;
    56import java.util.stream.IntStream;
    67
     
    1415
    1516import org.openstreetmap.josm.gui.dialogs.IEnabledStateUpdating;
     17import org.openstreetmap.josm.spi.preferences.Config;
    1618
    1719/**
     
    162164        selectionModel.setValueIsAdjusting(false);
    163165    }
     166
     167    /**
     168     * Sets the table font size based on the font scaling from the preferences
     169     * @param table the table
     170     * @param parent the parent component used for determining the preference key
     171     * @see JTable#setFont(Font)
     172     * @see JTable#setRowHeight(int)
     173     */
     174    public static void setFont(JTable table, Class<? extends Component> parent) {
     175        double fontFactor = Config.getPref().getDouble("gui.scale.table.font",
     176                Config.getPref().getDouble("gui.scale.table." + parent.getSimpleName() + ".font", 1.0));
     177        if (fontFactor == 1.0) {
     178            return;
     179        }
     180        Font font = table.getFont();
     181        table.setFont(font.deriveFont((float) (font.getSize2D() * fontFactor)));
     182        // need to setRowHeight, see comment in javax.swing.plaf.basic.BasicTableUI.installDefaults
     183        table.setRowHeight((int) (table.getRowHeight() * fontFactor));
     184    }
    164185}
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmTable.java

    r10070 r16960  
    1717import javax.swing.table.TableModel;
    1818
     19import org.openstreetmap.josm.gui.util.TableHelper;
     20
    1921/**
    2022 * Generic table offering custom cell navigation features.
     
    3436    protected JosmTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm) {
    3537        super(dm, cm, sm);
     38        TableHelper.setFont(this, getClass());
    3639    }
    3740
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java

    r16791 r16960  
    194194        };
    195195
     196        TableHelper.setFont(propertyTable, getClass());
    196197        propertyTable.setAutoCreateRowSorter(true);
    197198        propertyTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
Note: See TracChangeset for help on using the changeset viewer.