// draw the tics
float lowX = 0.5f * tickSizes.get(0).getWidth();
float lowY = 0;
float highX = lowX;
float highY = 0.333f * ticHeight;
Rectangle baseRect = new Rectangle(0, 0, ticWidth, 0.333f * ticHeight);
// fills
for (int i = 0; i < ticNumber; i++) {
if (i % 2 == 0) {
context.moveRectangleTo(baseRect, lowX, lowY);
context.fillRectangle(baseRect, Color.white);
context.strokeRectangle(baseRect, Color.black, 0.5f);
context.moveRectangleTo(baseRect, highX, highY);
context.fillRectangle(baseRect, Color.black);
context.strokeRectangle(baseRect, Color.black, 0.5f);
} else {
context.moveRectangleTo(baseRect, highX, highY);
context.fillRectangle(baseRect, Color.white);
context.strokeRectangle(baseRect, Color.black, 0.5f);
context.moveRectangleTo(baseRect, lowX, lowY);
context.fillRectangle(baseRect, Color.black);
context.strokeRectangle(baseRect, Color.black, 0.5f);
}
lowX += ticWidth;
highX += ticWidth;
}
// tick extensions
highX = 0.5f * tickSizes.get(0).getWidth();
highY = 0.6666f * ticHeight;
for (int i = 0; i <= ticNumber; i++) {
context.drawRelativePath(new float[] { 0, 0 }, new float[] { 0, 1 }, new Rectangle(highX, highY, highX,
0.75f * ticHeight), Color.black, 0.5f, null);
highX += ticWidth;
}
// position and print the labels
float labelX = 0.5f * tickSizes.get(0).getWidth();
float labelY = ticHeight;
for (int i = 0; i < tickLabels.size(); i++) {
Rectangle box = tickSizes.get(i);
// center the label
context.moveRectangleTo(box, labelX - 0.5f * box.getWidth(), labelY);
context.drawText(tickLabels.get(i), font, box, Color.black);
labelX += ticWidth;
}
}