|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.schwarzrot.util.GeometricCalculator
public class GeometricCalculator
helper class to support intersection shapes between rectangle and circle and
offers calls around circle calculations, as well as line calculations.
Rectangle is the base, which can be intersected/subtracted by circles. First
use-case is a sun in a rectangle surrounded by shapes that symbolize the
shafts of sunlight. This use-case is supported by calcQuadrant
, which
determines the quadrant of the circles center and based on the quadrant the
maximum angles for the shafts of sunlights. Base of calculation is the inner
rectangle taking into account the different padding settings.
Additionally the class offers helper functions, that calculate a circle dot or a border dot - based on given angle. All angles for calculations must be in radians.
Field Summary | |
---|---|
protected static double |
DELTA_FACTOR
|
Constructor Summary | |
---|---|
GeometricCalculator(int width,
int height,
int xCenter,
int yCenter,
int radius)
constructor to create a geometric calculator |
|
GeometricCalculator(PageProperties pp)
constructor that uses given PageProperties as internal data store |
Method Summary | |
---|---|
protected int |
angleQuadrant(double angle)
calculates the quadrant where the angle points to. |
int[] |
calcBorderPoint(double angle)
calculates a border point from rectangle (0, 0, width, height) using internal settings of circle center and rectangle dimensions. |
int[] |
calcBorderPoint(int xCenter,
int yCenter,
double angle)
calculates a border point from rectangle (0, 0, width, height) using the given coordinates as center of the circle and given angle. |
int[] |
calcBorderPoint(int xCenter,
int yCenter,
int xMin,
int xMax,
int yMin,
int yMax,
double angle)
caculates a border point from rectangle (xMin, yMin, xMax, yMax) using the given coordinates as center of the circle and given angle. |
int[] |
calcCirclePoint(double angle)
calculate a point from circles border using given angle to hit the border from circles center. |
int[] |
calcCirclePoint(int radius,
double angle)
calculate a point from circles border using given angle to hit the border from circles center. |
int[] |
calcCirclePoint(int xCenter,
int yCenter,
int radius,
double angle)
calculate a point from circles border using given angle to hit the border from circles center. |
int[] |
calcLimits(double startAngle,
double endAngle)
calculates the limits based on calculator settings and given angles. |
int[] |
calcLimits(int xCenter,
int yCenter,
double startAngle,
double endAngle)
calculates the limits based on calculator settings and given angles. |
protected int[] |
calcLimits(int xMin,
int yMin,
int xMax,
int yMax,
int xCenter,
int yCenter,
double startAngle,
double endAngle)
|
double |
calcLineAngle(Coordinate p0,
Coordinate p1)
calculates the angle of the given line |
double |
calcLineGradient(Coordinate p0,
Coordinate p1)
calculates the gradient of given line |
Coordinate |
calcLinesCrossPoint(Coordinate p0,
Coordinate p1,
Coordinate p2,
Coordinate p3)
calculates the intersection of the line {p0, p1} with the line {p2, p3} - line {p2, p3} should not be a vertical line, in deed the failure minimizes with gradient of line 2 beeing not vertical. |
int[] |
calcOvalPoint(double circleAngle,
double shearAngle)
|
int[] |
calcOvalPoint(int radius,
double circleAngle,
double shearAngle)
|
int[] |
calcOvalPoint(int xCenter,
int yCenter,
int radius,
double circleAngle,
double shearAngle)
|
int[] |
calcPadBorderPoint(double angle)
calculates a border point using given angle from circles center. |
int[] |
calcPadBorderPoint(int xCenter,
int yCenter,
double angle)
calculates a border point using given angle from circles center. |
int[] |
calcPadBorderPoint(int xCenter,
int yCenter,
double angle,
int padLeft,
int padTop,
int padRight,
int padBottom)
calculates a border point using given angle from circles center. |
double[] |
calcQuadrant()
base of major use-case: calculates first and last angle for shafts of sunlight base on the circles settings. |
protected double[] |
calcQuadrant(int xMin,
int yMin,
int xMax,
int yMax,
int xCenter,
int yCenter,
int r)
|
int |
getBottomPadding()
|
int |
getHeight()
|
int |
getLeftPadding()
|
int |
getRadius()
|
int |
getRightPadding()
|
int |
getTopPadding()
|
int |
getWidth()
|
int |
getXCenter()
|
int |
getYCenter()
|
void |
setBottomPadding(int bottomPadding)
|
static void |
setDebug(boolean debugFlag)
|
void |
setHeight(int height)
|
void |
setHorizontalPadding(int padding)
|
void |
setLeftPadding(int leftPadding)
|
void |
setPadding(int padding)
|
void |
setRadius(int radius)
|
void |
setRightPadding(int rightPadding)
|
void |
setTopPadding(int topPadding)
|
void |
setVerticalPadding(int padding)
|
void |
setWidth(int width)
|
void |
setXCenter(int xCenter)
|
void |
setYCenter(int yCenter)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final double DELTA_FACTOR
Constructor Detail |
---|
public GeometricCalculator(int width, int height, int xCenter, int yCenter, int radius)
width
- - rectangles width (unlikely to be subject of change)height
- - rectangles height (unlikely to be subject of change)xCenter
- - the x coordinate of the center of the circleyCenter
- - the y coordinate of the center of the circleradius
- - the circles radiuspublic GeometricCalculator(PageProperties pp)
PageProperties
as internal data store
pp
- - the PageProperties
to useMethod Detail |
---|
public int[] calcBorderPoint(double angle)
angle
- - the angle to use to hit the border (in radians)
public int[] calcBorderPoint(int xCenter, int yCenter, double angle)
xCenter
- - x coordinate of the center of the circleyCenter
- - y coordinate of the center of the circleangle
- - the angle to use to hit the border (in radians)
public int[] calcBorderPoint(int xCenter, int yCenter, int xMin, int xMax, int yMin, int yMax, double angle)
xCenter
- - x coordinate of the center of the circleyCenter
- - y coordinate of the center of the circlexMin
- - minimal x of the rectanglexMax
- - maximal x of the rectangleyMin
- - minimal y of the rectangleyMax
- - maximal y of the rectangleangle
- - the angle to use to hit the border
public int[] calcCirclePoint(double angle)
angle
- - the angle to use to hit the circles border
public int[] calcCirclePoint(int radius, double angle)
radius
- - the circles radiusangle
- - the angle to use to hit the circles border
public int[] calcCirclePoint(int xCenter, int yCenter, int radius, double angle)
xCenter
- - x coordinate of circles centeryCenter
- - y coordinate of circles centerradius
- - radius of the circleangle
- - angle to use to hit circles border
public int[] calcLimits(double startAngle, double endAngle)
startAngle
- - one angle that encloses desired shapeendAngle
- - other angle that encloses desired shape
startAngle
and endAngle
:
int[] limits = calcLimit(startAngle, endAngle); gp0 = new GeneralPath(); // cuts the rectangle before startAngle gp1 = new GeneralPath(); // cuts the rectangle after endAngle gp0.moveTo(xCenter, yCenter); gp0.lineTo(limits[0], limits[1]); gp0.lineTo(limits[4], limits[5]); gp0.lineTo(limits[6], limits[7]); gp0.closePath(); gp1.moveTo(xCenter, yCenter); gp1.lineTo(limits[2], limits[3]); gp1.lineTo(limits[8], limits[9]); gp1.lineTo(limits[10], limits[11]); gp1.closePath(); Area a = new Area(getBounds()); a.subtract(new Area(gp0)); a.subtract(new Area(gp1));
public int[] calcLimits(int xCenter, int yCenter, double startAngle, double endAngle)
xCenter
- - x coordinate of circles centeryCenter
- - y coordinate of circles centerstartAngle
- - one angle that encloses desired shapeendAngle
- - other angle that encloses desired shape
startAngle
and endAngle
:
int[] limits = calcLimit(startAngle, endAngle); gp0 = new GeneralPath(); // cuts the rectangle before startAngle gp1 = new GeneralPath(); // cuts the rectangle after endAngle gp0.moveTo(xCenter, yCenter); gp0.lineTo(limits[0], limits[1]); gp0.lineTo(limits[4], limits[5]); gp0.lineTo(limits[6], limits[7]); gp0.closePath(); gp1.moveTo(xCenter, yCenter); gp1.lineTo(limits[2], limits[3]); gp1.lineTo(limits[8], limits[9]); gp1.lineTo(limits[10], limits[11]); gp1.closePath(); Area a = new Area(getBounds()); a.subtract(new Area(gp0)); a.subtract(new Area(gp1));
public double calcLineAngle(Coordinate p0, Coordinate p1)
p0
- - first point from linep1
- - second point from line
public double calcLineGradient(Coordinate p0, Coordinate p1)
p0
- - first point from linep1
- - second point from line
public Coordinate calcLinesCrossPoint(Coordinate p0, Coordinate p1, Coordinate p2, Coordinate p3)
p0
- - first point from first linep1
- - second point from first linep2
- - first point from second linep3
- - second point from second line
public int[] calcOvalPoint(double circleAngle, double shearAngle)
public int[] calcOvalPoint(int radius, double circleAngle, double shearAngle)
public int[] calcOvalPoint(int xCenter, int yCenter, int radius, double circleAngle, double shearAngle)
public int[] calcPadBorderPoint(double angle)
calcBorderPoint
this method uses the inner rectangle taking
into account the various padding settings. Uses internal center of circle
and internal padding settings.
angle
- - the angle to use to hit the border from circles center
public int[] calcPadBorderPoint(int xCenter, int yCenter, double angle)
calcBorderPoint
this method uses the inner rectangle taking
into account the various padding settings. Uses internal padding
settings.
xCenter
- - x coordinate of circles centeryCenter
- - y coordinate of circles centerangle
- - the angle to use to hit the border from circles center
public int[] calcPadBorderPoint(int xCenter, int yCenter, double angle, int padLeft, int padTop, int padRight, int padBottom)
calcBorderPoint
this method uses the inner rectangle taking
into account the various padding settings.
xCenter
- - x coordinate of circles centeryCenter
- - y coordinate of circles centerangle
- - the angle to use to hit the border from circles centerpadLeft
- - left side paddingpadTop
- - top side paddingpadRight
- - right side paddingpadBottom
- - bottom side padding
public double[] calcQuadrant()
public int getBottomPadding()
public int getHeight()
public int getLeftPadding()
public int getRadius()
public int getRightPadding()
public int getTopPadding()
public int getWidth()
public int getXCenter()
public int getYCenter()
public void setBottomPadding(int bottomPadding)
public void setHeight(int height)
public void setHorizontalPadding(int padding)
public void setLeftPadding(int leftPadding)
public void setPadding(int padding)
public void setRadius(int radius)
public void setRightPadding(int rightPadding)
public void setTopPadding(int topPadding)
public void setVerticalPadding(int padding)
public void setWidth(int width)
public void setXCenter(int xCenter)
public void setYCenter(int yCenter)
protected int angleQuadrant(double angle)
calcQuadrant
.
angle
- - the angle to evaluate
protected int[] calcLimits(int xMin, int yMin, int xMax, int yMax, int xCenter, int yCenter, double startAngle, double endAngle)
protected double[] calcQuadrant(int xMin, int yMin, int xMax, int yMax, int xCenter, int yCenter, int r)
public static void setDebug(boolean debugFlag)
|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |