OSDN Git Service

srcディレクトリとdocディレクトリを作成
[xdf/git-repos.git] / src / xdf-swing / src / main / java / jp / ac / aiit / xdf / component / swing / attribute / WidthProcessor.java
1 package jp.ac.aiit.xdf.component.swing.attribute;
2
3 import java.awt.Component;
4 import java.awt.Dimension;
5
6
7 /**
8  * コンポーネントの幅に関する属性値(min-width, pref-width, max-width)を反映するクラス
9  *  
10  * @author Shunichi Takagi
11  */
12 public class WidthProcessor implements AttributeSetProcessor {
13         private boolean min, pref, max;
14         
15         public WidthProcessor(boolean min, boolean pref, boolean max) {
16                 this.min = min;
17                 this.pref = pref;
18                 this.max = max;
19         }
20         
21         @Override
22         public void invokeSet(Object target, String name, Object value) {
23                 if( target instanceof Component ) {
24                         if( min ) {
25                                 ((Component) target).setMinimumSize(new Dimension(((Integer) value).intValue(), ((Component) target).getMinimumSize().height));
26                         }
27                         if( pref ) {
28                                 ((Component) target).setPreferredSize(new Dimension(((Integer) value).intValue(), ((Component) target).getPreferredSize().height));
29                         }
30                         if( max ) {
31                                 ((Component) target).setMaximumSize(new Dimension(((Integer) value).intValue(), ((Component) target).getMaximumSize().height));
32                         }
33                 }
34         }
35         
36 }