333 |
314 |
334 // Width and height of the painting rectangle. |
315 // Width and height of the painting rectangle. |
335 int w = paintRect.width; |
316 int w = paintRect.width; |
336 int h = paintRect.height; |
317 int h = paintRect.height; |
337 |
318 |
338 if (!slider.isEnabled()) { |
319 if (slider.getOrientation() == JSlider.HORIZONTAL) { |
339 g.setColor(MetalLookAndFeel.getControlShadow()); |
320 int middleOfThumb = thumbRect.x + thumbRect.width / 2 - paintRect.x; |
340 g.drawRect(0, 0, w - 1, h - 1); |
321 |
341 } |
322 if (slider.isEnabled()) { |
342 else if (slider.getOrientation() == JSlider.HORIZONTAL) { |
323 int fillMinX; |
343 int middleOfThumb = thumbRect.x + (thumbRect.width / 2) - |
324 int fillMaxX; |
344 paintRect.x; |
325 |
345 int fillMinX; |
326 if (middleOfThumb > 0) { |
346 int fillMaxX; |
327 g.setColor(drawInverted ? MetalLookAndFeel.getControlDarkShadow() : |
347 |
328 MetalLookAndFeel.getPrimaryControlDarkShadow()); |
348 if (middleOfThumb > 0) { |
329 |
349 g.setColor(chooseColor(drawInverted, |
330 g.drawRect(0, 0, middleOfThumb - 1, h - 1); |
350 MetalLookAndFeel.getPrimaryControlDarkShadow(), |
331 } |
351 MetalLookAndFeel.getControlDarkShadow())); |
332 |
352 g.drawRect(0, 0, middleOfThumb - 1, h - 1); |
333 if (middleOfThumb < w) { |
353 } |
334 g.setColor(drawInverted ? MetalLookAndFeel.getPrimaryControlDarkShadow() : |
354 if (middleOfThumb < w) { |
335 MetalLookAndFeel.getControlDarkShadow()); |
355 g.setColor(chooseColor(drawInverted, |
336 |
356 MetalLookAndFeel.getControlDarkShadow(), |
337 g.drawRect(middleOfThumb, 0, w - middleOfThumb - 1, h - 1); |
357 MetalLookAndFeel.getPrimaryControlDarkShadow())); |
338 } |
358 g.drawRect(middleOfThumb, 0, w - middleOfThumb - 1, h - 1); |
339 |
359 } |
340 if (filledSlider) { |
360 g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); |
341 g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); |
361 if (drawInverted) { |
342 if (drawInverted) { |
362 fillMinX = middleOfThumb; |
343 fillMinX = middleOfThumb; |
363 fillMaxX = w - 2; |
344 fillMaxX = w - 2; |
364 g.drawLine(1, 1, middleOfThumb, 1); |
345 g.drawLine(1, 1, middleOfThumb, 1); |
365 } |
346 } else { |
366 else { |
347 fillMinX = 1; |
367 fillMinX = 1; |
348 fillMaxX = middleOfThumb; |
368 fillMaxX = middleOfThumb; |
349 g.drawLine(middleOfThumb, 1, w - 1, 1); |
369 g.drawLine(middleOfThumb, 1, w - 1, 1); |
350 } |
370 } |
351 if (h == 6) { |
371 if (h == 6) { |
352 g.setColor(MetalLookAndFeel.getWhite()); |
372 g.setColor(MetalLookAndFeel.getWhite()); |
353 g.drawLine(fillMinX, 1, fillMaxX, 1); |
373 g.drawLine(fillMinX, 1, fillMaxX, 1); |
354 g.setColor(sliderAltTrackColor); |
374 g.setColor(sliderAltTrackColor); |
355 g.drawLine(fillMinX, 2, fillMaxX, 2); |
375 g.drawLine(fillMinX, 2, fillMaxX, 2); |
356 g.setColor(MetalLookAndFeel.getControlShadow()); |
|
357 g.drawLine(fillMinX, 3, fillMaxX, 3); |
|
358 g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); |
|
359 g.drawLine(fillMinX, 4, fillMaxX, 4); |
|
360 } |
|
361 } |
|
362 } else { |
376 g.setColor(MetalLookAndFeel.getControlShadow()); |
363 g.setColor(MetalLookAndFeel.getControlShadow()); |
377 g.drawLine(fillMinX, 3, fillMaxX, 3); |
364 |
378 g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); |
365 if (middleOfThumb > 0) { |
379 g.drawLine(fillMinX, 4, fillMaxX, 4); |
366 if (!drawInverted && filledSlider) { |
380 } |
367 g.fillRect(0, 0, middleOfThumb - 1, h - 1); |
381 } |
368 } else { |
382 else { |
369 g.drawRect(0, 0, middleOfThumb - 1, h - 1); |
383 int middleOfThumb = thumbRect.y + (thumbRect.height / 2) - |
370 } |
384 paintRect.y; |
371 } |
385 int fillMinY; |
372 |
386 int fillMaxY; |
373 if (middleOfThumb < w) { |
387 |
374 if (drawInverted && filledSlider) { |
388 if (middleOfThumb > 0) { |
375 g.fillRect(middleOfThumb, 0, w - middleOfThumb - 1, h - 1); |
389 g.setColor(chooseColor(drawInverted, |
376 } else { |
390 MetalLookAndFeel.getControlDarkShadow(), |
377 g.drawRect(middleOfThumb, 0, w - middleOfThumb - 1, h - 1); |
391 MetalLookAndFeel.getPrimaryControlDarkShadow())); |
378 } |
392 g.drawRect(0, 0, w - 1, middleOfThumb - 1); |
379 } |
393 } |
380 } |
394 if (middleOfThumb < h) { |
381 } else { |
395 g.setColor(chooseColor(drawInverted, |
382 int middleOfThumb = thumbRect.y + (thumbRect.height / 2) - paintRect.y; |
396 MetalLookAndFeel.getPrimaryControlDarkShadow(), |
383 |
397 MetalLookAndFeel.getControlDarkShadow())); |
384 if (slider.isEnabled()) { |
398 g.drawRect(0, middleOfThumb, w - 1, h - middleOfThumb - 1); |
385 int fillMinY; |
399 } |
386 int fillMaxY; |
400 g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); |
387 |
401 if (drawInverted()) { |
388 if (middleOfThumb > 0) { |
402 fillMinY = 1; |
389 g.setColor(drawInverted ? MetalLookAndFeel.getPrimaryControlDarkShadow() : |
403 fillMaxY = middleOfThumb; |
390 MetalLookAndFeel.getControlDarkShadow()); |
404 if (leftToRight) { |
391 |
405 g.drawLine(1, middleOfThumb, 1, h - 1); |
392 g.drawRect(0, 0, w - 1, middleOfThumb - 1); |
406 } |
393 } |
407 else { |
394 |
408 g.drawLine(w - 2, middleOfThumb, w - 2, h - 1); |
395 if (middleOfThumb < h) { |
409 } |
396 g.setColor(drawInverted ? MetalLookAndFeel.getControlDarkShadow() : |
410 } |
397 MetalLookAndFeel.getPrimaryControlDarkShadow()); |
411 else { |
398 |
412 fillMinY = middleOfThumb; |
399 g.drawRect(0, middleOfThumb, w - 1, h - middleOfThumb - 1); |
413 fillMaxY = h - 2; |
400 } |
414 if (leftToRight) { |
401 |
415 g.drawLine(1, 1, 1, middleOfThumb); |
402 if (filledSlider) { |
416 } |
403 g.setColor(MetalLookAndFeel.getPrimaryControlShadow()); |
417 else { |
404 if (drawInverted()) { |
418 g.drawLine(w - 2, 1, w - 2, middleOfThumb); |
405 fillMinY = 1; |
419 } |
406 fillMaxY = middleOfThumb; |
420 } |
407 if (leftToRight) { |
421 if (w == 6) { |
408 g.drawLine(1, middleOfThumb, 1, h - 1); |
422 g.setColor(chooseColor(!leftToRight, |
409 } else { |
423 MetalLookAndFeel.getWhite(), |
410 g.drawLine(w - 2, middleOfThumb, w - 2, h - 1); |
424 MetalLookAndFeel.getPrimaryControlShadow())); |
411 } |
425 g.drawLine(1, fillMinY, 1, fillMaxY); |
412 } else { |
426 g.setColor(chooseColor(!leftToRight, sliderAltTrackColor, |
413 fillMinY = middleOfThumb; |
427 MetalLookAndFeel.getControlShadow())); |
414 fillMaxY = h - 2; |
428 g.drawLine(2, fillMinY, 2, fillMaxY); |
415 if (leftToRight) { |
429 g.setColor(chooseColor(!leftToRight, |
416 g.drawLine(1, 1, 1, middleOfThumb); |
430 MetalLookAndFeel.getControlShadow(), |
417 } else { |
431 sliderAltTrackColor)); |
418 g.drawLine(w - 2, 1, w - 2, middleOfThumb); |
432 g.drawLine(3, fillMinY, 3, fillMaxY); |
419 } |
433 g.setColor(chooseColor(!leftToRight, |
420 } |
434 MetalLookAndFeel.getPrimaryControlShadow(), |
421 if (w == 6) { |
435 MetalLookAndFeel.getWhite())); |
422 g.setColor(leftToRight ? MetalLookAndFeel.getWhite() : MetalLookAndFeel.getPrimaryControlShadow()); |
436 g.drawLine(4, fillMinY, 4, fillMaxY); |
423 g.drawLine(1, fillMinY, 1, fillMaxY); |
|
424 g.setColor(leftToRight ? sliderAltTrackColor : MetalLookAndFeel.getControlShadow()); |
|
425 g.drawLine(2, fillMinY, 2, fillMaxY); |
|
426 g.setColor(leftToRight ? MetalLookAndFeel.getControlShadow() : sliderAltTrackColor); |
|
427 g.drawLine(3, fillMinY, 3, fillMaxY); |
|
428 g.setColor(leftToRight ? MetalLookAndFeel.getPrimaryControlShadow() : MetalLookAndFeel.getWhite()); |
|
429 g.drawLine(4, fillMinY, 4, fillMaxY); |
|
430 } |
|
431 } |
|
432 } else { |
|
433 g.setColor(MetalLookAndFeel.getControlShadow()); |
|
434 |
|
435 if (middleOfThumb > 0) { |
|
436 if (drawInverted && filledSlider) { |
|
437 g.fillRect(0, 0, w - 1, middleOfThumb - 1); |
|
438 } else { |
|
439 g.drawRect(0, 0, w - 1, middleOfThumb - 1); |
|
440 } |
|
441 } |
|
442 |
|
443 if (middleOfThumb < h) { |
|
444 if (!drawInverted && filledSlider) { |
|
445 g.fillRect(0, middleOfThumb, w - 1, h - middleOfThumb - 1); |
|
446 } else { |
|
447 g.drawRect(0, middleOfThumb, w - 1, h - middleOfThumb - 1); |
|
448 } |
|
449 } |
437 } |
450 } |
438 } |
451 } |
439 |
452 |
440 g.translate(-paintRect.x, -paintRect.y); |
453 g.translate(-paintRect.x, -paintRect.y); |
441 } |
454 } |