home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text;
-
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import java.awt.Shape;
- import javax.swing.text.Position.Bias;
-
- public class AsyncBoxView$ChildLocator {
- protected AsyncBoxView.ChildState lastValidOffset;
- protected Rectangle lastAlloc;
- protected Rectangle childAlloc;
- // $FF: synthetic field
- private final AsyncBoxView this$0;
-
- public AsyncBoxView$ChildLocator(AsyncBoxView var1) {
- this.this$0 = var1;
- this.lastAlloc = new Rectangle();
- this.childAlloc = new Rectangle();
- }
-
- public synchronized void childChanged(AsyncBoxView.ChildState var1) {
- if (this.lastValidOffset == null) {
- this.lastValidOffset = var1;
- } else if (var1.getChildView().getStartOffset() < this.lastValidOffset.getChildView().getStartOffset()) {
- this.lastValidOffset = var1;
- }
-
- }
-
- public synchronized void paintChildren(Graphics var1) {
- Rectangle var2 = var1.getClipBounds();
- float var3 = this.this$0.axis == 0 ? (float)(var2.x - this.lastAlloc.x) : (float)(var2.y - this.lastAlloc.y);
- int var4 = this.getViewIndexAtVisualOffset(var3);
- int var5 = this.this$0.getViewCount();
- float var6 = this.this$0.getChildState(var4).getMajorOffset();
-
- for(int var7 = var4; var7 < var5; ++var7) {
- AsyncBoxView.ChildState var8 = this.this$0.getChildState(var7);
- var8.setMajorOffset(var6);
- Shape var9 = this.getChildAllocation(var7);
- if (!this.intersectsClip(var9, var2)) {
- break;
- }
-
- synchronized(var8) {
- View var11 = var8.getChildView();
- var11.paint(var1, var9);
- }
-
- var6 += var8.getMajorSpan();
- }
-
- }
-
- public synchronized Shape getChildAllocation(int var1, Shape var2) {
- if (var2 == null) {
- return null;
- } else {
- this.setAllocation(var2);
- AsyncBoxView.ChildState var3 = this.this$0.getChildState(var1);
- if (var3.getChildView().getStartOffset() > this.lastValidOffset.getChildView().getStartOffset()) {
- this.updateChildOffsetsToIndex(var1);
- }
-
- Shape var4 = this.getChildAllocation(var1);
- return var4;
- }
- }
-
- public int getViewIndexAtPoint(float var1, float var2, Shape var3) {
- this.setAllocation(var3);
- float var4 = this.this$0.axis == 0 ? var1 - (float)this.lastAlloc.x : var2 - (float)this.lastAlloc.y;
- int var5 = this.getViewIndexAtVisualOffset(var4);
- return var5;
- }
-
- protected Shape getChildAllocation(int var1) {
- AsyncBoxView.ChildState var2 = this.this$0.getChildState(var1);
- if (!var2.isLayoutValid()) {
- var2.run();
- }
-
- if (this.this$0.axis == 0) {
- this.childAlloc.x = this.lastAlloc.x + (int)var2.getMajorOffset();
- this.childAlloc.y = this.lastAlloc.y + (int)var2.getMinorOffset();
- this.childAlloc.width = (int)var2.getMajorSpan();
- this.childAlloc.height = (int)var2.getMinorSpan();
- } else {
- this.childAlloc.y = this.lastAlloc.y + (int)var2.getMajorOffset();
- this.childAlloc.x = this.lastAlloc.x + (int)var2.getMinorOffset();
- this.childAlloc.height = (int)var2.getMajorSpan();
- this.childAlloc.width = (int)var2.getMinorSpan();
- }
-
- return this.childAlloc;
- }
-
- protected void setAllocation(Shape var1) {
- if (var1 instanceof Rectangle) {
- this.lastAlloc.setBounds((Rectangle)var1);
- } else {
- this.lastAlloc.setBounds(var1.getBounds());
- }
-
- this.this$0.setSize((float)this.lastAlloc.width, (float)this.lastAlloc.height);
- }
-
- protected int getViewIndexAtVisualOffset(float var1) {
- int var2 = this.this$0.getViewCount();
- if (var2 > 0) {
- if (this.lastValidOffset == null) {
- this.lastValidOffset = this.this$0.getChildState(0);
- }
-
- if (var1 > this.this$0.majorSpan) {
- return 0;
- }
-
- if (var1 > this.lastValidOffset.getMajorOffset()) {
- return this.updateChildOffsets(var1);
- }
-
- float var3 = 0.0F;
-
- for(int var4 = 0; var4 < var2; ++var4) {
- AsyncBoxView.ChildState var5 = this.this$0.getChildState(var4);
- float var6 = var3 + var5.getMajorSpan();
- if (var1 < var6) {
- return var4;
- }
-
- var3 = var6;
- }
- }
-
- return var2 - 1;
- }
-
- int updateChildOffsets(float var1) {
- int var2 = this.this$0.getViewCount();
- int var3 = var2 - 1;
- int var4 = this.lastValidOffset.getChildView().getStartOffset();
- int var5 = this.this$0.getViewIndexAtPosition(var4, Bias.Forward);
- float var6 = this.lastValidOffset.getMajorOffset();
- float var7 = var6;
-
- for(int var8 = var5; var8 < var2; ++var8) {
- AsyncBoxView.ChildState var9 = this.this$0.getChildState(var8);
- var9.setMajorOffset(var7);
- var7 += var9.getMajorSpan();
- if (var1 < var7) {
- var3 = var8;
- this.lastValidOffset = var9;
- break;
- }
- }
-
- return var3;
- }
-
- void updateChildOffsetsToIndex(int var1) {
- int var2 = this.lastValidOffset.getChildView().getStartOffset();
- int var3 = this.this$0.getViewIndexAtPosition(var2, Bias.Forward);
- float var4 = this.lastValidOffset.getMajorOffset();
-
- for(int var5 = var3; var5 <= var1; ++var5) {
- AsyncBoxView.ChildState var6 = this.this$0.getChildState(var5);
- var6.setMajorOffset(var4);
- var4 += var6.getMajorSpan();
- }
-
- }
-
- boolean intersectsClip(Shape var1, Rectangle var2) {
- Rectangle var3 = var1 instanceof Rectangle ? (Rectangle)var1 : var1.getBounds();
- return var3.intersects(var2);
- }
- }
-