Class ScalingGraphMousePlugin
- java.lang.Object
-
- org.jungrapht.visualization.control.AbstractGraphMousePlugin
-
- org.jungrapht.visualization.control.ScalingGraphMousePlugin
-
- All Implemented Interfaces:
MouseListener,MouseWheelListener,EventListener,GraphMousePlugin
- Direct Known Subclasses:
SatelliteScalingGraphMousePlugin
public class ScalingGraphMousePlugin extends AbstractGraphMousePlugin implements MouseWheelListener, MouseListener
ScalingGraphMouse applies a scaling transformation to the graph layout. The Vertices get closer or farther apart, but do not themselves change size. ScalingGraphMouse uses MouseWheelEvents to apply the scaling.- Using only the mouse wheel, both the X-axis and Y-axis are scaled equally.
- If the CTRL key is pressed while the mouse wheel is turned, only the X-axis is scaled
- If the ALT key is pressed while the mouse wheel is turned, only the Y-axis is scaled
- Author:
- Tom Nelson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScalingGraphMousePlugin.Builder-
Nested classes/interfaces inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
AbstractGraphMousePlugin.Selecting
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanenableDoubleClickScaleResetprotected booleanenableMiddleMouseButtonScaleResetprotected floatinthe amount to zoom in byprotected ScalingControllayoutScalingControlprotected floatoutthe amount to zoom out byprotected intpickSizeprotected ScalingControlscalercontrols scaling operationsprotected intscalingMaskprotected intxAxisScalingMaskprotected intyAxisScalingMaskprotected booleanzoomAtMousewhether to center the zoom at the current mouse position-
Fields inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
cursor, down, modifiers
-
-
Constructor Summary
Constructors Constructor Description ScalingGraphMousePlugin()ScalingGraphMousePlugin(ScalingControl scaler, int scalingMask, int xAxisScalingMask, int yAxisScalingMask)ScalingGraphMousePlugin(ScalingControl scaler, int scalingMask, int xAxisScalingMask, int yAxisScalingMask, float in, float out)ScalingGraphMousePlugin(ScalingGraphMousePlugin.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ScalingGraphMousePlugin.Builderbuilder()booleancheckModifiers(MouseEvent e)check the mouse event modifiers against the instance member modifiers.floatgetIn()floatgetOut()ScalingControlgetScaler()voidmouseClicked(MouseEvent e)Invoked when the mouse button has been clicked (pressed and released) on a component.voidmouseEntered(MouseEvent e)Invoked when the mouse enters a component.voidmouseExited(MouseEvent e)Invoked when the mouse exits a component.voidmousePressed(MouseEvent e)Invoked when a mouse button has been pressed on a component.voidmouseReleased(MouseEvent e)Invoked when a mouse button has been released on a component.voidmouseWheelMoved(MouseWheelEvent e)zoom the display in or out, depending on the direction of the mouse wheel motion.voidsetIn(float in)voidsetOut(float out)voidsetScaler(ScalingControl scaler)voidsetZoomAtMouse(boolean zoomAtMouse)protected <V,E>
booleansingleEdgeSelection(MouseEvent e)protected <V,E>
booleansingleVertexSelection(MouseEvent e)-
Methods inherited from class org.jungrapht.visualization.control.AbstractGraphMousePlugin
getCursor, getModifiersEx, setCursor, setModifiers
-
-
-
-
Field Detail
-
pickSize
protected int pickSize
-
in
protected float in
the amount to zoom in by
-
out
protected float out
the amount to zoom out by
-
scalingMask
protected int scalingMask
-
xAxisScalingMask
protected int xAxisScalingMask
-
yAxisScalingMask
protected int yAxisScalingMask
-
zoomAtMouse
protected boolean zoomAtMouse
whether to center the zoom at the current mouse position
-
scaler
protected ScalingControl scaler
controls scaling operations
-
layoutScalingControl
protected ScalingControl layoutScalingControl
-
enableMiddleMouseButtonScaleReset
protected boolean enableMiddleMouseButtonScaleReset
-
enableDoubleClickScaleReset
protected boolean enableDoubleClickScaleReset
-
-
Constructor Detail
-
ScalingGraphMousePlugin
public ScalingGraphMousePlugin()
-
ScalingGraphMousePlugin
public ScalingGraphMousePlugin(ScalingGraphMousePlugin.Builder builder)
-
ScalingGraphMousePlugin
public ScalingGraphMousePlugin(ScalingControl scaler, int scalingMask, int xAxisScalingMask, int yAxisScalingMask)
-
ScalingGraphMousePlugin
public ScalingGraphMousePlugin(ScalingControl scaler, int scalingMask, int xAxisScalingMask, int yAxisScalingMask, float in, float out)
-
-
Method Detail
-
builder
public static ScalingGraphMousePlugin.Builder builder()
-
setZoomAtMouse
public void setZoomAtMouse(boolean zoomAtMouse)
- Parameters:
zoomAtMouse- The zoomAtMouse to set.
-
checkModifiers
public boolean checkModifiers(MouseEvent e)
Description copied from class:AbstractGraphMousePlugincheck the mouse event modifiers against the instance member modifiers. Default implementation checks equality. Can be overridden to test with a mask- Specified by:
checkModifiersin interfaceGraphMousePlugin- Overrides:
checkModifiersin classAbstractGraphMousePlugin- Parameters:
e- an event to compare to- Returns:
- whether the member modifiers match the event modifiers
-
mouseWheelMoved
public void mouseWheelMoved(MouseWheelEvent e)
zoom the display in or out, depending on the direction of the mouse wheel motion.- Specified by:
mouseWheelMovedin interfaceMouseWheelListener
-
getIn
public float getIn()
- Returns:
- Returns the zoom in value.
-
setIn
public void setIn(float in)
- Parameters:
in- The zoom in value to set.
-
getOut
public float getOut()
- Returns:
- Returns the zoom out value.
-
setOut
public void setOut(float out)
- Parameters:
out- The zoom out value to set.
-
getScaler
public ScalingControl getScaler()
-
setScaler
public void setScaler(ScalingControl scaler)
-
mouseClicked
public void mouseClicked(MouseEvent e)
Invoked when the mouse button has been clicked (pressed and released) on a component.- Specified by:
mouseClickedin interfaceMouseListener- Parameters:
e- the event to be processed
-
singleVertexSelection
protected <V,E> boolean singleVertexSelection(MouseEvent e)
-
singleEdgeSelection
protected <V,E> boolean singleEdgeSelection(MouseEvent e)
-
mousePressed
public void mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a component.- Specified by:
mousePressedin interfaceMouseListener- Parameters:
e- the event to be processed
-
mouseReleased
public void mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a component.- Specified by:
mouseReleasedin interfaceMouseListener- Parameters:
e- the event to be processed
-
mouseEntered
public void mouseEntered(MouseEvent e)
Invoked when the mouse enters a component.- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
e- the event to be processed
-
mouseExited
public void mouseExited(MouseEvent e)
Invoked when the mouse exits a component.- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
e- the event to be processed
-
-