mygfx.setFont(labelFont);
} // Just in case, requested font unavailable
else
mygfx = g;
FontMetrics fm = mygfx.getFontMetrics();
int offset = 0;
double w = (double) size.width;
double ppu = w / (max - min);
while (ppu * tickIncrement < 2) {
tickIncrement += 10;
}
int pix_inc = (int)(tickIncrement * ppu);
int labelSpan = labelIncrement * tickIncrement;
for (int i = min, x = 0, j = 0;
i <= max;
i += tickIncrement, x += pix_inc) {
if (i % labelSpan == 0) {
String label = String.valueOf(min + (j * labelSpan));
offset = 0;
// Place leftmost label to right
if (i != min)
offset = fm.stringWidth(label) / 2;
if (i >= max) // Place rightmost label to left
offset = fm.stringWidth(label);
mygfx.drawString(label, x - offset, size.height/2);
mygfx.drawLine(x, size.height/2, x, size.height);
j++;
} else