Package snap.view

Class ViewUtils

java.lang.Object
snap.view.ViewUtils

public class ViewUtils extends Object
Utility methods for nodes.
  • 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

      public static ViewEvent getMouseDown()
      Returns the last MouseDown event.
    • getBackFill

      public static Paint getBackFill()
      Returns the background fill.
    • getBackDarkFill

      public static Paint getBackDarkFill()
      Returns the background fill.
    • getTextFill

      public static Paint getTextFill()
      Returns the text fill.
    • getSelectFill

      public static Paint getSelectFill()
      Returns the selection color.
    • getSelectTextFill

      public static Paint getSelectTextFill()
      Returns the selection color.
    • getTargetFill

      public static Paint getTargetFill()
      Returns the selection color.
    • getTargetTextFill

      public static Paint getTargetTextFill()
      Returns the selection color.
    • getBoundsOfViews

      public static Rect getBoundsOfViews(View aPar, List<? extends View> aList)
      Returns the bounds of a given view list.
    • runLater

      public static void runLater(Runnable aRun)
      Run given runnable on event thread.
    • runDelayed

      public static void runDelayed(Runnable aRun, int aDelay, boolean inAppThread)
      Runs given runnable after delay.
    • runOnMouseUp

      public static void runOnMouseUp(Runnable aRun)
      Runs a runnable on next mouse release (assumes mouse is down).
    • getId

      public static String getId(View aView)
      Returns an identifier string for a given view.
    • paintAll

      public static void paintAll(View aView, Painter aPntr)
      Paint nodes.
    • layoutDeep

      public static void layoutDeep(View aView)
      Layout nodes deep.
    • getAlignX

      public static double getAlignX(View aView)
      Returns the align x factor.
    • getAlignY

      public static double getAlignY(View aView)
      Returns the align y factor.
    • getAlignX

      public static double getAlignX(Pos aPos)
      Returns the align x factor.
    • getAlignY

      public static double getAlignY(Pos aPos)
      Returns the align y factor.
    • getAlignX

      public static double getAlignX(HPos aPos)
      Returns the align x factor.
    • getAlignY

      public static double getAlignY(VPos aPos)
      Returns the align y factor.
    • getLeanX

      public static double getLeanX(View aView)
      Returns the lean x factor.
    • getLeanY

      public static double getLeanY(View aView)
      Returns the lean y factor.
    • getChildAt

      public static View getChildAt(View aView, double aX, double aY)
      Returns the child of given class hit by coords.
    • getChildAt

      public static <T extends View> T getChildAt(View aView, double aX, double aY, Class<T> aClass)
      Returns the child of given class hit by coords.
    • getDeepestViewAt

      public static View getDeepestViewAt(View aView, double aX, double aY)
      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

      public static View getDeepestChildAt(View aView, double aX, double aY)
      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

      public static View getCommonAncetor(View aView1, View aView2)
      Returns a common ancestor for two nodes.
    • bind

      public static void bind(View aView1, String aProp, View aView2, boolean doBoth)
      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.
    • getFileIconImage

      public static Image getFileIconImage(WebFile aFile)
      Returns the image for a file.
    • setParent

      public static void setParent(View aView, ParentView aParent)
      Backdoor for protected View method.
    • addChild

      public static void addChild(ParentView aPar, View aChild)
      Backdoor for protected ParentView method.
    • addChild

      public static void addChild(ParentView aPar, View aChild, int anIndex)
      Backdoor for protected ParentView method.
    • removeChild

      public static void removeChild(ParentView aPar, View aChild)
      Backdoor for protected ParentView method.
    • removeChild

      public static void removeChild(ParentView aPar, int anIndex)
      Backdoor for protected ParentView method.
    • moveToFront

      public static void moveToFront(ParentView aPar, View aChild)
      Moves given child to end of given parent child list, so it paints in front.
    • moveToBack

      public static void moveToBack(ParentView aPar, View aChild)
      Moves given child to start of given parent child list, so it paints in back.
    • replaceView

      public static void replaceView(View aView, View newView)
      Replace given view with new view.
    • getImage

      public static Image getImage(View aView)
      Returns an image for a View (at device dpi scale (2 for retina)).
    • getImageForScale

      public static Image getImageForScale(View aView, double aScale)
      Returns an image for a View (1 = 72 dpi, 2 = 144 dpi, 0 = device dpi).
    • getImageBoxForScale

      public static ImageBox getImageBoxForScale(View aView, double aScale)
      Returns an image box for a View (1 = 72 dpi, 2 = 144 dpi, 0 = device dpi).
    • beep

      public static void beep()
      Beep.
    • enableDragging

      public static void enableDragging(View aView)
      Silly feature to make any view draggable.
    • setShowing

      public static void setShowing(View aView, boolean aValue)
      Backdoor for protected View method.
    • setFocused

      public static void setFocused(View aView, boolean aValue)
      Backdoor for protected View method.
    • processEvent

      public static void processEvent(View aView, ViewEvent anEvent)
      Backdoor for protected View method.
    • enableEvents

      public static void enableEvents(View aView, ViewEvent.Type... theEvents)
      Backdoor for protected View method.
    • fireActionEvent

      public static void fireActionEvent(View aView, ViewEvent anEvent)
      Backdoor for protected View method.