// empty panel,  just add the tracks
void tracksDropped(Point startPoint, Point dropPoint, List<Track> tracks) {
            // This cast is horrid but we can't fix everything at once.
            TrackPanel panel = ((TrackPanel) getParent());
            List<MouseableRegion> regions = getMouseRegions();
            if (regions.isEmpty()) {
                // empty panel,  just add the tracks
                panel.addTracks(tracks);
            } else {
                // Find the regions containing the startPoint and point
                boolean before = true;
                MouseableRegion dropRegion = null;
                MouseableRegion startRegion = null;
                for (MouseableRegion region : regions) {
                    if (region.containsPoint(dropPoint.x, dropPoint.y)) {
                        dropRegion = region;
                        Rectangle bnds = dropRegion.getBounds();
                        int dy1 = (dropPoint.y - bnds.y);
                        int dy2 = bnds.height - dy1;
                        before = dy1 < dy2;
                    }
                    if (region.containsPoint(startPoint.x, startPoint.y)) {
                        startRegion = region;
                    }
                    if (dropRegion != null && startRegion != null) {
                        break;
                    }
                }
                Track dropTrack = null;
                if (dropRegion != null) {
                    Iterator<Track> tmp = dropRegion.getTracks().iterator();
                    if (tmp.hasNext()) {
                        dropTrack = tmp.next();
                    }
                }
                panel.moveSelectedTracksTo(tracks, dropTrack, before);
            }
        }
List<MouseableRegion> regions = getMouseRegions();
if (regions.isEmpty()) {
// empty panel, just add the tracks
panel.addTracks(tracks);
} else {
void tracksDropped(Point startPoint, Point dropPoint, List<Track> tracks) {
// This cast is horrid but we can't fix everything at once.
TrackPanel panel = ((TrackPanel) getParent());
List<MouseableRegion> regions = getMouseRegions();
if (regions.isEmpty()) {
// empty panel, just add the tracks
panel.addTracks(tracks);
} else {
// Find the regions containing the startPoint and point
boolean before = true;
MouseableRegion dropRegion = null;
MouseableRegion startRegion = null;
for (MouseableRegion region : regions) {
if (region.containsPoint(dropPoint.x, dropPoint.y)) {
dropRegion = region;
Rectangle bnds = dropRegion.getBounds();
void tracksDropped(Point startPoint, Point dropPoint, List<Track> tracks) {
// This cast is horrid but we can't fix everything at once.
TrackPanel panel = ((TrackPanel) getParent());
List<MouseableRegion> regions = getMouseRegions();
if (regions.isEmpty()) {
// empty panel, just add the tracks
panel.addTracks(tracks);
} else {
// Find the regions containing the startPoint and point
boolean before = true;
MouseableRegion dropRegion = null;
MouseableRegion startRegion = null;
for (MouseableRegion region : regions) {
if (region.containsPoint(dropPoint.x, dropPoint.y)) {
dropRegion = region;
Rectangle bnds = dropRegion.getBounds();
int dy1 = (dropPoint.y - bnds.y);
int dy2 = bnds.height - dy1;
before = dy1 < dy2;
}
if (region.containsPoint(startPoint.x, startPoint.y)) {
startRegion = region;
}
if (dropRegion != null && startRegion != null) {
break;
}