MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / calcAutoWidth

Method calcAutoWidth

ij/src/main/java/ij/text/TextCanvas.java:132–157  ·  view source on GitHub ↗
(int column)

Source from the content-addressed store, hash-verified

130 }
131
132 void calcAutoWidth(int column) {
133 if (tp.sColHead==null || column>=tp.iColWidth.length || gImage==null)
134 return;
135 if (fMetrics==null)
136 fMetrics=gImage.getFontMetrics();
137 int w=15;
138 int maxRows = 20;
139 if (column==0 && tp.sColHead[0].equals(" "))
140 w += 5;
141 else {
142 char[] chars = tp.sColHead[column].toCharArray();
143 w = Math.max(w,fMetrics.charsWidth(chars,0,chars.length));
144 }
145 int rowCount = Math.min(tp.iRowCount, maxRows);
146 for (int row=0; row<rowCount; row++) {
147 char[] chars = tp.getChars(column,row);
148 if (chars!=null)
149 w = Math.max(w,fMetrics.charsWidth(chars,0,chars.length));
150 }
151 //System.out.println("calcAutoWidth: "+column+" "+tp.iRowCount);
152 char[] chars = tp.iRowCount>0?tp.getChars(column, tp.iRowCount-1):null;
153 if (chars!=null)
154 w = Math.max(w,fMetrics.charsWidth(chars,0,chars.length));
155 if (column<tp.iColWidth.length)
156 tp.iColWidth[column] = w+15;
157 }
158
159}

Callers 2

paintMethod · 0.95
scrollToTopMethod · 0.80

Calls 5

getCharsMethod · 0.80
getFontMetricsMethod · 0.45
equalsMethod · 0.45
maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected