home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text;
-
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Graphics;
- import java.awt.Shape;
- import javax.swing.event.DocumentEvent;
- import javax.swing.text.Position.Bias;
-
- public class AsyncBoxView extends View {
- int axis;
- ChildVector stats = new ChildVector();
- float majorSpan;
- float minorSpan;
- protected ChildLocator locator;
- float topInset;
- float bottomInset;
- float leftInset;
- float rightInset;
- ChildState minRequest;
- ChildState prefRequest;
- boolean majorChanged;
- boolean minorChanged;
- Runnable flushTask;
- ChildState changing;
-
- public AsyncBoxView(Element var1, int var2) {
- super(var1);
- this.axis = var2;
- this.locator = new ChildLocator(this);
- this.flushTask = new FlushTask(this);
- this.minorSpan = 32767.0F;
- }
-
- public int getMajorAxis() {
- return this.axis;
- }
-
- public int getMinorAxis() {
- return this.axis == 0 ? 1 : 0;
- }
-
- public float getTopInset() {
- return this.topInset;
- }
-
- public void setTopInset(float var1) {
- this.topInset = var1;
- }
-
- public float getBottomInset() {
- return this.bottomInset;
- }
-
- public void setBottomInset(float var1) {
- this.bottomInset = var1;
- }
-
- public float getLeftInset() {
- return this.leftInset;
- }
-
- public void setLeftInset(float var1) {
- this.leftInset = var1;
- }
-
- public float getRightInset() {
- return this.rightInset;
- }
-
- public void setRightInset(float var1) {
- this.rightInset = var1;
- }
-
- protected ChildState getChildState(int var1) {
- ChildVector var2 = this.stats;
- synchronized(var2) {
- ChildState var3 = this.stats.getChildState(var1);
- return var3;
- }
- }
-
- protected LayoutQueue getLayoutQueue() {
- return LayoutQueue.getDefaultQueue();
- }
-
- protected ChildState createChildState(View var1) {
- return new ChildState(this, var1);
- }
-
- protected synchronized void majorRequirementChange(ChildState var1, float var2) {
- this.majorSpan += var2;
- this.majorChanged = true;
- }
-
- protected synchronized void minorRequirementChange(ChildState var1) {
- this.minorChanged = true;
- }
-
- protected synchronized void flushRequirementChanges() {
- if (this.majorChanged || this.minorChanged) {
- View var1 = ((View)this).getParent();
- if (var1 != null) {
- boolean var2;
- boolean var3;
- if (this.axis == 0) {
- var2 = this.majorChanged;
- var3 = this.minorChanged;
- } else {
- var3 = this.majorChanged;
- var2 = this.minorChanged;
- }
-
- var1.preferenceChanged(this, var2, var3);
- this.majorChanged = false;
- this.minorChanged = false;
- Container var4 = ((View)this).getContainer();
- if (var4 != null) {
- ((Component)var4).repaint();
- }
- }
- }
-
- }
-
- public void replace(int var1, int var2, View[] var3) {
- ChildVector var4 = this.stats;
- synchronized(var4) {
- LayoutQueue var5 = this.getLayoutQueue();
- ChildState[] var6 = new ChildState[var3.length];
-
- for(int var7 = 0; var7 < var6.length; ++var7) {
- var6[var7] = this.createChildState(var3[var7]);
- }
-
- this.stats.replace(var1, var2, var6);
- if (var6.length != 0) {
- for(int var8 = 0; var8 < var6.length; ++var8) {
- var5.addTask(var6[var8]);
- }
-
- var5.addTask(this.flushTask);
- }
-
- }
- }
-
- protected void loadChildren(ViewFactory var1) {
- Element var2 = ((View)this).getElement();
- int var3 = var2.getElementCount();
- if (var3 > 0) {
- View[] var4 = new View[var3];
-
- for(int var5 = 0; var5 < var3; ++var5) {
- var4[var5] = var1.create(var2.getElement(var5));
- }
-
- this.replace(0, 0, var4);
- }
-
- }
-
- protected synchronized int getViewIndexAtPosition(int var1, Position.Bias var2) {
- boolean var3 = var2 == Bias.Backward;
- var1 = var3 ? Math.max(0, var1 - 1) : var1;
- Element var4 = ((View)this).getElement();
- return var4.getElementIndex(var1);
- }
-
- protected void updateLayout(DocumentEvent.ElementChange var1, DocumentEvent var2, Shape var3) {
- if (var1 != null) {
- int var4 = Math.max(var1.getIndex() - 1, 0);
- ChildState var5 = this.getChildState(var4);
- this.locator.childChanged(var5);
- }
-
- }
-
- public void setParent(View var1) {
- super.setParent(var1);
- if (var1 != null && this.getViewCount() == 0) {
- ViewFactory var2 = ((View)this).getViewFactory();
- this.loadChildren(var2);
- }
-
- }
-
- public synchronized void preferenceChanged(View var1, boolean var2, boolean var3) {
- if (var1 == null) {
- ((View)this).getParent().preferenceChanged(this, var2, var3);
- } else {
- if (this.changing != null) {
- View var4 = this.changing.getChildView();
- if (var4 == var1) {
- this.changing.preferenceChanged(var2, var3);
- return;
- }
- }
-
- int var7 = this.getViewIndexAtPosition(var1.getStartOffset(), Bias.Forward);
- ChildState var5 = this.getChildState(var7);
- var5.preferenceChanged(var2, var3);
- LayoutQueue var6 = this.getLayoutQueue();
- var6.addTask(var5);
- var6.addTask(this.flushTask);
- }
-
- }
-
- public void setSize(float var1, float var2) {
- float var3;
- if (this.axis == 0) {
- var3 = var2 - this.getTopInset() - this.getBottomInset();
- } else {
- var3 = var1 - this.getLeftInset() - this.getRightInset();
- }
-
- if (var3 != this.minorSpan) {
- this.minorSpan = var3;
- int var4 = this.getViewCount();
- LayoutQueue var5 = this.getLayoutQueue();
-
- for(int var6 = 0; var6 < var4; ++var6) {
- ChildState var7 = this.getChildState(var6);
- javax.swing.text.AsyncBoxView.ChildState.access$002(var7, false);
- var5.addTask(var7);
- }
-
- var5.addTask(this.flushTask);
- }
-
- }
-
- public void paint(Graphics var1, Shape var2) {
- ChildLocator var3 = this.locator;
- synchronized(var3) {
- this.locator.setAllocation(var2);
- this.locator.paintChildren(var1);
- }
- }
-
- public float getPreferredSpan(int var1) {
- if (var1 == this.axis) {
- return this.majorSpan;
- } else if (this.prefRequest != null) {
- View var2 = this.prefRequest.getChildView();
- return var2.getPreferredSpan(var1);
- } else {
- return var1 == 0 ? this.getLeftInset() + this.getRightInset() + 30.0F : this.getTopInset() + this.getBottomInset() + 30.0F;
- }
- }
-
- public float getMinimumSpan(int var1) {
- if (var1 == this.axis) {
- return this.getPreferredSpan(var1);
- } else if (this.minRequest != null) {
- View var2 = this.minRequest.getChildView();
- return var2.getMinimumSpan(var1);
- } else {
- return var1 == 0 ? this.getLeftInset() + this.getRightInset() + 5.0F : this.getTopInset() + this.getBottomInset() + 5.0F;
- }
- }
-
- public float getMaximumSpan(int var1) {
- return var1 == this.axis ? this.getPreferredSpan(var1) : 32767.0F;
- }
-
- public int getViewCount() {
- ChildVector var1 = this.stats;
- synchronized(var1) {
- int var2 = this.stats.size();
- return var2;
- }
- }
-
- public View getView(int var1) {
- ChildVector var2 = this.stats;
- synchronized(var2) {
- if (var1 >= 0 && var1 < this.stats.size()) {
- ChildState var3 = this.stats.getChildState(var1);
- View var4 = var3.getChildView();
- return var4;
- } else {
- return null;
- }
- }
- }
-
- public Shape getChildAllocation(int var1, Shape var2) {
- Shape var3 = this.locator.getChildAllocation(var1, var2);
- return var3;
- }
-
- public int getViewIndex(int var1, Position.Bias var2) {
- return this.getViewIndexAtPosition(var1, var2);
- }
-
- public Shape modelToView(int var1, Shape var2, Position.Bias var3) throws BadLocationException {
- int var4 = this.getViewIndexAtPosition(var1, var3);
- Shape var5 = this.locator.getChildAllocation(var4, var2);
- ChildState var6 = this.getChildState(var4);
- synchronized(var6) {
- View var8 = var6.getChildView();
- Shape var9 = var8.modelToView(var1, var5, var3);
- return var9;
- }
- }
-
- public int viewToModel(float var1, float var2, Shape var3, Position.Bias[] var4) {
- ChildLocator var8 = this.locator;
- int var6;
- Shape var7;
- synchronized(var8) {
- var6 = this.locator.getViewIndexAtPoint(var1, var2, var3);
- var7 = this.locator.getChildAllocation(var6, var3);
- }
-
- ChildState var9 = this.getChildState(var6);
- synchronized(var9) {
- View var11 = var9.getChildView();
- int var5 = var11.viewToModel(var1, var2, var7, var4);
- return var5;
- }
- }
- }
-