-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathTitlePositionEditor.java
More file actions
37 lines (31 loc) · 875 Bytes
/
Copy pathTitlePositionEditor.java
File metadata and controls
37 lines (31 loc) · 875 Bytes
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
package chart;
import java.beans.*;
import java.util.*;
/**
* A custom editor for the titlePosition property of the ChartBean. The editor lets the user choose
* between Left, Center, and Right
* @version 1.20 2007-12-14
* @author Cay Horstmann
*/
public class TitlePositionEditor extends PropertyEditorSupport
{
private String[] tags = { "Left", "Center", "Right" };
public String[] getTags()
{
return tags;
}
public String getJavaInitializationString()
{
return ChartBean.Position.class.getName().replace('$', '.') + "." + getValue();
}
public String getAsText()
{
int index = ((ChartBean.Position) getValue()).ordinal();
return tags[index];
}
public void setAsText(String s)
{
int index = Arrays.asList(tags).indexOf(s);
if (index >= 0) setValue(ChartBean.Position.values()[index]);
}
}