01: package org.drools.eclipse.flow.common.editor.editpart.figure;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.eclipse.draw2d.Label;
20: import org.eclipse.draw2d.Panel;
21: import org.eclipse.draw2d.geometry.Rectangle;
22: import org.eclipse.swt.graphics.Image;
23:
24: /**
25: * Default implementation of an element Figure.
26: *
27: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
28: */
29: public abstract class ElementFigure extends Panel {
30:
31: private boolean selected;
32: private Label label = new Label();
33:
34: public ElementFigure() {
35: add(label);
36: customizeFigure();
37: setSize(80, 40);
38: }
39:
40: public void setIcon(Image icon) {
41: label.setIcon(icon);
42: }
43:
44: public void setText(String text) {
45: label.setText(text);
46: }
47:
48: public Label getLabel() {
49: return label;
50: }
51:
52: public void setBounds(Rectangle bounds) {
53: super .setBounds(bounds);
54: label.setBounds(bounds);
55: }
56:
57: protected abstract void customizeFigure();
58:
59: public void setSelected(boolean b) {
60: selected = b;
61: }
62:
63: public boolean isSelected() {
64: return selected;
65: }
66:
67: public void setFocus(boolean b) {
68: repaint();
69: }
70: }
|