/* */ package quicktime.app.view;
/* */
/* */ import java.awt.AWTEventMulticaster;
/* */ import java.awt.Canvas;
/* */ import java.awt.Component;
/* */ import java.awt.Container;
/* */ import java.awt.Dimension;
/* */ import java.awt.Graphics;
/* */ import java.awt.Point;
/* */ import java.awt.Rectangle;
/* */ import java.awt.Toolkit;
/* */ import java.awt.event.ComponentListener;
/* */ import java.util.Vector;
/* */ import quicktime.QTException;
/* */ import quicktime.QTRuntimeException;
/* */ import quicktime.QTSession;
/* */ import quicktime.QTUnknownOSException;
/* */ import quicktime.jdirect.QTNative;
/* */ import quicktime.qd.NativeGraphics;
/* */ import quicktime.qd.NativeGraphicsException;
/* */ import quicktime.qd.QDGraphics;
/* */ import quicktime.qd.QDPoint;
/* */ import quicktime.qd.QDRect;
/* */ import quicktime.qd.Region;
/* */ import quicktime.std.image.GraphicsImporter;
/* */ import quicktime.std.movies.Movie;
/* */ import quicktime.std.movies.MovieController;
/* */ import quicktime.std.sg.SGChannel;
/* */ import quicktime.std.sg.SGVideoChannel;
/* */ import quicktime.std.sg.SequenceGrabber;
/* */ import quicktime.util.QTUtils;
/* */
/* */ class QTJavaAWTCanvas extends Canvas
/* */ implements QTComponent
/* */ {
/* */ private static boolean MRJWorkaroundFlag;
/* */ private static final boolean debug = false;
/* 125 */ private static int canvasCount = 0;
/* */ transient int numCanvas;
/* */ private transient Vector mControllers;
/* */ private AWTCanvasHelper qtcHelper;
/* 190 */ private boolean doRedrawForQTPlayer = false;
/* */ transient int initialWidth;
/* */ transient int initialHeight;
/* */ int currentX;
/* */ int currentY;
/* */ private int minWidth;
/* */ private int minHeight;
/* */ private int maxWidth;
/* */ private int maxHeight;
/* */ private transient int prefWidth;
/* */ private transient int prefHeight;
/* */ int currentWidth;
/* */ int currentHeight;
/* 205 */ transient NativeGraphics ng = null;
/* 206 */ private transient long msecs = 0L;
/* 207 */ transient boolean deferResize = false;
/* 208 */ private transient boolean appHasSetPreferredSize = false;
/* 209 */ boolean isWin = QTSession.isCurrentOS(2);
/* 210 */ private boolean addDone = false;
/* 211 */ boolean deferRedraw = false;
/* */ Movie movie;
/* */ MovieController movieController;
/* */ GraphicsImporter graphicsImporter;
/* */ SequenceGrabber grabber;
/* */ SGChannel channel;
/* */ private boolean moved;
/* 672 */ private int countRegionErr = 0;
/* */ ComponentListener clientListener;
/* */
/* */ public QTJavaAWTCanvas(SGVideoChannel paramSGVideoChannel)
/* */ throws QTException
/* */ {
/* 141 */ this();
/* 142 */ this.channel = paramSGVideoChannel;
/* 143 */ setSGChannel(paramSGVideoChannel);
/* */ }
/* */
/* */ QTJavaAWTCanvas(Movie paramMovie) throws QTException
/* */ {
/* 148 */ this();
/* 149 */ setMovie(paramMovie);
/* */ }
/* */
/* */ QTJavaAWTCanvas(GraphicsImporter paramGraphicsImporter) throws QTException {
/* 153 */ this();
/* 154 */ setImage(paramGraphicsImporter);
/* */ }
/* */
/* */ QTJavaAWTCanvas(MovieController paramMovieController) throws QTException {
/* 158 */ this();
/* 159 */ setMovieController(paramMovieController);
/* */ }
/* */
/* */ private QTJavaAWTCanvas()
/* */ {
/* 172 */ this.initialWidth = 1;
/* 173 */ this.initialHeight = 1;
/* 174 */ this.minWidth = 1;
/* 175 */ this.minHeight = 1;
/* 176 */ this.maxWidth = 2147483647;
/* 177 */ this.maxHeight = 2147483647;
/* 178 */ this.numCanvas = (canvasCount++);
/* */
/* 183 */ this.qtcHelper = new AWTCanvasHelper(this);
/* */ }
/* */
/* */ public void displayChanged(int paramInt1, int paramInt2)
/* */ {
/* 222 */ Rectangle localRectangle = new Rectangle(getLocation(), new Dimension(this.initialWidth, this.initialHeight));
/* 223 */ if (paramInt1 < 0) this.initialWidth = 0; else {
/* 224 */ this.initialWidth = paramInt1;
/* */ }
/* 226 */ if (paramInt2 < 0) this.initialHeight = 0; else {
/* 227 */ this.initialHeight = paramInt2;
/* */ }
/* 229 */ if (!this.appHasSetPreferredSize) {
/* 230 */ this.prefWidth = this.initialWidth;
/* 231 */ this.prefHeight = this.initialHeight;
/* */ }
/* */ }
/* */
/* */ public final QDGraphics getPort()
/* */ throws QTUnknownOSException, NativeGraphicsException
/* */ {
/* 247 */ QDGraphics localQDGraphics = null;
/* 248 */ if (isVisible()) {
/* 249 */ localQDGraphics = this.ng != null ? this.ng.getGWorld() : null;
/* */ }
/* 251 */ return localQDGraphics == null ? QDGraphics.scratch : localQDGraphics;
/* */ }
/* */
/* */ public final Point getNGLocation()
/* */ throws QTUnknownOSException, NativeGraphicsException
/* */ {
/* 260 */ if (this.qtcHelper != null)
/* */ {
/* 262 */ return this.ng != null ? this.ng.getLocation() : new Point(0, 0);
/* */ }
/* 264 */ return getLocation();
/* */ }
/* */
/* */ public final NativeGraphics getNativeGraphics()
/* */ {
/* 274 */ return this.ng;
/* */ }
/* */
/* */ public final QDPoint translatePoint(int paramInt1, int paramInt2)
/* */ throws QTUnknownOSException, NativeGraphicsException
/* */ {
/* 286 */ Point localPoint = getNGLocation();
/* */
/* 288 */ return new QDPoint(paramInt1 + localPoint.x, paramInt2 + localPoint.y);
/* */ }
/* */
/* */ public Movie getMovie()
/* */ {
/* 296 */ return this.movie;
/* */ }
/* */
/* */ public MovieController getMovieController()
/* */ {
/* 304 */ return this.movieController;
/* */ }
/* */
/* */ public GraphicsImporter getImage()
/* */ {
/* 312 */ return this.graphicsImporter;
/* */ }
/* */
/* */ public synchronized void setMovieController(MovieController paramMovieController)
/* */ throws QTException
/* */ {
/* 325 */ paramMovieController.getMovie().setGWorld(QDGraphics.scratch, null);
/* 326 */ this.qtcHelper.doSetMovieController(paramMovieController, paramMovieController != null ? paramMovieController.getBounds() : null, getMinimumSize(), getMaximumSize(), false);
/* */ }
/* */
/* */ public synchronized void setMovie(Movie paramMovie)
/* */ throws QTException
/* */ {
/* 336 */ this.qtcHelper.doSetMovie(paramMovie, paramMovie != null ? paramMovie.getBounds() : null, getMinimumSize(), getMaximumSize(), false);
/* */ }
/* */
/* */ public synchronized void setImage(GraphicsImporter paramGraphicsImporter)
/* */ throws QTException
/* */ {
/* 345 */ this.qtcHelper.doSetGraphicsImporter(paramGraphicsImporter, paramGraphicsImporter != null ? paramGraphicsImporter.getBoundsRect() : null, getMinimumSize(), getMaximumSize(), false);
/* */ }
/* */
/* */ public synchronized void setSGChannel(SGVideoChannel paramSGVideoChannel)
/* */ throws QTException
/* */ {
/* 354 */ this.grabber = paramSGVideoChannel.getSequenceGrabber();
/* 355 */ this.qtcHelper.doSetSequenceGrabber(this.grabber, this.grabber != null ? paramSGVideoChannel.getBounds() : null, getMinimumSize(), getMaximumSize(), false);
/* */ }
/* */
/* */ void setInitialWidthAndHeight(QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2)
/* */ {
/* 364 */ this.initialWidth = paramQDRect.getWidth();
/* 365 */ this.initialHeight = paramQDRect.getHeight();
/* */
/* 368 */ if (paramDimension1.width < 0) this.minWidth = 0; else {
/* 369 */ this.minWidth = paramDimension1.width;
/* */ }
/* 371 */ if (paramDimension1.height < 0) this.minHeight = 0; else {
/* 372 */ this.minHeight = paramDimension1.height;
/* */ }
/* 374 */ if (paramDimension2.width < this.minWidth) this.maxWidth = this.minWidth; else {
/* 375 */ this.maxWidth = paramDimension2.width;
/* */ }
/* 377 */ if (paramDimension2.height < this.minHeight) this.maxHeight = this.minHeight; else {
/* 378 */ this.maxHeight = paramDimension2.height;
/* */ }
/* 380 */ if (this.initialWidth < this.minWidth) this.initialWidth = this.minWidth;
/* 381 */ else if (this.initialWidth > this.maxWidth) this.initialWidth = this.maxWidth;
/* */
/* 383 */ if (this.initialHeight < this.minHeight) this.initialHeight = this.minHeight;
/* 384 */ else if (this.initialHeight > this.maxHeight) this.initialHeight = this.maxHeight;
/* */
/* 386 */ if (!this.appHasSetPreferredSize) {
/* 387 */ this.prefWidth = this.initialWidth;
/* 388 */ this.prefHeight = this.initialHeight;
/* */ }
/* */ }
/* */
/* */ final void doParentLayout()
/* */ {
/* 395 */ Container localContainer = getParent();
/* 396 */ if (localContainer != null) {
/* 397 */ invalidate();
/* 398 */ localContainer.validate();
/* 399 */ return;
/* */ }
/* 401 */ super.reshape(this.currentX, this.currentY, this.currentWidth, this.currentHeight);
/* */ }
/* */
/* */ public void setMinimumSize(Dimension paramDimension)
/* */ {
/* 411 */ if (paramDimension == null)
/* 412 */ setMinimumSize(0, 0);
/* */ else
/* 414 */ setMinimumSize(paramDimension.width, paramDimension.height);
/* */ }
/* */
/* */ public void setMinimumSize(int paramInt1, int paramInt2)
/* */ {
/* 423 */ if (paramInt1 < 0) this.minWidth = 0; else {
/* 424 */ this.minWidth = paramInt1;
/* */ }
/* 426 */ if (paramInt2 < 0) this.minHeight = 0; else {
/* 427 */ this.minHeight = paramInt2;
/* */ }
/* 429 */ if ((this.currentWidth < this.minWidth) || (this.currentHeight < this.minHeight))
/* 430 */ doParentLayout();
/* */ }
/* */
/* */ public Dimension getMinimumSize()
/* */ {
/* 438 */ return new Dimension(this.minWidth, this.minHeight);
/* */ }
/* */
/* */ public Dimension getBestSize()
/* */ {
/* 448 */ return new Dimension(this.initialWidth, this.initialHeight);
/* */ }
/* */
/* */ public Dimension getPreferredSize()
/* */ {
/* 455 */ return new Dimension(this.prefWidth, this.prefHeight);
/* */ }
/* */
/* */ public void setPreferredSize(Dimension paramDimension)
/* */ {
/* 462 */ if (paramDimension == null)
/* 463 */ setPreferredSize(this.initialWidth, this.initialHeight);
/* */ else
/* 465 */ setPreferredSize(paramDimension.width, paramDimension.height);
/* */ }
/* */
/* */ public void setPreferredSize(int paramInt1, int paramInt2)
/* */ {
/* 477 */ if (paramInt1 < 0) {
/* 478 */ this.prefWidth = this.initialWidth;
/* 479 */ this.appHasSetPreferredSize = false;
/* */ } else {
/* 481 */ this.prefWidth = paramInt1;
/* 482 */ this.appHasSetPreferredSize = true;
/* */ }
/* */
/* 485 */ if (paramInt2 < 0) {
/* 486 */ this.prefHeight = this.initialHeight;
/* 487 */ this.appHasSetPreferredSize = false;
/* */ } else {
/* 489 */ this.prefHeight = paramInt2;
/* 490 */ this.appHasSetPreferredSize = true;
/* */ }
/* */
/* 493 */ if ((this.currentWidth != this.prefWidth) || (this.currentHeight != this.prefHeight))
/* 494 */ doParentLayout();
/* */ }
/* */
/* */ public boolean isFocusTraversable()
/* */ {
/* 503 */ return true;
/* */ }
/* */
/* */ public void setMaximumSize(Dimension paramDimension)
/* */ {
/* 514 */ if (paramDimension == null) {
/* 515 */ Dimension localDimension = Toolkit.getDefaultToolkit().getScreenSize();
/* 516 */ setMaximumSize(localDimension.width, localDimension.height);
/* */ }
/* */ else {
/* 519 */ setMaximumSize(paramDimension.width, paramDimension.height);
/* */ }
/* */ }
/* */
/* */ public void setMaximumSize(int paramInt1, int paramInt2)
/* */ {
/* 528 */ if (paramInt1 < 0) this.maxWidth = 0; else {
/* 529 */ this.maxWidth = paramInt1;
/* */ }
/* 531 */ if (paramInt2 < 0) this.maxHeight = 0; else {
/* 532 */ this.maxHeight = paramInt2;
/* */ }
/* 534 */ if ((this.currentWidth > this.maxWidth) || (this.currentHeight > this.maxHeight))
/* 535 */ doParentLayout();
/* */ }
/* */
/* */ public Dimension getMaximumSize()
/* */ {
/* 543 */ return new Dimension(this.maxWidth, this.maxHeight);
/* */ }
/* */
/* */ private void setCurrentWidthHeight(int paramInt1, int paramInt2)
/* */ {
/* 551 */ if (paramInt1 < this.minWidth) paramInt1 = this.minWidth;
/* 552 */ else if (paramInt1 > this.maxWidth) paramInt1 = this.maxWidth;
/* 553 */ if (paramInt2 < this.minHeight) paramInt2 = this.minHeight;
/* 554 */ else if (paramInt2 > this.maxHeight) paramInt2 = this.maxHeight;
/* */
/* 556 */ this.currentWidth = paramInt1;
/* 557 */ this.currentHeight = paramInt2;
/* */ }
/* */
/* */ private final void setCurrentXY(int paramInt1, int paramInt2)
/* */ {
/* 563 */ this.currentX = paramInt1;
/* 564 */ this.currentY = paramInt2;
/* */ }
/* */
/* */ public void setSize(Dimension paramDimension)
/* */ {
/* 571 */ setSize(paramDimension.width, paramDimension.height);
/* */ }
/* */
/* */ public void setSize(int paramInt1, int paramInt2)
/* */ {
/* 579 */ setBounds(this.currentX, this.currentY, paramInt1, paramInt2);
/* */ }
/* */
/* */ /** @deprecated */
/* */ public final void reshape(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/* */ {
/* 587 */ setBounds(paramInt1, paramInt2, paramInt3, paramInt4);
/* */ }
/* */
/* */ public final synchronized void setBounds(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/* */ {
/* 606 */ boolean bool = isValid();
/* */
/* 608 */ int i = this.currentWidth;
/* 609 */ int j = this.currentHeight;
/* 610 */ setCurrentWidthHeight(paramInt3, paramInt4);
/* 611 */ int k = (i != this.currentWidth) || (j != this.currentHeight) ? 1 : 0;
/* */
/* 613 */ int m = this.currentX;
/* 614 */ int n = this.currentY;
/* 615 */ setCurrentXY(paramInt1, paramInt2);
/* */
/* 617 */ super.reshape(this.currentX, this.currentY, this.currentWidth, this.currentHeight);
/* */
/* 621 */ if (this.movie != null) {
/* 622 */ this.deferResize = ((this.deferResize) || (k != 0));
/* 623 */ if (this.deferResize) {
/* 624 */ this.doRedrawForQTPlayer = ((!this.isWin) && (!bool) && (isShowing()));
/* */ }
/* */
/* 629 */ this.moved = ((m != this.currentX) || (n != this.currentY) || (this.moved));
/* */ }
/* */ }
/* */
/* */ public void paint(Graphics paramGraphics)
/* */ {
/* 641 */ if ((isValid()) && (this.qtcHelper != null)) {
/* 642 */ QDGraphics localQDGraphics = null;
/* 643 */ Region localRegion = null;
/* */ try
/* */ {
/* 646 */ if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4))) {
/* 647 */ localQDGraphics = getPort();
/* 648 */ localRegion = localQDGraphics.getClip();
/* 649 */ localQDGraphics.clipRect();
/* */ }
/* 651 */ if ((this.movie != null) || (this.graphicsImporter != null) || (this.grabber != null)) {
/* 652 */ this.qtcHelper.doSetBounds();
/* 653 */ if (!this.qtcHelper.getGWorld().equals(QDGraphics.scratch)) {
/* 654 */ QTUtils.checkFreeMemory();
/* 655 */ this.qtcHelper.redraw(null);
/* 656 */ } else if (isShowing()) {
/* 657 */ QTUtils.checkFreeMemory();
/* 658 */ this.qtcHelper.redraw(null);
/* */ }
/* */ }
/* */ } catch (QTException localQTException) {
/* */ }
/* */ finally {
/* 664 */ if ((localQDGraphics != null) && (localRegion != null))
/* 665 */ localQDGraphics.setClip(localRegion);
/* */ }
/* */ } else {
/* 668 */ doParentLayout();
/* 669 */ repaint();
/* */ }
/* */ }
/* */
/* */ public void update(Graphics paramGraphics)
/* */ {
/* 680 */ super.update(paramGraphics);
/* 681 */ if (QTSession.isCurrentOS(4))
/* 682 */ paint(paramGraphics);
/* 683 */ else if (this.deferRedraw)
/* 684 */ paint(paramGraphics);
/* */ }
/* */
/* */ public synchronized void setVisible(boolean paramBoolean)
/* */ {
/* 695 */ super.setVisible(paramBoolean);
/* */ try {
/* 697 */ if (paramBoolean) {
/* 698 */ this.qtcHelper.doSetGWorld(true);
/* 699 */ doParentLayout();
/* */ } else {
/* 701 */ this.qtcHelper.doSetGWorld(false);
/* 702 */ Container localContainer = getParent();
/* 703 */ if (localContainer != null)
/* 704 */ localContainer.repaint();
/* */ }
/* */ }
/* */ catch (QTException localQTException) {
/* 708 */ QTRuntimeException.handleOrThrow(new QTRuntimeException(localQTException), this.qtcHelper, "setGWorld");
/* */ }
/* */ }
/* */
/* */ public void addQTClientListener(ComponentListener paramComponentListener)
/* */ {
/* 727 */ this.clientListener = AWTEventMulticaster.add(this.clientListener, paramComponentListener);
/* */ }
/* */
/* */ public void removeQTClientListener(ComponentListener paramComponentListener)
/* */ {
/* 737 */ this.clientListener = AWTEventMulticaster.remove(this.clientListener, paramComponentListener);
/* */ }
/* */
/* */ public synchronized void addNotify()
/* */ {
/* 746 */ super.addNotify();
/* 747 */ if (!this.addDone) {
/* */ try {
/* 749 */ synchronized (QTNative.globalsLock)
/* */ {
/* 751 */ this.ng = NativeGraphics.getContext(this);
/* 752 */ if ((this.movie != null) || (this.graphicsImporter != null) || (this.grabber != null)) {
/* 753 */ this.qtcHelper.doSetGWorld(isVisible());
/* 754 */ this.qtcHelper.addedTo();
/* 755 */ if (isVisible()) {
/* 756 */ if (!this.isWin)
/* 757 */ this.deferRedraw = true;
/* */ else
/* 759 */ repaint();
/* */ }
/* */ }
/* 762 */ QTSession.addActiveCanvas(this);
/* */ }
/* */ } catch (QTException localQTException) {
/* 765 */ this.qtcHelper.doRemoveClient();
/* 766 */ throw new QTRuntimeException(localQTException);
/* */ }
/* 768 */ this.addDone = true;
/* */ }
/* */ }
/* */
/* */ public synchronized void removeNotify()
/* */ {
/* 779 */ synchronized (QTSession.terminationLock()) {
/* 780 */ if ((this.addDone) && (QTSession.isInitialized()))
/* */ try {
/* 782 */ this.qtcHelper.doSetGWorld(false);
/* 783 */ this.qtcHelper.removedFrom();
/* 784 */ QTSession.removeActiveCanvas(this);
/* */ }
/* */ catch (QTException localQTException)
/* */ {
/* 788 */ this.qtcHelper.doRemoveClient();
/* 789 */ throw new QTRuntimeException(localQTException);
/* */ } finally {
/* 791 */ if ((QTSession.isCurrentOS(2)) && (this.ng != null))
/* */ {
/* 793 */ synchronized (QTNative.globalsLock)
/* */ {
/* 795 */ QTJavaJNIAWTCanvas.RemoveNewContext(this.ng);
/* */ }
/* */ }
/* */
/* 799 */ this.ng = null;
/* 800 */ this.addDone = false;
/* 801 */ super.removeNotify();
/* */ }
/* */ else
/* 804 */ super.removeNotify();
/* */ }
/* */ }
/* */
/* */ public Component asComponent()
/* */ {
/* 810 */ return this;
/* */ }
/* */
/* */ public String toString()
/* */ {
/* 818 */ return getClass().getName() + "_" + this.numCanvas + "_" + "[Location=" + getLocation() + ",Size=" + getSize() + "]";
/* */ }
/* */
/* */ protected void finalize() throws Throwable {
/* */ try {
/* 823 */ removeNotify();
/* */ } finally {
/* 825 */ this.movie = null;
/* 826 */ this.movieController = null;
/* 827 */ this.graphicsImporter = null;
/* 828 */ this.grabber = null;
/* 829 */ this.channel = null;
/* 830 */ this.qtcHelper = null;
/* */ }
/* */
/* 833 */ super.finalize();
/* */ }
/* */
/* */ static
/* */ {
/* 93 */ if (QTSession.isCurrentOS(2)) {
/* 94 */ MRJWorkaroundFlag = false;
/* 95 */ } else if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* */ {
/* 97 */ String str = System.getProperty("java.version");
/* 98 */ int i = Character.getNumericValue(str.charAt(0));
/* */
/* 100 */ int j = 0;
/* 101 */ int k = 0;
/* 102 */ int m = 0;
/* */
/* 104 */ for (int n = 1; n < str.length(); n++) {
/* 105 */ char c = str.charAt(n);
/* 106 */ if (Character.isDigit(c)) {
/* 107 */ if (m == 0) {
/* 108 */ j = Character.getNumericValue(c);
/* 109 */ m = 1;
/* */ } else {
/* 111 */ k = Character.getNumericValue(c);
/* */ }
/* */ }
/* */
/* */ }
/* */
/* 117 */ if ((i == 1) && (j == 1) && (k < 8))
/* 118 */ MRJWorkaroundFlag = true;
/* */ else
/* 120 */ MRJWorkaroundFlag = false;
/* */ }
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name: quicktime.app.view.QTJavaAWTCanvas
* JD-Core Version: 0.6.2
*/