Record Class ConversionWithOffset

java.lang.Object
java.lang.Record
com.j3d.engine.math.convert.ConversionWithOffset
Record Components:
scale - The scale factor such that a unit length is not a pixel. e.g. a value of 10.0 means a CartesianPoint unit length of 1, is about 10 pixels long.
size - The dimension of the screen which the points belong to. This is used to determine the centre for converting to and between CartesianPoint and knowing the maximum height and length of a ScreenPoint
offset - The offset X and Y components to offset all points by. Generally speaking no conversion requires using offsetting unless they want panning the 2d view.

public record ConversionWithOffset(double scale, Dim size, Offset offset) extends Record
A specialisation of the Conversion record which stores the conversion required to turn a CartesianPoint into a ScreenPoint and vice versa.

Unlike Conversion, this stores an extra field, an Offset field such as to offset all coordinates by a given delta.

Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • scale

      private final double scale
      The field for the scale record component.
    • size

      private final Dim size
      The field for the size record component.
    • offset

      private final Offset offset
      The field for the offset record component.
  • Constructor Details

    • ConversionWithOffset

      public ConversionWithOffset(double scale, Dim size, Offset offset)
      Creates an instance of a ConversionWithOffset record class.
      Parameters:
      scale - the value for the scale record component
      size - the value for the size record component
      offset - the value for the offset record component
  • Method Details

    • from

      public static ConversionWithOffset from(Conversion conversion)
      Converts the given Conversion object into a ConversionWithOffset instance by passing an offset value of Offset.ZERO, which is identical to it's original class as no offset is applied.
      Parameters:
      conversion - The Conversion properties to convert
      Returns:
      A ConversioNWithOffset which is functionally identical to the original
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • scale

      public double scale()
      Returns the value of the scale record component.
      Returns:
      the value of the scale record component
    • size

      public Dim size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • offset

      public Offset offset()
      Returns the value of the offset record component.
      Returns:
      the value of the offset record component