Class GUIQuery
java.lang.Object
com.blackrook.gui.GUIQuery
-
Method Summary
Modifier and TypeMethodDescriptionAdds a name (or several) to the objects in this query.animate(long cumulativeDelay, long duration, GUIAnimation... animations) Enqueues an animation on this GUI Object, linear transition, and with a cumulative delay added to each object.animate(long cumulativeDelay, long duration, GUIEasingType transition, GUIAnimation... animations) Enqueues an animation on this GUI Object, and with a cumulative delay added to each object.animate(long duration, GUIAnimation... animations) Enqueues an animation on this GUI Object, linear transition.animate(long duration, GUIEasingType transition, GUIAnimation... animations) Enqueues an animation on this GUI Object.animate(GUIAnimation... animations) Enqueues an animation on this GUI Object, no duration.Aborts the animation on this object, abandoning it mid-animation.animateDelay(long duration) Enqueues a delay between animations on this GUI Object.Finishes the animation on this object all the way to the end.bindAction(GUIAction action, String... types) Binds an action of a particular type to the objects inside this query.callAction(GUIAction action) Calls an action on the objects inside the query.copy()Copies this query, returning a new query with the same objects.get(int index) Gets an object in this query wrapped in a query.Gets the object absolute bounds on the first object in this query result.floatgetAlpha()Gets the alpha color component of the first object in this query result.Gets a new query result containing objects that are currently animating.floatgetBlue()Gets the blue color component of the first object in this query result.Gets the object bounds on the first object in this query result.getByAttrib(Object layoutAttribute) Gets a new query result of all objects in the query with a specific layout attribute.Gets all GUI Objects that match all of the names provided in this query.getByPattern(Pattern pattern) Gets all GUI Objects with a matching name regex pattern in this query.Gets a new query result of all objects in the query with the same class.Gets all children of all of the objects in this query.getColor()Gets the color on the first object in this query result.Gets all descendants of all of the objects in this query.getDifference(GUIQuery query) Creates a new query result that is the objects in this query minus the ones present in another.getEvens()Gets each even-indexed object in this query as a new query.getEveryMultiple(int n) Gets every n-th object in this query as a new query.getFirst()Returns the first object in this query wrapped in a query.floatgetGreen()Gets the green color component of the first object in this query result.getHavingToggleState(boolean state) Gets a new query result containing objects with a matching toggle state.getIntersection(GUIQuery query) Creates a new query result that is the intersection of two queries (both objects must exist in this query and the other to be included).getLast()Returns the last object in this query wrapped in a query.getObject(int index) Gets an GUIObject in this query.getOdds()Gets each odd-indexed object in this query as a new query.getOffsetAndModulo(int offset, int modulo) Gets every object at the index pattern specified in this query as a new query.floatGets the opacity on the first object in this query result.Gets all parents of all of the objects in this query.Gets a new query result that is a random sub-selection of objects in this query.getRandomAmount(Random random, int objects) Gets a new query result that is a random sub-selection of a specific amount of objects in this query.getRandomSample(Random random, float chance) Gets a new query result that is a random sub-selection of objects in this query, weighted by a chance to select each one.floatgetRed()Gets the red color component of the first object in this query result.Gets all siblings of all of the objects in this query.getSubQuery(int startIndex, int endIndex) Gets a sublist of this query result as another query.getText()Gets the text on the first object in this query result, or null if the object is not a GUILabel type.Gets the texture on the first object in this query result.getTheme()Gets the theme on the first object in the query result.Gets the current theme key on the first object in the query.Creates a new query result that is the union of two queries.getValue()Gets the value on the first object in this query result, or null if the object is not a GUIValueField type.Gets a new query result containing objects that are visible.Creates a new query result that is the union of the objects in this query and another, minus the ones present in both.booleanisEmpty()booleanGets if the first object in the result can accept input.booleanisSet()Gets if the toggle state on the first object in this query result is "set," or false if the object is not an GUIToggleable type.booleanGets if the first object in the result is visible.iterator()Requests release of focus on all of the objects in the query.removeName(String... names) Removes a name (or several) from the objects in this query.Requests focus on the first object in the query.rotate(float rotation) Rotates this object by an amount of degrees on all objects in this query result.setBounds(float x, float y, float width, float height) Sets the object bounds on all objects in this query result.setColor(float red, float green, float blue, float alpha) Sets the color on all objects in this query result.Sets the color on all objects in this query result.setDimensions(float width, float height) Sets the object width and height on all objects in this query result.setEnabled(boolean enabled) Sets if the object can accept input on all objects in this query result.setOpacity(float opacity) Sets the opacity on all objects in this query result.setPosition(float x, float y) Sets the object position on all objects in this query result.setRotationZ(float rotation) Sets this object's rotation in degrees on all objects in this query result.setState(boolean state) Sets the state of all objects in this query result.Sets the text of all objects in this query result.setTexture(String texture) Sets this object's texture on all objects in this query result.Sets the theme on all objects in this query result.Sets the value on all objects in this query result.setVisible(boolean visible) Sets if the object is visible on all objects in this query result.Randomizes the order of the objects in this query.intsize()stretch(float width, float height) Changes this object's width/height by an x or y-coordinate amount on all objects in this query result.toggle()Toggles the state of all objects in this query result.toString()translate(float x, float y) Changes this object's position by an x or y-coordinate amount on all objects in this query result.unbindAction(GUIAction action, String... types) Unbinds an action of a particular type from the objects inside this query.unbindAllActions(String type) Unbinds all actions of a particular type from the objects inside this query.static GUIQueryWraps a set of objects in a new query, where its contents consist of the provided objects, in the same order.static GUIQueryWraps a set of objects in a new query, where its contents consist of the provided objects, in the same order.static GUIQueryWraps a set of objects in a new query, where its contents consist of the provided objects, in the same order.static GUIQueryWraps a set of objects in a new query, where its contents consist of the provided objects, in the same order.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
size
public int size()- Returns:
- the amount of objects in this query.
-
isEmpty
public boolean isEmpty()- Returns:
- true if there are no objects in this query, false if one or more.
-
iterator
-
wrap
-
wrap
-
wrap
-
wrap
-
copy
Copies this query, returning a new query with the same objects.- Returns:
- a new query.
-
get
Gets an object in this query wrapped in a query. The order of the objects in the query is the order in which they were added.- Parameters:
index- the index of the desired object.- Returns:
- a new query result that is the desired object.
-
getObject
Gets an GUIObject in this query. The order of the objects in the query is the order in which they were added.- Parameters:
index- the index of the desired object.- Returns:
- the GUIObject at the desired index, or null if no object at that index.
-
getEveryMultiple
Gets every n-th object in this query as a new query. For example, ifnis 3, this returns every multiple-of-3-indexed object. Conveience method forgetOffsetAndModulo(0, n).- Parameters:
n- the multiple stepping.- Returns:
- a new query result.
-
getEvens
Gets each even-indexed object in this query as a new query. Conveience method forgetOffsetAndModulo(0, 2).- Returns:
- a new query result.
-
getOdds
Gets each odd-indexed object in this query as a new query. Conveience method forgetOffsetAndModulo(1, 2).- Returns:
- a new query result.
-
getOffsetAndModulo
Gets every object at the index pattern specified in this query as a new query. For example, ifoffsetis 1 andstepis 3, this returns every 3rd object shifted after the first object.- Parameters:
offset- the starting offset.modulo- the modulo after the offset.- Returns:
- a new query result.
-
getFirst
Returns the first object in this query wrapped in a query. Convenience method forget(0). If there are no objects in this query, it will return an empty query.- Returns:
- a new query result with the first object in this query.
-
getLast
Returns the last object in this query wrapped in a query. Convenience method forget(size()-1).- Returns:
- a new query result with the last object in this query.
-
getByName
-
getByPattern
-
getByType
-
getByAttrib
-
getAnimating
Gets a new query result containing objects that are currently animating.- Returns:
- a new query result that has objects that are in an animation.
-
getChildren
Gets all children of all of the objects in this query.- Returns:
- a new query result.
-
getDescendants
Gets all descendants of all of the objects in this query.- Returns:
- a new query result.
-
getSiblings
Gets all siblings of all of the objects in this query. Does not get siblings of objects without parents.- Returns:
- a new query result.
-
getParents
Gets all parents of all of the objects in this query.- Returns:
- a new query result.
-
getUnion
-
getIntersection
Creates a new query result that is the intersection of two queries (both objects must exist in this query and the other to be included).- Parameters:
query- the query to intersect with this one.- Returns:
- a new query result consisting of objects that are in both queries.
-
getDifference
-
getXOr
Creates a new query result that is the union of the objects in this query and another, minus the ones present in both. The is essentially the union minus the intersection.- Parameters:
query- the query to XOR with this one.- Returns:
- a new query result with objects in this query and the provided one, but not both.
-
getSubQuery
Gets a sublist of this query result as another query.- Parameters:
startIndex- the starting index of this query, INCLUSIVE.endIndex- the ending index, EXCLUSIVE. If this is past the end of the query, this issize().- Returns:
- a new query result that is a sublist of the objects in this result.
-
getRandom
-
getRandomSample
Gets a new query result that is a random sub-selection of objects in this query, weighted by a chance to select each one.- Parameters:
random- the random number generator to use.chance- the random chance factor. if 0 or less, picks nothing. if 1 or greater, picks EVERYTHING. No random numbers are generated in these cases.- Returns:
- a new query result that is a random sub-selection of objects in this query.
-
getRandomAmount
Gets a new query result that is a random sub-selection of a specific amount of objects in this query.- Parameters:
random- the random number generator to use.objects- the number of objects to pick at random.- Returns:
- a new query result that is a random sub-selection of objects
in this query, with size
objects.
-
getHavingToggleState
Gets a new query result containing objects with a matching toggle state. Only works on GUIToggleable objects.- Parameters:
state- the set state to test for.- Returns:
- a new query result that has objects with a matching toggle state.
-
getVisible
Gets a new query result containing objects that are visible.- Returns:
- a new query result that has objects that are visible.
- See Also:
-
shuffle
-
requestFocus
Requests focus on the first object in the query. If the set is empty, this does nothing.- Returns:
- itself, in order to chain queries.
-
releaseFocus
Requests release of focus on all of the objects in the query. Only one object at a time can be focused, so this will actually unfocus at most one object in the query set.- Returns:
- itself, in order to chain queries.
-
setEnabled
Sets if the object can accept input on all objects in this query result.- Parameters:
enabled- true to enable, false to disable.- Returns:
- itself, in order to chain queries.
-
isEnabled
public boolean isEnabled()Gets if the first object in the result can accept input. Note that this can be affected by parents in the object's lineage. If the set is empty, this returns false.- Returns:
- true if so, false otherwise.
- See Also:
-
setVisible
Sets if the object is visible on all objects in this query result.- Parameters:
visible- true to set visible, false to not.- Returns:
- itself, in order to chain queries.
-
isVisible
public boolean isVisible()Gets if the first object in the result is visible. Note that this can be affected by parents in the object's lineage. If the set is empty, this returns false.- Returns:
- true if so, false otherwise.
- See Also:
-
setTheme
-
getTheme
Gets the theme on the first object in the query result. Note that this can be affected by the GUI that the object is attached to. If the set is empty, this returns null.- Returns:
- the attached theme or null if no theme.
- See Also:
-
getThemeKey
Gets the current theme key on the first object in the query. If the set is empty, this returns null.- Returns:
- the key name or null if no key is set.
- See Also:
-
setTexture
-
getTexture
Gets the texture on the first object in this query result. If the set is empty, this returns null.- Returns:
- the set texture or null if no texture is set.
-
setColor
Sets the color on all objects in this query result.- Parameters:
red- the red component value for the color.green- the green component value for the color.blue- the blue component value for the color.alpha- the alpha component value for the color.- Returns:
- itself, in order to chain queries.
-
setColor
-
getColor
Gets the color on the first object in this query result. If the set is empty, this returns null.- Returns:
- the color.
-
getRed
public float getRed()Gets the red color component of the first object in this query result. This color is a calculated color - it is affected by its parent's color components. If the set is empty, this returns 0.- Returns:
- the red color component.
- See Also:
-
getGreen
public float getGreen()Gets the green color component of the first object in this query result. This color is a calculated color - it is affected by its parent's color components. If the set is empty, this returns 0.- Returns:
- the green color component.
- See Also:
-
getBlue
public float getBlue()Gets the blue color component of the first object in this query result. This color is a calculated color - it is affected by its parent's color components. If the set is empty, this returns 0.- Returns:
- the blue color component.
- See Also:
-
getAlpha
public float getAlpha()Gets the alpha color component of the first object in this query result. This color is a calculated color - it is affected by its parent's color components. If the set is empty, this returns 0.- Returns:
- the alpha color component.
- See Also:
-
setOpacity
Sets the opacity on all objects in this query result.- Parameters:
opacity- the opacity to set.- Returns:
- itself, in order to chain queries.
-
getOpacity
public float getOpacity()Gets the opacity on the first object in this query result. If the set is empty, this returns 0.- Returns:
- the object's opacity value.
-
setBounds
Sets the object bounds on all objects in this query result.- Parameters:
x- its position x.y- its position y.width- its width.height- its height.- Returns:
- itself, in order to chain queries.
-
getBounds
Gets the object bounds on the first object in this query result. If the set is empty, this returns null.- Returns:
- a GUIBounds containing the object bounds. If the contents of the GUIBounds change, it will not affect the object.
-
getAbsoluteBounds
Gets the object absolute bounds on the first object in this query result. If the set is empty, this returns null.- Returns:
- a GUIBounds containing the object bounds. If the contents of the GUIBounds change, it will not affect the object.
-
setPosition
Sets the object position on all objects in this query result.- Parameters:
x- its position x.y- its position y.- Returns:
- itself, in order to chain queries.
-
setDimensions
Sets the object width and height on all objects in this query result.- Parameters:
width- its width.height- its height.- Returns:
- itself, in order to chain queries.
-
translate
Changes this object's position by an x or y-coordinate amount on all objects in this query result.- Parameters:
x- the x movement.y- the y movement.- Returns:
- itself, in order to chain queries.
-
stretch
Changes this object's width/height by an x or y-coordinate amount on all objects in this query result.- Parameters:
width- the width amount.height- the height amount.- Returns:
- itself, in order to chain queries.
-
setText
-
getText
Gets the text on the first object in this query result, or null if the object is not a GUILabel type. If the set is empty, this returns null.- Returns:
- the text as a String.
-
setValue
Sets the value on all objects in this query result. Only works onGUIValueFieldobjects.- Parameters:
value- the value to set.- Returns:
- itself, in order to chain queries.
-
getValue
Gets the value on the first object in this query result, or null if the object is not a GUIValueField type. If the set is empty, this returns null.- Returns:
- the text as a String.
-
toggle
Toggles the state of all objects in this query result. Only works onGUIToggleableobjects.- Returns:
- itself, in order to chain queries.
-
setState
Sets the state of all objects in this query result. Only operates onGUIToggleableobjects.- Parameters:
state- the new toggle state.- Returns:
- itself, in order to chain queries.
-
isSet
public boolean isSet()Gets if the toggle state on the first object in this query result is "set," or false if the object is not an GUIToggleable type. If the set is empty, this returns false.- Returns:
- if the toggleable is set or false otherwise.
- See Also:
-
setRotationZ
Sets this object's rotation in degrees on all objects in this query result.- Parameters:
rotation- the rotation to set.- Returns:
- itself, in order to chain queries.
-
rotate
Rotates this object by an amount of degrees on all objects in this query result.- Parameters:
rotation- the rotation to add.- Returns:
- itself, in order to chain queries.
-
addName
-
removeName
-
animate
Enqueues an animation on this GUI Object, no duration.- Parameters:
animations- the animations to perform (at once) for this animation.- Returns:
- itself, in order to chain queries.
-
animate
Enqueues an animation on this GUI Object, linear transition.- Parameters:
duration- the duration of the action in time units.animations- the animations to perform (at once) for this animation.- Returns:
- itself, in order to chain queries.
-
animate
Enqueues an animation on this GUI Object.- Parameters:
duration- the duration of the action in time units.transition- the transition type for the action.animations- the animations to perform (at once) for this animation.- Returns:
- itself, in order to chain queries.
-
animate
Enqueues an animation on this GUI Object, linear transition, and with a cumulative delay added to each object.For example, if
cumulativeDelayis 200, then the first object will receive 0 delay, but the next will receive 200ms, then the next will get 400ms, then the next 600ms, and so on.- Parameters:
cumulativeDelay- the cumulative delay to add to each object beyond the first.duration- the duration of the action in time units.animations- the animations to perform (at once) for this animation.- Returns:
- itself, in order to chain queries.
-
animate
public GUIQuery animate(long cumulativeDelay, long duration, GUIEasingType transition, GUIAnimation... animations) Enqueues an animation on this GUI Object, and with a cumulative delay added to each object.For example, if
cumulativeDelayis 200, then the first object will receive 0 delay, but the next will receive 200ms, then the next will get 400ms, then the next 600ms, and so on.- Parameters:
cumulativeDelay- the cumulative delay to add to each object beyond the first.duration- the duration of the action in time units.transition- the transition type for the action.animations- the animations to perform (at once) for this animation.- Returns:
- itself, in order to chain queries.
-
animateDelay
Enqueues a delay between animations on this GUI Object.- Parameters:
duration- the duration of the action in time units.- Returns:
- itself, in order to chain queries.
-
animateAbort
Aborts the animation on this object, abandoning it mid-animation.- Returns:
- itself, in order to chain queries.
-
animateFinish
Finishes the animation on this object all the way to the end.- Returns:
- itself, in order to chain queries.
-
bindAction
-
unbindAction
-
unbindAllActions
-
callAction
-
toString
-