375
376 labelRect.height = 0;
377 if (slider.getPaintLabels()) {
378 labelRect.height = getHeightOfTallestLabel();
379 }
380
381 contentRect.height = valueRect.height + trackRect.height
382 + trackInsets.top + trackInsets.bottom
383 + tickRect.height + labelRect.height + 4;
384 contentRect.width = slider.getWidth() - insetCache.left
385 - insetCache.right;
386
387 // Check if any of the labels will paint out of bounds.
388 int pad = 0;
389 if (slider.getPaintLabels()) {
390 // Calculate the track rectangle. It is necessary for
391 // xPositionForValue to return correct values.
392 trackRect.x = insetCache.left;
393 trackRect.width = contentRect.width;
394
395 Dictionary<Integer, JComponent> dictionary = slider.getLabelTable();
396 if (dictionary != null) {
397 int minValue = slider.getMinimum();
398 int maxValue = slider.getMaximum();
399
400 // Iterate through the keys in the dictionary and find the
401 // first and last labels indices that fall within the
402 // slider range.
403 int firstLblIdx = Integer.MAX_VALUE;
404 int lastLblIdx = Integer.MIN_VALUE;
405 for (Enumeration<Integer> keys = dictionary.keys();
406 keys.hasMoreElements(); ) {
407 int keyInt = keys.nextElement().intValue();
408 if (keyInt >= minValue && keyInt < firstLblIdx) {
409 firstLblIdx = keyInt;
410 }
411 if (keyInt <= maxValue && keyInt > lastLblIdx) {
412 lastLblIdx = keyInt;
413 }
414 }
415 // Calculate the pad necessary for the labels at the first
|
375
376 labelRect.height = 0;
377 if (slider.getPaintLabels()) {
378 labelRect.height = getHeightOfTallestLabel();
379 }
380
381 contentRect.height = valueRect.height + trackRect.height
382 + trackInsets.top + trackInsets.bottom
383 + tickRect.height + labelRect.height + 4;
384 contentRect.width = slider.getWidth() - insetCache.left
385 - insetCache.right;
386
387 // Check if any of the labels will paint out of bounds.
388 int pad = 0;
389 if (slider.getPaintLabels()) {
390 // Calculate the track rectangle. It is necessary for
391 // xPositionForValue to return correct values.
392 trackRect.x = insetCache.left;
393 trackRect.width = contentRect.width;
394
395 Dictionary<Integer, ? extends JComponent> dictionary = slider.getLabelTable();
396 if (dictionary != null) {
397 int minValue = slider.getMinimum();
398 int maxValue = slider.getMaximum();
399
400 // Iterate through the keys in the dictionary and find the
401 // first and last labels indices that fall within the
402 // slider range.
403 int firstLblIdx = Integer.MAX_VALUE;
404 int lastLblIdx = Integer.MIN_VALUE;
405 for (Enumeration<Integer> keys = dictionary.keys();
406 keys.hasMoreElements(); ) {
407 int keyInt = keys.nextElement().intValue();
408 if (keyInt >= minValue && keyInt < firstLblIdx) {
409 firstLblIdx = keyInt;
410 }
411 if (keyInt <= maxValue && keyInt > lastLblIdx) {
412 lastLblIdx = keyInt;
413 }
414 }
415 // Calculate the pad necessary for the labels at the first
|