double loc = tickRect.height + tickRect.y + 0.5; double increment = (max == min) ? 0 : -majorSpace * (double) (tickRect.height - 1) / (max - min); if (drawInverted()) { loc = tickRect.y + 0.5; increment *= -1; }
  public void paintTicks(Graphics g)  {    int max = slider.getMaximum();    int min = slider.getMinimum();    int majorSpace = slider.getMajorTickSpacing();    int minorSpace = slider.getMinorTickSpacing();    if (majorSpace > 0)      {	if (slider.getOrientation() == JSlider.HORIZONTAL)	  {	    double loc = tickRect.x + 0.5;	    double increment = (max == min) ? 0	        : majorSpace * (double) (tickRect.width - 1) / (max - min);            if (drawInverted())	      {		loc += tickRect.width;		increment *= -1;	      }            g.translate(0, tickRect.y);	    for (int i = min; i <= max; i += majorSpace)	      {		paintMajorTickForHorizSlider(g, tickRect, (int) loc);		loc += increment;	      }            g.translate(0, -tickRect.y);	  }	else	  {	    double loc = tickRect.height + tickRect.y + 0.5;	    double increment = (max == min) ? 0	        : -majorSpace * (double) (tickRect.height - 1) / (max - min);	    if (drawInverted())	      {		loc = tickRect.y + 0.5;		increment *= -1;	      }            g.translate(tickRect.x, 0);	    for (int i = min; i <= max; i += majorSpace)	      {		paintMajorTickForVertSlider(g, tickRect, (int) loc);		loc += increment;	      }            g.translate(-tickRect.x, 0);	  }      }    if (minorSpace > 0)      {	if (slider.getOrientation() == JSlider.HORIZONTAL)	  {	    double loc = tickRect.x + 0.5;	    double increment = (max == min) ? 0	        : minorSpace * (double) (tickRect.width - 1) / (max - min);	    if (drawInverted())	      {		loc += tickRect.width;		increment *= -1;	      }            g.translate(0, tickRect.y);	    for (int i = min; i <= max; i += minorSpace)	      {		paintMinorTickForHorizSlider(g, tickRect, (int) loc);		loc += increment;	      }            g.translate(0, -tickRect.y);	  }	else	  {	    double loc = tickRect.height + tickRect.y + 0.5;	    double increment = (max == min) ? 0	        : -minorSpace * (double) (tickRect.height - 1) / (max - min);	    if (drawInverted())	      {		loc = tickRect.y + 0.5;		increment *= -1;	      }            g.translate(tickRect.x, 0);	    for (int i = min; i <= max; i += minorSpace)	      {		paintMinorTickForVertSlider(g, tickRect, (int) loc);		loc += increment;	      }            g.translate(-tickRect.x, 0);	  }      }  }