1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57:
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64: import ;
65: import ;
66: import ;
67: import ;
68: import ;
69: import ;
70: import ;
71: import ;
72: import ;
73:
74:
77: public class BasicSplitPaneUI extends SplitPaneUI
78: {
79:
87: public class BasicHorizontalLayoutManager implements LayoutManager2
88: {
89:
90:
91:
92:
93:
94:
99: protected Component[] components = new Component[3];
100:
101:
102:
103:
108: protected int[] sizes = new int[3];
109:
110:
115: private int axis;
116:
117:
122: BasicHorizontalLayoutManager()
123: {
124: this(SwingConstants.HORIZONTAL);
125: }
126:
127:
136: BasicHorizontalLayoutManager(int a)
137: {
138: axis = a;
139: }
140:
141:
148: public void addLayoutComponent(Component comp, Object constraints)
149: {
150: addLayoutComponent((String) constraints, comp);
151: }
152:
153:
164: public void addLayoutComponent(String place, Component component)
165: {
166: int i = 0;
167: if (place == null)
168: i = 2;
169: else if (place.equals(JSplitPane.TOP) || place.equals(JSplitPane.LEFT))
170: i = 0;
171: else if (place.equals(JSplitPane.BOTTOM)
172: || place.equals(JSplitPane.RIGHT))
173: i = 1;
174: else
175: throw new IllegalArgumentException("Illegal placement in JSplitPane");
176: components[i] = component;
177: resetSizeAt(i);
178: splitPane.revalidate();
179: splitPane.repaint();
180: }
181:
182:
190: protected int getAvailableSize(Dimension containerSize, Insets insets)
191: {
192: int size;
193: if (axis == SwingConstants.HORIZONTAL)
194: size = containerSize.width - insets.left - insets.right;
195: else
196: size = containerSize.height - insets.top - insets.bottom;
197: return size;
198: }
199:
200:
208: protected int getInitialLocation(Insets insets)
209: {
210: int loc = 0;
211: if (insets != null)
212: {
213: if (axis == SwingConstants.HORIZONTAL)
214: loc = insets.left;
215: else
216: loc = insets.top;
217: }
218: return loc;
219: }
220:
221:
229: public float getLayoutAlignmentX(Container target)
230: {
231: return 0.0f;
232: }
233:
234:
242: public float getLayoutAlignmentY(Container target)
243: {
244: return 0.0f;
245: }
246:
247:
254: protected int getPreferredSizeOfComponent(Component c)
255: {
256: int size = 0;
257: Dimension dims = c.getPreferredSize();
258: if (axis == SwingConstants.HORIZONTAL)
259: {
260: if (dims != null)
261: size = dims.width;
262: }
263: else
264: {
265: if (dims != null)
266: size = dims.height;
267: }
268: return size;
269: }
270:
271:
278: protected int getSizeOfComponent(Component c)
279: {
280: int size;
281: if (axis == SwingConstants.HORIZONTAL)
282: size = c.getHeight();
283: else
284: size = c.getWidth();
285: return size;
286: }
287:
288:
293: protected int[] getSizes()
294: {
295: return sizes;
296: }
297:
298:
303: public void invalidateLayout(Container c)
304: {
305:
306: }
307:
308:
313: public void layoutContainer(Container container)
314: {
315: if (container instanceof JSplitPane)
316: {
317: JSplitPane split = (JSplitPane) container;
318: distributeExtraSpace();
319: Insets insets = split.getInsets();
320: Dimension dims = split.getSize();
321: int loc = getInitialLocation(insets);
322: int available = getAvailableSize(dims, insets);
323: sizes[0] = split.getDividerLocation();
324: sizes[1] = available - sizes[0] - sizes[2];
325:
326:
327:
328:
329: if (! dividerLocationSet)
330: {
331: sizes[0] = Math.max(sizes[0], minimumSizeOfComponent(0));
332: sizes[1] = Math.max(sizes[1], minimumSizeOfComponent(1));
333: }
334:
335:
336:
337: setComponentToSize(components[0], sizes[0], loc, insets, dims);
338:
339: loc += sizes[0];
340: setComponentToSize(components[2], sizes[2], loc, insets, dims);
341:
342: loc += sizes[2];
343: setComponentToSize(components[1], sizes[1], loc, insets, dims);
344: }
345: }
346:
347:
356: public Dimension maximumLayoutSize(Container target)
357: {
358: return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
359: }
360:
361:
370: public Dimension minimumLayoutSize(Container target)
371: {
372: Dimension dim = new Dimension();
373: if (target instanceof JSplitPane)
374: {
375: int primary = 0;
376: int secondary = 0;
377: for (int i = 0; i < components.length; i++)
378: {
379: if (components[i] != null)
380: {
381: Dimension dims = components[i].getMinimumSize();
382: primary += axis == SwingConstants.HORIZONTAL ? dims.width
383: : dims.height;
384: int sec = axis == SwingConstants.HORIZONTAL ? dims.height
385: : dims.width;
386: secondary = Math.max(sec, secondary);
387: }
388: }
389: int width = axis == SwingConstants.HORIZONTAL ? primary : secondary;
390: int height = axis == SwingConstants.VERTICAL ? secondary : primary;
391:
392: Insets i = splitPane.getInsets();
393: dim.setSize(width + i.left + i.right, height + i.top + i.bottom);
394: }
395: return dim;
396: }
397:
398:
407: public Dimension preferredLayoutSize(Container target)
408: {
409: Dimension dim = new Dimension();
410: if (target instanceof JSplitPane)
411: {
412: int primary = 0;
413: int secondary = 0;
414: for (int i = 0; i < components.length; i++)
415: {
416: if (components[i] != null)
417: {
418: Dimension dims = components[i].getPreferredSize();
419: primary += axis == SwingConstants.HORIZONTAL ? dims.width
420: : dims.height;
421: int sec = axis == SwingConstants.HORIZONTAL ? dims.height
422: : dims.width;
423: secondary = Math.max(sec, secondary);
424: }
425: }
426: int width = axis == SwingConstants.HORIZONTAL ? primary : secondary;
427: int height = axis == SwingConstants.VERTICAL ? secondary : primary;
428:
429: Insets i = splitPane.getInsets();
430: dim.setSize(width + i.left + i.right, height + i.top + i.bottom);
431: }
432: return dim;
433: }
434:
435:
440: public void removeLayoutComponent(Component component)
441: {
442: for (int i = 0; i < components.length; i++)
443: {
444: if (component == components[i])
445: {
446: components[i] = null;
447: sizes[i] = 0;
448: }
449: }
450: }
451:
452:
457: protected void resetSizeAt(int index)
458: {
459: if (components[index] != null)
460: sizes[index] = getPreferredSizeOfComponent(components[index]);
461: }
462:
463:
466: public void resetToPreferredSizes()
467: {
468: for (int i = 0; i < components.length; i++)
469: resetSizeAt(i);
470: }
471:
472:
484: protected void setComponentToSize(Component c, int size, int location,
485: Insets insets, Dimension containerSize)
486: {
487: if (insets != null)
488: {
489: if (axis == SwingConstants.HORIZONTAL)
490: c.setBounds(location, insets.top, size,
491: containerSize.height - insets.top - insets.bottom);
492: else
493: c.setBounds(insets.left, location,
494: containerSize.width - insets.left - insets.right,
495: size);
496: }
497: else
498: {
499: if (axis == SwingConstants.HORIZONTAL)
500: c.setBounds(location, 0, size, containerSize.height);
501: else
502: c.setBounds(0, location, containerSize.width, size);
503: }
504: }
505:
506:
511: protected void setSizes(int[] newSizes)
512: {
513: sizes = newSizes;
514: }
515:
516:
520: protected void updateComponents()
521: {
522: Component left = splitPane.getLeftComponent();
523: Component right = splitPane.getRightComponent();
524:
525: if (left != null)
526: {
527: components[0] = left;
528: resetSizeAt(0);
529: }
530: if (right != null)
531: {
532: components[1] = right;
533: resetSizeAt(1);
534: }
535: components[2] = divider;
536: }
537:
538:
542: void distributeExtraSpace()
543: {
544:
545: }
546:
547:
555: int minimumSizeOfComponent(int index)
556: {
557: Dimension dims = components[index].getMinimumSize();
558: int size = 0;
559: if (dims != null)
560: if (axis == SwingConstants.HORIZONTAL)
561: size = dims.width;
562: else
563: size = dims.height;
564: return size;
565: }
566: }
567:
568:
576: public class BasicVerticalLayoutManager
577: extends BasicHorizontalLayoutManager
578: {
579:
582: public BasicVerticalLayoutManager()
583: {
584: super(SwingConstants.VERTICAL);
585: }
586: }
587:
588:
595: public class FocusHandler extends FocusAdapter
596: {
597:
602: public void focusGained(FocusEvent ev)
603: {
604:
605:
606: divider.repaint();
607: }
608:
609:
614: public void focusLost(FocusEvent ev)
615: {
616:
617:
618: divider.repaint();
619: }
620: }
621:
622:
630: public class KeyboardDownRightHandler implements ActionListener
631: {
632:
637: public void actionPerformed(ActionEvent ev)
638: {
639:
640: }
641: }
642:
643:
651: public class KeyboardEndHandler implements ActionListener
652: {
653:
658: public void actionPerformed(ActionEvent ev)
659: {
660:
661: }
662: }
663:
664:
672: public class KeyboardHomeHandler implements ActionListener
673: {
674:
679: public void actionPerformed(ActionEvent ev)
680: {
681:
682: }
683: }
684:
685:
693: public class KeyboardResizeToggleHandler implements ActionListener
694: {
695:
700: public void actionPerformed(ActionEvent ev)
701: {
702:
703: }
704: }
705:
706:
714: public class KeyboardUpLeftHandler implements ActionListener
715: {
716:
721: public void actionPerformed(ActionEvent ev)
722: {
723:
724: }
725: }
726:
727:
735: public class PropertyHandler implements PropertyChangeListener
736: {
737:
743: public void propertyChange(PropertyChangeEvent e)
744: {
745: if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY))
746: {
747: int newSize = splitPane.getDividerSize();
748: int[] tmpSizes = layoutManager.getSizes();
749: dividerSize = tmpSizes[2];
750: int newSpace = newSize - tmpSizes[2];
751: tmpSizes[2] = newSize;
752:
753: tmpSizes[0] += newSpace / 2;
754: tmpSizes[1] += newSpace / 2;
755:
756: layoutManager.setSizes(tmpSizes);
757: }
758: else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY))
759: {
760: int max = layoutManager.getAvailableSize(splitPane.getSize(),
761: splitPane.getInsets());
762: int dividerLoc = getDividerLocation(splitPane);
763: double prop = ((double) dividerLoc) / max;
764:
765: resetLayoutManager();
766: if (prop <= 1 && prop >= 0)
767: splitPane.setDividerLocation(prop);
768: }
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785: }
786: }
787:
788:
789: protected int beginDragDividerLocation;
790:
791:
792: protected int dividerSize;
793:
794:
795: transient int lastDragLocation = -1;
796:
797:
798:
799: protected static int KEYBOARD_DIVIDER_MOVE_OFFSET = 3;
800:
801:
802: protected BasicSplitPaneDivider divider;
803:
804:
805: protected PropertyChangeListener propertyChangeListener;
806:
807:
808: protected FocusListener focusListener;
809:
810:
811: protected ActionListener keyboardDownRightListener;
812:
813:
814: protected ActionListener keyboardEndListener;
815:
816:
817: protected ActionListener keyboardHomeListener;
818:
819:
820: protected ActionListener keyboardResizeToggleListener;
821:
822:
823: protected ActionListener keyboardUpLeftListener;
824:
825:
826: protected BasicHorizontalLayoutManager layoutManager;
827:
828:
829: protected KeyStroke dividerResizeToggleKey;
830:
831:
832: protected KeyStroke downKey;
833:
834:
835: protected KeyStroke endKey;
836:
837:
838: protected KeyStroke homeKey;
839:
840:
841: protected KeyStroke leftKey;
842:
843:
844: protected KeyStroke rightKey;
845:
846:
847: protected KeyStroke upKey;
848:
849:
850: protected boolean draggingHW;
851:
852:
856: protected static final String NON_CONTINUOUS_DIVIDER
857: = "nonContinuousDivider";
858:
859:
860: protected Component nonContinuousLayoutDivider;
861:
862:
863: protected JSplitPane splitPane;
864:
865:
871: boolean dividerLocationSet;
872:
873:
876: public BasicSplitPaneUI()
877: {
878:
879: }
880:
881:
888: public static ComponentUI createUI(JComponent x)
889: {
890: return new BasicSplitPaneUI();
891: }
892:
893:
898: public void installUI(JComponent c)
899: {
900: if (c instanceof JSplitPane)
901: {
902: splitPane = (JSplitPane) c;
903: dividerLocationSet = false;
904: installDefaults();
905: installListeners();
906: installKeyboardActions();
907: }
908: }
909:
910:
915: public void uninstallUI(JComponent c)
916: {
917: uninstallKeyboardActions();
918: uninstallListeners();
919: uninstallDefaults();
920:
921: dividerLocationSet = false;
922: splitPane = null;
923: }
924:
925:
928: protected void installDefaults()
929: {
930: LookAndFeel.installColors(splitPane, "SplitPane.background",
931: "SplitPane.foreground");
932: LookAndFeel.installBorder(splitPane, "SplitPane.border");
933: divider = createDefaultDivider();
934: divider.setBorder(UIManager.getBorder("SplitPaneDivider.border"));
935: resetLayoutManager();
936: nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider();
937: splitPane.add(divider, JSplitPane.DIVIDER);
938:
939:
940: dividerSize = UIManager.getInt("SplitPane.dividerSize");
941: splitPane.setDividerSize(dividerSize);
942: divider.setDividerSize(dividerSize);
943: splitPane.setOpaque(true);
944: }
945:
946:
950: protected void uninstallDefaults()
951: {
952: layoutManager = null;
953: splitPane.remove(divider);
954: divider = null;
955: nonContinuousLayoutDivider = null;
956:
957: if (splitPane.getBackground() instanceof UIResource)
958: splitPane.setBackground(null);
959: if (splitPane.getBorder() instanceof UIResource)
960: splitPane.setBorder(null);
961: }
962:
963:
966: protected void installListeners()
967: {
968: propertyChangeListener = createPropertyChangeListener();
969: focusListener = createFocusListener();
970:
971: splitPane.addPropertyChangeListener(propertyChangeListener);
972: splitPane.addFocusListener(focusListener);
973: }
974:
975:
978: protected void uninstallListeners()
979: {
980: splitPane.removePropertyChangeListener(propertyChangeListener);
981: splitPane.removeFocusListener(focusListener);
982:
983: focusListener = null;
984: propertyChangeListener = null;
985: }
986:
987:
994: InputMap getInputMap(int condition)
995: {
996: if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
997: return (InputMap) UIManager.get("SplitPane.ancestorInputMap");
998: return null;
999: }
1000:
1001:
1008: ActionMap getActionMap()
1009: {
1010: ActionMap map = (ActionMap) UIManager.get("SplitPane.actionMap");
1011:
1012: if (map == null)
1013: {
1014: map = createActionMap();
1015: if (map != null)
1016: UIManager.put("SplitPane.actionMap", map);
1017: }
1018: return map;
1019: }
1020:
1021:
1031: ActionMap createActionMap()
1032: {
1033: ActionMap map = new ActionMapUIResource();
1034: map.put("toggleFocus",
1035: new AbstractAction("toggleFocus") {
1036: public void actionPerformed(ActionEvent event)
1037: {
1038:
1039: }
1040: }
1041: );
1042: map.put("startResize",
1043: new AbstractAction("startResize") {
1044: public void actionPerformed(ActionEvent event)
1045: {
1046: splitPane.requestFocus();
1047: }
1048: }
1049: );
1050: map.put("selectMax",
1051: new AbstractAction("selectMax") {
1052: public void actionPerformed(ActionEvent event)
1053: {
1054: splitPane.setDividerLocation(1.0);
1055: }
1056: }
1057: );
1058: map.put("selectMin",
1059: new AbstractAction("selectMin") {
1060: public void actionPerformed(ActionEvent event)
1061: {
1062: splitPane.setDividerLocation(0.0);
1063: }
1064: }
1065: );
1066: map.put("negativeIncrement",
1067: new AbstractAction("negativeIncrement") {
1068: public void actionPerformed(ActionEvent event)
1069: {
1070: int oldLoc = splitPane.getDividerLocation();
1071: int newLoc =
1072: Math.max(oldLoc - KEYBOARD_DIVIDER_MOVE_OFFSET, 0);
1073: splitPane.setDividerLocation(newLoc);
1074: }
1075: }
1076: );
1077: map.put("positiveIncrement",
1078: new AbstractAction("positiveIncrement") {
1079: public void actionPerformed(ActionEvent event)
1080: {
1081: int oldLoc = splitPane.getDividerLocation();
1082: int newLoc =
1083: Math.max(oldLoc + KEYBOARD_DIVIDER_MOVE_OFFSET, 0);
1084: splitPane.setDividerLocation(newLoc);
1085: }
1086: }
1087: );
1088: map.put("focusOutBackward",
1089: new AbstractAction("focusOutBackward") {
1090: public void actionPerformed(ActionEvent event)
1091: {
1092:
1093: }
1094: }
1095: );
1096: map.put("focusOutForward",
1097: new AbstractAction("focusOutForward") {
1098: public void actionPerformed(ActionEvent event)
1099: {
1100:
1101: }
1102: }
1103: );
1104: return map;
1105: }
1106:
1107:
1111: protected void installKeyboardActions()
1112: {
1113: InputMap keyMap = getInputMap(
1114: JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
1115: SwingUtilities.replaceUIInputMap(splitPane,
1116: JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, keyMap);
1117: ActionMap map = getActionMap();
1118: SwingUtilities.replaceUIActionMap(splitPane, map);
1119: }
1120:
1121:
1124: protected void uninstallKeyboardActions()
1125: {
1126: SwingUtilities.replaceUIActionMap(splitPane, null);
1127: SwingUtilities.replaceUIInputMap(splitPane,
1128: JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
1129: }
1130:
1131:
1136: protected PropertyChangeListener createPropertyChangeListener()
1137: {
1138: return new PropertyHandler();
1139: }
1140:
1141:
1146: protected FocusListener createFocusListener()
1147: {
1148: return new FocusHandler();
1149: }
1150:
1151:
1158: protected ActionListener createKeyboardUpLeftListener()
1159: {
1160: return new KeyboardUpLeftHandler();
1161: }
1162:
1163:
1170: protected ActionListener createKeyboardDownRightListener()
1171: {
1172: return new KeyboardDownRightHandler();
1173: }
1174:
1175:
1182: protected ActionListener createKeyboardHomeListener()
1183: {
1184: return new KeyboardHomeHandler();
1185: }
1186:
1187:
1194: protected ActionListener createKeyboardEndListener()
1195: {
1196: return new KeyboardEndHandler();
1197: }
1198:
1199:
1206: protected ActionListener createKeyboardResizeToggleListener()
1207: {
1208: return new KeyboardResizeToggleHandler();
1209: }
1210:
1211:
1216: public int getOrientation()
1217: {
1218: return splitPane.getOrientation();
1219: }
1220:
1221:
1226: public void setOrientation(int orientation)
1227: {
1228: splitPane.setOrientation(orientation);
1229: }
1230:
1231:
1236: public boolean isContinuousLayout()
1237: {
1238: return splitPane.isContinuousLayout();
1239: }
1240:
1241:
1246: public void setContinuousLayout(boolean b)
1247: {
1248: splitPane.setContinuousLayout(b);
1249: }
1250:
1251:
1256: public int getLastDragLocation()
1257: {
1258: return lastDragLocation;
1259: }
1260:
1261:
1266: public void setLastDragLocation(int l)
1267: {
1268: lastDragLocation = l;
1269: }
1270:
1271:
1277: public BasicSplitPaneDivider getDivider()
1278: {
1279: return divider;
1280: }
1281:
1282:
1289: protected Component createDefaultNonContinuousLayoutDivider()
1290: {
1291: if (nonContinuousLayoutDivider == null)
1292: {
1293: nonContinuousLayoutDivider = new Canvas();
1294: Color c = UIManager.getColor("SplitPaneDivider.draggingColor");
1295: nonContinuousLayoutDivider.setBackground(c);
1296: }
1297: return nonContinuousLayoutDivider;
1298: }
1299:
1300:
1305: protected void setNonContinuousLayoutDivider(Component newDivider)
1306: {
1307: setNonContinuousLayoutDivider(newDivider, true);
1308: }
1309:
1310:
1316: protected void setNonContinuousLayoutDivider(Component newDivider,
1317: boolean rememberSizes)
1318: {
1319:
1320: nonContinuousLayoutDivider = newDivider;
1321: }
1322:
1323:
1328: public Component getNonContinuousLayoutDivider()
1329: {
1330: return nonContinuousLayoutDivider;
1331: }
1332:
1333:
1338: public JSplitPane getSplitPane()
1339: {
1340: return splitPane;
1341: }
1342:
1343:
1348: public BasicSplitPaneDivider createDefaultDivider()
1349: {
1350: if (divider == null)
1351: divider = new BasicSplitPaneDivider(this);
1352: return divider;
1353: }
1354:
1355:
1361: public void resetToPreferredSizes(JSplitPane jc)
1362: {
1363: layoutManager.resetToPreferredSizes();
1364: }
1365:
1366:
1372: public void setDividerLocation(JSplitPane jc, int location)
1373: {
1374: dividerLocationSet = true;
1375: splitPane.revalidate();
1376: splitPane.repaint();
1377: }
1378:
1379:
1386: public int getDividerLocation(JSplitPane jc)
1387: {
1388: int loc;
1389: if (jc.getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
1390: loc = divider.getX();
1391: else
1392: loc = divider.getY();
1393: return loc;
1394: }
1395:
1396:
1404: public int getMinimumDividerLocation(JSplitPane jc)
1405: {
1406: int value = layoutManager.getInitialLocation(jc.getInsets());
1407: if (layoutManager.components[0] != null)
1408: value += layoutManager.minimumSizeOfComponent(0);
1409: return value;
1410: }
1411:
1412:
1420: public int getMaximumDividerLocation(JSplitPane jc)
1421: {
1422: int value = layoutManager.getInitialLocation(jc.getInsets())
1423: + layoutManager.getAvailableSize(jc.getSize(), jc.getInsets())
1424: - splitPane.getDividerSize();
1425: if (layoutManager.components[1] != null)
1426: value -= layoutManager.minimumSizeOfComponent(1);
1427: return value;
1428: }
1429:
1430:
1436: public void finishedPaintingChildren(JSplitPane jc, Graphics g)
1437: {
1438: if (! splitPane.isContinuousLayout() && nonContinuousLayoutDivider != null
1439: && nonContinuousLayoutDivider.isVisible())
1440: javax.swing.SwingUtilities.paintComponent(g, nonContinuousLayoutDivider,
1441: null,
1442: nonContinuousLayoutDivider
1443: .getBounds());
1444: }
1445:
1446:
1452: public void paint(Graphics g, JComponent jc)
1453: {
1454:
1455: }
1456:
1457:
1464: public Dimension getPreferredSize(JComponent jc)
1465: {
1466: return layoutManager.preferredLayoutSize(jc);
1467: }
1468:
1469:
1476: public Dimension getMinimumSize(JComponent jc)
1477: {
1478: return layoutManager.minimumLayoutSize(jc);
1479: }
1480:
1481:
1488: public Dimension getMaximumSize(JComponent jc)
1489: {
1490: return layoutManager.maximumLayoutSize(jc);
1491: }
1492:
1493:
1500: public Insets getInsets(JComponent jc)
1501: {
1502: return splitPane.getBorder().getBorderInsets(splitPane);
1503: }
1504:
1505:
1509: protected void resetLayoutManager()
1510: {
1511: if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
1512: layoutManager = new BasicHorizontalLayoutManager();
1513: else
1514: layoutManager = new BasicVerticalLayoutManager();
1515: getSplitPane().setLayout(layoutManager);
1516: layoutManager.updateComponents();
1517:
1518:
1519: getSplitPane().revalidate();
1520: }
1521:
1522:
1526: protected void startDragging()
1527: {
1528: Component left = splitPane.getLeftComponent();
1529: Component right = splitPane.getRightComponent();
1530: dividerSize = divider.getDividerSize();
1531: setLastDragLocation(-1);
1532:
1533: if ((left != null && !left.isLightweight())
1534: || (right != null && !right.isLightweight()))
1535: draggingHW = true;
1536:
1537: if (splitPane.isContinuousLayout())
1538: nonContinuousLayoutDivider.setVisible(false);
1539: else
1540: {
1541: nonContinuousLayoutDivider.setVisible(true);
1542: nonContinuousLayoutDivider.setBounds(divider.getBounds());
1543: }
1544: }
1545:
1546:
1553: protected void dragDividerTo(int location)
1554: {
1555: location = validLocation(location);
1556: if (beginDragDividerLocation == -1)
1557: beginDragDividerLocation = location;
1558:
1559: if (splitPane.isContinuousLayout())
1560: splitPane.setDividerLocation(location);
1561: else
1562: {
1563: Point p = nonContinuousLayoutDivider.getLocation();
1564: if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
1565: p.x = location;
1566: else
1567: p.y = location;
1568: nonContinuousLayoutDivider.setLocation(p);
1569: }
1570: setLastDragLocation(location);
1571: splitPane.repaint();
1572: }
1573:
1574:
1579: protected void finishDraggingTo(int location)
1580: {
1581: if (nonContinuousLayoutDivider != null)
1582: nonContinuousLayoutDivider.setVisible(false);
1583: draggingHW = false;
1584: location = validLocation(location);
1585: splitPane.setDividerLocation(location);
1586: splitPane.setLastDividerLocation(beginDragDividerLocation);
1587: beginDragDividerLocation = -1;
1588: }
1589:
1590:
1597: protected int getDividerBorderSize()
1598: {
1599: if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
1600: return divider.getBorder().getBorderInsets(divider).left;
1601: else
1602: return divider.getBorder().getBorderInsets(divider).top;
1603: }
1604:
1605:
1613: private int validLocation(int location)
1614: {
1615: int min = getMinimumDividerLocation(splitPane);
1616: int max = getMaximumDividerLocation(splitPane);
1617: if (min > 0 && location < min)
1618: return min;
1619: if (max > 0 && location > max)
1620: return max;
1621: return location;
1622: }
1623: }