|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
CrossPanel.java | - | 0% | 0% | 0% |
|
1 | /* | |
2 | * Copyright (C) 2007 Eric MIGNOT - mignots.eric@free.fr | |
3 | * | |
4 | * This library is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU Lesser General Public | |
6 | * License as published by the Free Software Foundation; either | |
7 | * version 2.1 of the License, or (at your option) any later version. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | * Lesser General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Lesser General Public | |
15 | * License along with this library; if not, write to the Free Software | |
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 | */ | |
18 | ||
19 | package org.ericmignot.modeler.util.graphic; | |
20 | ||
21 | import java.awt.Color; | |
22 | import java.awt.Graphics; | |
23 | ||
24 | import javax.swing.JPanel; | |
25 | ||
26 | ||
27 | public class CrossPanel extends JPanel | |
28 | { | |
29 | int crossHalfSize; | |
30 | ||
31 | 0 | public CrossPanel(int crossHalfSize) |
32 | { | |
33 | 0 | this.crossHalfSize = crossHalfSize; |
34 | 0 | this.setOpaque(false); |
35 | } | |
36 | ||
37 | 0 | public void paintComponent(Graphics g) |
38 | { | |
39 | 0 | int halfWidth = this.getWidth() / 2; |
40 | 0 | int halfHeight = this.getHeight() / 2; |
41 | 0 | Color oldColor = g.getColor(); |
42 | ||
43 | 0 | g.translate(halfWidth, halfHeight); |
44 | 0 | g.setColor(this.getForeground()); |
45 | 0 | g.drawLine(-this.crossHalfSize, 0, this.crossHalfSize, 0); |
46 | 0 | g.drawLine(0, -this.crossHalfSize, 0, this.crossHalfSize); |
47 | 0 | g.setColor(oldColor); |
48 | 0 | g.translate(-halfWidth, -halfHeight); |
49 | } | |
50 | } |
|