本文整理汇总了Java中com.graphbuilder.geom.PointFactory类的典型用法代码示例。如果您正苦于以下问题:Java PointFactory类的具体用法?Java PointFactory怎么用?Java PointFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PointFactory类属于com.graphbuilder.geom包,在下文中一共展示了PointFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cubicBSplineInterpolation
import com.graphbuilder.geom.PointFactory; //导入依赖的package包/类
public IDecimalAggregate<E> cubicBSplineInterpolation(final InterpolationConfig config) {
if (values.isEmpty()) {
return DummyDecimalAggregate.getInstance();
}
if (values.size() < 4) {
return parent;
}
final Pair<List<Double>, List<Double>> pair = fillInterpolationPoints(config, null);
final List<Double> xval = pair.getFirst();
final List<Double> yval = pair.getSecond();
final ControlPath cp = new ControlPath();
for (int i = 0; i < xval.size(); i++) {
cp.addPoint(PointFactory.create(xval.get(i), yval.get(i)));
}
final GroupIterator gi = new GroupIterator("0:n-1", cp.numPoints());
final CubicBSpline curve = new CubicBSpline(cp, gi);
curve.setInterpolateEndpoints(true);
calculateCurve(xval, yval, curve);
final UnivariateInterpolator interpolator = new SplineInterpolator();
return interpolate(config, xval, yval, interpolator);
}
示例2: bezierCurveInterpolation
import com.graphbuilder.geom.PointFactory; //导入依赖的package包/类
public IDecimalAggregate<E> bezierCurveInterpolation(final InterpolationConfig config) {
if (values.isEmpty()) {
return DummyDecimalAggregate.getInstance();
}
final Pair<List<Double>, List<Double>> pair = fillInterpolationPoints(config, BEZIER_CURVE_MAX_SIZE);
final List<Double> xval = pair.getFirst();
final List<Double> yval = pair.getSecond();
final ControlPath cp = new ControlPath();
for (int i = 0; i < xval.size(); i++) {
cp.addPoint(PointFactory.create(xval.get(i), yval.get(i)));
}
final GroupIterator gi = new GroupIterator("0:n-1", cp.numPoints());
final BezierCurve curve = new BezierCurve(cp, gi);
calculateCurve(xval, yval, curve);
final UnivariateInterpolator interpolator = new SplineInterpolator();
return interpolate(config, xval, yval, interpolator);
}
示例3: bSplineInterpolation
import com.graphbuilder.geom.PointFactory; //导入依赖的package包/类
public IDecimalAggregate<E> bSplineInterpolation(final BSplineInterpolationConfig config) {
if (values.isEmpty()) {
return DummyDecimalAggregate.getInstance();
}
final Pair<List<Double>, List<Double>> pair = fillInterpolationPoints(config, null);
final List<Double> xval = pair.getFirst();
final List<Double> yval = pair.getSecond();
final ControlPath cp = new ControlPath();
for (int i = 0; i < xval.size(); i++) {
cp.addPoint(PointFactory.create(xval.get(i), yval.get(i)));
}
final GroupIterator gi = new GroupIterator("0:n-1", cp.numPoints());
final BSpline curve = new BSpline(cp, gi);
curve.setDegree(config.getDegree());
final int maxDegree = cp.numPoints() - 1;
if (curve.getDegree() > maxDegree) {
curve.setDegree(maxDegree);
}
calculateCurve(xval, yval, curve);
final UnivariateInterpolator interpolator = new SplineInterpolator();
return interpolate(config, xval, yval, interpolator);
}
示例4: testContains
import com.graphbuilder.geom.PointFactory; //导入依赖的package包/类
@Test
public void testContains() throws Exception {
// TODO: test other types of shapes
ControlPath cp = new ControlPath();
cp.addPoint(PointFactory.create(10, 10));
cp.addPoint(PointFactory.create(10, 200));
cp.addPoint(PointFactory.create(290, 200));
cp.addPoint(PointFactory.create(290, 10));
Curve c = new BezierCurve(cp, new GroupIterator("0:n-1", cp.numPoints()));
ShapeMultiPath smp = new ShapeMultiPath();
c.appendTo(smp);
// TODO: more nuanced points..
assertFalse(smp.contains(0, 0));
assertFalse(smp.contains(9, 9));
assertFalse(smp.contains(30, 180));
assertFalse(smp.contains(280, 180));
assertTrue(smp.contains(11, 11));
assertTrue(smp.contains(100, 100));
assertTrue(smp.contains(289, 11));
}
示例5: addToPath
import com.graphbuilder.geom.PointFactory; //导入依赖的package包/类
public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
// ok, we have the start, and all knots... do something with this
Point2D last = path.getCurrentPoint();
// create a control path and knots
ControlPath controlPath = new ControlPath();
ValueVector knots = new ValueVector(_knots.size() + 3);
double firstKnot = _start.getB();
double lastKnot = _start.getC();
int degree = _start.getD();
// first/second knot
knots.add(firstKnot);
knots.add(_start.getA());
// first/second control point
controlPath.addPoint(PointFactory.create(last.getX(), last.getY()));
controlPath.addPoint(PointFactory.create(_start.getX(), _start.getY()));
// middle knots/control points
for (SplineKnot knot: _knots) {
knots.add(knot.getA());
controlPath.addPoint(PointFactory.create(knot.getX(), knot.getY()));
}
// last knot
knots.add(lastKnot);
ShapeMultiPath shape = SplineRenderer.createNurbsSpline(controlPath, knots, null, degree);
path.append(shape, true);
}
示例6: addToPath
import com.graphbuilder.geom.PointFactory; //导入依赖的package包/类
@Override
public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) {
if (getDel()) return;
Point2D last = path.getCurrentPoint();
// A NURBS formula: knotLast, degree, xType, yType, x1, y1, knot1, weight1, ..
String formula = getE().trim();
if (!formula.startsWith("NURBS(") || !formula.endsWith(")"))
throw new POIXMLException("Invalid NURBS formula: " + formula);
String [] components = formula.substring(6, formula.length()-1).split(",");
if (components.length < 8)
throw new POIXMLException("Invalid NURBS formula (not enough arguments)");
if ((components.length - 4) % 4 != 0)
throw new POIXMLException("Invalid NURBS formula -- need 4 + n*4 arguments, got " + components.length);
double lastControlX = getX();
double lastControlY = getY();
double secondToLastKnot = getA();
double lastWeight = getB();
double firstKnot = getC();
double firstWeight = getD();
double lastKnot = Double.parseDouble(components[0].trim());
int degree = Integer.parseInt(components[1].trim());
int xType = Integer.parseInt(components[2].trim());
int yType = Integer.parseInt(components[3].trim());
double xScale = 1;
double yScale = 1;
if (xType == 0)
xScale = parent.getWidth();
if (yType == 0)
yScale = parent.getHeight();
// setup first knots/weights/control point
ControlPath controlPath = new ControlPath();
ValueVector knots = new ValueVector();
ValueVector weights = new ValueVector();
knots.add(firstKnot);
weights.add(firstWeight);
controlPath.addPoint(PointFactory.create(last.getX(), last.getY()));
// iterate get knots/weights
int sets = (components.length - 4) / 4;
for (int i = 0; i < sets; i++) {
double x1 = Double.parseDouble(components[4 + i*4 + 0].trim());
double y1 = Double.parseDouble(components[4 + i*4 + 1].trim());
double k = Double.parseDouble(components[4 + i*4 + 2].trim());
double w = Double.parseDouble(components[4 + i*4 + 3].trim());
controlPath.addPoint(PointFactory.create(x1*xScale, y1*yScale));
knots.add(k);
weights.add(w);
}
// last knots/weights/control point
knots.add(secondToLastKnot);
knots.add(lastKnot);
weights.add(lastWeight);
controlPath.addPoint(PointFactory.create(lastControlX, lastControlY));
ShapeMultiPath shape = SplineRenderer.createNurbsSpline(controlPath, knots, weights, degree);
path.append(shape, true);
}