/* */ package quicktime.app.view;
/* */
/* */ import java.awt.Container;
/* */ import java.awt.Dimension;
/* */ import java.awt.Point;
/* */ import java.awt.Rectangle;
/* */ import java.awt.Window;
/* */ import java.awt.event.ComponentEvent;
/* */ import java.awt.event.ComponentListener;
/* */ import java.awt.event.KeyEvent;
/* */ import java.awt.event.KeyListener;
/* */ import java.awt.event.MouseEvent;
/* */ import java.awt.event.MouseListener;
/* */ import java.awt.event.WindowAdapter;
/* */ import java.awt.event.WindowEvent;
/* */ import quicktime.QTException;
/* */ import quicktime.QTRuntimeException;
/* */ import quicktime.QTSession;
/* */ import quicktime.app.time.TaskThread;
/* */ import quicktime.app.time.Tasking;
/* */ import quicktime.qd.QDException;
/* */ import quicktime.qd.QDGraphics;
/* */ import quicktime.qd.QDPoint;
/* */ import quicktime.qd.QDRect;
/* */ import quicktime.qd.Region;
/* */ import quicktime.std.StdQTException;
/* */ import quicktime.std.image.GraphicsImporter;
/* */ import quicktime.std.movies.Movie;
/* */ import quicktime.std.movies.MovieController;
/* */ import quicktime.std.movies.MoviePrePreroll;
/* */ import quicktime.std.sg.SGVideoChannel;
/* */ import quicktime.std.sg.SequenceGrabber;
/* */ import quicktime.util.QTUtils;
/* */
/* */ class AWTCanvasHelper extends Tasking
/* */ implements MouseListener, KeyListener
/* */ {
/* */ private static final boolean debug = false;
/* */ private TaskThread tt;
/* 37 */ private boolean deferTasking = false;
/* 38 */ private static TaskThread sgTasker = new TaskThread("Default SG Tasker", 20);
/* */ private QTJavaAWTCanvas canvas;
/* */ private Window parentWindow;
/* */ private WindowAdapter wa;
/* 66 */ private float lastRate = 0.0F;
/* */
/* */ AWTCanvasHelper(QTJavaAWTCanvas paramQTJavaAWTCanvas)
/* */ {
/* 41 */ this.canvas = paramQTJavaAWTCanvas;
/* */ }
/* */
/* */ public final void task()
/* */ throws QTException
/* */ {
/* 51 */ if (this.canvas.movieController != null) {
/* 52 */ this.canvas.movieController.idle();
/* 53 */ } else if (this.canvas.movie != null) {
/* 54 */ this.canvas.movie.task(0);
/* 55 */ } else if ((this.canvas.grabber != null) &&
/* 56 */ (!this.canvas.grabber.idleMore()))
/* */ {
/* 59 */ stopTasking();
/* 60 */ this.canvas.grabber.stop();
/* */ }
/* */ }
/* */
/* */ void setRate(float paramFloat)
/* */ throws StdQTException
/* */ {
/* 68 */ if (this.canvas.movieController != null) {
/* 69 */ if (paramFloat != 0.0F)
/* 70 */ this.canvas.movieController.prerollAndPlay(paramFloat);
/* */ else
/* 72 */ this.canvas.movieController.play(paramFloat);
/* 73 */ } else if (this.canvas.movie != null)
/* */ {
/* 75 */ synchronized (this) {
/* 76 */ this.lastRate = paramFloat;
/* */ }
/* 78 */ if (paramFloat == 0.0F)
/* 79 */ this.canvas.movie.stop();
/* */ else
/* 81 */ this.canvas.movie.prePreroll(this.canvas.movie.getTime(), paramFloat, new PrerollCallback(paramFloat));
/* */ }
/* */ }
/* */
/* */ protected void addedTo()
/* */ {
/* 111 */ if (this.canvas.movieController != null) {
/* 112 */ this.canvas.addMouseListener(this);
/* 113 */ this.canvas.addKeyListener(this);
/* */ }
/* 115 */ Object localObject1 = this.canvas.getParent();
/* 116 */ Object localObject2 = localObject1;
/* 117 */ while (localObject2 != null) {
/* 118 */ localObject1 = localObject2;
/* 119 */ if ((localObject1 instanceof Window))
/* */ break;
/* 121 */ localObject2 = ((Container)localObject1).getParent();
/* */ }
/* 123 */ if ((localObject1 instanceof Window)) {
/* 124 */ this.parentWindow = ((Window)localObject1);
/* 125 */ this.wa = new WindowAdapter() {
/* */ public void windowActivated(WindowEvent paramAnonymousWindowEvent) {
/* 127 */ if (QTSession.isInitialized())
/* */ try
/* */ {
/* 130 */ if (AWTCanvasHelper.this.canvas.movieController != null)
/* */ {
/* 133 */ AWTCanvasHelper.this.canvas.movieController.activate(AWTCanvasHelper.this.getGWorld(), true);
/* 134 */ AWTCanvasHelper.this.canvas.movieController.activate();
/* */ }
/* 136 */ else if (AWTCanvasHelper.this.canvas.movie != null)
/* */ {
/* 140 */ AWTCanvasHelper.this.canvas.movie.setActive(true);
/* */ }
/* 142 */ AWTCanvasHelper.this.redraw(null); } catch (QTException localQTException) {
/* */ }
/* */ }
/* */
/* */ public void windowDeactivated(WindowEvent paramAnonymousWindowEvent) {
/* 147 */ if (QTSession.isInitialized())
/* */ try
/* */ {
/* 150 */ if (AWTCanvasHelper.this.canvas.movieController != null) {
/* 151 */ AWTCanvasHelper.this.canvas.movieController.deactivate();
/* 152 */ AWTCanvasHelper.this.canvas.movieController.activate(AWTCanvasHelper.this.getGWorld(), false);
/* */ }
/* 154 */ AWTCanvasHelper.this.redraw(null);
/* */ }
/* */ catch (QTException localQTException) {
/* */ }
/* */ else
/* 159 */ AWTCanvasHelper.this.removedFrom();
/* */ }
/* */ };
/* 163 */ this.parentWindow.addWindowListener(this.wa);
/* */ }
/* */ }
/* */
/* */ protected void removedFrom()
/* */ {
/* 172 */ if (this.canvas.movieController != null) {
/* 173 */ this.canvas.removeMouseListener(this);
/* 174 */ this.canvas.removeKeyListener(this);
/* */ }
/* */
/* 177 */ if (this.parentWindow != null) {
/* 178 */ this.parentWindow.removeWindowListener(this.wa);
/* 179 */ this.parentWindow = null;
/* 180 */ this.wa = null;
/* */ }
/* */ }
/* */
/* */ public void keyPressed(KeyEvent paramKeyEvent)
/* */ {
/* */ try {
/* 187 */ if (this.canvas.movieController != null)
/* */ {
/* 191 */ this.canvas.movieController.key(paramKeyEvent.getKeyCode(), paramKeyEvent.getModifiers());
/* */ }
/* */ } catch (QTException localQTException) {
/* 194 */ QTRuntimeException.handleOrThrow(new QTRuntimeException(localQTException), this, "keyPressed");
/* */ }
/* */ }
/* */ public void keyReleased(KeyEvent paramKeyEvent) {
/* */ }
/* */
/* */ public void keyTyped(KeyEvent paramKeyEvent) {
/* */ }
/* */
/* */ public void mousePressed(MouseEvent paramMouseEvent) {
/* */ try { if (this.canvas.movieController != null)
/* */ {
/* 207 */ this.canvas.movieController.click(new QDPoint(paramMouseEvent.getX(), paramMouseEvent.getY()), paramMouseEvent.getModifiers());
/* */ }
/* */ } catch (QTException localQTException) {
/* 210 */ QTRuntimeException.handleOrThrow(new QTRuntimeException(localQTException), this, "mousePressed");
/* */ }
/* */ }
/* */ public void mouseClicked(MouseEvent paramMouseEvent) {
/* */ }
/* */ public void mouseEntered(MouseEvent paramMouseEvent) {
/* */ }
/* */ public void mouseExited(MouseEvent paramMouseEvent) {
/* */ }
/* */ public void mouseReleased(MouseEvent paramMouseEvent) {
/* */ }
/* */ void doRemoveClient() { try { if ((this.canvas.movieController != null) || (this.canvas.movie != null) || (this.canvas.graphicsImporter != null)) {
/* 222 */ if (QTSession.isInitialized())
/* 223 */ doSetGWorld(false);
/* 224 */ removedFrom();
/* */ }
/* */ } catch (QTException localQTException) {
/* */ }
/* */ finally {
/* 229 */ this.canvas.movieController = null;
/* 230 */ this.canvas.graphicsImporter = null;
/* 231 */ this.canvas.movie = null;
/* */ }
/* */ }
/* */
/* */ void doSetSequenceGrabber(SequenceGrabber paramSequenceGrabber, QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2, boolean paramBoolean)
/* */ throws QTException
/* */ {
/* 238 */ setDefaultTasker(sgTasker);
/* 239 */ this.canvas.grabber.setGWorld(QDGraphics.scratch, null);
/* 240 */ this.canvas.setInitialWidthAndHeight(paramQDRect, this.canvas.getMinimumSize(), this.canvas.getMaximumSize());
/* 241 */ int i = this.canvas.currentWidth;
/* 242 */ int j = this.canvas.currentHeight;
/* 243 */ doSetBounds();
/* */
/* 245 */ if (paramSequenceGrabber != null)
/* */ try {
/* 247 */ doSetGWorld(this.canvas.isVisible());
/* 248 */ if (this.canvas.getPeer() != null) {
/* 249 */ addedTo();
/* 250 */ this.canvas.repaint();
/* */ }
/* 252 */ if (this.canvas.isVisible())
/* 253 */ if ((!this.canvas.isWin) || (!paramBoolean) || ((i == this.canvas.currentWidth) && (j == this.canvas.currentHeight)))
/* 254 */ this.canvas.deferRedraw = true;
/* */ else
/* 256 */ this.canvas.repaint();
/* */ }
/* */ catch (QTException localQTException) {
/* 259 */ removedFrom();
/* 260 */ throw localQTException;
/* */ }
/* */ else
/* 263 */ this.canvas.repaint();
/* */ }
/* */
/* */ void doSetGraphicsImporter(GraphicsImporter paramGraphicsImporter, QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2, boolean paramBoolean)
/* */ throws QTException
/* */ {
/* 271 */ doRemoveClient();
/* */
/* 273 */ if (paramGraphicsImporter != null) {
/* 274 */ int i = this.canvas.currentWidth;
/* 275 */ int j = this.canvas.currentHeight;
/* 276 */ this.canvas.graphicsImporter = paramGraphicsImporter;
/* */
/* 278 */ this.canvas.setInitialWidthAndHeight(paramQDRect, this.canvas.getMinimumSize(), this.canvas.getMaximumSize());
/* 279 */ doSetBounds();
/* */ try {
/* 281 */ doSetGWorld(this.canvas.isVisible());
/* 282 */ if (this.canvas.getPeer() != null) {
/* 283 */ addedTo();
/* 284 */ this.canvas.repaint();
/* */ }
/* 286 */ if (this.canvas.isVisible())
/* 287 */ if ((!this.canvas.isWin) || (!paramBoolean) || ((i == this.canvas.currentWidth) && (j == this.canvas.currentHeight)))
/* 288 */ this.canvas.deferRedraw = true;
/* */ else
/* 290 */ this.canvas.repaint();
/* */ }
/* */ catch (QTException localQTException) {
/* 293 */ removedFrom();
/* 294 */ throw localQTException;
/* */ }
/* */ } else {
/* 297 */ this.canvas.repaint();
/* */ }
/* */ }
/* */
/* */ void doSetMovieController(MovieController paramMovieController, QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2, boolean paramBoolean)
/* */ throws QTException
/* */ {
/* 354 */ if (paramMovieController == this.canvas.movieController) return;
/* */
/* 357 */ doRemoveClient();
/* */
/* 359 */ if (paramMovieController != null) {
/* 360 */ int i = this.canvas.currentWidth;
/* 361 */ int j = this.canvas.currentHeight;
/* 362 */ this.canvas.movieController = paramMovieController;
/* 363 */ this.canvas.movie = paramMovieController.getMovie();
/* */
/* 365 */ this.canvas.setInitialWidthAndHeight(paramQDRect, this.canvas.getMinimumSize(), this.canvas.getMaximumSize());
/* 366 */ doSetBounds();
/* */ try {
/* 368 */ doSetGWorld(this.canvas.isVisible());
/* 369 */ this.canvas.movieController.setKeysEnabled(true);
/* 370 */ if (this.canvas.getPeer() != null) {
/* 371 */ addedTo();
/* 372 */ this.canvas.repaint();
/* */ }
/* 374 */ if (this.canvas.isVisible())
/* 375 */ if ((!this.canvas.isWin) || (!paramBoolean) || ((i == this.canvas.currentWidth) && (j == this.canvas.currentHeight)))
/* 376 */ this.canvas.deferRedraw = true;
/* */ else
/* 378 */ this.canvas.repaint();
/* */ }
/* */ catch (QTException localQTException) {
/* 381 */ removedFrom();
/* 382 */ throw localQTException;
/* */ }
/* */ } else {
/* 385 */ this.canvas.repaint();
/* */ }
/* */ }
/* */
/* */ void doSetMovie(Movie paramMovie, QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2, boolean paramBoolean) throws QTException
/* */ {
/* 391 */ if (paramMovie == this.canvas.movie) return;
/* */
/* 394 */ doRemoveClient();
/* */
/* 396 */ if (paramMovie != null) {
/* 397 */ this.canvas.movie = paramMovie;
/* 398 */ int i = this.canvas.currentWidth;
/* 399 */ int j = this.canvas.currentHeight;
/* */
/* 401 */ this.canvas.setInitialWidthAndHeight(paramQDRect, this.canvas.getMinimumSize(), this.canvas.getMaximumSize());
/* 402 */ doSetBounds();
/* */ try {
/* 404 */ doSetGWorld(this.canvas.isVisible());
/* 405 */ if (this.canvas.getPeer() != null) {
/* 406 */ addedTo();
/* 407 */ this.canvas.repaint();
/* */ }
/* 409 */ if (this.canvas.isVisible())
/* 410 */ if ((!this.canvas.isWin) || (!paramBoolean) || ((i == this.canvas.currentWidth) && (j == this.canvas.currentHeight)))
/* 411 */ this.canvas.deferRedraw = true;
/* */ else
/* 413 */ this.canvas.repaint();
/* */ }
/* */ catch (QTException localQTException) {
/* 416 */ removedFrom();
/* 417 */ throw localQTException;
/* */ }
/* */ } else {
/* 420 */ this.canvas.repaint();
/* */ }
/* */ }
/* */
/* */ synchronized void setControllerGWorld(MovieController paramMovieController, QDGraphics paramQDGraphics) throws QDException, StdQTException {
/* 425 */ this.canvas.movieController.getMovie().setGWorld(QDGraphics.scratch, null);
/* 426 */ if (this.canvas.movieController.getVisible())
/* 427 */ this.canvas.movieController.setPort(paramQDGraphics);
/* */ else {
/* 429 */ this.canvas.movieController.getMovie().setGWorld(paramQDGraphics, null);
/* */ }
/* */
/* 432 */ if (!QDGraphics.scratch.equals(paramQDGraphics)) {
/* 433 */ startTasking();
/* */
/* 435 */ paramMovieController.getMovie().setActive(true);
/* */ }
/* */ else {
/* 438 */ setRate(0.0F);
/* 439 */ stopTasking();
/* 440 */ paramMovieController.getMovie().setActive(false);
/* */ }
/* */ }
/* */
/* */ synchronized void setMovieGWorld(QDGraphics paramQDGraphics) throws QDException, StdQTException
/* */ {
/* 446 */ this.canvas.movie.setGWorld(paramQDGraphics, null);
/* 447 */ if (QDGraphics.scratch.equals(paramQDGraphics)) {
/* 448 */ stopTasking();
/* 449 */ setRate(0.0F);
/* 450 */ this.canvas.movie.setActive(false);
/* */ }
/* */ else {
/* 453 */ startTasking();
/* 454 */ this.canvas.movie.setActive(true);
/* */ }
/* */ }
/* */
/* */ void doSetGWorld(boolean paramBoolean)
/* */ throws QTException
/* */ {
/* */ QDGraphics localQDGraphics1;
/* 461 */ if ((paramBoolean) && (this.canvas.getPeer() != null))
/* 462 */ localQDGraphics1 = this.canvas.getPort();
/* */ else {
/* 464 */ localQDGraphics1 = QDGraphics.scratch;
/* */ }
/* 466 */ if (this.canvas.movieController != null) {
/* 467 */ MovieController localMovieController = this.canvas.movieController;
/* 468 */ QDGraphics localQDGraphics2 = localMovieController.getPort();
/* 469 */ if (!localQDGraphics1.equals(localQDGraphics2))
/* */ {
/* 471 */ setControllerGWorld(localMovieController, localQDGraphics1);
/* */ }
/* 473 */ } else if (this.canvas.movie != null)
/* */ {
/* 475 */ setMovieGWorld(localQDGraphics1);
/* 476 */ } else if (this.canvas.graphicsImporter != null) {
/* 477 */ this.canvas.graphicsImporter.setGWorld(localQDGraphics1, null);
/* 478 */ } else if (this.canvas.grabber != null) {
/* 479 */ this.canvas.grabber.setGWorld(localQDGraphics1, null);
/* */ }
/* */
/* 484 */ if (paramBoolean) {
/* 485 */ QTUtils.checkFreeMemory();
/* 486 */ if (this.canvas.clientListener != null)
/* 487 */ this.canvas.clientListener.componentShown(new ComponentEvent(this.canvas, 102));
/* */ }
/* 489 */ else if (this.canvas.clientListener != null) {
/* 490 */ this.canvas.clientListener.componentHidden(new ComponentEvent(this.canvas, 103));
/* */ }
/* */ }
/* */
/* */ boolean shouldRedrawQTPlayer(Rectangle paramRectangle)
/* */ {
/* 496 */ if ((!this.canvas.isWin) && (this.canvas.isShowing()) &&
/* 497 */ (!paramRectangle.equals(this.canvas.getBounds()))) {
/* 498 */ return true;
/* */ }
/* */
/* 501 */ return false;
/* */ }
/* */
/* */ final void redraw(Region paramRegion) throws QTException
/* */ {
/* 506 */ if (this.canvas.movieController != null) {
/* 507 */ if (paramRegion != null) {
/* */ try {
/* 509 */ this.canvas.movieController.invalidate(getGWorld(), paramRegion);
/* */ } catch (StdQTException localStdQTException) {
/* 511 */ this.canvas.movieController.draw();
/* */ }
/* */ } else {
/* 514 */ this.canvas.movieController.draw();
/* 515 */ this.canvas.movieController.idle();
/* */ }
/* 517 */ } else if (this.canvas.movie != null) {
/* 518 */ if (paramRegion != null)
/* 519 */ this.canvas.movie.invalidateRegion(paramRegion);
/* */ else
/* 521 */ this.canvas.movie.invalidateRegion(new Region(this.canvas.movie.getBounds()));
/* 522 */ this.canvas.movie.update();
/* 523 */ this.canvas.movie.task(0);
/* */ }
/* */ else
/* */ {
/* */ Region localRegion;
/* 524 */ if (this.canvas.graphicsImporter != null) {
/* 525 */ if (paramRegion != null) {
/* 526 */ localRegion = this.canvas.graphicsImporter.getClip();
/* 527 */ this.canvas.graphicsImporter.setClip(paramRegion);
/* 528 */ this.canvas.graphicsImporter.draw();
/* 529 */ this.canvas.graphicsImporter.setClip(localRegion);
/* */ } else {
/* 531 */ this.canvas.graphicsImporter.draw();
/* */ } } else if (this.canvas.grabber != null)
/* 533 */ if (paramRegion != null) {
/* 534 */ if ((this.canvas.channel instanceof SGVideoChannel))
/* */ {
/* 536 */ localRegion = ((SGVideoChannel)this.canvas.channel).getClip();
/* 537 */ ((SGVideoChannel)this.canvas.channel).setClip(paramRegion);
/* 538 */ this.canvas.grabber.update(paramRegion);
/* 539 */ ((SGVideoChannel)this.canvas.channel).setClip(localRegion);
/* */ }
/* */ }
/* 542 */ else this.canvas.grabber.update(null);
/* */ }
/* */ }
/* */
/* */ public QDGraphics getGWorld()
/* */ throws StdQTException
/* */ {
/* 549 */ if (this.canvas.movieController != null)
/* 550 */ return this.canvas.movieController.getPort();
/* 551 */ if (this.canvas.movie != null)
/* 552 */ return this.canvas.movie.getGWorld();
/* 553 */ if (this.canvas.graphicsImporter != null)
/* 554 */ return this.canvas.graphicsImporter.getGWorld();
/* 555 */ if (this.canvas.grabber != null) {
/* 556 */ return this.canvas.grabber.getGWorld();
/* */ }
/* */
/* 559 */ return QDGraphics.scratch;
/* */ }
/* */
/* */ void doSetBounds() throws QTException
/* */ {
/* 564 */ Point localPoint = this.canvas.getNGLocation();
/* */
/* 566 */ if (this.canvas.movie != null)
/* */ {
/* 568 */ if (this.canvas.movieController != null) {
/* 569 */ if ((this.canvas.movieController.getVisible()) && (this.canvas.isVisible()))
/* 570 */ this.canvas.movieController.setBounds(new QDRect(localPoint.x, localPoint.y, this.canvas.currentWidth, this.canvas.currentHeight));
/* */ }
/* 572 */ else this.canvas.movie.setBounds(new QDRect(localPoint.x, localPoint.y, this.canvas.currentWidth, this.canvas.currentHeight));
/* */ }
/* 573 */ else if (this.canvas.graphicsImporter != null) {
/* 574 */ this.canvas.graphicsImporter.setBoundsRect(new QDRect(localPoint.x, localPoint.y, this.canvas.currentWidth, this.canvas.currentHeight));
/* 575 */ } else if (this.canvas.channel != null) {
/* 576 */ ((SGVideoChannel)this.canvas.channel).setBounds(new QDRect(localPoint.x, localPoint.y, this.canvas.currentWidth, this.canvas.currentHeight));
/* 577 */ if (!QDGraphics.scratch.equals(getGWorld())) {
/* 578 */ this.deferTasking = false;
/* 579 */ startTasking();
/* */ }
/* */ }
/* */ }
/* */
/* */ class PrerollCallback
/* */ implements MoviePrePreroll
/* */ {
/* */ private float r;
/* */
/* */ PrerollCallback(float arg2)
/* */ {
/* */ Object localObject;
/* 87 */ this.r = localObject;
/* */ }
/* */
/* */ public void execute(Movie paramMovie, int paramInt)
/* */ {
/* 92 */ synchronized (this) {
/* 93 */ if (AWTCanvasHelper.this.lastRate == 0.0F) {
/* 94 */ return;
/* */ }
/* 96 */ if (paramInt == 0)
/* */ try {
/* 98 */ paramMovie.preroll(paramMovie.getTime(), this.r);
/* 99 */ paramMovie.setRate(this.r);
/* */ } catch (QTException localQTException) {
/* 101 */ QTRuntimeException.handleOrThrow(new QTRuntimeException(localQTException), paramMovie, "preroll");
/* */ }
/* */ else
/* 104 */ QTRuntimeException.handleOrThrow(new QTRuntimeException(paramInt), paramMovie, "prePreroll");
/* */ }
/* */ }
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name: quicktime.app.view.AWTCanvasHelper
* JD-Core Version: 0.6.2
*/