153 |
// left (top), middle, right(bottom) |
// left (top), middle, right(bottom) |
154 |
// 0 1 2 |
// 0 1 2 |
155 |
|
|
156 |
/** Keeps track of where the divider should be placed when using one touch expand |
/** |
157 |
* buttons. */ |
* Keeps track of where the divider should be placed when using one touch |
158 |
|
* expand buttons. |
159 |
|
*/ |
160 |
private transient int currentDividerLocation = 1; |
private transient int currentDividerLocation = 1; |
161 |
|
|
162 |
|
/** DOCUMENT ME! */ |
163 |
private transient Border tmpBorder = new Border() |
private transient Border tmpBorder = new Border() |
|
{ |
|
|
public Insets getBorderInsets(Component c) |
|
|
{ |
|
|
return new Insets(2, 2, 2, 2); |
|
|
} |
|
|
|
|
|
public boolean isBorderOpaque() |
|
164 |
{ |
{ |
165 |
return false; |
public Insets getBorderInsets(Component c) |
166 |
} |
{ |
167 |
|
return new Insets(2, 2, 2, 2); |
168 |
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) |
} |
169 |
{ |
|
170 |
Color saved = g.getColor(); |
public boolean isBorderOpaque() |
171 |
g.setColor(Color.BLACK); |
{ |
172 |
|
return false; |
173 |
g.drawRect(x + 2, y + 2, width - 4, height - 4); |
} |
174 |
|
|
175 |
g.setColor(saved); |
public void paintBorder(Component c, Graphics g, int x, int y, |
176 |
} |
int width, int height) |
177 |
}; |
{ |
178 |
|
Color saved = g.getColor(); |
179 |
|
g.setColor(Color.BLACK); |
180 |
|
|
181 |
|
g.drawRect(x + 2, y + 2, width - 4, height - 4); |
182 |
|
|
183 |
|
g.setColor(saved); |
184 |
|
} |
185 |
|
}; |
186 |
|
|
187 |
/** |
/** |
188 |
* Constructs a new divider. |
* Constructs a new divider. |
424 |
if (orientation == JSplitPane.VERTICAL_SPLIT) |
if (orientation == JSplitPane.VERTICAL_SPLIT) |
425 |
dir = SwingConstants.NORTH; |
dir = SwingConstants.NORTH; |
426 |
JButton button = new BasicArrowButton(dir); |
JButton button = new BasicArrowButton(dir); |
427 |
button.setBorderPainted(false); |
button.setBorder(null); |
428 |
|
|
429 |
return button; |
return button; |
430 |
} |
} |
441 |
if (orientation == JSplitPane.VERTICAL_SPLIT) |
if (orientation == JSplitPane.VERTICAL_SPLIT) |
442 |
dir = SwingConstants.SOUTH; |
dir = SwingConstants.SOUTH; |
443 |
JButton button = new BasicArrowButton(dir); |
JButton button = new BasicArrowButton(dir); |
444 |
button.setBorderPainted(false); |
button.setBorder(null); |
445 |
return button; |
return button; |
446 |
} |
} |
447 |
|
|
488 |
} |
} |
489 |
|
|
490 |
/** |
/** |
491 |
* This helper method moves the divider to one of the |
* This helper method moves the divider to one of the three locations when |
492 |
* three locations when using one touch expand buttons. |
* using one touch expand buttons. Location 0 is the left (or top) most |
493 |
* Location 0 is the left (or top) most location. |
* location. Location 1 is the middle. Location 2 is the right (or bottom) |
494 |
* Location 1 is the middle. |
* most location. |
|
* Location 2 is the right (or bottom) most location. |
|
495 |
* |
* |
496 |
* @param locationIndex The location to move to. |
* @param locationIndex The location to move to. |
497 |
*/ |
*/ |
615 |
*/ |
*/ |
616 |
protected class DragController |
protected class DragController |
617 |
{ |
{ |
618 |
/** The difference between where the mouse is clicked and the |
/** |
619 |
* initial divider location. */ |
* The difference between where the mouse is clicked and the initial |
620 |
|
* divider location. |
621 |
|
*/ |
622 |
transient int offset; |
transient int offset; |
623 |
|
|
624 |
/** |
/** |
655 |
} |
} |
656 |
|
|
657 |
/** |
/** |
658 |
* This method returns one of the two paramters |
* This method returns one of the two paramters for the orientation. In |
659 |
* for the orientation. In this case, it returns x. |
* this case, it returns x. |
660 |
* |
* |
661 |
* @param x The x coordinate. |
* @param x The x coordinate. |
662 |
* @param y The y coordinate. |
* @param y The y coordinate. |
669 |
} |
} |
670 |
|
|
671 |
/** |
/** |
672 |
* This method is called to pass on the drag information |
* This method is called to pass on the drag information to the UI through |
673 |
* to the UI through dragDividerTo. |
* dragDividerTo. |
674 |
* |
* |
675 |
* @param newX The x coordinate of the MouseEvent. |
* @param newX The x coordinate of the MouseEvent. |
676 |
* @param newY The y coordinate of the MouseEvent. |
* @param newY The y coordinate of the MouseEvent. |
682 |
} |
} |
683 |
|
|
684 |
/** |
/** |
685 |
* This method is called to pass on the drag information |
* This method is called to pass on the drag information to the UI |
686 |
* to the UI through dragDividerTo. |
* through dragDividerTo. |
687 |
* |
* |
688 |
* @param e The MouseEvent. |
* @param e The MouseEvent. |
689 |
*/ |
*/ |
694 |
} |
} |
695 |
|
|
696 |
/** |
/** |
697 |
* This method is called to finish the drag session |
* This method is called to finish the drag session by calling |
698 |
* by calling finishDraggingTo. |
* finishDraggingTo. |
699 |
* |
* |
700 |
* @param x The x coordinate of the MouseEvent. |
* @param x The x coordinate of the MouseEvent. |
701 |
* @param y The y coordinate of the MouseEvent. |
* @param y The y coordinate of the MouseEvent. |
706 |
} |
} |
707 |
|
|
708 |
/** |
/** |
709 |
* This method is called to finish the drag session |
* This method is called to finish the drag session by calling |
710 |
* by calling finishDraggingTo. |
* finishDraggingTo. |
711 |
* |
* |
712 |
* @param e The MouseEvent. |
* @param e The MouseEvent. |
713 |
*/ |
*/ |
715 |
{ |
{ |
716 |
finishDraggingTo(positionForMouseEvent(e)); |
finishDraggingTo(positionForMouseEvent(e)); |
717 |
} |
} |
718 |
|
|
719 |
/** |
/** |
720 |
* This is a helper method that includes the offset |
* This is a helper method that includes the offset in the needed |
721 |
* in the needed location. |
* location. |
722 |
* |
* |
723 |
* @param x The x coordinate of the MouseEvent. |
* @param x The x coordinate of the MouseEvent. |
724 |
* @param y The y coordinate of the MouseEvent. |
* @param y The y coordinate of the MouseEvent. |
732 |
} |
} |
733 |
|
|
734 |
/** |
/** |
735 |
* This is a helper class that controls dragging when |
* This is a helper class that controls dragging when the orientation is |
736 |
* the orientation is VERTICAL_SPLIT. |
* VERTICAL_SPLIT. |
737 |
*/ |
*/ |
738 |
protected class VerticalDragController extends DragController |
protected class VerticalDragController extends DragController |
739 |
{ |
{ |
749 |
} |
} |
750 |
|
|
751 |
/** |
/** |
752 |
* This method returns one of the two parameters given |
* This method returns one of the two parameters given the orientation. In |
753 |
* the orientation. In this case, it returns y. |
* this case, it returns y. |
754 |
* |
* |
755 |
* @param x The x coordinate of the MouseEvent. |
* @param x The x coordinate of the MouseEvent. |
756 |
* @param y The y coordinate of the MouseEvent. |
* @param y The y coordinate of the MouseEvent. |
763 |
} |
} |
764 |
|
|
765 |
/** |
/** |
766 |
* This method returns the new location of the divider |
* This method returns the new location of the divider given a MouseEvent. |
|
* given a MouseEvent. |
|
767 |
* |
* |
768 |
* @param e The MouseEvent. |
* @param e The MouseEvent. |
769 |
* |
* |
775 |
} |
} |
776 |
|
|
777 |
/** |
/** |
778 |
* This is a helper method that includes the offset |
* This is a helper method that includes the offset in the needed |
779 |
* in the needed location. |
* location. |
780 |
* |
* |
781 |
* @param x The x coordinate of the MouseEvent. |
* @param x The x coordinate of the MouseEvent. |
782 |
* @param y The y coordinate of the MouseEvent. |
* @param y The y coordinate of the MouseEvent. |
786 |
int adjust(int x, int y) |
int adjust(int x, int y) |
787 |
{ |
{ |
788 |
return getNeededLocation(x, y) + getY() - offset; |
return getNeededLocation(x, y) + getY() - offset; |
789 |
} |
} |
790 |
} |
} |
791 |
|
|
792 |
/** |
/** |
793 |
* This helper class acts as the Layout Manager for |
* This helper class acts as the Layout Manager for the divider. |
|
* the divider. |
|
794 |
*/ |
*/ |
795 |
protected class DividerLayout implements LayoutManager |
protected class DividerLayout implements LayoutManager |
796 |
{ |
{ |
861 |
} |
} |
862 |
|
|
863 |
/** |
/** |
864 |
* This method changes the button orientation when |
* This method changes the button orientation when the orientation of the |
865 |
* the orientation of the SplitPane changes. |
* SplitPane changes. |
866 |
*/ |
*/ |
867 |
private void changeButtonOrientation() |
private void changeButtonOrientation() |
868 |
{ |
{ |