1+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+ /*
4+ Part of the Processing project - http://processing.org
5+
6+ Copyright (c) 2017 The Processing Foundation
7+
8+ This program is free software; you can redistribute it and/or modify
9+ it under the terms of the GNU General Public License as published by
10+ the Free Software Foundation; either version 2 of the License, or
11+ (at your option) any later version.
12+
13+ This program is distributed in the hope that it will be useful,
14+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+ GNU General Public License for more details.
17+
18+ You should have received a copy of the GNU General Public License
19+ along with this program; if not, write to the Free Software Foundation,
20+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+ */
22+
23+ package processing .app .ui ;
24+
25+ import java .awt .Component ;
26+
27+ import javax .swing .JTree ;
28+ import javax .swing .tree .DefaultTreeCellRenderer ;
29+
30+
31+ class ZoomTreeCellRenderer extends DefaultTreeCellRenderer {
32+
33+ @ Override
34+ public Component getTreeCellRendererComponent (JTree tree , Object value ,
35+ boolean selected ,
36+ boolean expanded ,
37+ boolean leaf , int row ,
38+ boolean hasFocus ) {
39+
40+ // Adjust height for magnified displays. The font is scaled properly,
41+ // but the rows don't automatically use the scaled preferred size.
42+ // https://github.com/processing/processing/issues/4936
43+ int high = getPreferredSize ().height ;
44+ if (high != 0 ) {
45+ int current = getSize ().height ;
46+ if (current != high ) {
47+ tree .setRowHeight (high );
48+ }
49+ }
50+ return super .getTreeCellRendererComponent (tree , value , selected ,
51+ expanded , leaf , row , hasFocus );
52+ }
53+ }
0 commit comments