/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Manages all the <code>ToolTips</code> in the system.
* <p>
* ToolTipManager contains numerous properties for configuring how long it
* will take for the tooltips to become visible, and how long till they
* hide. Consider a component that has a different tooltip based on where
* the mouse is, such as JTree. When the mouse moves into the JTree and
* over a region that has a valid tooltip, the tooltip will become
* visibile after <code>initialDelay</code> milliseconds. After
* <code>dismissDelay</code> milliseconds the tooltip will be hidden. If
* the mouse is over a region that has a valid tooltip, and the tooltip
* is currently visible, when the mouse moves to a region that doesn't have
* a valid tooltip the tooltip will be hidden. If the mouse then moves back
* into a region that has a valid tooltip within <code>reshowDelay</code>
* milliseconds, the tooltip will immediately be shown, otherwise the
* tooltip will be shown again after <code>initialDelay</code> milliseconds.
*
* @see JComponent#createToolTip
* @author Dave Moore
* @author Rich Schiavi
*/
boolean showImmediately;
/** The Window tip is being displayed in. This will be non-null if
* the Window tip is in differs from that of insideComponent's Window.
*/
boolean enabled = true;
private boolean tipShowing = false;
// PENDING(ges)
protected boolean lightWeightPopupEnabled = true;
protected boolean heavyWeightPopupEnabled = false;
ToolTipManager() {
enterTimer.setRepeats(false);
exitTimer.setRepeats(false);
insideTimer.setRepeats(false);
}
/**
* Enables or disables the tooltip.
*
* @param flag true to enable the tip, false otherwise
*/
if (!flag) {
}
}
/**
* Returns true if this object is enabled.
*
* @return true if this object is enabled, false otherwise
*/
public boolean isEnabled() {
return enabled;
}
/**
* When displaying the <code>JToolTip</code>, the
* <code>ToolTipManager</code> chooses to use a lightweight
* <code>JPanel</code> if it fits. This method allows you to
* disable this feature. You have to do disable it if your
* application mixes light weight and heavy weights components.
*
* @param aFlag true if a lightweight panel is desired, false otherwise
*
*/
}
/**
* Returns true if lightweight (all-Java) <code>Tooltips</code>
* are in use, or false if heavyweight (native peer)
* <code>Tooltips</code> are being used.
*
* @return true if lightweight <code>ToolTips</code> are in use
*/
public boolean isLightWeightPopupEnabled() {
return lightWeightPopupEnabled;
}
/**
* Specifies the initial delay value.
*
* @param milliseconds the number of milliseconds to delay
* (after the cursor has paused) before displaying the
* tooltip
* @see #getInitialDelay
*/
}
/**
* Returns the initial delay value.
*
* @return an integer representing the initial delay value,
* in milliseconds
* @see #setInitialDelay
*/
public int getInitialDelay() {
return enterTimer.getInitialDelay();
}
/**
* Specifies the dismissal delay value.
*
* @param milliseconds the number of milliseconds to delay
* before taking away the tooltip
* @see #getDismissDelay
*/
}
/**
* Returns the dismissal delay value.
*
* @return an integer representing the dismissal delay value,
* in milliseconds
* @see #setDismissDelay
*/
public int getDismissDelay() {
return insideTimer.getInitialDelay();
}
/**
* Used to specify the amount of time before the user has to wait
* <code>initialDelay</code> milliseconds before a tooltip will be
* shown. That is, if the tooltip is hidden, and the user moves into
* a region of the same Component that has a valid tooltip within
* <code>milliseconds</code> milliseconds the tooltip will immediately
* be shown. Otherwise, if the user moves into a region with a valid
* tooltip after <code>milliseconds</code> milliseconds, the user
* will have to wait an additional <code>initialDelay</code>
* milliseconds before the tooltip is shown again.
*
* @param milliseconds time in milliseconds
* @see #getReshowDelay
*/
}
/**
* Returns the reshow delay property.
*
* @return reshown delay property
* @see #setReshowDelay
*/
public int getReshowDelay() {
return exitTimer.getInitialDelay();
}
// Returns GraphicsConfiguration instance that toFind belongs to or null
// if drawing point is set to a point beyond visible screen area (e.g.
// Point(20000, 20000))
return config;
}
}
}
return null;
}
void showTipWindow() {
return;
return;
}
}
if (enabled) {
if (preferredLocation != null) {
screenLocation.y + preferredLocation.y);
} else {
}
}
}
// Take into account screen insets, decrease viewport
boolean leftToRight
// Just to be paranoid
if(preferredLocation != null) {
if (!leftToRight) {
}
} else {
if (!leftToRight) {
}
}
}
// we do not adjust x/y when using awt.Window tips
}
// Fit as much of the tooltip on screen as possible
}
;
}
}
}
if (lightWeightPopupEnabled) {
if (x>0 || y>0) {
} else {
}
}
else {
}
location.x,
location.y);
window.addMouseListener(this);
}
else {
}
insideTimer.start();
tipShowing = true;
}
}
void hideTipWindow() {
window.removeMouseListener(this);
}
tipShowing = false;
insideTimer.stop();
}
}
/**
* Returns a shared <code>ToolTipManager</code> instance.
*
* @return a shared <code>ToolTipManager</code> object
*/
if (value instanceof ToolTipManager) {
return (ToolTipManager) value;
}
return manager;
}
// add keylistener here to trigger tip for access
/**
* Registers a component for tooltip management.
* <p>
* This will register key bindings to show and hide the tooltip text
* only if <code>component</code> has focus bindings. This is done
* so that components that are not normally focus traversable, such
* as <code>JLabel</code>, are not made focus traversable as a result
* of invoking this method.
*
* @param component a <code>JComponent</code> object to add
* @see JComponent#isFocusTraversable
*/
component.removeMouseListener(this);
component.addMouseListener(this);
}
/**
* Removes a component from tooltip control.
*
* @param component a <code>JComponent</code> object to remove
*/
component.removeMouseListener(this);
}
// implements java.awt.event.MouseListener
/**
* Called when the mouse enters the region of a component.
* This determines whether the tool tip should be shown.
*
* @param event the event in question
*/
}
return;
}
// ensure tooltip shows only in proper place
if (location.x < 0 ||
location.y < 0 ||
return;
}
if (insideComponent != null) {
enterTimer.stop();
}
// A component in an unactive internal frame is sent two
// mouseEntered events, make sure we don't end up adding
// ourselves an extra time.
component.addMouseMotionListener(this);
mouseEvent = event;
if (showImmediately) {
event);
(newPreferredLocation == null);
!sameLoc) {
}
} else {
enterTimer.start();
}
}
}
// implements java.awt.event.MouseListener
/**
* Called when the mouse exits the region of a component.
* Any tool tip showing should be hidden.
*
* @param event the event in question
*/
boolean shouldHide = true;
if (insideComponent == null) {
// Drag exit
}
// if we get an exit and have a heavy window
// we need to check if it if overlapping the inside component
// insideComponent may be removed after tooltip is made visible
if (insideComponentWindow != null) {
shouldHide = false;
} else {
shouldHide = true;
}
}
win);
shouldHide = false;
} else {
shouldHide = true;
}
}
}
if (shouldHide) {
enterTimer.stop();
if (insideComponent != null) {
}
toolTipText = null;
mouseEvent = null;
}
}
// implements java.awt.event.MouseListener
/**
* Called when the mouse is pressed.
* Any tool tip showing should be hidden.
*
* @param event the event in question
*/
enterTimer.stop();
showImmediately = false;
mouseEvent = null;
}
// implements java.awt.event.MouseMotionListener
/**
* Called when the mouse is pressed and dragged.
* Does nothing.
*
* @param event the event in question
*/
}
// implements java.awt.event.MouseMotionListener
/**
* Called when the mouse is moved.
* Determines whether the tool tip should be displayed.
*
* @param event the event in question
*/
if (tipShowing) {
}
else if (showImmediately) {
if (toolTipText != null) {
mouseEvent = event;
}
}
else {
// Lazily lookup the values from within insideTimerAction
mouseEvent = event;
toolTipText = null;
}
}
/**
* Checks to see if the tooltip needs to be changed in response to
* the MouseMoved event <code>event</code>.
*/
mouseEvent = event;
|| newPreferredLocation == null)) {
} else {
}
} else {
if (showImmediately) {
} else {
}
}
} else {
toolTipText = null;
mouseEvent = null;
enterTimer.stop();
}
}
// Lazy lookup
}
if(toolTipText != null) {
showImmediately = true;
}
else {
toolTipText = null;
mouseEvent = null;
}
}
}
}
showImmediately = false;
}
}
enterTimer.stop();
showImmediately = false;
mouseEvent = null;
}
}
/* This listener is registered when the tooltip is first registered
* on a component in order to catch the situation where the tooltip
* was turned on while the mouse was already within the bounds of
* the component. This way, the tooltip will be initiated on a
* mouse-entered or mouse-moved, whichever occurs first. Once the
* tooltip has been initiated, we can remove this listener and rely
* solely on mouse-entered to initiate the tooltip.
*/
initiateToolTip(e);
}
}
}
}
return new FocusAdapter(){
}
};
}
// Returns: 0 no adjust
// -1 can't fit
// >0 adjust value by amount returned
// fix internal frame size bug: 4139087 - 4159012
if (popupFrameRect == null){
popupFrameRect = new Rectangle();
}
popupFrameRect.setBounds(p.x,p.y,
}
}
}
return 0;
}
// Returns: 0 no adjust
// >0 adjust by value return
if (popupFrameRect == null){
popupFrameRect = new Rectangle();
}
popupFrameRect.setBounds(p.x,p.y,
}
}
}
return 0;
}
return 0;
else
}
// Return the number of pixels over the edge we are extending.
// If we are over the edge the ToolTipManager can adjust.
// REMIND: what if the Tooltip is just too big to fit at all - we currently will just clip
return 0;
}
else {
}
}
//
// Actions
//
}
else {
hideTipWindow(); // be safe
enterTimer.stop();
insideTimer.stop();
if (insideComponent != null){
10); // manual set
// put a focuschange listener on to bring the tip down
if (focusChangeListener == null){
}
}
}
}
}
/* This listener is registered when the tooltip is first registered
* on a component in order to process accessibility keybindings.
* This will apply globally across L&F
*
* Post Tip: Ctrl+F1
* Unpost Tip: Esc and Ctrl+F1
*/
if (!e.isConsumed()) {
e.consume();
}
// Shown tooltip will be hidden
e.consume();
}
}
}
}
}