Package snap.geom

Class Size

java.lang.Object
snap.geom.Size
All Implemented Interfaces:
Cloneable

public class Size extends Object implements Cloneable
A class to represent a simple geometric size.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
     
    double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new Size.
    Size(double aW, double aH)
    Create a new Size.
    Size(Size aSize)
    Create a new Size.
  • Method Summary

    Modifier and Type
    Method
    Description
    Standard clone implementation.
    boolean
    equals(double w, double h)
    Returns whether size is equal to given width and height.
    static boolean
    equals(double x0, double y0, double x1, double y1)
    Standard equals implementation.
    boolean
    equals(Object anObj)
    Standard equals implementation.
    static Size
    get(String aString)
    Creates a size from a string (assumes comma separated).
    double
    Returns the height.
    double
    Returns the square root of the sum of the squares of the width and height.
    double
    Returns the width.
    void
    Simply sets the width and height to their negatives.
    void
    Normalizes the receiver by scaling its width and height such that its magnitude will be 1.
    void
    setHeight(double aValue)
    Sets the height.
    void
    setSize(double aW, double aH)
    Sets the size.
    void
    setWidth(double aValue)
    Sets the width.
    Standard toString implementation.

    Methods inherited from class java.lang.Object

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

    • width

      public double width
    • height

      public double height
  • Constructor Details

    • Size

      public Size()
      Create a new Size.
    • Size

      public Size(double aW, double aH)
      Create a new Size.
    • Size

      public Size(Size aSize)
      Create a new Size.
  • Method Details

    • getWidth

      public double getWidth()
      Returns the width.
    • setWidth

      public void setWidth(double aValue)
      Sets the width.
    • getHeight

      public double getHeight()
      Returns the height.
    • setHeight

      public void setHeight(double aValue)
      Sets the height.
    • setSize

      public void setSize(double aW, double aH)
      Sets the size.
    • getMagnitude

      public double getMagnitude()
      Returns the square root of the sum of the squares of the width and height.
    • normalize

      public void normalize()
      Normalizes the receiver by scaling its width and height such that its magnitude will be 1.
    • negate

      public void negate()
      Simply sets the width and height to their negatives.
    • equals

      public boolean equals(double w, double h)
      Returns whether size is equal to given width and height.
    • clone

      public Size clone()
      Standard clone implementation.
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object
    • equals

      public static boolean equals(double x0, double y0, double x1, double y1)
      Standard equals implementation.
    • get

      public static Size get(String aString)
      Creates a size from a string (assumes comma separated).