OSDN Git Service

initial commit
[xdf/git-repos.git] / xdf-swing / src / main / java / jp / ac / aiit / xdf / component / swing / attribute / CommonAttributeStore.java
1 package jp.ac.aiit.xdf.component.swing.attribute;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import jp.ac.aiit.xdf.component.swing.typeconvert.ColorConverter;
7 import jp.ac.aiit.xdf.component.swing.typeconvert.FontConverter;
8 import jp.ac.aiit.xdf.core.model.ObjectModel;
9 import jp.ac.aiit.xdf.core.typeconvert.PixelValueConverter;
10 import jp.ac.aiit.xdf.core.typeconvert.StringConverter;
11
12 /**
13  * @author Takagi Pin.Yuan
14  * 実コンポーネントに対する共通属性の処理方法を各マッパーへ提供する
15  *
16  */
17 public class CommonAttributeStore {
18         
19         /**
20          * 共通属性の処理方法を取得する
21          * @param model
22          * @return 共通属性の処理方法
23          */
24         public static Map<String, AttributeProcessingUnit> commonAttributes(ObjectModel model) {
25                 Map<String, AttributeProcessingUnit> result = new HashMap<String, AttributeProcessingUnit>();
26                 
27                 //コンポーネントの幅に関する共通属性
28                 result.put("width", new AttributeProcessingUnit(new WidthProcessor(true,true,true), new GetterAttributeProcessor("getWidth"), new PixelValueConverter()));
29                 result.put("min-width", new AttributeProcessingUnit(new WidthProcessor(true,false,false), new WidthHeightGetProcessor("width", "min"), new PixelValueConverter()));
30                 result.put("pref-width", new AttributeProcessingUnit(new WidthProcessor(false,true,false), new WidthHeightGetProcessor("width", "pref"), new PixelValueConverter()));
31                 result.put("max-width", new AttributeProcessingUnit(new WidthProcessor(false,false,true), new WidthHeightGetProcessor("width", "max"), new PixelValueConverter()));
32                 
33                 //コンポーネントの高さに関する共通属性
34                 result.put("height", new AttributeProcessingUnit(new HeightProcessor(true,true,true), new GetterAttributeProcessor("getHeight"), new PixelValueConverter()));
35                 result.put("min-height", new AttributeProcessingUnit(new WidthProcessor(true,false,false), new WidthHeightGetProcessor("height", "min"), new PixelValueConverter()));
36                 result.put("pref-height", new AttributeProcessingUnit(new WidthProcessor(false,true,false), new WidthHeightGetProcessor("height", "pref"), new PixelValueConverter()));
37                 result.put("max-height", new AttributeProcessingUnit(new WidthProcessor(false,false,true), new WidthHeightGetProcessor("height", "max"), new PixelValueConverter()));
38                 
39                 //コンポーネントの色に関する共通属性
40                 result.put("bgcolor", new AttributeProcessingUnit(new BgcolorProcessor(), new GetterAttributeProcessor("getBackground"), new ColorConverter()));
41                 result.put("fgcolor", new AttributeProcessingUnit(new SetterAttributeProcessor("setForeground", false), new GetterAttributeProcessor("getForeground"), new ColorConverter()));
42                 
43                 //その他、見た目に関する共通属性
44                 result.put("font", new AttributeProcessingUnit(new SetterAttributeProcessor("setFont", false), new GetterAttributeProcessor("getFont"), new FontConverter()));
45                 result.put("tooltip", new AttributeProcessingUnit(new SetterAttributeProcessor("setToolTipText", false), new GetterAttributeProcessor("getToolTipText"), new StringConverter()));
46
47                 return result;
48         }
49 }