Class ConstraintImpl<T extends ConstraintImpl<?>>

java.lang.Object
codechicken.lib.gui.modular.lib.geometry.ConstraintImpl<T>
All Implemented Interfaces:
Constraint
Direct Known Subclasses:
ConstraintImpl.Between, ConstraintImpl.BetweenDynamic, ConstraintImpl.Dynamic, ConstraintImpl.Literal, ConstraintImpl.MidPoint, ConstraintImpl.MidPointDynamic, ConstraintImpl.Relative, ConstraintImpl.RelativeDynamic

public abstract non-sealed class ConstraintImpl<T extends ConstraintImpl<?>> extends Object implements Constraint
Created by brandon3055 on 04/07/2023
  • Field Details

    • precise

      protected boolean precise
    • axis

      protected Axis axis
  • Constructor Details

    • ConstraintImpl

      public ConstraintImpl()
  • Method Details

    • isPrecise

      public boolean isPrecise()
      Returns:
      True if precise mode is enabled.
      See Also:
    • precise

      public T precise()
      By default, all constraint values are cast to (int). This helps avoid a lot of visual artifacts that can occur when using floating point positions in MC Screens.

      Calling this enables precise mode, which allows floating point precision to be used.

      Returns:
      The Constraint.
    • get

      public double get()
      Description copied from interface: Constraint
      This method will return the current value of this constraint. This could be a fixed stored value, or a dynamically computed value depending on the type of constraint.

      All position and size values in ModularGui are doubles. However, by default, all the builtin constraints will cast their outputs to integer values. This avoids a lot of random visual artifacts that can occur when using floating point values in MC Screens.

      If you need floating-point precision, it can be enabled calling .precise() on any of the builtin constraints.

      Specified by:
      get in interface Constraint
      Returns:
      The computed or stored value of this constraint.
    • axis

      @Nullable public @Nullable Axis axis()
      Specified by:
      axis in interface Constraint
      Returns:
      the axis this constraint applies to, Ether X, Y or null for undefined.
    • setAxis

      public T setAxis(@Nullable @Nullable Axis axis)
    • markDirty

      public void markDirty()
      Description copied from interface: Constraint
      This is part of a late addition to improve performance. Rather than computing a constraint value every single time it is queried, which can be many, many times per render frame, We now cache the constraint value, and that cache is cleared at the start of each render frame.
      Specified by:
      markDirty in interface Constraint
    • getImpl

      protected abstract double getImpl()