-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathInverseEditor.java
More file actions
52 lines (43 loc) · 1.23 KB
/
Copy pathInverseEditor.java
File metadata and controls
52 lines (43 loc) · 1.23 KB
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
45
46
47
48
49
50
51
52
package chart;
import java.awt.*;
import java.beans.*;
import javax.swing.*;
/**
* The property editor for the inverse property of the ChartBean. The inverse property toggles
* between colored graph bars and colored background.
* @version 1.30 2007-10-03
* @author Cay Horstmann
*/
public class InverseEditor extends PropertyEditorSupport
{
private ImageIcon normalIcon = new ImageIcon(getClass().getResource("ChartBean_MONO_16x16.gif"));
private ImageIcon inverseIcon = new ImageIcon(getClass().getResource(
"ChartBean_INVERSE_16x16.gif"));
public Component getCustomEditor()
{
return new InverseEditorPanel(this);
}
public boolean supportsCustomEditor()
{
return true;
}
public boolean isPaintable()
{
return true;
}
public String getAsText()
{
return null;
}
public String getJavaInitializationString()
{
return "" + getValue();
}
public void paintValue(Graphics g, Rectangle bounds)
{
ImageIcon icon = (Boolean) getValue() ? inverseIcon : normalIcon;
int x = bounds.x + (bounds.width - icon.getIconWidth()) / 2;
int y = bounds.y + (bounds.height - icon.getIconHeight()) / 2;
g.drawImage(icon.getImage(), x, y, null);
}
}