Package snap.view
Class ViewUtils
java.lang.Object
snap.view.ViewUtils
Utility methods for nodes.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static boolean
protected static boolean
protected static boolean
protected static boolean
protected static boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addChild
(ParentView aPar, View aChild) Backdoor for protected ParentView method.static void
addChild
(ParentView aPar, View aChild, int anIndex) Backdoor for protected ParentView method.static void
beep()
Beep.static void
Binds a view property to another view's same prop.static void
Binds a view property to another view prop with given expression.static void
enableDragging
(View aView) Silly feature to make any view draggable.static void
enableEvents
(View aView, ViewEvent.Type... theEvents) Backdoor for protected View method.static void
fireActionEvent
(View aView, ViewEvent anEvent) Backdoor for protected View method.static double
Returns the align x factor.static double
Returns the align x factor.static double
Returns the align x factor.static double
Returns the align y factor.static double
Returns the align y factor.static double
Returns the align y factor.static Paint
Returns the background fill.static Paint
Returns the background fill.static Rect
getBoundsOfViews
(View aPar, List<? extends View> aList) Returns the bounds of a given view list.static View
getChildAt
(View aView, double aX, double aY) Returns the child of given class hit by coords.static <T extends View>
TgetChildAt
(View aView, double aX, double aY, Class<T> aClass) Returns the child of given class hit by coords.static View
getCommonAncetor
(View aView1, View aView2) Returns a common ancestor for two nodes.static View
getDeepestChildAt
(View aView, double aX, double aY) Returns the deepest child hit by given coords starting with children of given view.static <T extends View>
TgetDeepestChildAt
(View aView, double aX, double aY, Class<T> aClass) Returns the deepest child of given class hit by given coords starting with children of given view.static View
getDeepestViewAt
(View aView, double aX, double aY) Returns the view or child view hit by given coords, starting at given view.static <T extends View>
TgetDeepestViewAt
(View aView, double aX, double aY, Class<T> aClass) Returns the view or child view of given class hit by given coords, starting at given view.static String
Returns an identifier string for a given view.static Image
Returns an image for a View (at device dpi scale (2 for retina)).static ImageBox
getImageBoxForScale
(View aView, double aScale) Returns an image box for a View (1 = 72 dpi, 2 = 144 dpi, 0 = device dpi).static Image
getImageForScale
(View aView, double aScale) Returns an image for a View (1 = 72 dpi, 2 = 144 dpi, 0 = device dpi).static double
Returns the lean x factor.static double
Returns the lean y factor.static ViewEvent
Returns the last MouseDown event.static Paint
Returns the selection color.static Paint
Returns the selection color.static Paint
Returns the selection color.static Paint
Returns the selection color.static Paint
Returns the text fill.static boolean
Returns whether alt is down.static boolean
Returns whether control is down.static boolean
Returns whether current thread is event dispatch thread.static boolean
Returns whether meta is down.static boolean
Returns whether mouse is down.static boolean
Returns whether mouse is being dragged.static boolean
Returns whether shift is down.static boolean
Returns whether shortcut is down.static void
layoutDeep
(View aView) Layout nodes deep.static void
moveToBack
(ParentView aPar, View aChild) Moves given child to start of given parent child list, so it paints in back.static void
moveToFront
(ParentView aPar, View aChild) Moves given child to end of given parent child list, so it paints in front.static void
Deprecated.static void
Paints given view.static void
paintViewInView
(View aView, View aParentView, Painter aPntr) Paints a given view in another view.static void
paintViewWithTransform
(View aView, Transform transform, Painter aPntr) Paints given view with transform.static void
processEvent
(View aView, ViewEvent anEvent) Backdoor for protected View method.static void
removeChild
(ParentView aPar, int anIndex) Backdoor for protected ParentView method.static void
removeChild
(ParentView aPar, View aChild) Backdoor for protected ParentView method.static void
replaceView
(View aView, View newView) Replace given view with new view.static void
runDelayed
(Runnable aRun, int aDelay) Runs given runnable after delay.static void
runDelayedCancelPrevious
(Runnable aRun, int aDelay) Invokes the given runnable after delay (cancels unexecuted previous runDelayed if still pending).static void
Run given runnable on event thread.static void
runOnMouseUp
(Runnable aRun) Runs a runnable on next mouse release (assumes mouse is down).static void
setFocused
(View aView, boolean aValue) Backdoor for protected View method.static void
setParent
(View aView, ParentView aParent) Backdoor for protected View method.static void
setShowing
(View aView, boolean aValue) Backdoor for protected View method.
-
Field Details
-
_altDown
protected static boolean _altDown -
_cntrDown
protected static boolean _cntrDown -
_metaDown
protected static boolean _metaDown -
_shiftDown
protected static boolean _shiftDown -
_shortcutDown
protected static boolean _shortcutDown
-
-
Constructor Details
-
ViewUtils
public ViewUtils()
-
-
Method Details
-
isAltDown
public static boolean isAltDown()Returns whether alt is down. -
isControlDown
public static boolean isControlDown()Returns whether control is down. -
isMetaDown
public static boolean isMetaDown()Returns whether meta is down. -
isShiftDown
public static boolean isShiftDown()Returns whether shift is down. -
isShortcutDown
public static boolean isShortcutDown()Returns whether shortcut is down. -
isMouseDown
public static boolean isMouseDown()Returns whether mouse is down. -
isMouseDrag
public static boolean isMouseDrag()Returns whether mouse is being dragged. -
getMouseDown
Returns the last MouseDown event. -
getBackFill
Returns the background fill. -
getBackDarkFill
Returns the background fill. -
getTextFill
Returns the text fill. -
getSelectFill
Returns the selection color. -
getSelectTextFill
Returns the selection color. -
getTargetFill
Returns the selection color. -
getTargetTextFill
Returns the selection color. -
getBoundsOfViews
Returns the bounds of a given view list. -
isEventThread
public static boolean isEventThread()Returns whether current thread is event dispatch thread. -
runLater
Run given runnable on event thread. -
runDelayed
Runs given runnable after delay. -
runDelayedCancelPrevious
Invokes the given runnable after delay (cancels unexecuted previous runDelayed if still pending). -
runOnMouseUp
Runs a runnable on next mouse release (assumes mouse is down). -
getId
Returns an identifier string for a given view. -
paintAll
Deprecated.Deprecated - use paintView(). -
paintView
Paints given view. -
paintViewInView
Paints a given view in another view. -
paintViewWithTransform
Paints given view with transform. -
layoutDeep
Layout nodes deep. -
getAlignX
Returns the align x factor. -
getAlignY
Returns the align y factor. -
getAlignX
Returns the align x factor. -
getAlignY
Returns the align y factor. -
getAlignX
Returns the align x factor. -
getAlignY
Returns the align y factor. -
getLeanX
Returns the lean x factor. -
getLeanY
Returns the lean y factor. -
getChildAt
Returns the child of given class hit by coords. -
getChildAt
Returns the child of given class hit by coords. -
getDeepestViewAt
Returns the view or child view hit by given coords, starting at given view. -
getDeepestViewAt
public static <T extends View> T getDeepestViewAt(View aView, double aX, double aY, Class<T> aClass) Returns the view or child view of given class hit by given coords, starting at given view. -
getDeepestChildAt
Returns the deepest child hit by given coords starting with children of given view. -
getDeepestChildAt
public static <T extends View> T getDeepestChildAt(View aView, double aX, double aY, Class<T> aClass) Returns the deepest child of given class hit by given coords starting with children of given view. -
getCommonAncetor
Returns a common ancestor for two nodes. -
bind
Binds a view property to another view's same prop. -
bindExpr
public static void bindExpr(View aView1, String aProp, View aView2, String aProp2, String aKeyChainExpr) Binds a view property to another view prop with given expression. -
setParent
Backdoor for protected View method. -
addChild
Backdoor for protected ParentView method. -
addChild
Backdoor for protected ParentView method. -
removeChild
Backdoor for protected ParentView method. -
removeChild
Backdoor for protected ParentView method. -
moveToFront
Moves given child to end of given parent child list, so it paints in front. -
moveToBack
Moves given child to start of given parent child list, so it paints in back. -
replaceView
Replace given view with new view. -
getImage
Returns an image for a View (at device dpi scale (2 for retina)). -
getImageForScale
Returns an image for a View (1 = 72 dpi, 2 = 144 dpi, 0 = device dpi). -
getImageBoxForScale
Returns an image box for a View (1 = 72 dpi, 2 = 144 dpi, 0 = device dpi). -
beep
public static void beep()Beep. -
enableDragging
Silly feature to make any view draggable. -
setShowing
Backdoor for protected View method. -
setFocused
Backdoor for protected View method. -
processEvent
Backdoor for protected View method. -
enableEvents
Backdoor for protected View method. -
fireActionEvent
Backdoor for protected View method.
-