本文整理汇总了Java中com.vividsolutions.jts.math.MathUtil.clamp方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtil.clamp方法的具体用法?Java MathUtil.clamp怎么用?Java MathUtil.clamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.math.MathUtil
的用法示例。
在下文中一共展示了MathUtil.clamp方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
/**
* Extracts a subsequence of the input {@link Coordinate} array
* from indices <code>start</code> to
* <code>end</code> (inclusive).
* The input indices are clamped to the array size;
* If the end index is less than the start index,
* the extracted array will be empty.
*
* @param pts the input array
* @param start the index of the start of the subsequence to extract
* @param end the index of the end of the subsequence to extract
* @return a subsequence of the input array
*/
public static Coordinate[] extract(Coordinate[] pts, int start, int end) {
start = MathUtil.clamp(start, 0, pts.length);
end = MathUtil.clamp(end, -1, pts.length);
int npts = end - start + 1;
if (end < 0) npts = 0;
if (start >= pts.length) npts = 0;
if (end < start) npts = 0;
Coordinate[] extractPts = new Coordinate[npts];
if (npts == 0) return extractPts;
int iPts = 0;
for (int i = start; i <= end; i++) {
extractPts[iPts++] = pts[i];
}
return extractPts;
}
示例2: extract
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
/**
* Extracts a subsequence of the input {@link Coordinate} array
* from indices <code>start</code> to
* <code>end</code> (inclusive).
* The input indices are clamped to the array size;
* If the end index is less than the start index,
* the extracted array will be empty.
*
* @param pts the input array
* @param start the index of the start of the subsequence to extract
* @param end the index of the end of the subsequence to extract
* @return a subsequence of the input array
*/
public static Coordinate[] extract(Coordinate[] pts, int start, int end)
{
start = MathUtil.clamp(start, 0, pts.length);
end = MathUtil.clamp(end, -1, pts.length);
int npts = end - start + 1;
if (end < 0) npts = 0;
if (start >= pts.length) npts = 0;
if (end < start) npts = 0;
Coordinate[] extractPts = new Coordinate[npts];
if (npts == 0) return extractPts;
int iPts = 0;
for (int i = start; i <= end; i++) {
extractPts[iPts++] = pts[i];
}
return extractPts;
}
示例3: extract
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
/**
* Extracts a subsequence of the input {@link Coordinate} array
* from indices <code>start</code> to
* <code>end</code> (inclusive).
* The input indices are clamped to the array size;
* If the end index is less than the start index,
* the extracted array will be empty.
*
* @param pts the input array
* @param start the index of the start of the subsequence to extract
* @param end the index of the end of the subsequence to extract
* @return a subsequence of the input array
*/
public static Coordinate[] extract(Coordinate[] pts, int start, int end) {
start = MathUtil.clamp(start, 0, pts.length);
end = MathUtil.clamp(end, -1, pts.length);
int npts = end - start + 1;
if (end < 0) {
npts = 0;
}
if (start >= pts.length) {
npts = 0;
}
if (end < start) {
npts = 0;
}
Coordinate[] extractPts = new Coordinate[npts];
if (npts == 0) {
return extractPts;
}
int iPts = 0;
for (int i = start; i <= end; i++) {
extractPts[iPts++] = pts[i];
}
return extractPts;
}
示例4: getGeometry
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
/**
* Gets the {@link MultiPoint} containing the generated point
*
* @return a MultiPoint
*/
@Override
public Geometry getGeometry() {
int nCells = (int) Math.sqrt(this.numPts);
// ensure that at least numPts points are generated
if (nCells * nCells < this.numPts) {
nCells += 1;
}
double gridDX = this.getExtent().getWidth() / nCells;
double gridDY = this.getExtent().getHeight() / nCells;
double gutterFrac = MathUtil.clamp(this.gutterFraction, 0.0, 1.0);
double gutterOffsetX = gridDX * gutterFrac / 2;
double gutterOffsetY = gridDY * gutterFrac / 2;
double cellFrac = 1.0 - gutterFrac;
double cellDX = cellFrac * gridDX;
double cellDY = cellFrac * gridDY;
Coordinate[] pts = new Coordinate[nCells * nCells];
int index = 0;
for (int i = 0; i < nCells; i++) {
for (int j = 0; j < nCells; j++) {
double orgX = this.getExtent().getMinX() + i * gridDX + gutterOffsetX;
double orgY = this.getExtent().getMinY() + j * gridDY + gutterOffsetY;
pts[index++] = this.randomPointInCell(orgX, orgY, cellDX, cellDY);
}
}
return this.geomFactory.createMultiPoint(pts);
}
示例5: getGeometry
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
/**
* Gets the {@link MultiPoint} containing the generated point
*
* @return a MultiPoint
*/
public Geometry getGeometry() {
int nCells = (int) Math.sqrt(numPts);
// ensure that at least numPts points are generated
if (nCells * nCells < numPts)
nCells += 1;
double gridDX = getExtent().getWidth() / nCells;
double gridDY = getExtent().getHeight() / nCells;
double gutterFrac = MathUtil.clamp(gutterFraction, 0.0, 1.0);
double gutterOffsetX = gridDX * gutterFrac / 2;
double gutterOffsetY = gridDY * gutterFrac / 2;
double cellFrac = 1.0 - gutterFrac;
double cellDX = cellFrac * gridDX;
double cellDY = cellFrac * gridDY;
Coordinate[] pts = new Coordinate[nCells * nCells];
int index = 0;
for (int i = 0; i < nCells; i++) {
for (int j = 0; j < nCells; j++) {
double orgX = getExtent().getMinX() + i * gridDX + gutterOffsetX;
double orgY = getExtent().getMinY() + j * gridDY + gutterOffsetY;
pts[index++] = randomPointInCell(orgX, orgY, cellDX, cellDY);
}
}
return geomFactory.createMultiPoint(pts);
}
示例6: getGeometry
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
/**
* Gets the {@link MultiPoint} containing the generated point
*
* @return a MultiPoint
*/
public Geometry getGeometry()
{
int nCells = (int) Math.sqrt(numPts);
// ensure that at least numPts points are generated
if (nCells * nCells < numPts)
nCells += 1;
double gridDX = getExtent().getWidth() / nCells;
double gridDY = getExtent().getHeight() / nCells;
double gutterFrac = MathUtil.clamp(gutterFraction, 0.0, 1.0);
double gutterOffsetX = gridDX * gutterFrac/2;
double gutterOffsetY = gridDY * gutterFrac/2;
double cellFrac = 1.0 - gutterFrac;
double cellDX = cellFrac * gridDX;
double cellDY = cellFrac * gridDY;
Coordinate[] pts = new Coordinate[nCells * nCells];
int index = 0;
for (int i = 0; i < nCells; i++) {
for (int j = 0; j < nCells; j++) {
double orgX = getExtent().getMinX() + i * gridDX + gutterOffsetX;
double orgY = getExtent().getMinY() + j * gridDY + gutterOffsetY;
pts[index++] = randomPointInCell(orgX, orgY, cellDX, cellDY);
}
}
return geomFactory.createMultiPoint(pts);
}
示例7: temperature
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
public static Color temperature(double fraction) {
fraction = MathUtil.clamp(fraction, 0, 1);
int n = temperatureCols.length;
double index = fraction * (n - 1);
int low = (int) Math.floor(index);
int high = (int) Math.ceil(index);
double ifrac = index - low;
Color l = temperatureCols[low];
Color h = temperatureCols[high];
Color ret = new Color(lerp(l.getRed(), h.getRed(), ifrac), lerp(l.getGreen(), h.getGreen(), ifrac), lerp(l.getBlue(), h.getBlue(), ifrac));
return ret;
}
示例8: getRenderColour
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
public static Color getRenderColour(DrawableObject pnt, boolean isSelected) {
if(isSelected){
return SELECTION_COLOUR;
}
Color col = getNoAlphaColour(pnt.getColour(), pnt.getColourKey());
double opaque = pnt.getOpaque();
opaque = MathUtil.clamp(opaque, 0, 1);
col = Colours.setAlpha(col, (int) Math.round((255 * opaque)));
return col;
}
示例9: saturate
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
public static Color saturate(Color clr, double saturation)
{
float[] hsb = new float[3];
Color.RGBtoHSB(clr.getRed(), clr.getGreen(), clr.getBlue(), hsb);
hsb[1] = (float) MathUtil.clamp(saturation, 0, 1);;
return Color.getHSBColor(hsb[0], hsb[1], hsb[2]);
}
示例10: lerp
import com.vividsolutions.jts.math.MathUtil; //导入方法依赖的package包/类
private static int lerp(int low, int high, double fraction) {
fraction = MathUtil.clamp(fraction, 0, 1);
double val = low * (1.0 - fraction) + high * fraction;
return ensureRange((int) Math.round(val));
}