// Test for RT-13820 @Test public void changingShapeElementsShouldResultInRender() { Region r = new Region(); r.setPrefWidth(640); r.setPrefHeight(480); LineTo lineTo; Path p = new Path( new MoveTo(0, 0), lineTo = new LineTo(100, 0), new LineTo(50, 100), new ClosePath()); r.setBackground(new Background(new BackgroundFill(Color.BLUE, null, null))); r.setCenterShape(true); r.setScaleShape(true); r.setShape(p); r.impl_syncPeer(); NGRegion peer = r.impl_getPeer(); assertFalse(peer.isClean()); peer.clearDirtyTree(); assertTrue(peer.isClean()); lineTo.setX(200); p.impl_syncPeer(); r.impl_syncPeer(); assertFalse(peer.isClean()); }
public static Path getFXShape(LinkedList swingShapeList) { Path sfx = new Path(); for (Object s : swingShapeList) { java.awt.Shape ss = (java.awt.Shape) s; if (ss instanceof java.awt.Shape) { double[] coords = new double[6]; ArrayList<double[]> areaPoints = new ArrayList<double[]>(); for (PathIterator pi = ss.getPathIterator(null); !pi.isDone(); pi.next()) { int type = pi.currentSegment(coords); double[] pathIteratorCoords = { type, coords[0], coords[1], coords[2], coords[3], coords[4], coords[5] }; areaPoints.add(pathIteratorCoords); } for (double[] d : areaPoints) { if (d[0] == PathIterator.SEG_MOVETO) { MoveTo moveTo = new MoveTo(); moveTo.setX(d[1]); moveTo.setY(d[2]); sfx.getElements().add(moveTo); } else if (d[0] == PathIterator.SEG_LINETO) { LineTo lineTo = new LineTo(); lineTo.setX(d[1]); lineTo.setY(d[2]); sfx.getElements().add(lineTo); } else if (d[0] == PathIterator.SEG_CUBICTO) { CubicCurveTo ccTo = new CubicCurveTo(d[1], d[2], d[3], d[4], d[5], d[6]); sfx.getElements().add(ccTo); } else if (d[0] == PathIterator.SEG_QUADTO) { QuadCurveTo qcTo = new QuadCurveTo(d[1], d[2], d[3], d[4]); sfx.getElements().add(qcTo); } else if (d[0] == PathIterator.SEG_CLOSE) { ClosePath cp = new ClosePath(); sfx.getElements().add(cp); } } } } return sfx; }
public void update(Point2D center, Dimension2D dim) { moveTo1.setX(center.getX() - 10); moveTo1.setY(center.getY()); lineTo1.setX(center.getX() + 10); lineTo1.setY(center.getY()); moveTo2.setX(center.getX()); moveTo2.setY(center.getY() - 10); lineTo2.setX(center.getX()); lineTo2.setY(center.getY() + 10); }
public ObservableList<PathElement> pathChanger( ObservableList<PathElement> elements, double angle) { MoveTo moveTo = (MoveTo) elements.get(0); LineTo lineToSecond = (LineTo) elements.get(1); LineTo lineToThird = (LineTo) elements.get(2); LineTo lineToFourth = (LineTo) elements.get(3); LineTo lineToFifth = (LineTo) elements.get(4); LineTo lineToSixth = (LineTo) elements.get(5); LineTo lineToSeventh = (LineTo) elements.get(6); LineTo lineToEighth = (LineTo) elements.get(7); double x = moveTo.getX(); double y = moveTo.getY(); double[] res = rotationCoordinates(new double[] {x, y}, angle); moveTo.setX(res[0]); moveTo.setY(res[1]); x = lineToSecond.getX(); y = lineToSecond.getY(); res = rotationCoordinates(new double[] {x, y}, angle); lineToSecond.setX(res[0]); lineToSecond.setY(res[1]); x = lineToThird.getX(); y = lineToThird.getY(); res = rotationCoordinates(new double[] {x, y}, angle); lineToThird.setX(res[0]); lineToThird.setY(res[1]); x = lineToFourth.getX(); y = lineToFourth.getY(); res = rotationCoordinates(new double[] {x, y}, angle); lineToFourth.setX(res[0]); lineToFourth.setY(res[1]); x = lineToFifth.getX(); y = lineToFifth.getY(); res = rotationCoordinates(new double[] {x, y}, angle); lineToFifth.setX(res[0]); lineToFifth.setY(res[1]); x = lineToSixth.getX(); y = lineToSixth.getY(); res = rotationCoordinates(new double[] {x, y}, angle); lineToSixth.setX(res[0]); lineToSixth.setY(res[1]); x = lineToSeventh.getX(); y = lineToSeventh.getY(); res = rotationCoordinates(new double[] {x, y}, angle); lineToSeventh.setX(res[0]); lineToSeventh.setY(res[1]); x = lineToEighth.getX(); y = lineToEighth.getY(); res = rotationCoordinates(new double[] {x, y}, angle); lineToEighth.setX(res[0]); lineToEighth.setY(res[1]); elements.remove(0, 8); elements.add(0, moveTo); elements.add(1, lineToSecond); elements.add(2, lineToThird); elements.add(3, lineToFourth); elements.add(4, lineToFifth); elements.add(5, lineToSixth); elements.add(6, lineToSeventh); elements.add(7, lineToEighth); return elements; }