diff options
author | Anthony Balkissoon <abalkiss@redhat.com> | 2005-11-16 22:21:17 +0000 |
---|---|---|
committer | Anthony Balkissoon <abalkiss@redhat.com> | 2005-11-16 22:21:17 +0000 |
commit | 5ccba33d6afe39aa4cc188712ada69d3d0b6f01b (patch) | |
tree | b04092a07be2e0ef02a7d262223b8c6498deff2d | |
parent | dcae832fd047d910f20131fd62cf7e73d4211e59 (diff) | |
download | classpath-5ccba33d6afe39aa4cc188712ada69d3d0b6f01b.tar.gz |
2005-11-16 Anthony Balkissoon <abalkiss@redhat.com>
* javax/swing/JSplitPane.java: Reformatted file.
* javax/swing/plaf/basic/BasicSplitPaneUI.java: Reformatted file.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | javax/swing/JSplitPane.java | 111 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicSplitPaneUI.java | 290 |
3 files changed, 209 insertions, 197 deletions
@@ -1,3 +1,8 @@ +2005-11-16 Anthony Balkissoon <abalkiss@redhat.com> + + * javax/swing/JSplitPane.java: Reformatted file. + * javax/swing/plaf/basic/BasicSplitPaneUI.java: Reformatted file. + 2005-11-16 Lillian Angel <langel@redhat.com> * javax/swing/ToolTipManager.java diff --git a/javax/swing/JSplitPane.java b/javax/swing/JSplitPane.java index 187281652..70feefab2 100644 --- a/javax/swing/JSplitPane.java +++ b/javax/swing/JSplitPane.java @@ -170,13 +170,15 @@ public class JSplitPane extends JComponent implements Accessible public static final int HORIZONTAL_SPLIT = 1; /** The property fired when the last divider location property changes. */ - public static final String LAST_DIVIDER_LOCATION_PROPERTY = "lastDividerLocation"; + public static final String LAST_DIVIDER_LOCATION_PROPERTY = + "lastDividerLocation"; /** The constraints string used to add components to the left. */ public static final String LEFT = "left"; /** The property fired when the one touch expandable property changes. */ - public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = "oneTouchExpandable"; + public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = + "oneTouchExpandable"; /** The property fired when the orientation property changes. */ public static final String ORIENTATION_PROPERTY = "orientation"; @@ -199,7 +201,8 @@ public class JSplitPane extends JComponent implements Accessible /** Whether the JSplitPane uses one touch expandable buttons. */ protected boolean oneTouchExpandable = false; - // This is the master dividerSize variable and sets the BasicSplitPaneDivider one accordingly + // This is the master dividerSize variable and sets the + // BasicSplitPaneDivider one accordingly /** The size of the divider. */ protected int dividerSize = 10; @@ -301,7 +304,8 @@ public class JSplitPane extends JComponent implements Accessible * @param constraints The constraints string to use. * @param index Where to place to component in the list of components. * - * @throws IllegalArgumentException When the constraints is not a known identifier. + * @throws IllegalArgumentException When the constraints is not a known + * identifier. */ protected void addImpl(Component comp, Object constraints, int index) { @@ -311,34 +315,35 @@ public class JSplitPane extends JComponent implements Accessible int place; if (constraints == null) { - if (leftComponent == null) - constraints = LEFT; - else if (rightComponent == null) - constraints = RIGHT; + if (leftComponent == null) + constraints = LEFT; + else if (rightComponent == null) + constraints = RIGHT; } if (constraints instanceof String) { - String placement = (String) constraints; - - if (placement.equals(BOTTOM) || placement.equals(RIGHT)) - { - if (rightComponent != null) - remove(rightComponent); - rightComponent = comp; - } - else if (placement.equals(LEFT) || placement.equals(TOP)) - { - if (leftComponent != null) - remove(leftComponent); - leftComponent = comp; - } - else if (placement.equals(DIVIDER)) - constraints = null; - else - throw new IllegalArgumentException("Constraints is not a known identifier."); - - super.addImpl(comp, constraints, index); + String placement = (String) constraints; + + if (placement.equals(BOTTOM) || placement.equals(RIGHT)) + { + if (rightComponent != null) + remove(rightComponent); + rightComponent = comp; + } + else if (placement.equals(LEFT) || placement.equals(TOP)) + { + if (leftComponent != null) + remove(leftComponent); + leftComponent = comp; + } + else if (placement.equals(DIVIDER)) + constraints = null; + else + throw new + IllegalArgumentException("Constraints is not a known identifier."); + + super.addImpl(comp, constraints, index); } invalidate(); layout(); @@ -615,10 +620,10 @@ public class JSplitPane extends JComponent implements Accessible { if (newContinuousLayout != continuousLayout) { - boolean oldValue = continuousLayout; - continuousLayout = newContinuousLayout; - firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue, - continuousLayout); + boolean oldValue = continuousLayout; + continuousLayout = newContinuousLayout; + firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue, + continuousLayout); } } @@ -635,7 +640,8 @@ public class JSplitPane extends JComponent implements Accessible public void setDividerLocation(double proportionalLocation) { if (proportionalLocation > 1 || proportionalLocation < 0) - throw new IllegalArgumentException("proportion has to be between 0 and 1."); + throw new IllegalArgumentException + ("proportion has to be between 0 and 1."); int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight(); setDividerLocation((int) (proportionalLocation * max)); @@ -650,9 +656,9 @@ public class JSplitPane extends JComponent implements Accessible { if (ui != null && location != getDividerLocation()) { - int oldLocation = getDividerLocation(); - ((SplitPaneUI) ui).setDividerLocation(this, location); - firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location); + int oldLocation = getDividerLocation(); + ((SplitPaneUI) ui).setDividerLocation(this, location); + firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location); } } @@ -665,9 +671,9 @@ public class JSplitPane extends JComponent implements Accessible { if (newSize != dividerSize) { - int oldSize = dividerSize; - dividerSize = newSize; - firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize); + int oldSize = dividerSize; + dividerSize = newSize; + firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize); } } @@ -684,10 +690,10 @@ public class JSplitPane extends JComponent implements Accessible { if (newLastLocation != lastDividerLocation) { - int oldValue = lastDividerLocation; - lastDividerLocation = newLastLocation; - firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue, - lastDividerLocation); + int oldValue = lastDividerLocation; + lastDividerLocation = newLastLocation; + firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue, + lastDividerLocation); } } @@ -716,10 +722,10 @@ public class JSplitPane extends JComponent implements Accessible { if (newValue != oneTouchExpandable) { - boolean oldValue = oneTouchExpandable; - oneTouchExpandable = newValue; - firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue, - oneTouchExpandable); + boolean oldValue = oneTouchExpandable; + oneTouchExpandable = newValue; + firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue, + oneTouchExpandable); } } @@ -733,13 +739,14 @@ public class JSplitPane extends JComponent implements Accessible public void setOrientation(int orientation) { if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT) - throw new IllegalArgumentException("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT"); + throw new IllegalArgumentException + ("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT"); if (orientation != this.orientation) { - int oldOrientation = this.orientation; - this.orientation = orientation; - firePropertyChange(ORIENTATION_PROPERTY, oldOrientation, - this.orientation); + int oldOrientation = this.orientation; + this.orientation = orientation; + firePropertyChange(ORIENTATION_PROPERTY, oldOrientation, + this.orientation); } } diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java index eb3959df9..cf31e8b5d 100644 --- a/javax/swing/plaf/basic/BasicSplitPaneUI.java +++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java @@ -126,14 +126,14 @@ public class BasicSplitPaneUI extends SplitPaneUI { int i = 0; if (place == null) - i = 2; + i = 2; else if (place.equals(JSplitPane.TOP) || place.equals(JSplitPane.LEFT)) - i = 0; + i = 0; else if (place.equals(JSplitPane.BOTTOM) || place.equals(JSplitPane.RIGHT)) - i = 1; + i = 1; else - throw new IllegalArgumentException("Illegal placement in JSplitPane"); + throw new IllegalArgumentException("Illegal placement in JSplitPane"); components[i] = component; resetSizeAt(i); splitPane.revalidate(); @@ -164,7 +164,7 @@ public class BasicSplitPaneUI extends SplitPaneUI protected int getInitialLocation(Insets insets) { if (insets != null) - return insets.left; + return insets.left; return 0; } @@ -205,7 +205,7 @@ public class BasicSplitPaneUI extends SplitPaneUI { Dimension dims = c.getPreferredSize(); if (dims != null) - return dims.width; + return dims.width; return 0; } @@ -250,23 +250,23 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (container instanceof JSplitPane) { - JSplitPane split = (JSplitPane) container; - distributeExtraSpace(); - Insets insets = split.getInsets(); - int width = getInitialLocation(insets); - Dimension dims = split.getSize(); - for (int i = 0; i < components.length; i += 2) - { - if (components[i] == null) - continue; - setComponentToSize(components[i], sizes[i], width, insets, dims); - width += sizes[i]; - } - if (components[1] != null) - { - setComponentToSize(components[1], sizes[1], width, insets, dims); - width += sizes[1]; - } + JSplitPane split = (JSplitPane) container; + distributeExtraSpace(); + Insets insets = split.getInsets(); + int width = getInitialLocation(insets); + Dimension dims = split.getSize(); + for (int i = 0; i < components.length; i += 2) + { + if (components[i] == null) + continue; + setComponentToSize(components[i], sizes[i], width, insets, dims); + width += sizes[i]; + } + if (components[1] != null) + { + setComponentToSize(components[1], sizes[1], width, insets, dims); + width += sizes[1]; + } } } @@ -297,23 +297,23 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (target instanceof JSplitPane) { - JSplitPane split = (JSplitPane) target; - Insets insets = target.getInsets(); - - int height = 0; - int width = 0; - for (int i = 0; i < components.length; i++) - { - if (components[i] == null) - continue; - Dimension dims = components[i].getMinimumSize(); - if (dims != null) - { - width += dims.width; - height = Math.max(height, dims.height); - } - } - return new Dimension(width, height); + JSplitPane split = (JSplitPane) target; + Insets insets = target.getInsets(); + + int height = 0; + int width = 0; + for (int i = 0; i < components.length; i++) + { + if (components[i] == null) + continue; + Dimension dims = components[i].getMinimumSize(); + if (dims != null) + { + width += dims.width; + height = Math.max(height, dims.height); + } + } + return new Dimension(width, height); } return null; } @@ -331,24 +331,24 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (target instanceof JSplitPane) { - JSplitPane split = (JSplitPane) target; - Insets insets = target.getInsets(); - - int height = 0; - int width = 0; - for (int i = 0; i < components.length; i++) - { - if (components[i] == null) - continue; - Dimension dims = components[i].getPreferredSize(); - if (dims != null) - { - width += dims.width; - if (! (components[i] instanceof BasicSplitPaneDivider)) - height = Math.max(height, dims.height); - } - } - return new Dimension(width, height); + JSplitPane split = (JSplitPane) target; + Insets insets = target.getInsets(); + + int height = 0; + int width = 0; + for (int i = 0; i < components.length; i++) + { + if (components[i] == null) + continue; + Dimension dims = components[i].getPreferredSize(); + if (dims != null) + { + width += dims.width; + if (!(components[i] instanceof BasicSplitPaneDivider)) + height = Math.max(height, dims.height); + } + } + return new Dimension(width, height); } return null; } @@ -362,11 +362,11 @@ public class BasicSplitPaneUI extends SplitPaneUI { for (int i = 0; i < components.length; i++) { - if (component == components[i]) - { - components[i] = null; - sizes[i] = 0; - } + if (component == components[i]) + { + components[i] = null; + sizes[i] = 0; + } } } @@ -378,7 +378,7 @@ public class BasicSplitPaneUI extends SplitPaneUI protected void resetSizeAt(int index) { if (components[index] != null) - sizes[index] = getPreferredSizeOfComponent(components[index]); + sizes[index] = getPreferredSizeOfComponent(components[index]); } /** @@ -387,7 +387,7 @@ public class BasicSplitPaneUI extends SplitPaneUI public void resetToPreferredSizes() { for (int i = 0; i < components.length; i++) - resetSizeAt(i); + resetSizeAt(i); } /** @@ -433,13 +433,13 @@ public class BasicSplitPaneUI extends SplitPaneUI if (left != null) { - components[0] = left; - resetSizeAt(0); + components[0] = left; + resetSizeAt(0); } if (right != null) { - components[1] = right; - resetSizeAt(1); + components[1] = right; + resetSizeAt(1); } components[2] = divider; resetSizeAt(2); @@ -480,9 +480,9 @@ public class BasicSplitPaneUI extends SplitPaneUI { Dimension dims = components[index].getMinimumSize(); if (dims != null) - return dims.width; + return dims.width; else - return 0; + return 0; } } //end BasicHorizontalLayoutManager @@ -534,7 +534,7 @@ public class BasicSplitPaneUI extends SplitPaneUI { Dimension dims = c.getPreferredSize(); if (dims != null) - return dims.height; + return dims.height; return 0; } @@ -563,23 +563,23 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (container instanceof JSplitPane) { - JSplitPane split = (JSplitPane) container; - Insets insets = container.getInsets(); - - int height = 0; - int width = 0; - for (int i = 0; i < components.length; i++) - { - if (components[i] == null) - continue; - Dimension dims = components[i].getMinimumSize(); - if (dims != null) - { - height += dims.height; - width = Math.max(width, dims.width); - } - } - return new Dimension(width, height); + JSplitPane split = (JSplitPane) container; + Insets insets = container.getInsets(); + + int height = 0; + int width = 0; + for (int i = 0; i < components.length; i++) + { + if (components[i] == null) + continue; + Dimension dims = components[i].getMinimumSize(); + if (dims != null) + { + height += dims.height; + width = Math.max(width, dims.width); + } + } + return new Dimension(width, height); } return null; } @@ -597,23 +597,23 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (container instanceof JSplitPane) { - JSplitPane split = (JSplitPane) container; - Insets insets = container.getInsets(); - - int height = 0; - int width = 0; - for (int i = 0; i < components.length; i++) - { - if (components[i] == null) - continue; - Dimension dims = components[i].getPreferredSize(); - if (dims != null) - { - height += dims.height; - width = Math.max(width, dims.width); - } - } - return new Dimension(width, height); + JSplitPane split = (JSplitPane) container; + Insets insets = container.getInsets(); + + int height = 0; + int width = 0; + for (int i = 0; i < components.length; i++) + { + if (components[i] == null) + continue; + Dimension dims = components[i].getPreferredSize(); + if (dims != null) + { + height += dims.height; + width = Math.max(width, dims.width); + } + } + return new Dimension(width, height); } return null; } @@ -652,9 +652,9 @@ public class BasicSplitPaneUI extends SplitPaneUI { Dimension dims = components[index].getMinimumSize(); if (dims != null) - return dims.height; + return dims.height; else - return 0; + return 0; } } @@ -813,27 +813,27 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY)) { - int newSize = splitPane.getDividerSize(); - int[] tmpSizes = layoutManager.getSizes(); - dividerSize = tmpSizes[2]; - int newSpace = newSize - tmpSizes[2]; - tmpSizes[2] = newSize; - - tmpSizes[0] += newSpace / 2; - tmpSizes[1] += newSpace / 2; + int newSize = splitPane.getDividerSize(); + int[] tmpSizes = layoutManager.getSizes(); + dividerSize = tmpSizes[2]; + int newSpace = newSize - tmpSizes[2]; + tmpSizes[2] = newSize; + + tmpSizes[0] += newSpace / 2; + tmpSizes[1] += newSpace / 2; - layoutManager.setSizes(tmpSizes); + layoutManager.setSizes(tmpSizes); } else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY)) { - int max = layoutManager.getAvailableSize(splitPane.getSize(), - splitPane.getInsets()); - int dividerLoc = getDividerLocation(splitPane); - double prop = ((double) dividerLoc) / max; - - resetLayoutManager(); - if (prop <= 1 && prop >= 0) - splitPane.setDividerLocation(prop); + int max = layoutManager.getAvailableSize(splitPane.getSize(), + splitPane.getInsets()); + int dividerLoc = getDividerLocation(splitPane); + double prop = ((double) dividerLoc) / max; + + resetLayoutManager(); + if (prop <= 1 && prop >= 0) + splitPane.setDividerLocation(prop); } layoutManager.layoutContainer(splitPane); splitPane.repaint(); @@ -843,13 +843,13 @@ public class BasicSplitPaneUI extends SplitPaneUI // Don't have to deal with resize_weight (as there // will be no extra space associated with this // event - the changes to the weighting will - // be taken into account the next time the + // be taken into account the next time the // sizes change.) - // Don't have to deal with divider_location + // Don't have to deal with divider_location // The method in JSplitPane calls our setDividerLocation // so we'll know about those anyway. // Don't have to deal with last_divider_location - // Although I'm not sure why, it doesn't seem to + // Although I'm not sure why, it doesn't seem to // have any effect on Sun's JSplitPane. // one_touch_expandable changes are dealt with // by our divider. @@ -962,10 +962,10 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (c instanceof JSplitPane) { - splitPane = (JSplitPane) c; - installDefaults(); - installListeners(); - installKeyboardActions(); + splitPane = (JSplitPane) c; + installDefaults(); + installListeners(); + installKeyboardActions(); } } @@ -1218,8 +1218,8 @@ public class BasicSplitPaneUI extends SplitPaneUI { if (nonContinuousLayoutDivider == null) { - nonContinuousLayoutDivider = new Canvas(); - nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY); + nonContinuousLayoutDivider = new Canvas(); + nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY); } return nonContinuousLayoutDivider; } @@ -1307,7 +1307,7 @@ public class BasicSplitPaneUI extends SplitPaneUI // check if the size has been set for the splitpane if (size.width == 0 && size.height == 0) size = jc.getPreferredSize(); - + if (getOrientation() == 0 && location > size.height) { location = size.height; @@ -1326,11 +1326,11 @@ public class BasicSplitPaneUI extends SplitPaneUI p = p.getParent(); } } - + setLastDragLocation(getDividerLocation(splitPane)); splitPane.setLastDividerLocation(getDividerLocation(splitPane)); int[] tmpSizes = layoutManager.getSizes(); - tmpSizes[0] = location + tmpSizes[0] = location - layoutManager.getInitialLocation(splitPane.getInsets()); tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(), splitPane.getInsets()) @@ -1498,8 +1498,8 @@ public class BasicSplitPaneUI extends SplitPaneUI nonContinuousLayoutDivider.setVisible(false); else { - nonContinuousLayoutDivider.setVisible(true); - nonContinuousLayoutDivider.setBounds(divider.getBounds()); + nonContinuousLayoutDivider.setVisible(true); + nonContinuousLayoutDivider.setBounds(divider.getBounds()); } splitPane.revalidate(); splitPane.repaint(); @@ -1522,12 +1522,12 @@ public class BasicSplitPaneUI extends SplitPaneUI splitPane.setDividerLocation(location); else { - Point p = nonContinuousLayoutDivider.getLocation(); - if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) - p.x = location; - else - p.y = location; - nonContinuousLayoutDivider.setLocation(p); + Point p = nonContinuousLayoutDivider.getLocation(); + if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) + p.x = location; + else + p.y = location; + nonContinuousLayoutDivider.setLocation(p); } setLastDragLocation(location); splitPane.repaint(); |