698 */
699 int getKeyboardMoveIncrement() {
700 return 3;
701 }
702
703 /**
704 * Implementation of the PropertyChangeListener
705 * that the JSplitPane UI uses.
706 * <p>
707 * This class should be treated as a "protected" inner class.
708 * Instantiate it only within subclasses of BasicSplitPaneUI.
709 */
710 public class PropertyHandler implements PropertyChangeListener
711 {
712 // NOTE: This class exists only for backward compatibility. All
713 // its functionality has been moved into Handler. If you need to add
714 // new functionality add it to the Handler, but make sure this
715 // class calls into the Handler.
716
717 /**
718 * Messaged from the <code>JSplitPane</code> the receiver is
719 * contained in. May potentially reset the layout manager and cause a
720 * <code>validate</code> to be sent.
721 */
722 public void propertyChange(PropertyChangeEvent e) {
723 getHandler().propertyChange(e);
724 }
725 }
726
727
728 /**
729 * Implementation of the FocusListener that the JSplitPane UI uses.
730 * <p>
731 * This class should be treated as a "protected" inner class.
732 * Instantiate it only within subclasses of BasicSplitPaneUI.
733 */
734 public class FocusHandler extends FocusAdapter
735 {
736 // NOTE: This class exists only for backward compatibility. All
737 // its functionality has been moved into Handler. If you need to add
738 // new functionality add it to the Handler, but make sure this
739 // class calls into the Handler.
740 public void focusGained(FocusEvent ev) {
1789 */
1790 int getSizeForPrimaryAxis(Dimension size) {
1791 if (axis == 0) {
1792 return size.width;
1793 }
1794 return size.height;
1795 }
1796
1797 /**
1798 * If the axis == 0, the width is returned, otherwise the height.
1799 */
1800 int getSizeForSecondaryAxis(Dimension size) {
1801 if (axis == 0) {
1802 return size.height;
1803 }
1804 return size.width;
1805 }
1806
1807 /**
1808 * Returns a particular value of the inset identified by the
1809 * axis and <code>isTop</code><p>
1810 * axis isTop
1811 * 0 true - left
1812 * 0 false - right
1813 * 1 true - top
1814 * 1 false - bottom
1815 */
1816 int getSizeForPrimaryAxis(Insets insets, boolean isTop) {
1817 if (axis == 0) {
1818 if (isTop) {
1819 return insets.left;
1820 }
1821 return insets.right;
1822 }
1823 if (isTop) {
1824 return insets.top;
1825 }
1826 return insets.bottom;
1827 }
1828
1829 /**
1830 * Returns a particular value of the inset identified by the
1831 * axis and <code>isTop</code><p>
1832 * axis isTop
1833 * 0 true - left
1834 * 0 false - right
1835 * 1 true - top
1836 * 1 false - bottom
1837 */
1838 int getSizeForSecondaryAxis(Insets insets, boolean isTop) {
1839 if (axis == 0) {
1840 if (isTop) {
1841 return insets.top;
1842 }
1843 return insets.bottom;
1844 }
1845 if (isTop) {
1846 return insets.left;
1847 }
1848 return insets.right;
1849 }
1850
1851 /**
1885 if(children[counter] != components[0] &&
1886 children[counter] != components[1] &&
1887 children[counter] != nonContinuousLayoutDivider) {
1888 if(oldDivider != children[counter]) {
1889 components[2] = children[counter];
1890 } else {
1891 components[2] = oldDivider;
1892 }
1893 break;
1894 }
1895 }
1896 if(components[2] == null) {
1897 sizes[2] = 0;
1898 }
1899 else {
1900 sizes[2] = getSizeForPrimaryAxis(components[2].getPreferredSize());
1901 }
1902 }
1903
1904 /**
1905 * Resets the size of the first component to <code>leftSize</code>,
1906 * and the right component to the remainder of the space.
1907 */
1908 void setDividerLocation(int leftSize, int availableSize) {
1909 boolean lValid = (components[0] != null &&
1910 components[0].isVisible());
1911 boolean rValid = (components[1] != null &&
1912 components[1].isVisible());
1913 boolean dValid = (components[2] != null &&
1914 components[2].isVisible());
1915 int max = availableSize;
1916
1917 if (dValid) {
1918 max -= sizes[2];
1919 }
1920 leftSize = Math.max(0, Math.min(leftSize, max));
1921 if (lValid) {
1922 if (rValid) {
1923 sizes[0] = leftSize;
1924 sizes[1] = max - leftSize;
1925 }
1986 for (int counter = 0; counter < 3; counter++) {
1987 if (testSizes[counter] != -1) {
1988 totalSize += testSizes[counter];
1989 }
1990 }
1991 if (totalSize > availableSize) {
1992 testSizes = getMinimumSizes();
1993
1994 totalSize = 0;
1995 for (int counter = 0; counter < 3; counter++) {
1996 if (testSizes[counter] != -1) {
1997 totalSize += testSizes[counter];
1998 }
1999 }
2000 }
2001 setSizes(testSizes);
2002 distributeSpace(availableSize - totalSize, false);
2003 }
2004
2005 /**
2006 * Distributes <code>space</code> between the two components
2007 * (divider won't get any extra space) based on the weighting. This
2008 * attempts to honor the min size of the components.
2009 *
2010 * @param keepHidden if true and one of the components is 0x0
2011 * it gets none of the extra space
2012 */
2013 void distributeSpace(int space, boolean keepHidden) {
2014 boolean lValid = (components[0] != null &&
2015 components[0].isVisible());
2016 boolean rValid = (components[1] != null &&
2017 components[1].isVisible());
2018
2019 if (keepHidden) {
2020 if (lValid && getSizeForPrimaryAxis(
2021 components[0].getSize()) == 0) {
2022 lValid = false;
2023 if (rValid && getSizeForPrimaryAxis(
2024 components[1].getSize()) == 0) {
2025 // Both aren't valid, force them both to be valid
2026 lValid = true;
2102 * VERTICAL_SPLIT.
2103 *
2104 */
2105 public class BasicVerticalLayoutManager extends
2106 BasicHorizontalLayoutManager
2107 {
2108 /**
2109 * Constructs a new instance of {@code BasicVerticalLayoutManager}.
2110 */
2111 public BasicVerticalLayoutManager() {
2112 super(1);
2113 }
2114 }
2115
2116
2117 private class Handler implements FocusListener, PropertyChangeListener {
2118 //
2119 // PropertyChangeListener
2120 //
2121 /**
2122 * Messaged from the <code>JSplitPane</code> the receiver is
2123 * contained in. May potentially reset the layout manager and cause a
2124 * <code>validate</code> to be sent.
2125 */
2126 public void propertyChange(PropertyChangeEvent e) {
2127 if(e.getSource() == splitPane) {
2128 String changeName = e.getPropertyName();
2129
2130 if(changeName == JSplitPane.ORIENTATION_PROPERTY) {
2131 orientation = splitPane.getOrientation();
2132 resetLayoutManager();
2133 } else if(changeName == JSplitPane.CONTINUOUS_LAYOUT_PROPERTY){
2134 setContinuousLayout(splitPane.isContinuousLayout());
2135 if(!isContinuousLayout()) {
2136 if(nonContinuousLayoutDivider == null) {
2137 setNonContinuousLayoutDivider(
2138 createDefaultNonContinuousLayoutDivider(),
2139 true);
2140 } else if(nonContinuousLayoutDivider.getParent() ==
2141 null) {
2142 setNonContinuousLayoutDivider(
2143 nonContinuousLayoutDivider,
2144 true);
|
698 */
699 int getKeyboardMoveIncrement() {
700 return 3;
701 }
702
703 /**
704 * Implementation of the PropertyChangeListener
705 * that the JSplitPane UI uses.
706 * <p>
707 * This class should be treated as a "protected" inner class.
708 * Instantiate it only within subclasses of BasicSplitPaneUI.
709 */
710 public class PropertyHandler implements PropertyChangeListener
711 {
712 // NOTE: This class exists only for backward compatibility. All
713 // its functionality has been moved into Handler. If you need to add
714 // new functionality add it to the Handler, but make sure this
715 // class calls into the Handler.
716
717 /**
718 * Messaged from the {@code JSplitPane} the receiver is
719 * contained in. May potentially reset the layout manager and cause a
720 * {@code validate} to be sent.
721 */
722 public void propertyChange(PropertyChangeEvent e) {
723 getHandler().propertyChange(e);
724 }
725 }
726
727
728 /**
729 * Implementation of the FocusListener that the JSplitPane UI uses.
730 * <p>
731 * This class should be treated as a "protected" inner class.
732 * Instantiate it only within subclasses of BasicSplitPaneUI.
733 */
734 public class FocusHandler extends FocusAdapter
735 {
736 // NOTE: This class exists only for backward compatibility. All
737 // its functionality has been moved into Handler. If you need to add
738 // new functionality add it to the Handler, but make sure this
739 // class calls into the Handler.
740 public void focusGained(FocusEvent ev) {
1789 */
1790 int getSizeForPrimaryAxis(Dimension size) {
1791 if (axis == 0) {
1792 return size.width;
1793 }
1794 return size.height;
1795 }
1796
1797 /**
1798 * If the axis == 0, the width is returned, otherwise the height.
1799 */
1800 int getSizeForSecondaryAxis(Dimension size) {
1801 if (axis == 0) {
1802 return size.height;
1803 }
1804 return size.width;
1805 }
1806
1807 /**
1808 * Returns a particular value of the inset identified by the
1809 * axis and {@code isTop}<p>
1810 * axis isTop
1811 * 0 true - left
1812 * 0 false - right
1813 * 1 true - top
1814 * 1 false - bottom
1815 */
1816 int getSizeForPrimaryAxis(Insets insets, boolean isTop) {
1817 if (axis == 0) {
1818 if (isTop) {
1819 return insets.left;
1820 }
1821 return insets.right;
1822 }
1823 if (isTop) {
1824 return insets.top;
1825 }
1826 return insets.bottom;
1827 }
1828
1829 /**
1830 * Returns a particular value of the inset identified by the
1831 * axis and {@code isTop}<p>
1832 * axis isTop
1833 * 0 true - left
1834 * 0 false - right
1835 * 1 true - top
1836 * 1 false - bottom
1837 */
1838 int getSizeForSecondaryAxis(Insets insets, boolean isTop) {
1839 if (axis == 0) {
1840 if (isTop) {
1841 return insets.top;
1842 }
1843 return insets.bottom;
1844 }
1845 if (isTop) {
1846 return insets.left;
1847 }
1848 return insets.right;
1849 }
1850
1851 /**
1885 if(children[counter] != components[0] &&
1886 children[counter] != components[1] &&
1887 children[counter] != nonContinuousLayoutDivider) {
1888 if(oldDivider != children[counter]) {
1889 components[2] = children[counter];
1890 } else {
1891 components[2] = oldDivider;
1892 }
1893 break;
1894 }
1895 }
1896 if(components[2] == null) {
1897 sizes[2] = 0;
1898 }
1899 else {
1900 sizes[2] = getSizeForPrimaryAxis(components[2].getPreferredSize());
1901 }
1902 }
1903
1904 /**
1905 * Resets the size of the first component to {@code leftSize},
1906 * and the right component to the remainder of the space.
1907 */
1908 void setDividerLocation(int leftSize, int availableSize) {
1909 boolean lValid = (components[0] != null &&
1910 components[0].isVisible());
1911 boolean rValid = (components[1] != null &&
1912 components[1].isVisible());
1913 boolean dValid = (components[2] != null &&
1914 components[2].isVisible());
1915 int max = availableSize;
1916
1917 if (dValid) {
1918 max -= sizes[2];
1919 }
1920 leftSize = Math.max(0, Math.min(leftSize, max));
1921 if (lValid) {
1922 if (rValid) {
1923 sizes[0] = leftSize;
1924 sizes[1] = max - leftSize;
1925 }
1986 for (int counter = 0; counter < 3; counter++) {
1987 if (testSizes[counter] != -1) {
1988 totalSize += testSizes[counter];
1989 }
1990 }
1991 if (totalSize > availableSize) {
1992 testSizes = getMinimumSizes();
1993
1994 totalSize = 0;
1995 for (int counter = 0; counter < 3; counter++) {
1996 if (testSizes[counter] != -1) {
1997 totalSize += testSizes[counter];
1998 }
1999 }
2000 }
2001 setSizes(testSizes);
2002 distributeSpace(availableSize - totalSize, false);
2003 }
2004
2005 /**
2006 * Distributes {@code space} between the two components
2007 * (divider won't get any extra space) based on the weighting. This
2008 * attempts to honor the min size of the components.
2009 *
2010 * @param keepHidden if true and one of the components is 0x0
2011 * it gets none of the extra space
2012 */
2013 void distributeSpace(int space, boolean keepHidden) {
2014 boolean lValid = (components[0] != null &&
2015 components[0].isVisible());
2016 boolean rValid = (components[1] != null &&
2017 components[1].isVisible());
2018
2019 if (keepHidden) {
2020 if (lValid && getSizeForPrimaryAxis(
2021 components[0].getSize()) == 0) {
2022 lValid = false;
2023 if (rValid && getSizeForPrimaryAxis(
2024 components[1].getSize()) == 0) {
2025 // Both aren't valid, force them both to be valid
2026 lValid = true;
2102 * VERTICAL_SPLIT.
2103 *
2104 */
2105 public class BasicVerticalLayoutManager extends
2106 BasicHorizontalLayoutManager
2107 {
2108 /**
2109 * Constructs a new instance of {@code BasicVerticalLayoutManager}.
2110 */
2111 public BasicVerticalLayoutManager() {
2112 super(1);
2113 }
2114 }
2115
2116
2117 private class Handler implements FocusListener, PropertyChangeListener {
2118 //
2119 // PropertyChangeListener
2120 //
2121 /**
2122 * Messaged from the {@code JSplitPane} the receiver is
2123 * contained in. May potentially reset the layout manager and cause a
2124 * {@code validate} to be sent.
2125 */
2126 public void propertyChange(PropertyChangeEvent e) {
2127 if(e.getSource() == splitPane) {
2128 String changeName = e.getPropertyName();
2129
2130 if(changeName == JSplitPane.ORIENTATION_PROPERTY) {
2131 orientation = splitPane.getOrientation();
2132 resetLayoutManager();
2133 } else if(changeName == JSplitPane.CONTINUOUS_LAYOUT_PROPERTY){
2134 setContinuousLayout(splitPane.isContinuousLayout());
2135 if(!isContinuousLayout()) {
2136 if(nonContinuousLayoutDivider == null) {
2137 setNonContinuousLayoutDivider(
2138 createDefaultNonContinuousLayoutDivider(),
2139 true);
2140 } else if(nonContinuousLayoutDivider.getParent() ==
2141 null) {
2142 setNonContinuousLayoutDivider(
2143 nonContinuousLayoutDivider,
2144 true);
|