Package org.gnome.gtk
Class Constraint
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.gobject.TypeInstance
org.gnome.gobject.GObject
org.gnome.gtk.Constraint
- All Implemented Interfaces:
Proxy
GtkConstraint
describes a constraint between attributes of two widgets,
expressed as a linear equation.
The typical equation for a constraint is:
target.target_attr = source.source_attr × multiplier + constant
Each GtkConstraint
is part of a system that will be solved by a
ConstraintLayout
in order to allocate and position each
child widget or guide.
The source and target, as well as their attributes, of a GtkConstraint
instance are immutable after creation.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Constraint.Builder<B extends Constraint.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionConstraint
(MemorySegment address) Create a Constraint proxy instance for the provided memory address.Constraint
(@Nullable ConstraintTarget target, ConstraintAttribute targetAttribute, ConstraintRelation relation, @Nullable ConstraintTarget source, ConstraintAttribute sourceAttribute, double multiplier, double constant, int strength) Creates a new constraint representing a relation between a layout attribute on a source and a layout attribute on a target. -
Method Summary
Modifier and TypeMethodDescriptionprotected Constraint
asParent()
Returns this instance as if it were its parent type.static Constraint.Builder
<? extends Constraint.Builder> builder()
AConstraint.Builder
object constructs aConstraint
with the specified properties.static Constraint
constant
(@Nullable ConstraintTarget target, ConstraintAttribute targetAttribute, ConstraintRelation relation, double constant, int strength) Creates a new constraint representing a relation between a layout attribute on a target and a constant value.double
Retrieves the constant factor added to the source attributes' value.double
Retrieves the multiplication factor applied to the source attribute's value.The order relation between the terms of the constraint.Retrieves theConstraintTarget
used as the source for the constraint.Retrieves the attribute of the source to be read by the constraint.int
Retrieves the strength of the constraint.Retrieves theConstraintTarget
used as the target for the constraint.Retrieves the attribute of the target to be set by the constraint.static Type
getType()
Get the GType of the Constraint classboolean
Checks whether the constraint is attached to aConstraintLayout
, and it is contributing to the layout.boolean
Checks whether the constraint describes a relation between an attribute on theGtk.Constraint:target
and a constant value.boolean
Checks whether the constraint is a required relation for solving the constraint layout.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Constraint
Create a Constraint proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Constraint
public Constraint(@Nullable @Nullable ConstraintTarget target, ConstraintAttribute targetAttribute, ConstraintRelation relation, @Nullable @Nullable ConstraintTarget source, ConstraintAttribute sourceAttribute, double multiplier, double constant, int strength) Creates a new constraint representing a relation between a layout attribute on a source and a layout attribute on a target.- Parameters:
target
- the target of the constrainttargetAttribute
- the attribute oftarget
to be setrelation
- the relation equivalence betweentarget_attribute
andsource_attribute
source
- the source of the constraintsourceAttribute
- the attribute ofsource
to be readmultiplier
- a multiplication factor to be applied tosource_attribute
constant
- a constant factor to be added tosource_attribute
strength
- the strength of the constraint
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
constant
public static Constraint constant(@Nullable @Nullable ConstraintTarget target, ConstraintAttribute targetAttribute, ConstraintRelation relation, double constant, int strength) Creates a new constraint representing a relation between a layout attribute on a target and a constant value.- Parameters:
target
- a the target of the constrainttargetAttribute
- the attribute oftarget
to be setrelation
- the relation equivalence betweentarget_attribute
andconstant
constant
- a constant factor to be set ontarget_attribute
strength
- the strength of the constraint- Returns:
- the newly created constraint
-
getConstant
public double getConstant()Retrieves the constant factor added to the source attributes' value.- Returns:
- a constant factor
-
getMultiplier
public double getMultiplier()Retrieves the multiplication factor applied to the source attribute's value.- Returns:
- a multiplication factor
-
getRelation
The order relation between the terms of the constraint.- Returns:
- a relation type
-
getSource
Retrieves theConstraintTarget
used as the source for the constraint.If the source is set to
NULL
at creation, the constraint will use the widget using theConstraintLayout
as the source.- Returns:
- the source of the constraint
-
getSourceAttribute
Retrieves the attribute of the source to be read by the constraint.- Returns:
- the source's attribute
-
getStrength
public int getStrength()Retrieves the strength of the constraint.- Returns:
- the strength value
-
getTarget
Retrieves theConstraintTarget
used as the target for the constraint.If the targe is set to
NULL
at creation, the constraint will use the widget using theConstraintLayout
as the target.- Returns:
- a
GtkConstraintTarget
-
getTargetAttribute
Retrieves the attribute of the target to be set by the constraint.- Returns:
- the target's attribute
-
isAttached
public boolean isAttached()Checks whether the constraint is attached to aConstraintLayout
, and it is contributing to the layout.- Returns:
TRUE
if the constraint is attached
-
isConstant
public boolean isConstant()Checks whether the constraint describes a relation between an attribute on theGtk.Constraint:target
and a constant value.- Returns:
TRUE
if the constraint is a constant relation
-
isRequired
public boolean isRequired()Checks whether the constraint is a required relation for solving the constraint layout.- Returns:
true
if the constraint is required
-
builder
AConstraint.Builder
object constructs aConstraint
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withConstraint.Builder.build()
.
-