当前位置: 首页>>代码示例>>Java>>正文


Java MathUtil.clamp方法代码示例

本文整理汇总了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;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:32,代码来源:CoordinateArrays.java

示例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;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:33,代码来源:CoordinateArrays.java

示例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;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:40,代码来源:CoordinateArrays.java

示例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);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:35,代码来源:RandomPointsInGridBuilder.java

示例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);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:33,代码来源:RandomPointsInGridBuilder.java

示例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);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:34,代码来源:RandomPointsInGridBuilder.java

示例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;
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:13,代码来源:Colours.java

示例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;
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:12,代码来源:DatastoreRenderer.java

示例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]);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:8,代码来源:ColorUtil.java

示例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));
}
 
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:6,代码来源:Colours.java


注:本文中的com.vividsolutions.jts.math.MathUtil.clamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。