home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.basic;
-
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Insets;
- import java.awt.LayoutManager2;
- import java.io.Serializable;
-
- public class BasicSplitPaneUI$BasicHorizontalLayoutManager implements LayoutManager2, Serializable {
- // $FF: synthetic field
- BasicSplitPaneUI this$0;
- protected int[] sizes;
- protected Component[] components;
- protected int dividerLocation;
-
- // $FF: synthetic method
- BasicSplitPaneUI$BasicHorizontalLayoutManager(BasicSplitPaneUI this$0) {
- this.this$0 = this$0;
- this.components = new Component[3];
- this.components[0] = this.components[1] = this.components[2] = null;
- this.sizes = new int[3];
- this.dividerLocation = -1;
- }
-
- protected void resetSizeAt(int index) {
- this.sizes[index] = -1;
- }
-
- protected void setSizes(int[] newSizes) {
- System.arraycopy(newSizes, 0, this.sizes, 0, 3);
- }
-
- protected int[] getSizes() {
- int[] retSizes = new int[3];
- System.arraycopy(this.sizes, 0, retSizes, 0, 3);
- return retSizes;
- }
-
- protected int getPreferredSizeOfComponent(Component c) {
- return c.getPreferredSize().width;
- }
-
- protected int getSizeOfComponent(Component c) {
- return c.getSize().width;
- }
-
- protected int getAvailableSize(Dimension containerSize, Insets insets) {
- return insets == null ? containerSize.width : containerSize.width - (insets.left + insets.right + 2 * this.this$0.getDividerBorderSize());
- }
-
- protected int getInitialLocation(Insets insets) {
- return insets != null ? insets.left : 0;
- }
-
- protected void setComponentToSize(Component c, int size, int location, Insets insets, Dimension containerSize) {
- if (insets != null) {
- c.setBounds(location, insets.top, size, containerSize.height - (insets.top + insets.bottom));
- } else {
- c.setBounds(location, 0, size, containerSize.height);
- }
-
- }
-
- public void layoutContainer(Container container) {
- Dimension containerSize = ((Component)container).getSize();
- if (containerSize.height != 0 && containerSize.width != 0) {
- int totalSize = 0;
- Insets insets = this.this$0.splitPane.getInsets();
- int availableSize = this.getAvailableSize(containerSize, insets);
- int beginLocation = this.this$0.splitPane.getDividerLocation();
-
- for(int counter = 0; counter < 3; ++counter) {
- if (this.components[counter] != null) {
- if (this.sizes[counter] == -1) {
- this.sizes[counter] = Math.min(availableSize, this.getPreferredSizeOfComponent(this.components[counter]));
- } else {
- int newSize = this.getSizeOfComponent(this.components[counter]);
- if (this.sizes[counter] != newSize) {
- if (counter == 0) {
- if (this.components[1] != null) {
- this.sizes[1] = Math.max(0, this.sizes[1] + (this.sizes[counter] - newSize));
- }
- } else if (counter == 1 && this.components[0] != null) {
- this.sizes[0] = Math.max(0, this.sizes[0] + (this.sizes[counter] - newSize));
- }
-
- this.sizes[counter] = newSize;
- if (counter == 0) {
- counter = 1;
- }
- }
- }
- }
- }
-
- for(int var11 = 0; var11 < 3; ++var11) {
- totalSize += this.sizes[var11];
- }
-
- if (totalSize != availableSize) {
- int toDiff = availableSize - totalSize;
- if (this.components[1] != null) {
- int var13 = Math.max(0, this.sizes[1] + toDiff);
- if (var13 == 0) {
- toDiff += this.sizes[1];
- this.sizes[1] = 0;
- if (this.components[0] != null) {
- this.sizes[0] = Math.max(0, this.sizes[0] + toDiff);
- }
- } else {
- this.sizes[1] = var13;
- }
- } else if (this.components[0] != null) {
- this.sizes[0] = Math.max(0, this.sizes[0] + toDiff);
- }
- }
-
- int nextLocation = this.getInitialLocation(insets);
- int bdSize = this.this$0.getDividerBorderSize();
- int var12 = 0;
-
- while(var12 < 3) {
- if (this.components[var12] != null) {
- this.setComponentToSize(this.components[var12], this.sizes[var12], nextLocation, insets, containerSize);
- nextLocation += this.sizes[var12];
- }
-
- switch (var12) {
- case 0:
- var12 = 2;
- nextLocation += bdSize;
- break;
- case 1:
- var12 = 3;
- break;
- case 2:
- var12 = 1;
- nextLocation += bdSize;
- }
- }
-
- if (beginLocation != this.this$0.splitPane.getDividerLocation()) {
- this.this$0.splitPane.setLastDividerLocation(beginLocation);
- }
-
- }
- }
-
- public void addLayoutComponent(String place, Component component) {
- boolean isValid = true;
- if (place != null) {
- if (place.equals("divider")) {
- this.components[2] = component;
- this.sizes[2] = -1;
- } else if (!place.equals("left") && !place.equals("top")) {
- if (!place.equals("right") && !place.equals("bottom")) {
- if (!place.equals("nonContinuousDivider")) {
- isValid = false;
- }
- } else {
- this.components[1] = component;
- this.sizes[1] = -1;
- }
- } else {
- this.components[0] = component;
- this.sizes[0] = -1;
- }
- } else {
- isValid = false;
- }
-
- if (!isValid) {
- throw new IllegalArgumentException("cannot add to layout: unknown constraint: " + place);
- }
- }
-
- public Dimension minimumLayoutSize(Container container) {
- Insets insets = this.this$0.splitPane.getInsets();
- int minY = 0;
- int minX = 0;
-
- for(int counter = 0; counter < 3; ++counter) {
- if (this.components[counter] != null) {
- Dimension minSize = this.components[counter].getMinimumSize();
- minX += minSize.width;
- if (minSize.height > minY) {
- minY = minSize.height;
- }
- }
- }
-
- if (insets != null) {
- minX += insets.left + insets.right;
- minY += insets.bottom + insets.top;
- }
-
- return new Dimension(minX, minY);
- }
-
- public Dimension preferredLayoutSize(Container container) {
- Insets insets = this.this$0.splitPane.getInsets();
- int preY = 0;
- int preX = 0;
-
- for(int counter = 0; counter < 3; ++counter) {
- if (this.components[counter] != null) {
- Dimension preSize = this.components[counter].getPreferredSize();
- preX += preSize.width;
- if (preSize.height > preY) {
- preY = preSize.height;
- }
- }
- }
-
- if (insets != null) {
- preX += insets.left + insets.right;
- preY += insets.bottom + insets.top;
- }
-
- return new Dimension(preX, preY);
- }
-
- public void removeLayoutComponent(Component component) {
- for(int counter = 0; counter < 3; ++counter) {
- if (this.components[counter] == component) {
- this.components[counter] = null;
- this.sizes[counter] = 0;
- }
- }
-
- }
-
- public void addLayoutComponent(Component comp, Object constraints) {
- if (constraints != null && !(constraints instanceof String)) {
- throw new IllegalArgumentException("cannot add to layout: constraint must be a string (or null)");
- } else {
- this.addLayoutComponent((String)constraints, comp);
- }
- }
-
- public float getLayoutAlignmentX(Container target) {
- return 0.0F;
- }
-
- public float getLayoutAlignmentY(Container target) {
- return 0.0F;
- }
-
- public void invalidateLayout(Container c) {
- }
-
- public Dimension maximumLayoutSize(Container target) {
- return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
- }
-
- public void resetToPreferredSizes() {
- for(int counter = 0; counter < 3; ++counter) {
- this.sizes[counter] = -1;
- }
-
- }
-
- protected void updateComponents() {
- Component comp = this.this$0.splitPane.getLeftComponent();
- if (this.components[0] != comp) {
- this.components[0] = comp;
- if (comp == null) {
- this.sizes[0] = 0;
- } else {
- this.sizes[0] = -1;
- }
- }
-
- comp = this.this$0.splitPane.getRightComponent();
- if (this.components[1] != comp) {
- this.components[1] = comp;
- if (comp == null) {
- this.sizes[1] = 0;
- } else {
- this.sizes[1] = -1;
- }
- }
-
- Component[] children = this.this$0.splitPane.getComponents();
- Component oldDivider = this.components[2];
- this.components[2] = null;
-
- for(int counter = children.length - 1; counter >= 0; --counter) {
- if (children[counter] != this.components[0] && children[counter] != this.components[1] && children[counter] != this.this$0.nonContinuousLayoutDivider) {
- if (oldDivider != children[counter]) {
- this.components[2] = children[counter];
- if (children[counter] == null) {
- this.sizes[2] = 0;
- } else {
- this.sizes[2] = -1;
- }
- } else {
- this.components[2] = oldDivider;
- }
- break;
- }
- }
-
- if (this.components[2] == null) {
- this.sizes[2] = 0;
- }
-
- }
- }
-