Package org.gnome.gtk
Class Constraint
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.gobject.TypeInstance
org.gnome.gobject.GObject
org.gnome.gtk.Constraint
- All Implemented Interfaces:
Proxy
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
Nested ClassesModifier and TypeClassDescriptionstatic classConstraint.Builder<B extends Constraint.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Constraint.Constraint(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 ConstraintasParent()Returns this instance as if it were its parent type.static Constraint.Builder<? extends Constraint.Builder> builder()AConstraint.Builderobject constructs aConstraintwith the specified properties.static Constraintconstant(@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.doubleRetrieves the constant factor added to the source attributes' value.doubleRetrieves the multiplication factor applied to the source attribute's value.The order relation between the terms of the constraint.@Nullable ConstraintTargetRetrieves theConstraintTargetused as the source for the constraint.Retrieves the attribute of the source to be read by the constraint.intRetrieves the strength of the constraint.@Nullable ConstraintTargetRetrieves theConstraintTargetused as the target for the constraint.Retrieves the attribute of the target to be set by the constraint.static @Nullable TypegetType()Get the GType of the Constraint classbooleanChecks whether the constraint is attached to aConstraintLayout, and it is contributing to the layout.booleanChecks whether the constraint describes a relation between an attribute on theGtk.Constraint:targetand a constant value.booleanChecks 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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 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.- Parameters:
target- the target of the constrainttargetAttribute- the attribute oftargetto be setrelation- the relation equivalence betweentarget_attributeandsource_attributesource- the source of the constraintsourceAttribute- the attribute ofsourceto be readmultiplier- a multiplication factor to be applied tosource_attributeconstant- a constant factor to be added tosource_attributestrength- the strength of the constraint
-
Constraint
public Constraint()Creates a new Constraint.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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 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 oftargetto be setrelation- the relation equivalence betweentarget_attributeandconstantconstant- a constant factor to be set ontarget_attributestrength- 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 theConstraintTargetused as the source for the constraint.If the source is set to
NULLat creation, the constraint will use the widget using theConstraintLayoutas 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 theConstraintTargetused as the target for the constraint.If the targe is set to
NULLat creation, the constraint will use the widget using theConstraintLayoutas 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:
TRUEif the constraint is attached
-
isConstant
public boolean isConstant()Checks whether the constraint describes a relation between an attribute on theGtk.Constraint:targetand a constant value.- Returns:
TRUEif the constraint is a constant relation
-
isRequired
public boolean isRequired()Checks whether the constraint is a required relation for solving the constraint layout.- Returns:
trueif the constraint is required
-
builder
AConstraint.Builderobject constructs aConstraintwith the specified properties. Use the variousset...()methods to set properties, and finish construction withConstraint.Builder.build().- Returns:
- the builder object
-