KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > figures > MLDCFreeformLayer


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * Project author: Daniel Mazurek <Daniel.Mazurek [at] nightlabs [dot] org> *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin St, Fifth Floor, *
20  * Boston, MA 02110-1301 USA *
21  * *
22  * Or get it online : *
23  * http://www.gnu.org/copyleft/lesser.html *
24  * *
25  * *
26  ******************************************************************************/

27
28 package org.nightlabs.editor2d.figures;
29
30 import java.util.Map JavaDoc;
31
32 import org.eclipse.draw2d.FreeformLayer;
33 import org.eclipse.draw2d.UpdateListener;
34 import org.eclipse.draw2d.UpdateManager;
35 import org.eclipse.draw2d.geometry.Rectangle;
36
37 import org.nightlabs.editor2d.edit.MultiLayerDrawComponentEditPart;
38 import org.nightlabs.editor2d.util.EditorUtil;
39
40
41 public class MLDCFreeformLayer
42 extends FreeformLayer
43 implements UpdateListener
44 {
45   public MLDCFreeformLayer() {
46     super();
47   }
48     
49   public void registerOnDeferredUpdateManager(UpdateManager updateManager) {
50     if (updateManager == null)
51       return;
52     updateManager.removeUpdateListener(this);
53     updateManager.addUpdateListener(this);
54   }
55     
56   private MultiLayerDrawComponentEditPart mldcEditPart;
57     public void setMldcEditPart(MultiLayerDrawComponentEditPart mldcEditPart) {
58       this.mldcEditPart = mldcEditPart;
59     }
60     
61   private Rectangle notifiedDamage;
62   
63   public void notifyPainting(Rectangle damage, Map JavaDoc dirtyRegions) {
64     if (mldcEditPart == null)
65         return;
66     notifiedDamage = damage;
67     notifiedDamage = EditorUtil.toAbsolute(mldcEditPart, damage);
68 // System.out.println("MLDC notify Painting called with "+damage);
69
}
70   
71   public void notifyValidating() {
72   }
73       
74 // public void paint(Graphics graphics) {
75
// super.paint(graphics);
76
// System.out.println("MLDC paint called with ");
77
// if (notifiedDamage == null) {
78
// super.paint(graphics);
79
// return;
80
// }
81
//
82
//// System.out.println("MLDC notifiedDamage != null");
83
// for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
84
// IFigure child = (IFigure) iter.next();
85
// if (child.intersects(notifiedDamage)) {
86
// graphics.pushState();
87
// try {
88
// graphics.setClip(child.getBounds());
89
//// System.out.println("MLDC paint child: "+child+" child.getBounds() "+child.getBounds());
90
// child.paint(graphics);
91
// graphics.restoreState();
92
// } finally
93
// {
94
// graphics.popState();
95
// }
96
// }
97
// }
98
// notifiedDamage = null;
99
// }
100
}
101
Popular Tags