home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / text / AsyncBoxView$ChildLocator.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.2 KB  |  179 lines

  1. package javax.swing.text;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.Rectangle;
  5. import java.awt.Shape;
  6. import javax.swing.text.Position.Bias;
  7.  
  8. public class AsyncBoxView$ChildLocator {
  9.    protected AsyncBoxView.ChildState lastValidOffset;
  10.    protected Rectangle lastAlloc;
  11.    protected Rectangle childAlloc;
  12.    // $FF: synthetic field
  13.    private final AsyncBoxView this$0;
  14.  
  15.    public AsyncBoxView$ChildLocator(AsyncBoxView var1) {
  16.       this.this$0 = var1;
  17.       this.lastAlloc = new Rectangle();
  18.       this.childAlloc = new Rectangle();
  19.    }
  20.  
  21.    public synchronized void childChanged(AsyncBoxView.ChildState var1) {
  22.       if (this.lastValidOffset == null) {
  23.          this.lastValidOffset = var1;
  24.       } else if (var1.getChildView().getStartOffset() < this.lastValidOffset.getChildView().getStartOffset()) {
  25.          this.lastValidOffset = var1;
  26.       }
  27.  
  28.    }
  29.  
  30.    public synchronized void paintChildren(Graphics var1) {
  31.       Rectangle var2 = var1.getClipBounds();
  32.       float var3 = this.this$0.axis == 0 ? (float)(var2.x - this.lastAlloc.x) : (float)(var2.y - this.lastAlloc.y);
  33.       int var4 = this.getViewIndexAtVisualOffset(var3);
  34.       int var5 = this.this$0.getViewCount();
  35.       float var6 = this.this$0.getChildState(var4).getMajorOffset();
  36.  
  37.       for(int var7 = var4; var7 < var5; ++var7) {
  38.          AsyncBoxView.ChildState var8 = this.this$0.getChildState(var7);
  39.          var8.setMajorOffset(var6);
  40.          Shape var9 = this.getChildAllocation(var7);
  41.          if (!this.intersectsClip(var9, var2)) {
  42.             break;
  43.          }
  44.  
  45.          synchronized(var8) {
  46.             View var11 = var8.getChildView();
  47.             var11.paint(var1, var9);
  48.          }
  49.  
  50.          var6 += var8.getMajorSpan();
  51.       }
  52.  
  53.    }
  54.  
  55.    public synchronized Shape getChildAllocation(int var1, Shape var2) {
  56.       if (var2 == null) {
  57.          return null;
  58.       } else {
  59.          this.setAllocation(var2);
  60.          AsyncBoxView.ChildState var3 = this.this$0.getChildState(var1);
  61.          if (var3.getChildView().getStartOffset() > this.lastValidOffset.getChildView().getStartOffset()) {
  62.             this.updateChildOffsetsToIndex(var1);
  63.          }
  64.  
  65.          Shape var4 = this.getChildAllocation(var1);
  66.          return var4;
  67.       }
  68.    }
  69.  
  70.    public int getViewIndexAtPoint(float var1, float var2, Shape var3) {
  71.       this.setAllocation(var3);
  72.       float var4 = this.this$0.axis == 0 ? var1 - (float)this.lastAlloc.x : var2 - (float)this.lastAlloc.y;
  73.       int var5 = this.getViewIndexAtVisualOffset(var4);
  74.       return var5;
  75.    }
  76.  
  77.    protected Shape getChildAllocation(int var1) {
  78.       AsyncBoxView.ChildState var2 = this.this$0.getChildState(var1);
  79.       if (!var2.isLayoutValid()) {
  80.          var2.run();
  81.       }
  82.  
  83.       if (this.this$0.axis == 0) {
  84.          this.childAlloc.x = this.lastAlloc.x + (int)var2.getMajorOffset();
  85.          this.childAlloc.y = this.lastAlloc.y + (int)var2.getMinorOffset();
  86.          this.childAlloc.width = (int)var2.getMajorSpan();
  87.          this.childAlloc.height = (int)var2.getMinorSpan();
  88.       } else {
  89.          this.childAlloc.y = this.lastAlloc.y + (int)var2.getMajorOffset();
  90.          this.childAlloc.x = this.lastAlloc.x + (int)var2.getMinorOffset();
  91.          this.childAlloc.height = (int)var2.getMajorSpan();
  92.          this.childAlloc.width = (int)var2.getMinorSpan();
  93.       }
  94.  
  95.       return this.childAlloc;
  96.    }
  97.  
  98.    protected void setAllocation(Shape var1) {
  99.       if (var1 instanceof Rectangle) {
  100.          this.lastAlloc.setBounds((Rectangle)var1);
  101.       } else {
  102.          this.lastAlloc.setBounds(var1.getBounds());
  103.       }
  104.  
  105.       this.this$0.setSize((float)this.lastAlloc.width, (float)this.lastAlloc.height);
  106.    }
  107.  
  108.    protected int getViewIndexAtVisualOffset(float var1) {
  109.       int var2 = this.this$0.getViewCount();
  110.       if (var2 > 0) {
  111.          if (this.lastValidOffset == null) {
  112.             this.lastValidOffset = this.this$0.getChildState(0);
  113.          }
  114.  
  115.          if (var1 > this.this$0.majorSpan) {
  116.             return 0;
  117.          }
  118.  
  119.          if (var1 > this.lastValidOffset.getMajorOffset()) {
  120.             return this.updateChildOffsets(var1);
  121.          }
  122.  
  123.          float var3 = 0.0F;
  124.  
  125.          for(int var4 = 0; var4 < var2; ++var4) {
  126.             AsyncBoxView.ChildState var5 = this.this$0.getChildState(var4);
  127.             float var6 = var3 + var5.getMajorSpan();
  128.             if (var1 < var6) {
  129.                return var4;
  130.             }
  131.  
  132.             var3 = var6;
  133.          }
  134.       }
  135.  
  136.       return var2 - 1;
  137.    }
  138.  
  139.    int updateChildOffsets(float var1) {
  140.       int var2 = this.this$0.getViewCount();
  141.       int var3 = var2 - 1;
  142.       int var4 = this.lastValidOffset.getChildView().getStartOffset();
  143.       int var5 = this.this$0.getViewIndexAtPosition(var4, Bias.Forward);
  144.       float var6 = this.lastValidOffset.getMajorOffset();
  145.       float var7 = var6;
  146.  
  147.       for(int var8 = var5; var8 < var2; ++var8) {
  148.          AsyncBoxView.ChildState var9 = this.this$0.getChildState(var8);
  149.          var9.setMajorOffset(var7);
  150.          var7 += var9.getMajorSpan();
  151.          if (var1 < var7) {
  152.             var3 = var8;
  153.             this.lastValidOffset = var9;
  154.             break;
  155.          }
  156.       }
  157.  
  158.       return var3;
  159.    }
  160.  
  161.    void updateChildOffsetsToIndex(int var1) {
  162.       int var2 = this.lastValidOffset.getChildView().getStartOffset();
  163.       int var3 = this.this$0.getViewIndexAtPosition(var2, Bias.Forward);
  164.       float var4 = this.lastValidOffset.getMajorOffset();
  165.  
  166.       for(int var5 = var3; var5 <= var1; ++var5) {
  167.          AsyncBoxView.ChildState var6 = this.this$0.getChildState(var5);
  168.          var6.setMajorOffset(var4);
  169.          var4 += var6.getMajorSpan();
  170.       }
  171.  
  172.    }
  173.  
  174.    boolean intersectsClip(Shape var1, Rectangle var2) {
  175.       Rectangle var3 = var1 instanceof Rectangle ? (Rectangle)var1 : var1.getBounds();
  176.       return var3.intersects(var2);
  177.    }
  178. }
  179.