|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.Graph2DViewMouseWheelZoomListener
public class Graph2DViewMouseWheelZoomListener
Zooms a Graph2DView
's view port in response to mouse wheel events.
Instances of this class should be registered as a listener for mouse wheel
events using method addToCanvas(Graph2DView)
.
Graph2DViewMouseWheelScrollListener
Field Summary | |
---|---|
protected java.awt.event.MouseWheelEvent |
lastMouseWheelEvent
Stores last mouse event received via mouseWheelMoved(MouseWheelEvent) |
Constructor Summary | |
---|---|
Graph2DViewMouseWheelZoomListener()
Creates a new Graph2DViewMouseWheelZoomListener If it receives MouseWheelListener events that come from the canvas component of a Graph2DView (see Graph2DView.getCanvasComponent() ), it
will zoom into or out of the Graph2DView . |
Method Summary | |
---|---|
void |
addToCanvas(Graph2DView view)
Adds this listener to the set of listeners that are notified of mouse wheel events for the specified view. |
protected void |
adjustWorldRect(Graph2DView view)
Adjusts the world rectangle that defines the accessible area of the given view after its zoom and clip has been changed. |
protected double |
calcZoom(double zoom,
int amount)
Calculates the new zoom level to be assigned to the canvas. |
double |
getMaximumZoom()
Gets the maximum zoom level of Graph2DView
that will be assigned when scrolling the mouse wheel. |
double |
getMinimumZoom()
Returns the minimum zoom level of Graph2DView
that will be assigned when scrolling the mouse wheel. |
java.awt.Color |
getZoomIndicatorColor()
Returns the base color of the zoom indicator. |
protected boolean |
isCenterZoomEvent(java.awt.event.MouseWheelEvent mwe)
Determines whether for the current event center zooming should be used. |
boolean |
isCenterZooming()
Returns the property centerZooming. |
boolean |
isDownInZooming()
Returns property downInZooming . |
boolean |
isLimitMinimumZoomByContentSize()
Returns whether or not the minimum zoom level shall be bound by the maximum zoom level that will still allow to fit the complete graph into the view. |
boolean |
isZoomIndicatorShowing()
Returns whether or not the view shall display an animated zoom indicator at the mouse position whenever the zoom level gets changed by this class. |
void |
mouseWheelMoved(java.awt.event.MouseWheelEvent e)
|
protected void |
paintZoomIndicator(java.awt.Graphics2D gfx,
int x,
int y,
int width,
int height,
double time,
java.awt.event.MouseWheelEvent ev)
Paints the zoom indicator inside the given bounds. |
void |
removeFromCanvas(Graph2DView view)
Removes this listener from the set of listeners that are notified of mouse wheel events for the specified view. |
void |
setCenterZooming(boolean centerZooming)
Sets the property centerZooming. |
void |
setDownInZooming(boolean downIn)
Sets property downInZooming . |
void |
setLimitMinimumZoomByContentSize(boolean limitMinimumZoomByContentSize)
Sets whether or not the minimum zoom level shall be bound by the maximum zoom level that will still allow to fit the complete graph into the view. |
void |
setMaximumZoom(double maximumZoom)
Sets the maximum zoom level of Graph2DView
that will be assigned when scrolling the mouse wheel. |
void |
setMinimumZoom(double minimumZoom)
Sets the minimum zoom level of Graph2DView
that will be assigned when scrolling the mouse wheel. |
void |
setZoomIndicatorColor(java.awt.Color zoomIndicatorColor)
Sets the base color of the zoom indicator. |
void |
setZoomIndicatorShowing(boolean zoomIndicatorShowing)
Whether or not the view shall display an animated zoom indicator at the mouse position whenever the zoom level gets changed by this class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.awt.event.MouseWheelEvent lastMouseWheelEvent
mouseWheelMoved(MouseWheelEvent)
Constructor Detail |
---|
public Graph2DViewMouseWheelZoomListener()
Graph2DView
(see Graph2DView.getCanvasComponent()
), it
will zoom into or out of the Graph2DView
.
Method Detail |
---|
public void addToCanvas(Graph2DView view)
view.getCanvasComponent().addMouseWheelListener(this);
view
- the Graph2DView
instance whose mouse wheel events
should be handled by this listener.removeFromCanvas(Graph2DView)
public void removeFromCanvas(Graph2DView view)
view.getCanvasComponent().removeMouseWheelListener(this);
view
- the Graph2DView
instance whose mouse wheel events
were handled by this listener.addToCanvas(Graph2DView)
public void setLimitMinimumZoomByContentSize(boolean limitMinimumZoomByContentSize)
public boolean isLimitMinimumZoomByContentSize()
public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
mouseWheelMoved
in interface java.awt.event.MouseWheelListener
protected double calcZoom(double zoom, int amount)
zoom
- the current zoom level set on the canvas.amount
- the amount of scroll wheel rotation or units to scroll.protected void adjustWorldRect(Graph2DView view)
protected boolean isCenterZoomEvent(java.awt.event.MouseWheelEvent mwe)
isCenterZooming()
returns
false
or the Event.CTRL_MASK
flag is set in
mwe
's modifiers.
mwe
- the current MouseWheelEvent
true
if center zooming should be usedpublic boolean isCenterZooming()
true
.
public void setCenterZooming(boolean centerZooming)
centerZooming
- whether to enable simple center zoomingpublic double getMaximumZoom()
Graph2DView
that will be assigned when scrolling the mouse wheel.
By default, this value is set to Double.MAX_VALUE
.
public void setMaximumZoom(double maximumZoom)
Graph2DView
that will be assigned when scrolling the mouse wheel.
By default, this value is set to Double.MAX_VALUE
.
public double getMinimumZoom()
Graph2DView
that will be assigned when scrolling the mouse wheel.
public void setMinimumZoom(double minimumZoom)
Graph2DView
that will be assigned when scrolling the mouse wheel.
By default, this value is set to Double.MIN_VALUE
.
public boolean isDownInZooming()
downInZooming
.
downInZooming
.setDownInZooming(boolean)
public void setDownInZooming(boolean downIn)
downInZooming
. If set to true
scrolling down (using the mouse wheel) will be translated into a
zoom in action and scrolling up will be translated into
a zoom out action. By default, this property is set to
false
, i.e. scrolling down triggers zoom out behavior and
scrolling up zoom in behavior.
downIn
- if true
, scrolling down will zoom in; otherwise
scrolling down will zoom out.public void setZoomIndicatorShowing(boolean zoomIndicatorShowing)
public boolean isZoomIndicatorShowing()
protected void paintZoomIndicator(java.awt.Graphics2D gfx, int x, int y, int width, int height, double time, java.awt.event.MouseWheelEvent ev)
getZoomIndicatorColor()
.
time
- a value between 0.0 and 1.0 that indicates what frame of the zoom indicator animation needs to be painted.AnimationObject
public void setZoomIndicatorColor(java.awt.Color zoomIndicatorColor)
public java.awt.Color getZoomIndicatorColor()
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |