本文整理汇总了Java中javafx.scene.shape.PathElement类的典型用法代码示例。如果您正苦于以下问题:Java PathElement类的具体用法?Java PathElement怎么用?Java PathElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathElement类属于javafx.scene.shape包,在下文中一共展示了PathElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearSmallPolygons
import javafx.scene.shape.PathElement; //导入依赖的package包/类
private void clearSmallPolygons(Path... paths){
validPaths = new ArrayList<>();
Point2D p0 = Point2D.ZERO;
for (Path path : paths) {
for (PathElement elem : path.getElements()) {
if (elem instanceof MoveTo) {
elements = new ArrayList<>();
elements.add(elem);
listPoints = new ArrayList<>();
p0 = new Point2D(((MoveTo)elem).getX(), ((MoveTo)elem).getY());
listPoints.add(p0);
} else if (elem instanceof CubicCurveTo) {
elements.add(elem);
Point2D ini = listPoints.size() > 0 ? listPoints.get(listPoints.size() - 1) : p0;
listPoints.addAll(evalCubicCurve((CubicCurveTo) elem, ini, POINTS_CURVE));
} else if (elem instanceof ClosePath) {
elements.add(elem);
listPoints.add(p0);
if (Math.abs(calculateArea()) > MINIMUM_AREA) {
validPaths.add(new Path(elements));
}
}
}
}
}
示例2: Draw
import javafx.scene.shape.PathElement; //导入依赖的package包/类
@Override
public void Draw(Pane canvas)
{
double height = canvas.getHeight();
double width = canvas.getWidth();
canvas.getChildren().add(new Rectangle(width, height, Colors[0]));
Path p = new Path(new PathElement[]
{
new MoveTo(width, 0),
new LineTo(width, height),
new LineTo(0, height),
new LineTo(width, 0)
});
p.fillProperty().set(Colors[1]);
p.strokeWidthProperty().set(0);
canvas.getChildren().add(p);
}
示例3: Draw
import javafx.scene.shape.PathElement; //导入依赖的package包/类
@Override
public void Draw(Pane canvas)
{
double height = canvas.getHeight();
double width = canvas.getWidth();
canvas.getChildren().add(new Rectangle(width, height, Colors[0]));
Path p = new Path(new PathElement[]
{
new MoveTo(0, height),
new LineTo(width, 0),
new LineTo(width, height),
new LineTo(0, 0)
});
p.fillProperty().set(Colors[1]);
p.strokeWidthProperty().set(0);
canvas.getChildren().add(p);
}
示例4: Draw
import javafx.scene.shape.PathElement; //导入依赖的package包/类
@Override
public void Draw(Pane canvas)
{
double height = canvas.getHeight();
double width = canvas.getWidth();
canvas.getChildren().add(new Rectangle(width, height, Colors[0]));
Path p = new Path(new PathElement[]
{
new MoveTo(width, height),
new LineTo(0, height),
new LineTo(0, 0),
new LineTo(width, height)
});
p.fillProperty().set(Colors[1]);
p.strokeWidthProperty().set(0);
canvas.getChildren().add(p);
}
示例5: setSelection
import javafx.scene.shape.PathElement; //导入依赖的package包/类
public void setSelection(int ix)
{
if(ix < 0)
{
caret.getElements().clear();
setCaretVisible(false);
}
else
{
if(caret.getParent() == null)
{
textField.getChildren().add(caret);
}
PathElement[] es = getCaretShape(ix, true);
caret.getElements().setAll(es);
setCaretVisible(true);
}
selectionIndex.set(ix);
}
示例6: getCaretLocation
import javafx.scene.shape.PathElement; //导入依赖的package包/类
public CaretLocation getCaretLocation(Region parent, Marker pos)
{
if(pos != null)
{
LineBox b = getLineBox(pos.getLine());
if(b != null)
{
Region box = b.getCenter();
if(box instanceof CTextFlow)
{
PathElement[] es = ((CTextFlow)box).getCaretShape(pos.getCharIndex(), pos.isLeading());
if(es != null)
{
return EditorTools.translateCaretLocation(parent, box, es);
}
}
}
}
return null;
}
示例7: getRange
import javafx.scene.shape.PathElement; //导入依赖的package包/类
/** returns selection shape for a given range */
public PathElement[] getRange(int start, int end)
{
if(center instanceof CTextFlow)
{
CTextFlow t = (CTextFlow)center;
return t.getRange(start, end);
}
else
{
double w = center.getWidth();
double h = center.getHeight();
return new PathElement[]
{
new MoveTo(0, 0),
new LineTo(w, 0),
new LineTo(w, h),
new LineTo(0, h),
new LineTo(0, 0)
};
}
}
示例8: getCaretShape
import javafx.scene.shape.PathElement; //导入依赖的package包/类
/** returns selection shape for a given range */
public PathElement[] getCaretShape(int index, boolean leading)
{
if(center instanceof CTextFlow)
{
CTextFlow t = (CTextFlow)center;
return t.getCaretShape(index, leading);
}
else
{
double x = leading ? 0 : center.getWidth();
double h = center.getHeight();
return new PathElement[]
{
new MoveTo(x, 0),
new LineTo(x, h)
};
}
}
示例9: pathsToSVGPath
import javafx.scene.shape.PathElement; //导入依赖的package包/类
private String pathsToSVGPath() {
final StringBuilder sb = new StringBuilder();
for (Path path : validPaths) {
for (PathElement element : path.getElements()) {
if (element instanceof MoveTo) {
sb.append("M ").append(((MoveTo) element).getX()).append(" ")
.append(((MoveTo) element).getY());
} else if (element instanceof CubicCurveTo) {
CubicCurveTo curve = (CubicCurveTo) element;
sb.append(" C ")
.append(curve.getControlX1()).append(" ").append(curve.getControlY1()).append(" ")
.append(curve.getControlX2()).append(" ").append(curve.getControlY2()).append(" ")
.append(curve.getX()).append(" ").append(curve.getY());
} else if (element instanceof ClosePath) {
sb.append(" Z ");
}
}
}
return sb.toString();
}
示例10: getCaretLocation
import javafx.scene.shape.PathElement; //导入依赖的package包/类
public CaretLocation getCaretLocation(Region parent, Marker pos)
{
if(pos != null)
{
LineBox b = getLineBox(pos.getLine());
if(b != null)
{
Region box = b.getBox();
if(box instanceof CTextFlow)
{
PathElement[] es = ((CTextFlow)box).getCaretShape(pos.getCharIndex(), pos.isLeading());
if(es != null)
{
return EditorTools.translateCaretLocation(parent, box, es);
}
}
}
}
return null;
}
示例11: getBounds
import javafx.scene.shape.PathElement; //导入依赖的package包/类
protected Rectangle2D getBounds(int start, int end) {
PathElement[] shape = getShape(start, end);
double minX = 0, minY = 0, maxX = 0, maxY = 0;
for (PathElement pathElement : shape) {
if (pathElement instanceof MoveTo) {
MoveTo moveTo = (MoveTo) pathElement;
minX = maxX = moveTo.getX();
minY = maxY = moveTo.getY();
} else if (pathElement instanceof LineTo) {
LineTo lineTo = (LineTo) pathElement;
double x = lineTo.getX();
double y = lineTo.getY();
minX = Math.min(minX, x);
minY = Math.min(minY, y);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
}
}
return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
示例12: Draw
import javafx.scene.shape.PathElement; //导入依赖的package包/类
@Override
public void Draw(Pane canvas)
{
double width = canvas.getWidth() * (GetDoubleAttribute("Width") / (double) MaximumX);
double height = GetDoubleAttribute("Height") == 0
? width
: canvas.getHeight() * (GetDoubleAttribute("Height") / MaximumY);
double left = canvas.getWidth() * (GetDoubleAttribute("X") / MaximumX) - width / 2;
double top = canvas.getHeight() * (GetDoubleAttribute("Y") / MaximumY) - height / 2;
Path path = new Path(new PathElement[]
{
new MoveTo(0, height / 2),
new LineTo(width / 2, 0),
new LineTo(width, height / 2),
new LineTo(width / 2, height),
new LineTo(0, height / 2)
});
path.setFill(GetColorAttribute("Color"));
path.setStrokeWidth(0);
path.setLayoutX(left);
path.setLayoutY(top);
canvas.getChildren().add(path);
}
示例13: Draw
import javafx.scene.shape.PathElement; //导入依赖的package包/类
@Override
public void Draw(Pane canvas)
{
double widthX = canvas.getWidth() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;
double widthY = canvas.getHeight() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;
Path path = new Path(new PathElement[]
{
new MoveTo(widthX, 0),
new LineTo(0, 0),
new LineTo(0, widthY),
new LineTo(canvas.getWidth() - widthX, canvas.getHeight()),
new LineTo(canvas.getWidth(), canvas.getHeight()),
new LineTo(canvas.getWidth(), canvas.getHeight() - widthY),
new LineTo(widthX, 0)
});
path.setFill(GetColorAttribute("Color"));
path.setStrokeWidth(0);
canvas.getChildren().add(path);
}
示例14: Thumbnail
import javafx.scene.shape.PathElement; //导入依赖的package包/类
@Override
protected Shape[] Thumbnail()
{
return new Shape[]
{
new Path(new PathElement[]
{
new MoveTo(0, 5),
new LineTo(30, 5),
new LineTo(30, 25),
new LineTo(0, 25),
new LineTo(0, 5),
new MoveTo(5, 10),
new LineTo(5, 20),
new LineTo(25, 20),
new LineTo(25, 10),
new LineTo(5, 10)
})
};
}
示例15: Draw
import javafx.scene.shape.PathElement; //导入依赖的package包/类
@Override
public void Draw(Pane canvas)
{
double widthX = canvas.getWidth() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;
double widthY = canvas.getHeight() * (GetDoubleAttribute("Thickness") / MaximumX) / 2;
Path path = new Path(new PathElement[]
{
new MoveTo(canvas.getWidth() - widthX, 0),
new LineTo(canvas.getWidth(), 0),
new LineTo(canvas.getWidth(), widthY),
new LineTo(widthX, canvas.getHeight()),
new LineTo(0, canvas.getHeight()),
new LineTo(0, canvas.getHeight() - widthY),
new LineTo(canvas.getWidth() - widthX, 0)
});
path.setFill(GetColorAttribute("Color"));
path.setStrokeWidth(0);
canvas.getChildren().add(path);
}