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