]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/notification/AbstractNotification.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / notification / AbstractNotification.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.notification;\r
13 \r
14 import java.awt.geom.Rectangle2D;\r
15 \r
16 /**\r
17  * @author Tuukka Lehtonen\r
18  */\r
19 public abstract class AbstractNotification implements INotification {\r
20 \r
21     protected Rectangle2D bounds = new Rectangle2D.Double();\r
22     protected long        creationTime;\r
23     protected double      progress;\r
24 \r
25     public AbstractNotification() {\r
26         this.creationTime = System.currentTimeMillis();\r
27     }\r
28 \r
29     @Override\r
30     public long getCreationTime() {\r
31         return creationTime;\r
32     }\r
33 \r
34 //    @Override\r
35 //    public Rectangle2D getBounds(Graphics2D g) {\r
36 //        return bounds;\r
37 //    }\r
38 \r
39     @Override\r
40     public void setBounds(Rectangle2D r) {\r
41         this.bounds.setFrame(r);\r
42     }\r
43 \r
44     @Override\r
45     public void setProgress(double p) {\r
46         this.progress = p;\r
47     }\r
48 \r
49     @Override\r
50     public int compareTo(INotification o) {\r
51         long delta = getCreationTime() - o.getCreationTime();\r
52         return delta < 0 ? -1 : delta > 0 ? 1 : 0;\r
53     }\r
54 \r
55     @Override\r
56     public String toString() {\r
57         return getClass().getSimpleName() + "[" + creationTime + ", progress=" + progress + "]";\r
58     }\r
59 \r
60 }