2
* Copyright (c) 2005-2010 Laf-Widget Kirill Grouchnikov. All Rights Reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* o Redistributions of source code must retain the above copyright notice,
8
* this list of conditions and the following disclaimer.
10
* o Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
14
* o Neither the name of Laf-Widget Kirill Grouchnikov nor the names of
15
* its contributors may be used to endorse or promote products derived
16
* from this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
package org.pushingpixels.lafwidget.tabbed;
34
import javax.swing.JFrame;
35
import javax.swing.JTabbedPane;
37
import org.pushingpixels.lafwidget.utils.LafConstants.TabOverviewKind;
40
* Base class for tab preview painters.
42
* @author Kirill Grouchnikov
44
public abstract class TabPreviewPainter {
46
* Draws a tab preview on the specified graphics.
51
* tabIndex Tab index for the preview paint.
55
* X coordinate of the preview area.
57
* Y coordinate of the preview area.
59
* Width of the preview area.
61
* Height of the preview area.
63
public void previewTab(JTabbedPane tabPane, int tabIndex, Graphics g,
64
int x, int y, int w, int h) {
68
* Checks whether the specified tab component is previewable.
73
* Tab index for the preview paint.
74
* @return <code>true</code> if the specified tab component is
75
* previewable, <code>false</code> otherwise.
77
public boolean hasPreview(JTabbedPane tabPane, int tabIndex) {
82
* Checks whether the specified tab component is sensitive to events.
83
* Overriding implementation may decide that disabled tabs do not respond to
84
* mouse and keyboard events, thus not allowing selecting the corresponding
91
* @return <code>true</code> if the specified tab component is sensitive
92
* to events, <code>false</code> otherwise.
94
public boolean isSensitiveToEvents(JTabbedPane tabPane, int tabIndex) {
99
* Returns the screen bounds of the tab preview dialog window.
103
* @return Screen bounds of the preview dialog window of the specified
106
public Rectangle getPreviewDialogScreenBounds(JTabbedPane tabPane) {
107
Rectangle tabPaneBounds = tabPane.getBounds();
108
Point tabPaneScreenLoc = tabPane.getLocationOnScreen();
109
return new Rectangle(tabPaneScreenLoc.x, tabPaneScreenLoc.y,
110
tabPaneBounds.width, tabPaneBounds.height);
114
* Returns the owner of the overview dialog of the specified tabbed pane. If
115
* this function retuns a non-<code>null</code> value, the overview
116
* dialog will be modal for the corresponding frame.
120
* @return If not <code>null</code>, the overview dialog for the
121
* specified tabbed pane will be modal for the corresponding frame.
123
public JFrame getModalOwner(JTabbedPane tabPane) {
128
* Checks whether the specified tabbed pane has an overview dialog.
132
* @return <code>true</code> if the specified tabbed pane has an overview
133
* dialog, <code>false</code> otherwise.
135
public boolean hasOverviewDialog(JTabbedPane tabPane) {
140
* Checks whether the specified tabbed pane has a preview window for the
147
* @return <code>true</code> if the specified tabbed pane has a preview
148
* window for the specified tab, <code>false</code> otherwise.
150
public boolean hasPreviewWindow(JTabbedPane tabPane, int tabIndex) {
155
* Returns the dimension for the tab preview window.
161
* @return Dimension of the tab preview window for the specified tab in the
162
* specified tabbed pane.
164
public Dimension getPreviewWindowDimension(JTabbedPane tabPane, int tabIndex) {
165
return new Dimension(300, 200);
169
* Returns extra delay (in milliseconds) for showing the tab preview window.
170
* The base delay is 2000 milliseconds (2 seconds). This function must
171
* return a non-negative value.
177
* @return Non-negative extra delay (in milliseconds) for showing the tab
180
public int getPreviewWindowExtraDelay(JTabbedPane tabPane, int tabIndex) {
185
* Returns indication whether the thumbnail preview should be updated
186
* periodically. If the return value is <code>true</code>, then the
187
* implementation of {@link #getUpdateCycle(JTabbedPane)} returns the
188
* refresh cycle length in milliseconds.
192
* @return <code>true</code> if the thumbnail preview of the specified
193
* tabbed pane should be updated periodically, <code>false</code>
196
public boolean toUpdatePeriodically(JTabbedPane tabPane) {
201
* If the result of {@link #toUpdatePeriodically(JTabbedPane)} is
202
* <code>true</code>, returns the update cycle length in milliseconds.
206
* @return Update cycle length in milliseconds for the thumbnail preview of
207
* the specified tabbed pane.
209
public int getUpdateCycle(JTabbedPane tabPane) {
214
* Returns the tab overview kind for the specified tabbed pane. Relevant if
215
* {@link #hasOverviewDialog(JTabbedPane)} returns <code>true</code> for
216
* the same tabbed pane. If {@link #hasOverviewDialog(JTabbedPane)} returns
217
* <code>true</code>, the result should be not <code>null</code>.
222
* @return Tab overview kind for the specified tabbed pane.
225
public TabOverviewKind getOverviewKind(JTabbedPane tabPane) {
226
return TabOverviewKind.GRID;
230
* Returns indication whether the tab overview dialog should be
231
* automatically disposed when it loses focus.
233
* @return if <code>true</code>, the tab overview dialog will be disposed
234
* when it loses focus.
236
public boolean toDisposeOverviewOnFocusLoss() {