Package quicktime.app.view

Source Code of quicktime.app.view.JQTCanvas

/*     */ package quicktime.app.view;
/*     */
/*     */ import java.awt.AWTEventMulticaster;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Image;
/*     */ import java.awt.Toolkit;
/*     */ import java.awt.event.ComponentListener;
/*     */ import java.awt.image.BufferedImage;
/*     */ import java.awt.image.DirectColorModel;
/*     */ import java.awt.image.ImageProducer;
/*     */ import java.awt.image.MacDirectColorModel;
/*     */ import java.awt.image.MemoryImageSource;
/*     */ import java.io.PrintStream;
/*     */ import javax.swing.JComponent;
/*     */ import quicktime.QTException;
/*     */ import quicktime.QTObject;
/*     */ import quicktime.QTSession;
/*     */ import quicktime.qd.QDGraphics;
/*     */ import quicktime.qd.QDRect;
/*     */ import quicktime.util.RawEncodedImage;
/*     */
/*     */ class JQTCanvas extends JComponent
/*     */   implements DrawingListener, QTJComponent
/*     */ {
/*  35 */   public static boolean flashScaling = false;
/*  36 */   public static boolean useMacOSXAcceleration = false;
/*     */   transient Presentable client;
/*  41 */   private int initialWidth = 0;
/*  42 */   private int initialHeight = 0;
/*  43 */   private int minWidth = 0;
/*  44 */   private int minHeight = 0;
/*     */   private int maxWidth;
/*     */   private int maxHeight;
/*     */   private int currentWidth;
/*     */   private int currentHeight;
/*     */   private int currentX;
/*     */   private int currentY;
/*     */   private transient int prefWidth;
/*     */   private transient int prefHeight;
/*  53 */   private transient boolean inited = false;
/*     */   private int resizeFlag;
/*  55 */   private boolean debug = false;
/*  56 */   private boolean paintlock = false;
/*  57 */   DirectColorModel colorModel = new DirectColorModel(32, 16711680, 65280, 255, 0);
/*     */   public QTImageProducer ip;
/*     */   Image image;
/*  60 */   QDGraphics gw = null;
/*     */   QDRect gwBounds;
/*     */   int[] pixels;
/*     */   private ComponentListener clientListener;
/*     */
/*     */   JQTCanvas(Presentable paramPresentable)
/*     */     throws QTException
/*     */   {
/*  70 */     this.initialWidth = 1;
/*  71 */     this.initialHeight = 1;
/*  72 */     this.minWidth = 1;
/*  73 */     this.minHeight = 1;
/*  74 */     this.minWidth = 1;
/*  75 */     this.minHeight = 1;
/*  76 */     this.maxWidth = 2147483647;
/*  77 */     this.maxHeight = 2147483647;
/*  78 */     doSetClient(paramPresentable, paramPresentable != null ? paramPresentable.getDisplayBounds() : null, getMinimumSize(), getMaximumSize(), true);
/*     */   }
/*     */
/*     */   public MoviePlayer getMoviePlayer()
/*     */   {
/*  87 */     return (this.client instanceof MoviePlayer) ? (MoviePlayer)this.client : null;
/*     */   }
/*     */
/*     */   public GraphicsImporterDrawer getGraphicsImporterDrawer()
/*     */   {
/*  95 */     return (this.client instanceof GraphicsImporterDrawer) ? (GraphicsImporterDrawer)this.client : null;
/*     */   }
/*     */
/*     */   public void setGraphicsImporterDrawer(GraphicsImporterDrawer paramGraphicsImporterDrawer) throws QTException {
/*  99 */     doSetClient(paramGraphicsImporterDrawer, paramGraphicsImporterDrawer != null ? paramGraphicsImporterDrawer.getDisplayBounds() : null, getMinimumSize(), getMaximumSize(), false);
/*     */   }
/*     */
/*     */   public void setMoviePlayer(MoviePlayer paramMoviePlayer) throws QTException
/*     */   {
/* 104 */     doSetClient(paramMoviePlayer, paramMoviePlayer != null ? paramMoviePlayer.getDisplayBounds() : null, getMinimumSize(), getMaximumSize(), false);
/*     */   }
/*     */
/*     */   public void paint(Graphics paramGraphics)
/*     */   {
/* 112 */     if ((!this.inited) && (this.client != null)) {
/* 113 */       this.client.addedTo(this);
/* 114 */       this.inited = true;
/* 115 */       super.paint(paramGraphics);
/*     */     }
/*     */
/* 119 */     if (this.image != null) {
/* 120 */       Dimension localDimension = getSize();
/* 121 */       paramGraphics.drawImage(this.image, 0, 0, localDimension.width, localDimension.height, this);
/*     */     }
/*     */   }
/*     */
/* 125 */   public void setFlashScaling(boolean paramBoolean) { flashScaling = paramBoolean; }
/*     */   public boolean isFlashScaling() {
/* 127 */     return flashScaling;
/*     */   }
/*     */
/*     */   Image imageFromEncodedImage(RawEncodedImage paramRawEncodedImage, QDRect paramQDRect)
/*     */   {
/* 132 */     paramRawEncodedImage.copyToArray(0, this.pixels, 0, this.pixels.length);
/* 133 */     MemoryImageSource localMemoryImageSource = new MemoryImageSource(paramQDRect.getWidth(), paramQDRect.getHeight(), this.colorModel, this.pixels, 0, paramRawEncodedImage.getRowBytes() / 4);
/*     */
/* 135 */     return getToolkit().createImage(localMemoryImageSource);
/*     */   }
/*     */
/*     */   private final void removeClient()
/*     */   {
/* 142 */     if ((this.client instanceof DrawingNotifier))
/* 143 */       ((DrawingNotifier)this.client).removeDrawingListener(this);
/*     */     try
/*     */     {
/* 146 */       this.client.setGWorld(QDGraphics.scratch);
/*     */     } catch (QTException localQTException) {
/*     */     }
/*     */     finally {
/* 150 */       this.client.removedFrom(this);
/* 151 */       this.client = null;
/*     */     }
/* 153 */     if (QTSession.isCurrentOS(4))
/* 154 */       this.gw = null;
/* 155 */     if (this.image != null) {
/* 156 */       this.image = null;
/*     */     }
/* 158 */     repaint();
/*     */   }
/*     */   public Dimension getBestSize() {
/* 161 */     return new Dimension(this.initialWidth, this.initialHeight);
/*     */   }
/*     */   public Dimension getMinimumSize() {
/* 164 */     Dimension localDimension = null;
/* 165 */     localDimension = new Dimension(this.minWidth, this.minHeight);
/* 166 */     return localDimension;
/*     */   }
/*     */
/*     */   public Dimension getMaximumSize() {
/* 170 */     Dimension localDimension = null;
/* 171 */     localDimension = new Dimension(32767, 32767);
/* 172 */     return localDimension;
/*     */   }
/*     */
/*     */   public Dimension getPreferredSize() {
/* 176 */     Dimension localDimension = null;
/* 177 */     localDimension = new Dimension(this.prefWidth, this.prefHeight);
/* 178 */     return localDimension;
/*     */   }
/*     */
/*     */   void setInitialWidthAndHeight(QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2) {
/* 182 */     this.initialWidth = paramQDRect.getWidth();
/* 183 */     this.initialHeight = paramQDRect.getHeight();
/*     */
/* 186 */     if (paramDimension1.width < 0) this.minWidth = 0; else {
/* 187 */       this.minWidth = paramDimension1.width;
/*     */     }
/* 189 */     if (paramDimension1.height < 0) this.minHeight = 0; else {
/* 190 */       this.minHeight = paramDimension1.height;
/*     */     }
/* 192 */     if (paramDimension2.width < this.minWidth) this.maxWidth = this.minWidth; else {
/* 193 */       this.maxWidth = paramDimension2.width;
/*     */     }
/* 195 */     if (paramDimension2.height < this.minHeight) this.maxHeight = this.minHeight; else {
/* 196 */       this.maxHeight = paramDimension2.height;
/*     */     }
/* 198 */     if (this.initialWidth < this.minWidth) this.initialWidth = this.minWidth;
/* 199 */     else if (this.initialWidth > this.maxWidth) this.initialWidth = this.maxWidth;
/*     */
/* 201 */     if (this.initialHeight < this.minHeight) this.initialHeight = this.minHeight;
/* 202 */     else if (this.initialHeight > this.maxHeight) this.initialHeight = this.maxHeight;
/*     */
/* 204 */     this.prefWidth = this.initialWidth;
/* 205 */     this.prefHeight = this.initialHeight;
/* 206 */     if (this.debug)
/* 207 */       System.err.println("setInitialWidthAndHeight " + this.initialWidth + " " + this.initialHeight + " " + this.prefWidth + " " + this.prefHeight);
/*     */   }
/*     */
/*     */   private void doSetClient(Presentable paramPresentable, QDRect paramQDRect, Dimension paramDimension1, Dimension paramDimension2, boolean paramBoolean) throws QTException {
/* 211 */     if (paramPresentable == this.client) return;
/*     */
/* 213 */     if (this.client != null) {
/* 214 */       removeClient();
/*     */     }
/* 216 */     if (paramPresentable != null) {
/* 217 */       this.client = paramPresentable;
/*     */
/* 219 */       if (paramBoolean) {
/* 220 */         setPreferredSize(new Dimension(paramQDRect.getWidth(), paramQDRect.getHeight()));
/* 221 */         setInitialWidthAndHeight(paramQDRect, paramDimension1, paramDimension2);
/* 222 */         this.currentX = paramQDRect.getX();
/* 223 */         this.currentY = paramQDRect.getY();
/* 224 */         this.currentWidth = this.initialWidth;
/* 225 */         this.currentHeight = this.initialHeight;
/*     */
/* 227 */         doParentLayout();
/*     */       }
/* 229 */       setPreferredSize(new Dimension(paramQDRect.getWidth(), paramQDRect.getHeight()));
/* 230 */       setInitialWidthAndHeight(paramQDRect, paramDimension1, paramDimension2);
/* 231 */       this.currentX = paramQDRect.getX();
/* 232 */       this.currentY = paramQDRect.getY();
/* 233 */       this.currentWidth = this.initialWidth;
/* 234 */       this.currentHeight = this.initialHeight;
/*     */
/* 236 */       doParentLayout();
/*     */
/* 238 */       this.client.redraw(null);
/* 239 */       this.ip = new QTImageProducer(this.client, new Dimension(paramQDRect.getWidth(), paramQDRect.getHeight()));
/* 240 */       this.image = createImage(this.ip);
/* 241 */       prepareImage(this.image, this);
/* 242 */       if ((this.client instanceof DrawingNotifier))
/* 243 */         ((DrawingNotifier)this.client).addDrawingListener(this);
/*     */     }
/* 245 */     repaint();
/*     */   }
/*     */
/*     */   public Image createImage(ImageProducer paramImageProducer)
/*     */   {
/* 250 */     if ((QTSession.isCurrentOS(4)) && (useMacOSXAcceleration))
/*     */     {
/* 252 */       boolean bool = false;
/*     */
/* 254 */       QTImageProducer localQTImageProducer = (QTImageProducer)paramImageProducer;
/*     */
/* 256 */       Dimension localDimension = localQTImageProducer.getSize();
/* 257 */       QDGraphics localQDGraphics = localQTImageProducer.getGWorld();
/* 258 */       this.gw = localQDGraphics;
/*     */
/* 260 */       BufferedImage localBufferedImage = MacDirectColorModel.GetWrappedGWorldImage(QTObject.ID(localQDGraphics), 32, localDimension.width, localDimension.height, bool);
/*     */
/* 262 */       return localBufferedImage;
/*     */     }
/*     */
/* 266 */     return super.createImage(paramImageProducer);
/*     */   }
/*     */
/*     */   public void setBounds(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/*     */   {
/* 280 */     if (this.debug) System.out.println("setBounds( " + paramInt1 + ", " + paramInt2 + ", " + paramInt3 + ", " + paramInt4 + ")");
/*     */
/* 282 */     Dimension localDimension = setCurrentWidthHeight(paramInt3, paramInt4);
/* 283 */     if (flashScaling) {
/* 284 */       setPreferredSize(localDimension);
/* 285 */       this.initialWidth = paramInt3;
/* 286 */       this.initialHeight = paramInt4;
/*     */       try
/*     */       {
/* 289 */         this.client.redraw(null);
/* 290 */         this.ip = new QTImageProducer(this.client, localDimension);
/* 291 */         this.image = createImage(this.ip);
/* 292 */         prepareImage(this.image, this);
/*     */       } catch (QTException localQTException) {
/* 294 */         localQTException.printStackTrace();
/*     */       }
/* 296 */       repaint();
/*     */     }
/*     */
/* 300 */     this.currentX = paramInt1;
/* 301 */     this.currentY = paramInt2;
/*     */
/* 303 */     super.reshape(this.currentX, this.currentY, localDimension.width, localDimension.height);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public final void reshape(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
/*     */   {
/* 311 */     if (this.debug) System.out.println("reshape( " + paramInt1 + ", " + paramInt2 + ", " + paramInt3 + ", " + paramInt4 + ")");
/* 312 */     setBounds(paramInt1, paramInt2, paramInt3, paramInt4);
/*     */   }
/*     */
/*     */   private final void doParentLayout()
/*     */   {
/* 317 */     if (this.debug)
/* 318 */       System.out.println("doParentLayout()");
/* 319 */     Container localContainer = getParent();
/* 320 */     if (localContainer != null) {
/* 321 */       invalidate();
/* 322 */       localContainer.validate();
/* 323 */       return;
/*     */     }
/* 325 */     super.reshape(this.currentX, this.currentY, this.currentWidth, this.currentHeight);
/*     */   }
/*     */
/*     */   private Dimension setCurrentWidthHeight(int paramInt1, int paramInt2) {
/* 329 */     if (this.debug) System.out.println("setCurrentWidthHeight( " + paramInt1 + ", " + paramInt2 + ", " + this.minWidth + ", " + this.minHeight);
/*     */
/* 333 */     if (this.currentWidth < this.minWidth) this.currentWidth = this.minWidth;
/* 334 */     else if (this.currentWidth > this.maxWidth) this.currentWidth = this.maxWidth;
/* 335 */     if (this.currentHeight < this.minHeight) this.currentHeight = this.minHeight;
/* 336 */     else if (this.currentHeight > this.maxHeight) this.currentHeight = this.maxHeight;
/*     */
/* 338 */     this.currentWidth = paramInt1;
/* 339 */     this.currentHeight = paramInt2;
/* 340 */     return new Dimension(this.currentWidth, this.currentHeight);
/*     */   }
/*     */
/*     */   public void drawingComplete(Presentable paramPresentable)
/*     */   {
/* 347 */     if ((QTSession.isCurrentOS(4)) && (useMacOSXAcceleration)) {
/* 348 */       repaint();
/* 349 */       return;
/*     */     }
/*     */     try
/*     */     {
/* 353 */       this.ip.updateConsumers(null);
/*     */     }
/*     */     catch (QTException localQTException) {
/* 356 */       localQTException.printStackTrace();
/*     */     }
/*     */   }
/*     */
/*     */   public JComponent asJComponent()
/*     */   {
/* 363 */     return this;
/*     */   }
/*     */
/*     */   public void addQTClientListener(ComponentListener paramComponentListener)
/*     */   {
/* 379 */     this.clientListener = AWTEventMulticaster.add(this.clientListener, paramComponentListener);
/*     */   }
/*     */
/*     */   public void removeQTClientListener(ComponentListener paramComponentListener)
/*     */   {
/* 389 */     this.clientListener = AWTEventMulticaster.remove(this.clientListener, paramComponentListener);
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name:     quicktime.app.view.JQTCanvas
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of quicktime.app.view.JQTCanvas

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.