Changeset 1102 for trunk/src/org/apollo/gui/FrameLayoutDaemon.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/gui/FrameLayoutDaemon.java
r1061 r1102 1 1 package org.apollo.gui; 2 2 3 import java.awt.Point;4 import java.awt.event.ComponentEvent;5 import java.awt.event.ComponentListener;6 import java.awt.event.MouseEvent;7 3 import java.io.File; 8 import java.lang.reflect.InvocationTargetException;9 4 import java.util.Collection; 10 5 import java.util.HashMap; 11 6 import java.util.Map; 12 13 import javax.swing.SwingUtilities;14 7 15 8 import org.apollo.audio.ApolloSubjectChangedEvent; … … 30 23 import org.apollo.widgets.LinkedTrack; 31 24 import org.apollo.widgets.SampledTrack; 32 import org.expeditee.gui.Browser; 33 import org.expeditee.gui.DisplayIO; 34 import org.expeditee.gui.DisplayIOObserver; 25 import org.expeditee.core.Point; 26 import org.expeditee.gio.EcosystemManager; 27 import org.expeditee.gio.InputManager.WindowEventListener; 28 import org.expeditee.gio.InputManager.WindowEventType; 29 import org.expeditee.gio.gesture.StandardGestureActions; 30 import org.expeditee.gui.DisplayController; 31 import org.expeditee.gui.DisplayObserver; 35 32 import org.expeditee.gui.Frame; 36 import org.expeditee.gui.FrameMouseActions;37 33 import org.expeditee.gui.FreeItems; 38 import org.expeditee.gui.MouseEventRouter;39 34 import org.expeditee.items.Item; 40 35 import org.expeditee.items.ItemUtils; 41 import org.expeditee.items.widgets. InteractiveWidget;36 import org.expeditee.items.widgets.Widget; 42 37 import org.expeditee.items.widgets.WidgetCorner; 43 38 import org.expeditee.items.widgets.WidgetEdge; … … 46 41 * A daemon that lays out overdubbed frames. 47 42 * 48 * It is a singleton e. Also it is a subject which raises empty events whenever43 * It is a singleton. Also it is a subject which raises empty events whenever 49 44 * a new timeline is created. 50 45 * … … 52 47 * 53 48 */ 54 public class FrameLayoutDaemon extends AbstractSubject implements Observer, Display IOObserver {49 public class FrameLayoutDaemon extends AbstractSubject implements Observer, DisplayObserver { 55 50 56 51 /** The frame that should not be layout out at any point in time. */ … … 98 93 daemon.start(); 99 94 AudioStructureModel.getInstance().addObserver(this); 100 DisplayIO.addDisplayIOObserver(this); 101 102 // Listen for resize events 103 SwingUtilities.invokeLater(new Runnable() { 104 public void run() { 105 106 // Keep expanded view centered to the browser window 107 if (Browser._theBrowser != null) { 108 Browser._theBrowser.addComponentListener(new ComponentListener() { 109 110 public void componentHidden(ComponentEvent e) { 111 } 112 113 public void componentMoved(ComponentEvent e) { 114 } 115 116 public void componentResized(ComponentEvent e) { 117 forceRecheck(); 118 } 119 120 public void componentShown(ComponentEvent e) { 121 } 122 123 }); 124 } 125 95 DisplayController.addDisplayObserver(this); 96 97 EcosystemManager.getInputManager().addWindowEventListener(new WindowEventListener() 98 { 99 @Override 100 public void onWindowEvent(WindowEventType type) 101 { 102 if (type == WindowEventType.WINDOW_RESIZED) forceRecheck(); 126 103 } 127 104 }); … … 321 298 // Note that accessing expeditee model in another thread -- 322 299 // Being real careful not to do anything unsafe 323 Frame currentFrame = Display IO.getCurrentFrame();300 Frame currentFrame = DisplayController.getCurrentFrame(); 324 301 if (currentFrame == null) continue; 325 302 … … 340 317 341 318 try { 342 SwingUtilities.invokeAndWait(trackFormatter);343 } catch ( InterruptedExceptione) {319 EcosystemManager.getMiscManager().runOnGIOThread(trackFormatter); 320 } catch (Throwable e) { 344 321 e.printStackTrace(); 345 } catch (InvocationTargetException e) {346 e.printStackTrace();347 322 } 348 323 … … 359 334 assert(toFormat != null); 360 335 361 // To late?362 if (toFormat != Display IO.getCurrentFrame()) return;336 // Too late? 337 if (toFormat != DisplayController.getCurrentFrame()) return; 363 338 364 339 boolean supressSpatialLayout = suspendedFrame == toFormat; … … 370 345 boolean hasRunningTime = false; // A flag set to true if there is actual audio to [lay 371 346 372 Map< InteractiveWidget, AbstractTrackGraphNode> widgetsToFormat = new HashMap<InteractiveWidget, AbstractTrackGraphNode>();373 374 for ( InteractiveWidget iw : toFormat.getInteractiveWidgets()) {347 Map<Widget, AbstractTrackGraphNode> widgetsToFormat = new HashMap<Widget, AbstractTrackGraphNode>(); 348 349 for (Widget iw : toFormat.getInteractiveWidgets()) { 375 350 376 351 AbstractTrackGraphNode abinf = null; … … 429 404 430 405 // Anything to format? 431 if (!hasRunningTime || 432 widgetsToFormat.isEmpty() || 433 longestEndTime == firstInitiationTime) { 406 if (!hasRunningTime || widgetsToFormat.isEmpty() || longestEndTime == firstInitiationTime) { 434 407 435 408 // NOTE: longestEndTime == firstInitiationTime indicates linked tracks … … 450 423 // Ensure that left most pixel is at a reasonable position 451 424 if (!supressSpatialLayout && (initiationXPixel < 0 || 452 (initiationXPixel > Browser._theBrowser.getWidth() && Browser._theBrowser.getWidth() > leftMargin))) {425 (initiationXPixel > DisplayController.getFramePaintArea().getWidth() && DisplayController.getFramePaintArea().getWidth() > leftMargin))) { 453 426 initiationXPixel = leftMargin; 454 427 } else if (!supressSpatialLayout && initiationXPixel > LAYOUT_MAX_INITIATION_PIXEL) { … … 459 432 timelineWidth = rightMostPixel - initiationXPixel; 460 433 } else { 461 timelineWidth = Browser._theBrowser.getWidth() - initiationXPixel - rightMargin;434 timelineWidth = DisplayController.getFramePaintArea().getWidth() - initiationXPixel - rightMargin; 462 435 } 463 436 … … 483 456 if (!supressSpatialLayout) { 484 457 485 for ( InteractiveWidget iw : widgetsToFormat.keySet()) {458 for (Widget iw : widgetsToFormat.keySet()) { 486 459 487 460 AbstractTrackGraphNode atgi = widgetsToFormat.get(iw); … … 545 518 546 519 Item i = FreeItems.getItemAttachedToCursor(); 547 InteractiveWidget freespaceTrackToFormat = null;520 Widget freespaceTrackToFormat = null; 548 521 if (i != null && i instanceof WidgetEdge) { 549 522 freespaceTrackToFormat = ((WidgetEdge)i).getWidgetSource(); … … 573 546 if (width > 0) { 574 547 575 if (width > (Browser._theBrowser.getWidth() - (2 * FREE_SPACE_MARGINS))) 576 width = Browser._theBrowser.getWidth() - (2 * FREE_SPACE_MARGINS); 548 if (width > (DisplayController.getFramePaintArea().getWidth() - (2 * FREE_SPACE_MARGINS))) { 549 width = DisplayController.getFramePaintArea().getWidth() - (2 * FREE_SPACE_MARGINS); 550 } 577 551 578 552 freespaceTrackToFormat.setSize( … … 582 556 583 557 // Keep the floating track on the cursor 584 MouseEvent me = MouseEventRouter.getCurrentMouseEvent();585 Point containerPoint = SwingUtilities.convertPoint(me.getComponent(), me.getPoint(), Browser._theBrowser.getContentPane());586 558 Point containerPoint = EcosystemManager.getInputManager().getCursorPosition(); 559 560 // If due to resize the track is not longer over the cursor then just center it. 587 561 if (!ItemUtils.expandRectangle(freespaceTrackToFormat.getBounds(), 20).contains(containerPoint)) { 588 // If due to resize the track is not longer over the cursor then just center it.589 562 int offsetX = width / 2; 590 563 int offsetY = freespaceTrackToFormat.getHeight() / 2; 591 freespaceTrackToFormat.setPosition( 592 containerPoint.x - offsetX, 593 containerPoint.y - offsetY); 594 FrameMouseActions.resetOffset(); 595 564 freespaceTrackToFormat.setPosition(containerPoint.x - offsetX, containerPoint.y - offsetY); 565 StandardGestureActions.resetOffset(); 596 566 } 597 567 … … 756 726 757 727 // Look for all track widgets 758 for ( InteractiveWidget iw : frame.getInteractiveWidgets()) {728 for (Widget iw : frame.getInteractiveWidgets()) { 759 729 760 730 if (iw instanceof SampledTrack) { … … 928 898 public static long inferCurrentTotalMSTime() { 929 899 930 Frame currentFrame = Display IO.getCurrentFrame();900 Frame currentFrame = DisplayController.getCurrentFrame(); 931 901 String currentFrameName = (currentFrame != null) ? currentFrame.getName() : null; 932 902
Note:
See TracChangeset
for help on using the changeset viewer.