Search this API

y.view
Class TooltipMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.TooltipMode
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class TooltipMode
extends ViewMode

A ViewMode which shows tooltips for every kind of graph element when moving the mouse over it. Graph elements which tooltips can be shown for are Nodes, Edges, NodeLabels, EdgeLabels and NodePorts.

It is possible to enable/disable tooltips for every kind of graph element separately.

Note: If TooltipMode is used the tooltip functionality of EditMode must not be executed any more to avoid interferences.

 

Field Summary
 
Fields inherited from class y.view.ViewMode
ACTIVE_PROPERTY, ACTIVE_VIEW_PROPERTY, CHILD_MODE_PROPERTY, EDITING_PROPERTY, GRAB_FOCUS_ENABLED_PROPERTY, lastClickEvent, lastDragEvent, lastMoveEvent, lastPressEvent, lastReleaseEvent, MODIFIER_MASK_PROPERTY, NAME_PROPERTY, originalX, originalY, PARENT_MODE_PROPERTY, view
 
Constructor Summary
TooltipMode()
          Creates a new TooltipMode.
 
Method Summary
protected  java.lang.String getEdgeLabelTip(EdgeLabel label)
          Returns the text of the tooltip for a edge's label.
protected  java.lang.String getEdgeTip(Edge edge)
          Returns the text of the tooltip for an edge.
protected  HitInfo getHitInfo(double x, double y)
          Overwrites ViewMode.getHitInfo(double, double) in order to get the hit information of only the first hit of every kind of graph element at the coordinates (x,y).
protected  java.lang.String getNodeLabelTip(NodeLabel label)
          Returns the text of the tooltip for a node's label.
protected  java.lang.String getNodePortTip(NodePort port)
          Returns the text of the tooltip for a node port.
protected  java.lang.String getNodeTip(Node node)
          Returns the text of the tooltip for a given node.
 boolean isEdgeLabelTipEnabled()
          Determines whether tooltips for edge labels will be displayed.
 boolean isEdgeTipEnabled()
          Determines whether tooltips for edges will be displayed.
 boolean isNodeLabelTipEnabled()
          Determines whether tooltips for node labels will be displayed.
 boolean isNodeTipEnabled()
          Determines whether tooltips for nodes will be displayed.
 boolean isPortTipEnabled()
          Determines whether tooltips for node ports will be displayed.
 void mouseMoved(double x, double y)
          Sets a tooltip for the topmost graph element at the coordinates (x,y) which belongs to a kind of graph element where tooltips are enabled and a tooltip text is set.
 void setEdgeLabelTipEnabled(boolean edgeLabelTipEnabled)
          Specifies whether tooltips for edge labels will be displayed.
 void setEdgeTipEnabled(boolean edgeTipEnabled)
          Specifies whether tooltips for edges will be displayed.
 void setNodeLabelTipEnabled(boolean nodeLabelTipEnabled)
          Specifies whether tooltips for node labels will be displayed.
 void setNodeTipEnabled(boolean nodeTipEnabled)
          Specifies whether tooltips for nodes will be displayed.
 void setPortTipEnabled(boolean portTipEnabled)
          Specifies whether tooltips for node ports will be displayed.
 
Methods inherited from class y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, cancelEditing, deactivateChild, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getLastClickEvent, getLastDragEvent, getLastHitInfo, getLastMoveEvent, getLastPressEvent, getLastReleaseEvent, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseClicked, mouseDragged, mouseDraggedLeft, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mousePressed, mousePressedLeft, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleased, mouseReleasedLeft, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedLeft, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, setChild, setChild, setEditing, setGrabFocusEnabled, setGridMode, setLastHitInfo, setModifierMask, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TooltipMode

public TooltipMode()
Creates a new TooltipMode. Tooltips for every kind of graph element are activated.

Method Detail

getHitInfo

protected HitInfo getHitInfo(double x,
                             double y)
Overwrites ViewMode.getHitInfo(double, double) in order to get the hit information of only the first hit of every kind of graph element at the coordinates (x,y). Only the graph elements for which tooltips are enabled will be considered.

Note: As getHitInfo stores the last hit information for further use, any overwriting method has to make sure that ViewMode.setLastHitInfo(HitInfo) is called, so the methods ViewMode.setLastHitInfo(HitInfo) and ViewMode.getLastHitInfo() will access the right HitInfo object.

Overrides:
getHitInfo in class ViewMode
Parameters:
x - x world coordinate
y - y world coordinate
Returns:
a new HitInfo that contains the first hit of every kind of graph elements at (x,y)
See Also:
ViewMode.createHitInfo(double,double,boolean)

mouseMoved

public void mouseMoved(double x,
                       double y)
Sets a tooltip for the topmost graph element at the coordinates (x,y) which belongs to a kind of graph element where tooltips are enabled and a tooltip text is set.

Overrides:
mouseMoved in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.
See Also:
setNodeTipEnabled(boolean), setEdgeTipEnabled(boolean), setNodeLabelTipEnabled(boolean), setEdgeLabelTipEnabled(boolean), setPortTipEnabled(boolean)

