1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
private class LineSeparator extends BasicSeparatorUI {
/**
* Initialise les type de traits.
*/
private void initStrokes(Graphics2D graphics2D) {
strokes = new BasicStroke[3];
if (graphics2D == null) {
graphics2D = (Graphics2D) getGraphics();
}
strokes[DEFAULT] = (BasicStroke) graphics2D.getStroke();
strokes[LINE] = new BasicStroke(strokes[DEFAULT].getLineWidth() * 2);
strokes[LIMIT] = new BasicStroke(strokes[DEFAULT].getLineWidth(), BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, new float[] { 10, 5 }, 0);
}
public void paint(Graphics g, JComponent c) {
Rectangle r = new Rectangle();
SwingUtilities.calculateInnerArea(c, r);
JSeparator s;
if (c instanceof JSeparator)
s = (JSeparator) c;
else
return;
Graphics2D graphics2D = (Graphics2D)g;
// Test si traits initialisés ?
if (strokes == null) {
initStrokes((Graphics2D)g);
}
if (s.getOrientation() == JSeparator.HORIZONTAL) {
int midAB = r.height / 2;
graphics2D.setStroke(strokes[LIMIT]);
graphics2D.drawLine(r.x, r.y + midAB - 1, r.x + r.width, r.y + midAB - 1);
} else {
int midAD = r.height / 2 + r.y;
graphics2D.setStroke(strokes[LIMIT]);
graphics2D.drawLine(r.x, r.y, r.x, r.y + r.height);
}
}
} |
Partager