KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > diagrams > ClassNameFigure


1 /*
2   Copyright (C) 2002-2003 Renaud Pawlak <renaud@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program 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
12   GNU 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 program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 */

18
19 package org.objectweb.jac.ide.diagrams;
20
21 import org.objectweb.jac.aspects.gui.FieldUpdate;
22 import org.objectweb.jac.aspects.gui.Utils;
23 import org.objectweb.jac.core.rtti.ClassRepository;
24 import org.objectweb.jac.core.rtti.FieldItem;
25 import org.objectweb.jac.ide.Class;
26 import java.awt.Color JavaDoc;
27
28 public class ClassNameFigure extends TextFigure implements FieldUpdate {
29
30    Class JavaDoc substance;
31    ClassFigure parentFigure;
32
33    static FieldItem nameField =
34       ClassRepository.get().getClass(Class JavaDoc.class).getField("name");
35
36    public ClassNameFigure(Class JavaDoc substance, ClassFigure parentFigure) {
37       this.substance = substance;
38       this.parentFigure = parentFigure;
39       super.setText(substance.getName());
40       Utils.registerField(substance,nameField,this);
41    }
42
43    public Color JavaDoc getTextColor() {
44       return parentFigure.getColor();
45    }
46
47    /**
48     * Get the value of substance.
49     * @return value of substance.
50     */

51    public Class JavaDoc getSubstance() {
52       return substance;
53    }
54    
55    /**
56     * Set the value of substance.
57     * @param v Value to assign to substance.
58     */

59    public void setSubstance(Class JavaDoc v) {
60       this.substance = v;
61    }
62
63    public String JavaDoc getName() {
64       return getText();
65    }
66
67    public void setText(String JavaDoc s) {
68       super.setText(s);
69       if (substance != null && !DiagramView.init) {
70          substance.setName(s);
71       }
72    }
73
74    // FieldUpdate interface
75
public void fieldUpdated(Object JavaDoc substance, FieldItem field, Object JavaDoc
76                             value, Object JavaDoc param) {
77       super.setText((String JavaDoc)value);
78    }
79 }
80
Popular Tags