Class Insets

java.lang.Object
org.eclipse.draw2d.geometry.Insets
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
IFigure.NoInsets

public class Insets extends Object implements Cloneable, Serializable
Stores four integers for top, left, bottom, and right measurements.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    distance from bottom
    int
    distance from left
    int
    distance from right
    int
    distance from top
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an Insets with all zeroes.
    Insets(int i)
    Constructs a new Insets with all the sides set to the speicifed value.
    Insets(int top, int left, int bottom, int right)
    Creates a new Insets with the specified top, left, bottom, and right values.
    Constructs a new Insets with initial values the same as the provided Insets.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Insets insets)
    Adds the values of the specified Insets to this Insets' values.
    boolean
    Test for equality.
    getAdded(Insets insets)
    Creates an Insets representing the sum of this Insets with the specified Insets.
    int
    Returns the height for this Insets, equal to top + bottom.
    Creates a new Insets with negated values.
    Creates a new Insets with transposed values.
    int
    Returns the width for this Insets, equal to left + right.
    int
     
    boolean
    Returns true if all values are 0.
    static Insets
    min(Insets insets_1, Insets insets_2)
    Creates a new minimal Insets using the distances of the given arguments.
     
    Transposes this object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • left

      public int left
      distance from left
    • top

      public int top
      distance from top
    • bottom

      public int bottom
      distance from bottom
  • Constructor Details

    • Insets

      public Insets()
      Constructs an Insets with all zeroes.
      Since:
      2.0
    • Insets

      public Insets(Insets i)
      Constructs a new Insets with initial values the same as the provided Insets.
      Parameters:
      i - The insets to copy.
      Since:
      2.0
    • Insets

      public Insets(int i)
      Constructs a new Insets with all the sides set to the speicifed value.
      Parameters:
      i - Value applied to all sides of new Insets.
      Since:
      2.0
    • Insets

      public Insets(int top, int left, int bottom, int right)
      Creates a new Insets with the specified top, left, bottom, and right values.
      Parameters:
      top - Value of the top space.
      left - Value of the left space.
      bottom - Value of the bottom space.
      right - Value of the right space.
      Since:
      2.0
  • Method Details

    • add

      public Insets add(Insets insets)
      Adds the values of the specified Insets to this Insets' values.
      Parameters:
      insets - the Insets being added
      Returns:
      this for convenience
      Since:
      2.0
    • equals

      public boolean equals(Object o)
      Test for equality. The Insets are equal if their top, left, bottom, and right values are equivalent.
      Overrides:
      equals in class Object
      Parameters:
      o - Object being tested for equality.
      Returns:
      true if all values are the same.
      Since:
      2.0
    • getAdded

      public Insets getAdded(Insets insets)
      Creates an Insets representing the sum of this Insets with the specified Insets.
      Parameters:
      insets - Insets to be added
      Returns:
      A new Insets
      Since:
      2.0
    • getHeight

      public int getHeight()
      Returns the height for this Insets, equal to top + bottom.
      Returns:
      The sum of top + bottom
      Since:
      2.0
      See Also:
    • getTransposed

      public Insets getTransposed()
      Creates a new Insets with transposed values. Top and Left are transposed. Bottom and Right are transposed.
      Returns:
      New Insets with the transposed values.
      Since:
      2.0
    • getNegated

      public Insets getNegated()
      Creates a new Insets with negated values. Top, Left, Bottom and Right are multiplied by -1
      Returns:
      The negate of this Insets
      Since:
      3.13
    • getWidth

      public int getWidth()
      Returns the width for this Insets, equal to left + right.
      Returns:
      The sum of left + right
      Since:
      2.0
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • isEmpty

      public boolean isEmpty()
      Returns true if all values are 0.
      Returns:
      true if all values are 0
      Since:
      2.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      String representation.
      Since:
      2.0
    • transpose

      public Insets transpose()
      Transposes this object. Top and Left are exchanged. Bottom and Right are exchanged. Can be used in orientation changes.
      Returns:
      this for convenience
      Since:
      2.0
    • min

      public static Insets min(Insets insets_1, Insets insets_2)
      Creates a new minimal Insets using the distances of the given arguments. The Top, Left, Bottom and Right computes using the minimum of the respective distances.
      Parameters:
      insets_1 - The first Insets.
      insets_2 - The second Insets.
      Returns:
      the minimal Insets (minimum for each side) from two given Insets.
      Since:
      3.13