Package resources
Class Settings.Region2D
- java.lang.Object
-
- java.awt.geom.RectangularShape
-
- java.awt.geom.Rectangle2D
-
- java.awt.geom.Rectangle2D.Double
-
- resources.Settings.Region2D
-
- All Implemented Interfaces:
java.awt.Shape,java.io.Serializable,java.lang.Cloneable
- Enclosing class:
- Settings
public static class Settings.Region2D extends java.awt.geom.Rectangle2D.DoubleA specializedRectangle2Dthat is more easily converted to or from a setting value.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Region2D()Creates a new region at (0,0) with zero width and height.Region2D(double x, double y, double w, double h)Creates a new region with the specified coordinates and dimensions.Region2D(java.awt.geom.Rectangle2D.Double r)Creates a new region from the specified rectangle.Region2D(java.lang.String settingValue)Creates a new region from a string using the same format as a region setting value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetX2()Returns the x-coordinate of the right edge of the region.doublegetY2()Returns the y-coordinate of the bottom edge of the region.Settings.Region2Dinset(double dx, double dy)Returns a new region that is inset by the specified amount.voidsetX2(double x2)Moves the right edge of the region to the specified x-coordinate by changing the width of the region.voidsetY2(double y2)Moves the bottom edge of the region to the specified y-coordinate by changing the height of the region.Settings.RegiontoRegion()Returns an integer precision region by rounding this region's coordinates and dimensions.java.lang.StringtoString()Returns a string value suitable for storing this region in a setting.-
Methods inherited from class java.awt.geom.Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect
-
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
-
-
-
-
Constructor Detail
-
Region2D
public Region2D(java.lang.String settingValue)
Creates a new region from a string using the same format as a region setting value.- Parameters:
settingValue- the setting value to create a region from
-
Region2D
public Region2D(java.awt.geom.Rectangle2D.Double r)
Creates a new region from the specified rectangle.- Parameters:
r- the rectangle to convert
-
Region2D
public Region2D(double x, double y, double w, double h)Creates a new region with the specified coordinates and dimensions.- Parameters:
x- the x-coordinatey- the y-coordinatew- the region widthh- the region height
-
Region2D
public Region2D()
Creates a new region at (0,0) with zero width and height.
-
-
Method Detail
-
toRegion
public Settings.Region toRegion()
Returns an integer precision region by rounding this region's coordinates and dimensions.- Returns:
- an integer precision region
-
inset
public Settings.Region2D inset(double dx, double dy)
Returns a new region that is inset by the specified amount. For example, if the region is (0,0,10,10) and you callinset(2,2), the result will be (2,2,6,6). Passing a negative value will cause the region to grow. If the region is too small to be inset by the specified amount, the result will have a width or height of zero.- Parameters:
dx- the amount to move the left and right edges inwarddy- the amount to move the top and bottom edges inward- Returns:
- a new region that is inset by the specified amount
-
setX2
public void setX2(double x2)
Moves the right edge of the region to the specified x-coordinate by changing the width of the region.- Parameters:
x2- the new x-coordinate for the right edge
-
getX2
public double getX2()
Returns the x-coordinate of the right edge of the region. Equivalent togetMaxX, but provides consistency withRegion.- Returns:
- the x-coordinate of the right edge
-
setY2
public void setY2(double y2)
Moves the bottom edge of the region to the specified y-coordinate by changing the height of the region.- Parameters:
y2- the new y-coordinate for the bottom edge
-
getY2
public double getY2()
Returns the y-coordinate of the bottom edge of the region. Equivalent togetMaxY, but provides consistency withRegion.- Returns:
- the y-coordinate of the bottom edge
-
toString
public java.lang.String toString()
Returns a string value suitable for storing this region in a setting.- Overrides:
toStringin classjava.awt.geom.Rectangle2D.Double- Returns:
- a regions string with form
x,y,width,height
-
-