org.flexdock.docking.drag.DragPipeline Maven / Gradle / Ivy
The newest version!
/*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.flexdock.docking.drag;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import org.flexdock.docking.DockingConstants;
import org.flexdock.docking.DockingPort;
import org.flexdock.docking.defaults.DefaultDockingPort;
import org.flexdock.docking.drag.effects.EffectsManager;
import org.flexdock.docking.drag.effects.RubberBand;
import org.flexdock.util.RootWindow;
import org.flexdock.util.SwingUtility;
public class DragPipeline {
private GlassPaneMonitor paneMonitor;
private RootWindow[] windows;
private HashMap rootWindowsByBounds;
private DragGlasspane currentGlasspane;
private DragGlasspane newGlassPane;
private Rectangle[] windowBounds;
private boolean heavyweightDockableSupportted;
private boolean open;
private DragOperation dragToken;
private RubberBand rubberBand;
public DragPipeline() {
paneMonitor = new GlassPaneMonitor();
rubberBand = EffectsManager.getRubberBand();
}
public boolean isOpen() {
return open;
}
public void open(DragOperation token) {
if(token==null) {
throw new NullPointerException("'token' parameter cannot be null.");
}
if(EventQueue.isDispatchThread()) {
openImpl(token);
return;
}
final DragOperation dToken = token;
try {
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
openImpl(dToken);
}
});
} catch(Exception e) {
System.err.println("Exception: " +e.getMessage());
}
}
private void openImpl(DragOperation operation) {
// check to see if we're going to support heavyweight dockables for this operation
heavyweightDockableSupportted = Boolean.getBoolean(DockingConstants.HEAVYWEIGHT_DOCKABLES);
this.dragToken = operation;
// turn the current drag operation on
setCurrentDragOperation(operation);
windows = RootWindow.getVisibleWindows();
windowBounds = new Rectangle[windows.length];
rootWindowsByBounds = new HashMap();
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy