1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hivegui.docking; |
16 | |
17 | import java.awt.Component; |
18 | import java.awt.Polygon; |
19 | import java.util.Map; |
20 | |
21 | import org.flexdock.docking.Dockable; |
22 | import org.flexdock.docking.DockingPort; |
23 | import org.flexdock.docking.drag.effects.DragPreview; |
24 | import org.flexdock.docking.drag.preview.GhostPreview; |
25 | |
26 | import net.sourceforge.hivegui.application.ApplicationContextHolder; |
27 | |
28 | public class CursorTrackGhostPreview |
29 | extends GhostPreview |
30 | implements DragPreview |
31 | { |
32 | public void setContextHolder(ApplicationContextHolder holder) |
33 | { |
34 | _tracker.setContext(holder.getContext()); |
35 | } |
36 | |
37 | @Override public Polygon createPreviewPolygon( Component dockable, |
38 | DockingPort port, |
39 | Dockable hover, |
40 | String targetRegion, |
41 | Component paintingTarget, |
42 | Map dragInfo) |
43 | { |
44 | if (!_tracker.trackCursor(dockable, port, targetRegion, paintingTarget)) |
45 | { |
46 | return null; |
47 | } |
48 | else |
49 | { |
50 | return super.createPreviewPolygon( dockable, |
51 | port, |
52 | hover, |
53 | targetRegion, |
54 | paintingTarget, |
55 | dragInfo); |
56 | } |
57 | } |
58 | |
59 | private final CursorTracker _tracker = new CursorTracker(); |
60 | } |