getNodeTip

protected java.lang.String getNodeTip(Node node)
Returns the text of the tooltip for a given node. This method will be called to get the tip text associated with the given node. The tip will only be displayed if node tips are activated via setNodeTipEnabled(boolean).

By default the label text of the node will be returned. Subclasses may want to overwrite this behavior.

Parameters:
node - the node for which the tooltip is set
Returns:
the text for the tooltip of the node

getEdgeTip

protected java.lang.String getEdgeTip(Edge edge)
Returns the text of the tooltip for an edge. This method will be called to get the tip text associated with the given edge. The tip will only be displayed if edge tips are activated via setEdgeTipEnabled(boolean).

By default the first label text of the edge will be returned. Subclasses may want to overwrite this behavior.

Parameters:
edge - the edge for which the tooltip is set
Returns:
the text for the tooltip of the edge

getNodeLabelTip

protected java.lang.String getNodeLabelTip(NodeLabel label)
Returns the text of the tooltip for a node's label. This method will be called to get the tip text associated with the given node label. The tip will only be displayed if node label tips are activated via setNodeLabelTipEnabled(boolean).

By default the label text will be returned. Subclasses may want to overwrite this behavior.

Parameters:
label - the label for which the tooltip is set
Returns:
the text for the tooltip of the label

getEdgeLabelTip

protected java.lang.String getEdgeLabelTip(EdgeLabel label)
Returns the text of the tooltip for a edge's label. This method will be called to get the tip text associated with the given edge label. The tip will only be displayed if edge label tips are activated via setEdgeLabelTipEnabled(boolean).

By default the label text will be returned. Subclasses may want to overwrite this behavior.

Parameters:
label - the label for which the tooltip is set
Returns:
the text for the tooltip of the label

getNodePortTip

protected java.lang.String getNodePortTip(NodePort port)
Returns the text of the tooltip for a node port. This method will be called to get the tip text associated with the given node port. The tip will only be displayed if node port tips are activated via setPortTipEnabled(boolean).

By default the label text of the node port will be returned. Subclasses may want to overwrite this behavior.

Parameters:
port - the node port for which the tooltip is set
Returns:
the text for the tooltip of the node port

isEdgeLabelTipEnabled

public boolean isEdgeLabelTipEnabled()
Determines whether tooltips for edge labels will be displayed.

Returns:
true if tooltips for edge labels will be displayed, false otherwise
See Also:
setEdgeLabelTipEnabled(boolean)

setEdgeLabelTipEnabled

public void setEdgeLabelTipEnabled(boolean edgeLabelTipEnabled)
Specifies whether tooltips for edge labels will be displayed.

The default setting is false.

Parameters:
edgeLabelTipEnabled - true if tooltips for edge labels will be displayed, false otherwise
See Also:
isEdgeLabelTipEnabled()

isEdgeTipEnabled

public boolean isEdgeTipEnabled()
Determines whether tooltips for edges will be displayed.

Returns:
true if tooltips for edges will be displayed, false otherwise
See Also:
setEdgeTipEnabled(boolean)

setEdgeTipEnabled

public void setEdgeTipEnabled(boolean edgeTipEnabled)
Specifies whether tooltips for edges will be displayed.

The default setting is true.

Parameters:
edgeTipEnabled - true if tooltips for edges will be displayed, false otherwise
See Also:
isEdgeTipEnabled()

isNodeLabelTipEnabled

public boolean isNodeLabelTipEnabled()
Determines whether tooltips for node labels will be displayed.

Returns:
true if tooltips for node labels will be displayed, false otherwise
See Also:
setNodeLabelTipEnabled(boolean)

setNodeLabelTipEnabled

public void setNodeLabelTipEnabled(boolean nodeLabelTipEnabled)
Specifies whether tooltips for node labels will be displayed.

The default setting is false.

Parameters:
nodeLabelTipEnabled - true if tooltips for node labels will be displayed, false otherwise
See Also:
isNodeLabelTipEnabled()

isNodeTipEnabled

public boolean isNodeTipEnabled()
Determines whether tooltips for nodes will be displayed.

Returns:
true if tooltips for nodes will be displayed, false otherwise
See Also:
setNodeTipEnabled(boolean)

setNodeTipEnabled

public void setNodeTipEnabled(boolean nodeTipEnabled)
Specifies whether tooltips for nodes will be displayed.

The default setting is true.

Parameters:
nodeTipEnabled - true if tooltips for nodes will be displayed, false otherwise
See Also:
isNodeTipEnabled()

isPortTipEnabled

public boolean isPortTipEnabled()
Determines whether tooltips for node ports will be displayed.

Returns:
true if tooltips for node ports will be displayed, false otherwise
See Also:
setPortTipEnabled(boolean)

setPortTipEnabled

public void setPortTipEnabled(boolean portTipEnabled)
Specifies whether tooltips for node ports will be displayed.

The default setting is false.

Parameters:
portTipEnabled - true if tooltips for node ports will be displayed, false otherwise
See Also:
isPortTipEnabled()

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.