View Javadoc

1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2007, Ontotext Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  /***
19   * <p>Title: WSMO Studio</p>
20   * <p>Description: Semantic Web Service Editor</p>
21   * <p>Copyright:  Copyright (c) 2004-2007</p>
22   * <p>Company: Ontotext Lab. / SIRMA </p>
23   */
24  
25  package org.wsmostudio.bpmo.figures;
26  
27  import org.eclipse.draw2d.*;
28  import org.eclipse.draw2d.geometry.Rectangle;
29  
30  public class TimerFigure extends Shape {
31  
32      boolean selected;
33      
34      public TimerFigure() {
35          super();
36          setBorder(new MarginBorder(3,3,3,3));
37          setOpaque(false);
38      }
39  
40      protected void outlineShape(Graphics graphics) {
41  
42          Rectangle r = getBounds();
43          int centerX = r.x + r.width / 2;
44          int centerY = r.y + r.height / 2;
45          
46          int rad = Math.min(r.width / 2, r.height / 2) - getLineWidth();
47          
48          graphics.setLineWidth(getLineWidth());
49          graphics.drawOval(centerX - r.width / 2 + getLineWidth(), centerY - r.height / 2 + getLineWidth(),
50          		(r.width / 2) * 2 - 2 * getLineWidth(), (r.height / 2) * 2 - 2 * getLineWidth());
51          graphics.drawOval(centerX - r.width / 2 + getLineWidth() + 2, centerY - r.height / 2 + getLineWidth() + 2,
52                  (r.width / 2) * 2 - 2 * getLineWidth() - 4, (r.height / 2) * 2 - 2 * getLineWidth() - 4);
53  
54          
55          graphics.drawLine(centerX, centerY, centerX, centerY - rad/3);
56          graphics.drawLine(centerX, centerY, centerX + rad / 4, centerY);
57  
58          graphics.setLineWidth(3);
59          graphics.drawOval(centerX - rad / 2, centerY - rad / 2, rad, rad);
60          
61      }
62  
63      protected void fillShape(Graphics g) {
64          Rectangle r = getBounds();
65          int centerX = r.x + r.width / 2;
66          int centerY = r.y + r.height / 2;
67          g.fillOval(centerX - r.width / 2 + getLineWidth(), centerY - r.height / 2 + getLineWidth(),
68          		(r.width / 2) * 2 - 2 * getLineWidth(), (r.height / 2) * 2 - 2 * getLineWidth());
69      }
70  
71      public void setSelected(boolean selected) {
72          if (this.selected == selected)
73              return;
74          this.selected = selected;
75          repaint();
76      }
77  
78  }
79  
80  /*
81   * $Log$
82   * Revision 1.2  2007/08/23 15:33:00  alex_simov
83   * ui and save/load update
84   *
85   * Revision 1.1  2007/08/22 16:19:10  alex_simov
86   * no message
87   *
88   */