Package com.metsci.glimpse.core.context
Class TargetStackUtil
- java.lang.Object
-
- com.metsci.glimpse.core.context.TargetStackUtil
-
public class TargetStackUtil extends Object
Utility method for manipulating
GlimpseTargetStackinstances.In order to uniquely name a GlimpseLayout, the stack containing the GlimpseLayout and all of its parent layouts down to the underlying GlimpseCanvas must be provided (because the GlimpseLayout may be reused and could have multiple parents).
- Author:
- ulman
-
-
Constructor Summary
Constructors Constructor Description TargetStackUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancontains(GlimpseTargetStack query, GlimpseTarget target)Returns true if the query target stack contains the provided target.static booleanendsWith(GlimpseTargetStack query, GlimpseTargetStack suffix)Returns true if the query stack ends with the sequence of GlimpseTargets defined by the prefix stack.static booleanintersects(GlimpseTargetStack query1, GlimpseTargetStack query2)static GlimpseTargetStacknewTargetStack(GlimpseTarget... targets)Creates a new target stack which is the concatenation of the provided GlimpseTargets.static GlimpseTargetStacknewTargetStack(GlimpseTargetStack stack)Creates a new GlimpseTargetStack which is an exact copy of the given stack.static GlimpseTargetStacknewUnmodifiableTargetStack(GlimpseTargetStack stack)Creates a new GlimpseTargetStack which is an exact copy of the given stack and is unmodifiable.static GlimpseTargetStackpopTo(GlimpseTargetStack stack, GlimpseTarget target)static GlimpseTargetStackpushToBottom(GlimpseTargetStack stack, int x, int y)static booleanstartsWith(GlimpseTargetStack query, GlimpseTargetStack prefix)Returns true if the query stack starts with the sequence of GlimpseTargets defined by the prefix stack.static GlimpseMouseEventtranslateCoordinates(GlimpseMouseEvent event, GlimpseTarget target)
-
-
-
Method Detail
-
newTargetStack
public static GlimpseTargetStack newTargetStack(GlimpseTargetStack stack)
Creates a new GlimpseTargetStack which is an exact copy of the given stack.- Parameters:
stack- the stack to copy- Returns:
- a deep copy of the provided stack
-
newUnmodifiableTargetStack
public static GlimpseTargetStack newUnmodifiableTargetStack(GlimpseTargetStack stack)
Creates a new GlimpseTargetStack which is an exact copy of the given stack and is unmodifiable.- Parameters:
stack- the stack to copy- Returns:
- a deep copy of the provided stack
-
newTargetStack
public static GlimpseTargetStack newTargetStack(GlimpseTarget... targets)
Creates a new target stack which is the concatenation of the provided GlimpseTargets. The first provided GlimpseTarget is placed at the bottom of the new GlimpseTargetStack.- Parameters:
targets- the GlimpseTargets to concatenate- Returns:
- the newly constructed GlimpseTargetStack
-
endsWith
public static boolean endsWith(GlimpseTargetStack query, GlimpseTargetStack suffix)
Returns true if the query stack ends with the sequence of GlimpseTargets defined by the prefix stack. Ignores the GlimpseBounds.- Parameters:
query- the GlimpseTargetStack to investigatesuffix- a GlimpseTargetStack to search for at the end of the query stack- Returns:
- whether the query stack ends with the GlimpseTargets in the prefix stack
-
contains
public static boolean contains(GlimpseTargetStack query, GlimpseTarget target)
Returns true if the query target stack contains the provided target.- Parameters:
query- the GlimpseTargetStack to investigatetarget- the GlimpseTarget to look for in the query stack- Returns:
- true if the query stack contains the target
-
intersects
public static boolean intersects(GlimpseTargetStack query1, GlimpseTargetStack query2)
- Returns:
- true if either target stack contain a GlimpseTarget in common
-
startsWith
public static boolean startsWith(GlimpseTargetStack query, GlimpseTargetStack prefix)
Returns true if the query stack starts with the sequence of GlimpseTargets defined by the prefix stack. Ignores the GlimpseBounds.- Parameters:
query- the GlimpseTargetStack to investigateprefix- a GlimpseTargetStack to search for at the start of the query stack- Returns:
- whether the query stack starts with the GlimpseTargets in the prefix stack
-
popTo
public static GlimpseTargetStack popTo(GlimpseTargetStack stack, GlimpseTarget target)
-
pushToBottom
public static GlimpseTargetStack pushToBottom(GlimpseTargetStack stack, int x, int y)
-
translateCoordinates
public static GlimpseMouseEvent translateCoordinates(GlimpseMouseEvent event, GlimpseTarget target)
-
-