Package quicktime.app.image

Source Code of quicktime.app.image.QTImageDrawer

/*     */ package quicktime.app.image;
/*     */
/*     */ import java.awt.Component;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Image;
/*     */ import java.awt.Rectangle;
/*     */ import java.awt.image.PixelGrabber;
/*     */ import quicktime.QTException;
/*     */ import quicktime.QTRuntimeException;
/*     */ import quicktime.QTSession;
/*     */ import quicktime.app.QTAppException;
/*     */ import quicktime.app.actions.Invalidator;
/*     */ import quicktime.app.actions.Notifier;
/*     */ import quicktime.app.actions.NotifyListener;
/*     */ import quicktime.app.anim.SWCompositor;
/*     */ import quicktime.app.anim.TwoDSprite;
/*     */ import quicktime.app.display.QTDrawable;
/*     */ import quicktime.qd.QDDimension;
/*     */ import quicktime.qd.QDGraphics;
/*     */ import quicktime.qd.QDRect;
/*     */ import quicktime.qd.Region;
/*     */ import quicktime.std.StdQTException;
/*     */ import quicktime.std.image.GraphicsExporter;
/*     */ import quicktime.std.image.GraphicsMode;
/*     */ import quicktime.std.image.ImageDescription;
/*     */ import quicktime.std.image.Matrix;
/*     */ import quicktime.util.EncodedImage;
/*     */ import quicktime.util.IntEncodedImage;
/*     */ import quicktime.util.RawEncodedImage;
/*     */
/*     */ /** @deprecated */
/*     */ public class QTImageDrawer
/*     */   implements Notifier, QTDrawable, DynamicImage, Redrawable
/*     */ {
/*     */   private static final boolean debug = false;
/*  76 */   private static final boolean isWin = QTSession.isCurrentOS(2);
/*     */
/*     */   /** @deprecated */
/*     */   public static final int kMultiFrameRetain = 6;
/*     */   private ImagePresenter image;
/*     */   private Dimension mSize;
/*     */   private Image offscreenImage;
/*     */   private Image jPainterImage;
/*     */   private Graphics offscreenGraphics;
/*     */   private Paintable painter;
/* 153 */   private boolean interruptedGrab = false;
/*     */   private Component canv;
/* 155 */   private boolean mRedrawFlag = false;
/*     */   private NotifyListener nl;
/*     */   private int singleFrameFlag;
/*     */   private RawEncodedImage rei;
/*     */   private IntEncodedImage iData;
/*     */   private TwoDSprite sprite;
/*     */
/* 106 */   /** @deprecated */
/*     */   public QTImageDrawer(Paintable paramPaintable, Dimension paramDimension, int paramInt) { this.mSize = paramDimension;
/* 107 */     this.painter = paramPaintable;
/* 108 */     this.image = new ImagePresenter(new QDRect(this.mSize));
/* 109 */     this.singleFrameFlag = paramInt;
/* 110 */     this.mRedrawFlag = (paramInt != 1);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public QTImageDrawer(Image paramImage)
/*     */     throws QTAppException
/*     */   {
/* 122 */     int i = paramImage.getWidth(null);
/* 123 */     if (i == -1)
/* 124 */       throw new QTAppException("Image size must be known");
/* 125 */     int j = paramImage.getHeight(null);
/*     */
/* 127 */     this.mSize = new Dimension(i, j);
/* 128 */     this.image = new ImagePresenter(new QDRect(this.mSize));
/* 129 */     this.painter = new JImagePainter(paramImage);
/* 130 */     this.singleFrameFlag = 1;
/* 131 */     this.mRedrawFlag = false;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public QTImageDrawer(Image paramImage, Dimension paramDimension)
/*     */   {
/* 143 */     this(new JImagePainter(paramImage), paramDimension, 1);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public Paintable getPaintable()
/*     */   {
/* 172 */     return this.painter;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public int export(GraphicsExporter paramGraphicsExporter)
/*     */     throws QTException
/*     */   {
/* 185 */     QDGraphics localQDGraphics = new QDGraphics(getDescription(), 0);
/*     */
/* 187 */     return export(paramGraphicsExporter, localQDGraphics);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public int export(GraphicsExporter paramGraphicsExporter, QDGraphics paramQDGraphics)
/*     */     throws QTException
/*     */   {
/* 201 */     if (this.canv == null) {
/* 202 */       throw new QTAppException("QTImageDrawer must be added to a QTCanvas before it can export");
/*     */     }
/* 204 */     if (!paramQDGraphics.isOffscreen()) {
/* 205 */       throw new QTAppException("QTImageDrawer.export must be supplied an offscreen QDGraphics");
/*     */     }
/*     */
/* 208 */     QDGraphics localQDGraphics = getGWorld();
/*     */
/* 211 */     setGWorld(paramQDGraphics);
/* 212 */     redraw(null);
/*     */
/* 215 */     setGWorld(localQDGraphics);
/*     */
/* 217 */     paramGraphicsExporter.setInputGWorld(paramQDGraphics);
/*     */
/* 220 */     int i = paramGraphicsExporter.doExport();
/*     */
/* 222 */     paramQDGraphics = null;
/* 223 */     return i;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   private synchronized void setSize(Dimension paramDimension)
/*     */   {
/* 236 */     this.mSize = paramDimension;
/* 237 */     if (this.canv == null) return;
/*     */
/* 240 */     this.offscreenImage = this.canv.createImage(this.mSize.width, this.mSize.height);
/*     */
/* 242 */     if (this.offscreenImage == null) {
/* 243 */       QTRuntimeException.handleOrThrow(new QTRuntimeException("must have a valid offscreen image"), this.canv, "createImage");
/* 244 */       return;
/*     */     }
/* 246 */     if (this.singleFrameFlag == 6) {
/* 247 */       this.offscreenGraphics = this.offscreenImage.getGraphics();
/*     */     }
/*     */     try
/*     */     {
/* 251 */       ImageDescription localImageDescription = ImageDescription.getJavaDefaultPixelDescription(this.mSize.width, this.mSize.height);
/* 252 */       this.iData = new IntEncodedImage(this.mSize.width * this.mSize.height);
/*     */
/* 254 */       localImageDescription.setDataSize(this.iData.getSize());
/*     */
/* 256 */       this.image.setImageData(this.iData, localImageDescription);
/* 257 */       this.painter.newSizeNotified(this, this.mSize);
/* 258 */       if ((this.painter instanceof JImagePainter))
/* 259 */         ((JImagePainter)this.painter).prepareImage(this.canv);
/* 260 */       prepaint();
/* 261 */       if ((!this.interruptedGrab) && (isSingleFrame()))
/* 262 */         doSingleFrame();
/*     */     }
/*     */     catch (QTException localQTException) {
/* 265 */       QTRuntimeException.handleOrThrow(new QTRuntimeException(localQTException), this, "addedTo");
/*     */     }
/*     */   }
/*     */
/*     */   private void doSingleFrame() throws QTException
/*     */   {
/* 271 */     this.rei = new RawEncodedImage(this.iData.getInts());
/* 272 */     this.image.setImageData(this.rei);
/* 273 */     this.iData = null;
/* 274 */     this.offscreenImage.flush();
/* 275 */     this.offscreenImage = null;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public Dimension getSize()
/*     */   {
/* 284 */     return new Dimension(this.mSize.width, this.mSize.height);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public final Region getClip()
/*     */     throws QTException
/*     */   {
/* 291 */     return this.image.getClip();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public final void setClip(Region paramRegion)
/*     */     throws StdQTException
/*     */   {
/* 299 */     this.image.setClip(paramRegion);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public ImagePresenter toImagePresenter()
/*     */     throws QTException
/*     */   {
/* 314 */     if (this.iData == null) {
/* 315 */       if (this.rei == null)
/* 316 */         return null;
/* 317 */       if (isSingleFrame()) {
/* 318 */         return ImagePresenter.fromQTImage(this.rei, (ImageDescription)this.image.getDescription().clone());
/*     */       }
/* 320 */       return ImagePresenter.fromQTImage((EncodedImage)this.rei.clone(), (ImageDescription)this.image.getDescription().clone());
/*     */     }
/*     */
/* 323 */     return ImagePresenter.fromQTImage(new RawEncodedImage(this.iData.getInts()), (ImageDescription)this.image.getDescription().clone());
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public ImageDescription getDescription()
/*     */     throws QTException
/*     */   {
/* 334 */     return this.image.getDescription();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public synchronized EncodedImage getImage()
/*     */     throws QTException
/*     */   {
/* 343 */     if (this.iData == null)
/* 344 */       return this.rei;
/* 345 */     return this.iData;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public final Matrix getMatrix()
/*     */     throws StdQTException
/*     */   {
/* 355 */     return this.image.getMatrix();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public final void setMatrix(Matrix paramMatrix)
/*     */     throws QTException
/*     */   {
/* 367 */     this.image.setMatrix(paramMatrix);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public Dimension getInitialSize()
/*     */     throws QTException
/*     */   {
/* 378 */     return this.image.getInitialSize();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public QDDimension getOriginalSize()
/*     */     throws QTException
/*     */   {
/* 389 */     return this.image.getOriginalSize();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public final QDGraphics getGWorld()
/*     */   {
/* 398 */     return this.image.getGWorld();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void setGWorld(QDGraphics paramQDGraphics)
/*     */     throws QTException
/*     */   {
/* 411 */     this.image.setGWorld(paramQDGraphics);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public synchronized void setDisplayBounds(QDRect paramQDRect)
/*     */     throws StdQTException
/*     */   {
/* 422 */     this.image.setDisplayBounds(paramQDRect);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void setLocation(int paramInt1, int paramInt2)
/*     */     throws QTException
/*     */   {
/* 432 */     QDRect localQDRect = getDisplayBounds();
/* 433 */     localQDRect.setX(paramInt1);
/* 434 */     localQDRect.setY(paramInt2);
/* 435 */     setDisplayBounds(localQDRect);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public QDRect getDisplayBounds()
/*     */   {
/* 446 */     return this.image.getDisplayBounds();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public synchronized void redraw(Region paramRegion)
/*     */     throws QTException
/*     */   {
/* 464 */     if ((this.iData == null) && (this.rei == null))
/*     */       return;
/*     */     Region localRegion;
/* 465 */     if (this.interruptedGrab) {
/* 466 */       localRegion = prepaint();
/* 467 */       if ((localRegion != null) && (paramRegion != null))
/* 468 */         paramRegion = localRegion.union(paramRegion);
/* 469 */       if ((!this.interruptedGrab) && (isSingleFrame()))
/* 470 */         doSingleFrame();
/*     */     }
/* 472 */     else if ((!isSingleFrame()) && (isRedrawing())) {
/* 473 */       localRegion = prepaint();
/* 474 */       if ((localRegion != null) && (paramRegion != null))
/* 475 */         paramRegion = localRegion.union(paramRegion);
/*     */     }
/* 477 */     this.image.redraw(paramRegion);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void setRedrawing(boolean paramBoolean)
/*     */   {
/* 488 */     this.mRedrawFlag = paramBoolean;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public boolean isSingleFrame()
/*     */   {
/* 497 */     return this.singleFrameFlag == 1;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public boolean isRedrawing()
/*     */   {
/* 505 */     return this.mRedrawFlag;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public Region prepaint()
/*     */     throws QTException
/*     */   {
/* 518 */     if (this.offscreenImage == null) return null;
/*     */
/* 520 */     Region localRegion = null;
/*     */     try
/*     */     {
/* 524 */       if (this.offscreenGraphics == null) {
/* 525 */         this.offscreenGraphics = this.offscreenImage.getGraphics();
/*     */       }
/* 527 */       Rectangle[] arrayOfRectangle = this.painter.paint(this.offscreenGraphics);
/* 528 */       if (arrayOfRectangle != null)
/* 529 */         for (int i = 0; (i < arrayOfRectangle.length) &&
/* 530 */           (arrayOfRectangle[i] != null); i++)
/*     */         {
/* 531 */           int j = arrayOfRectangle[i].x;
/* 532 */           int k = arrayOfRectangle[i].y;
/* 533 */           int m = arrayOfRectangle[i].width > this.mSize.width ? this.mSize.width : arrayOfRectangle[i].width;
/* 534 */           int n = arrayOfRectangle[i].height > this.mSize.height ? this.mSize.height : arrayOfRectangle[i].height;
/* 535 */           PixelGrabber localPixelGrabber = new PixelGrabber(this.offscreenImage, j, k, m, n, this.iData.getInts(), k * this.mSize.width + j, this.mSize.width);
/* 536 */           localPixelGrabber.grabPixels();
/* 537 */           if (localRegion == null)
/* 538 */             localRegion = new Region(new QDRect(arrayOfRectangle[i].x, arrayOfRectangle[i].y, arrayOfRectangle[i].width, arrayOfRectangle[i].height));
/*     */           else
/* 540 */             localRegion = localRegion.union(new QDRect(arrayOfRectangle[i].x, arrayOfRectangle[i].y, arrayOfRectangle[i].width, arrayOfRectangle[i].height));
/*     */         }
/*     */     }
/*     */     catch (InterruptedException localInterruptedException) {
/* 544 */       this.interruptedGrab = true;
/* 545 */       if (this.singleFrameFlag == 2)
/* 546 */         this.offscreenGraphics = null;
/* 547 */       return null;
/*     */     }
/* 549 */     this.interruptedGrab = false;
/* 550 */     if ((this.sprite != null) && (!isSingleFrame()) && (this.sprite.isValid()))
/* 551 */       this.sprite.invalidate();
/* 552 */     if (this.singleFrameFlag == 2)
/* 553 */       this.offscreenGraphics = null;
/* 554 */     return localRegion;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void setGraphicsMode(GraphicsMode paramGraphicsMode)
/*     */     throws QTException
/*     */   {
/* 563 */     this.image.setGraphicsMode(paramGraphicsMode);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public GraphicsMode getGraphicsMode()
/*     */   {
/* 571 */     return this.image.getGraphicsMode();
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public Invalidator addedToCompositor(SWCompositor paramSWCompositor, TwoDSprite paramTwoDSprite)
/*     */   {
/* 614 */     this.sprite = paramTwoDSprite;
/* 615 */     return isSingleFrame() ? null : new RedrawInvalidator(paramTwoDSprite);
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void removedFromCompositor(SWCompositor paramSWCompositor)
/*     */   {
/* 626 */     this.sprite = null;
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public synchronized void addedTo(Object paramObject)
/*     */   {
/* 641 */     if ((paramObject instanceof Component)) {
/* 642 */       if (this.canv != null)
/* 643 */         removedFrom(this.canv);
/* 644 */       this.canv = ((Component)paramObject);
/*     */
/* 646 */       setSize(this.mSize);
/*     */
/* 648 */       if (this.nl != null)
/* 649 */         this.nl.notifyComplete();
/*     */     }
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public void removedFrom(Object paramObject)
/*     */   {
/* 664 */     if ((paramObject instanceof Component)) {
/* 665 */       this.canv = null;
/* 666 */       this.offscreenImage = null;
/*     */     }
/*     */   }
/*     */
/*     */   /** @deprecated */
/*     */   public boolean addNotifyListener(NotifyListener paramNotifyListener)
/*     */   {
/* 677 */     this.nl = paramNotifyListener;
/* 678 */     if (!paramNotifyListener.setNotifier(this)) {
/* 679 */       paramNotifyListener = null;
/* 680 */       return false;
/*     */     }
/* 682 */     if (this.canv != null)
/* 683 */       paramNotifyListener.notifyComplete();
/* 684 */     return true;
/*     */   }
/*     */
/*     */   static
/*     */   {
/*  70 */     if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() >= 65540))
/*  71 */       throw new QTRuntimeException("Unsupported on Mac OS X and Java 1.4 and higher.");
/*     */   }
/*     */
/*     */   class RedrawInvalidator extends Invalidator
/*     */   {
/*     */     RedrawInvalidator(TwoDSprite arg2)
/*     */     {
/* 576 */       super();
/*     */     }
/*     */
/*     */     public boolean tickle(float paramFloat, int paramInt) throws QTException {
/* 580 */       if (QTImageDrawer.this.iData != null) {
/* 581 */         if (QTImageDrawer.this.isRedrawing())
/* 582 */           QTImageDrawer.this.redraw(null);
/*     */         else
/* 584 */           this.s.setImage(QTImageDrawer.this.iData);
/*     */       }
/* 586 */       return true;
/*     */     }
/*     */   }
/*     */ }

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

Related Classes of quicktime.app.image.QTImageDrawer

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.