home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / GroupLayout$AutoPreferredGapSpring.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  4.2 KB  |  182 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import javax.swing.LayoutStyle.ComponentPlacement;
  7.  
  8. class GroupLayout$AutoPreferredGapSpring extends GroupLayout.Spring {
  9.    List<GroupLayout.ComponentSpring> sources;
  10.    GroupLayout.ComponentSpring source;
  11.    private List<GroupLayout.AutoPreferredGapMatch> matches;
  12.    int size;
  13.    int lastSize;
  14.    private final int pref;
  15.    private final int max;
  16.    private LayoutStyle.ComponentPlacement type;
  17.    private boolean userCreated;
  18.    // $FF: synthetic field
  19.    final GroupLayout this$0;
  20.  
  21.    private GroupLayout$AutoPreferredGapSpring(GroupLayout var1) {
  22.       super(var1);
  23.       this.this$0 = var1;
  24.       this.pref = -2;
  25.       this.max = -2;
  26.       this.type = ComponentPlacement.RELATED;
  27.    }
  28.  
  29.    GroupLayout$AutoPreferredGapSpring(GroupLayout var1, int var2, int var3) {
  30.       super(var1);
  31.       this.this$0 = var1;
  32.       this.pref = var2;
  33.       this.max = var3;
  34.    }
  35.  
  36.    GroupLayout$AutoPreferredGapSpring(GroupLayout var1, LayoutStyle.ComponentPlacement var2, int var3, int var4) {
  37.       super(var1);
  38.       this.this$0 = var1;
  39.       this.type = var2;
  40.       this.pref = var3;
  41.       this.max = var4;
  42.       this.userCreated = true;
  43.    }
  44.  
  45.    public void setSource(GroupLayout.ComponentSpring var1) {
  46.       this.source = var1;
  47.    }
  48.  
  49.    public void setSources(List<GroupLayout.ComponentSpring> var1) {
  50.       this.sources = new ArrayList(var1);
  51.    }
  52.  
  53.    public void setUserCreated(boolean var1) {
  54.       this.userCreated = var1;
  55.    }
  56.  
  57.    public boolean getUserCreated() {
  58.       return this.userCreated;
  59.    }
  60.  
  61.    void unset() {
  62.       this.lastSize = this.getSize();
  63.       super.unset();
  64.       this.size = 0;
  65.    }
  66.  
  67.    public void reset() {
  68.       this.size = 0;
  69.       this.sources = null;
  70.       this.source = null;
  71.       this.matches = null;
  72.    }
  73.  
  74.    public void calculatePadding(int var1) {
  75.       this.size = Integer.MIN_VALUE;
  76.       int var2 = Integer.MIN_VALUE;
  77.       if (this.matches != null) {
  78.          LayoutStyle var3 = GroupLayout.access$800(this.this$0);
  79.          byte var4;
  80.          if (var1 == 0) {
  81.             if (GroupLayout.access$900(this.this$0)) {
  82.                var4 = 3;
  83.             } else {
  84.                var4 = 7;
  85.             }
  86.          } else {
  87.             var4 = 5;
  88.          }
  89.  
  90.          for(int var5 = this.matches.size() - 1; var5 >= 0; --var5) {
  91.             GroupLayout.AutoPreferredGapMatch var6 = (GroupLayout.AutoPreferredGapMatch)this.matches.get(var5);
  92.             var2 = Math.max(var2, this.calculatePadding(var3, var4, var6.source, var6.target));
  93.          }
  94.       }
  95.  
  96.       if (this.size == Integer.MIN_VALUE) {
  97.          this.size = 0;
  98.       }
  99.  
  100.       if (var2 == Integer.MIN_VALUE) {
  101.          var2 = 0;
  102.       }
  103.  
  104.       if (this.lastSize != Integer.MIN_VALUE) {
  105.          this.size += Math.min(var2, this.lastSize);
  106.       }
  107.  
  108.    }
  109.  
  110.    private int calculatePadding(LayoutStyle var1, int var2, GroupLayout.ComponentSpring var3, GroupLayout.ComponentSpring var4) {
  111.       int var5 = var4.getOrigin() - (var3.getOrigin() + var3.getSize());
  112.       if (var5 < 0) {
  113.          return 0;
  114.       } else {
  115.          int var6;
  116.          if (var3.getComponent() instanceof JComponent && var4.getComponent() instanceof JComponent) {
  117.             var6 = var1.getPreferredGap((JComponent)var3.getComponent(), (JComponent)var4.getComponent(), this.type, var2, GroupLayout.access$700(this.this$0));
  118.          } else {
  119.             var6 = 10;
  120.          }
  121.  
  122.          if (var6 > var5) {
  123.             this.size = Math.max(this.size, var6 - var5);
  124.          }
  125.  
  126.          return var6;
  127.       }
  128.    }
  129.  
  130.    public void addTarget(GroupLayout.ComponentSpring var1, int var2) {
  131.       int var3 = var2 == 0 ? 1 : 0;
  132.       if (this.source != null) {
  133.          if (GroupLayout.access$1000(this.this$0, this.source.getComponent(), var1.getComponent(), var3)) {
  134.             this.addValidTarget(this.source, var1);
  135.          }
  136.       } else {
  137.          Component var4 = var1.getComponent();
  138.  
  139.          for(int var5 = this.sources.size() - 1; var5 >= 0; --var5) {
  140.             GroupLayout.ComponentSpring var6 = (GroupLayout.ComponentSpring)this.sources.get(var5);
  141.             if (GroupLayout.access$1000(this.this$0, var6.getComponent(), var4, var3)) {
  142.                this.addValidTarget(var6, var1);
  143.             }
  144.          }
  145.       }
  146.  
  147.    }
  148.  
  149.    private void addValidTarget(GroupLayout.ComponentSpring var1, GroupLayout.ComponentSpring var2) {
  150.       if (this.matches == null) {
  151.          this.matches = new ArrayList(1);
  152.       }
  153.  
  154.       this.matches.add(new GroupLayout.AutoPreferredGapMatch(var1, var2));
  155.    }
  156.  
  157.    int calculateMinimumSize(int var1) {
  158.       return this.size;
  159.    }
  160.  
  161.    int calculatePreferredSize(int var1) {
  162.       return this.pref != -2 && this.pref != -1 ? Math.max(this.size, this.pref) : this.size;
  163.    }
  164.  
  165.    int calculateMaximumSize(int var1) {
  166.       return this.max >= 0 ? Math.max(this.getPreferredSize(var1), this.max) : this.size;
  167.    }
  168.  
  169.    String getMatchDescription() {
  170.       return this.matches == null ? "" : this.matches.toString();
  171.    }
  172.  
  173.    public String toString() {
  174.       return super.toString() + this.getMatchDescription();
  175.    }
  176.  
  177.    // $FF: synthetic method
  178.    GroupLayout$AutoPreferredGapSpring(GroupLayout var1, GroupLayout.1 var2) {
  179.       this(var1);
  180.    }
  181. }
  182.