(Graphics g)
| 722 | |
| 723 | /// {@inheritDoc} |
| 724 | @Override |
| 725 | public void paint(Graphics g) { |
| 726 | |
| 727 | Image cthumbImage = getCurrentThumbImage(); |
| 728 | Image cTrackImage = value ? getCurrentTrackOnImage() : getCurrentTrackOffImage(); |
| 729 | //Image ctrackOnImage = getCurrentTrackOnImage(); |
| 730 | //Image ctrackOffImage = getCurrentTrackOffImage(); |
| 731 | int strackLength = Math.max(cTrackImage.getWidth(), cTrackImage.getWidth()); |
| 732 | int sheight = Math.max(cthumbImage.getHeight(), Math.max(cTrackImage.getHeight(), cTrackImage.getHeight())); |
| 733 | |
| 734 | int vdeltaX = -deltaX; //virtual increase in slider "value" where OFF state = 0 and ON state = itrackLength |
| 735 | if (isRTL()) { |
| 736 | vdeltaX = deltaX; |
| 737 | } |
| 738 | |
| 739 | Style s = getStyle(); |
| 740 | int padLeft = s.getPaddingLeft(isRTL()); //s.getPaddingLeftNoRTL(); |
| 741 | int padRight = s.getPaddingRight(isRTL()); |
| 742 | int padTop = s.getPaddingTop(); |
| 743 | int padBot = s.getPaddingBottom(); |
| 744 | int innerHeight = getHeight() - padTop - padBot; //cache it to avoid calling getPadding multiple times, which costs CPU as it make the unit conversion at each call... |
| 745 | int innerWidth = getWidth() - padLeft - padRight; |
| 746 | int halign = s.getAlignment(); //TODO: swap left and right if RTL |
| 747 | |
| 748 | int thumbrX = 0; //X position of the thumb relative to the start of the track |
| 749 | if (isRTL()) { |
| 750 | if (!value) { |
| 751 | thumbrX = cTrackImage.getWidth() - cthumbImage.getWidth(); |
| 752 | } |
| 753 | } else { |
| 754 | if (value) { |
| 755 | thumbrX = cTrackImage.getWidth() - cthumbImage.getWidth(); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | Image nextThumbImage = null; |
| 760 | Image nextTrackImage = null; |
| 761 | double nextImageProgress = 0.0; |
| 762 | |
| 763 | if (value) { //switch is ON so only drag movements going to the OFF position are relevant, meaning a vdelta < 0 |
| 764 | if (vdeltaX > 0) { |
| 765 | dragged = false; |
| 766 | } else { |
| 767 | nextThumbImage = getThumbOffImage(); |
| 768 | nextTrackImage = getTrackOffImage(); |
| 769 | int trackMLength = cTrackImage.getWidth() - cthumbImage.getWidth(); |
| 770 | if (vdeltaX < -trackMLength) { |
| 771 | vdeltaX = -trackMLength; |
| 772 | } |
| 773 | nextImageProgress = Math.abs(vdeltaX) / (double) Math.abs(trackMLength); |
| 774 | |
| 775 | |
| 776 | } |
| 777 | } else { //switch is OFF so only consider drag movements toward the ON position, meaning a vdelta > 0 |
| 778 | if (vdeltaX < 0) { |
| 779 | dragged = false; |
| 780 | } else { |
| 781 | nextThumbImage = getThumbOnImage(); |
nothing calls this directly
no test coverage detected