Java 类javafx.scene.shape.Shape 实例源码

项目:lttng-scope    文件:TimeGraphWidgetDrawnEventsTest.java   
/**
 * Test several enabled+registered providers at the same time. They should
 * all paint their own events.
 */
@Test
public void testManyProviders() {
    TimeGraphDrawnEventProvider provider1 = new StubDrawnEventProvider1();
    TimeGraphDrawnEventProvider provider2 = new StubDrawnEventProvider2();
    MANAGER.getRegisteredProviders().add(provider1);
    MANAGER.getRegisteredProviders().add(provider2);
    provider1.enabledProperty().set(true);
    provider2.enabledProperty().set(true);

    repaint();

    Collection<Shape> events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider1.NB_SYMBOLS + StubDrawnEventProvider2.NB_SYMBOLS,
            events.size());
}
项目:lttng-scope    文件:TimeGraphWidgetDrawnEventsTest.java   
/**
 * Test changing the 'enabled' property of a provider from false to true.
 * This should result in new events being painted.
 */
@Test
public void testEnabling() {
    TimeGraphDrawnEventProvider provider = new StubDrawnEventProvider1();
    MANAGER.getRegisteredProviders().add(provider);
    provider.enabledProperty().set(false);
    repaint();

    Collection<Shape> events = getRenderedEvents();
    assertTrue(events.isEmpty());

    provider.enabledProperty().set(true);
    repaint();

    events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider1.NB_SYMBOLS, events.size());
}
项目:lttng-scope    文件:TimeGraphWidgetDrawnEventsTest.java   
/**
 * Test changing the 'enabled' property of a provider from true to false.
 * This should remove its events from the view.
 */
@Test
public void testDisabling() {
    TimeGraphDrawnEventProvider provider = new StubDrawnEventProvider1();
    MANAGER.getRegisteredProviders().add(provider);

    provider.enabledProperty().set(true);
    repaint();

    Collection<Shape> events = getRenderedEvents();
    assertEquals(StubDrawnEventProvider1.NB_SYMBOLS, events.size());

    provider.enabledProperty().set(false);
    repaint();

    events = getRenderedEvents();
    assertTrue(events.isEmpty());
}
项目:HotaruFX    文件:NodeUtilsBundle.java   
private static Function strokePattern(Context context) {
    return args -> {
        val validator = Validator.with(args);
        validator.checkOrOr(1, 2);
        if (args[0].type() != Types.NODE || !(args[0].raw() instanceof ShapeNode)) {
            throw new TypeException("Shape required at first argument");
        }
        val shape = (Shape) ((ShapeNode) args[0].raw()).getFxNode();
        if (args.length == 2) {
            val array = validator.requireArrayAt(1);
            val dashList = array.stream()
                    .map(Value::asDouble)
                    .collect(Collectors.toList());
            shape.getStrokeDashArray().setAll(dashList);
            return NumberValue.ZERO;
        } else {
            return ArrayValue.from(shape.getStrokeDashArray(), NumberValue::of);
        }
    };
}
项目:IO    文件:BaseController.java   
private static void scaleShape(Scene scene, Shape shape) {
    double sceneWidth = scene.getWidth();
    double sceneHeight = scene.getHeight();
    ChangeListener<Number> widthResizer = (arg0, oldValue, newValue) -> shape.setScaleX(newValue.doubleValue() / sceneWidth);
    scene.widthProperty().addListener(widthResizer);
    ChangeListener<Number> heightResizer = (arg0, oldValue, newValue) -> shape.setScaleY(newValue.doubleValue() / sceneHeight);
    scene.heightProperty().addListener(heightResizer);

}
项目:shuffleboard    文件:CurvedArrow.java   
/**
 * Creates a new curved arrow.
 *
 * @param startAngle the starting angle of the arc, in radians
 * @param radius     the radius of the arrow. Must be non-negative.
 * @param length     the length of the arrow, in the same units as {@code radius}
 * @param xOffset    how much to offset the arc along the X-axis
 * @param headSize   the length of the head of the arrow
 *
 * @return a curved arrow shape
 *
 * @throws IllegalArgumentException if {@code radius} or {@code headSize} are negative
 */
public static Shape create(double startAngle,
                           double radius,
                           double length,
                           double xOffset,
                           double headSize) {
  if (radius < 0) {
    throw new IllegalArgumentException("Radius cannot be negative. Given: " + radius);
  }
  if (headSize < 0) {
    throw new IllegalArgumentException("The size of the arrowhead cannot be negative. Given: " + headSize);
  }
  if (radius == Double.POSITIVE_INFINITY) {
    // infinite radius = straight
    return createStraight(length, startAngle, xOffset, headSize);
  }
  return Shape.union(
      makeBody(startAngle, radius, length, xOffset),
      curvedHead(startAngle, headSize, radius, xOffset, length)
  );
}
项目:shuffleboard    文件:MecanumDriveWidget.java   
/**
 * Generates a mecanum drive base.
 *
 * @param wheelWidth  the width (or thickness) of the wheels
 * @param wheelHeight the height (or diameter) of the wheels
 * @param frameWidth  the width of the robot frame
 * @param frameHeight the height of the robot frame
 */
private static Shape generateMecanumDriveBase(double wheelWidth,
                                              double wheelHeight,
                                              double frameWidth,
                                              double frameHeight) {
  Rectangle frame = new Rectangle(wheelWidth, 0, frameWidth, frameHeight);
  frame.setFill(null);
  frame.setStroke(Color.WHITE);

  final Shape fl = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.FRONT_LEFT);
  final Shape fr = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.FRONT_RIGHT);
  final Shape rl = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.REAR_LEFT);
  final Shape rr = mecanumWheel(wheelWidth, wheelHeight, MecanumWheelPos.REAR_RIGHT);
  fr.setTranslateX(frameWidth + wheelWidth);
  rl.setTranslateY(frameHeight - wheelHeight);
  rr.setTranslateX(frameWidth + wheelWidth);
  rr.setTranslateY(frameHeight - wheelHeight);

  Shape combined = union(frame, fl, fr, rl, rr);
  combined.getStyleClass().addAll("robot-drive", "mecanum-drive");
  return combined;
}
项目:worldheatmap    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:charts    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:Paradinc-FX    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:javaone2016    文件:BadgeOutline.java   
/**
 * Once we have drawn the path, we call this method to generate two paths 
 * (outer and inner paths) and get a SVGPath with them that can be exported
 * @param drawPath The original path
 * @param svg
 * @return the content string of the SVGPath with two paths
 */
public boolean generateOutline(Path drawPath, SVGPath svg) {
    Pane pane = (Pane) drawPath.getParent();
    final double width = pane.getWidth() * WIDTH_FACTOR; 

    Path outterPath = new Path(drawPath.getElements());
    outterPath.setStroke(drawPath.getStroke());
    outterPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
    outterPath.setStrokeLineCap(drawPath.getStrokeLineCap());
    outterPath.setStrokeWidth(width);
    Path s1 = (Path) Shape.subtract(outterPath, new Rectangle(0, 0));

    Path innerPath = new Path(drawPath.getElements());
    innerPath.setStrokeWidth(0);
    innerPath.setStroke(drawPath.getStroke());
    innerPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
    innerPath.setStrokeLineCap(drawPath.getStrokeLineCap());
    Path s2 = (Path) Shape.subtract(innerPath, new Rectangle(0, 0));

    Path result = (Path) Shape.subtract(s1, s2);
    clearSmallPolygons(result);
    svg.setContent(pathsToSVGPath());
    return validPaths.size() == 2;
}
项目:worldfx    文件:World.java   
private void registerListeners() {
    widthProperty().addListener(o -> resize());
    heightProperty().addListener(o -> resize());
    sceneProperty().addListener(o -> {
        if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
        if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }

        locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
            if (CHANGE.wasAdded()) {
                addShapesToScene(CHANGE.getValueAdded());
            } else if(CHANGE.wasRemoved()) {
                Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
            }
        });
    });
}
项目:Shapify    文件:Document.java   
public void addPropertyChangedListener(Node object) {
    if (object instanceof Shape) {
        Shape shape = (Shape) object;

        shape.fillProperty().addListener((observable, oldValue, newValue) -> {
            HistoryController.getInstance(mainController).createHistoryPoint();
        });

        shape.strokeProperty().addListener((observable, oldValue, newValue) -> {
            HistoryController.getInstance(mainController).createHistoryPoint();
        });

        shape.strokeWidthProperty().addListener((observable, oldValue, newValue) -> {
            HistoryController.getInstance(mainController).createHistoryPoint();
        });
    }
}
项目:openjfx-8u-dev-tests    文件:Shapes2App.java   
private void register(final ShapeFactory content, final int slotsize) {
    final PageWithSlots page = new PageWithSlots(content.name, height, width);
    page.setSlotSize(slotsize, slotsize);
    for (final AbstractEffect effect : effects) {
                Pane slot = new Pane();//Region();
                Shape shape = content.createShape();
                shape.setTranslateX(10);
                shape.setTranslateY(10);
                effect.setEffect(shape, slot); // will add shape to scene at the appropriate moment
        page.add(new TestNodeLeaf(effect.name(), slot));
    }

    Shape customShape = content.createCustomShape();
    if (null != customShape) {
        customShape.setTranslateX(10);
        customShape.setTranslateY(10);
        page.add(new TestNodeLeaf("customShape", customShape));
    }
    rootTestNode.add(page);
}
项目:openjfx-8u-dev-tests    文件:ShapePathElementsApp.java   
private void register(final ShapeFactory content, final int slotsize) {
    addPage(content.name, new Runnable() {
        public void run() {
            SLOTSIZEX = slotsize;
            SLOTSIZEY = slotsize;

            for (Effects effect : Effects.values()) {
                //Region slot = new Region();
                Pane slot = new Pane();
                Shape shape = content.createShape();
                effect.setEffect(shape, slot); // will add shape to scene at the appropriate moment
                addSlot(effect.name(), slot);
            }

            content.addCustomShapes(getPageContent(), shiftX, shiftY);
        }
    });
}
项目:openjfx-8u-dev-tests    文件:LocalTo_TransformsTest.java   
@Before
@Override
public void before()
{
    super.before();
    circleOneWrap = byID(getScene(), "circle_one", Shape.class);
    circleTwoWrap = byID(getScene(), "circle_two", Shape.class);
    circleThreeWrap = byID(getScene(), "circle_three", Shape.class);
    circleFourWrap = byID(getScene(), "circle_four", Shape.class);
    realTranform.setMxx(1);
    realTranform.setMxy(0);
    realTranform.setMxz(0);
    realTranform.setMyx(0);
    realTranform.setMyy(1);
    realTranform.setMyz(0);
    realTranform.setMzx(0);
    realTranform.setMzy(0);
    realTranform.setMzz(1);
}
项目:openjfx-8u-dev-tests    文件:DepthTestTest.java   
@Override
@Before
public void before()
{
    super.before();
    System.out.println("fx: " + VersionInfo.getRuntimeVersion());
    firstDTest = byID(getScene(), "first_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    secondDTest = byID(getScene(), "second_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    parentDTest = byID(getScene(), "parent_depth_test", ComboBox.class).as(ComboBoxWrap.class);
    firstNodeCombo = byID(getScene(), "first_node_combo", ComboBox.class).as(ComboBoxWrap.class);
    secondNodeCombo = byID(getScene(), "second_node_combo", ComboBox.class).as(ComboBoxWrap.class);
    firstToFront = byID(getScene(), "first_node_to_front", RadioButton.class).as(ToggleButtonWrap.class);
    secondToFront = byID(getScene(), "second_node_to_front", RadioButton.class).as(ToggleButtonWrap.class);
    indicator = byID(getScene(), "indicator", Shape.class);
    referenceGreen = byID(getScene(), "reference_green", Shape.class);
    referenceRed = byID(getScene(), "reference_red", Shape.class);
}
项目:Simulizer    文件:ALU.java   
/**
 * Sets attributes on the shape, useful when resizing
 * @param x The new x coordinate
 * @param y The new y coordinate
 * @param width The new width
 * @param height The new height
 */
public void setAttrs(double x, double y, double width, double height){
    Shape shape = getComponentShape();
    Text text = getComponentLabel();
    setLayoutX(x);
    shape.setLayoutX(x);
    setLayoutY(y);
    shape.setLayoutY(y);
    setX(x);
    setY(y);
    setShapeWidth(width);
    setPrefWidth(width);
    setShapeHeight(height);
    setPrefHeight(height);
    text.setWrappingWidth(width);
    drawShape(((Polyline) shape));
}
项目:MagicMetro    文件:ConcreteTrainView.java   
/**
 * Instantiates a new Concrete train view.
 *
 * @param sprite               the sprite
 * @param spriteWidth          the sprite width
 * @param spriteHeight         the sprite height
 * @param passengersPositions  the passengers positions
 * @param passengerViewFactory the PassengerView factory
 * @param mapView              the map view
 */
public ConcreteTrainView(Shape sprite,
                         int spriteWidth,
                         int spriteHeight,
                         List<Point2d> passengersPositions,
                         PassengerViewFactory passengerViewFactory,
                         MapView mapView) {
    this.sprite = sprite;
    this.mapView = mapView;
    Platform.runLater(() -> {
        this.getChildren().add(this.sprite);
        this.sprite.setTranslateX(0);
        this.sprite.setTranslateY(0);
        this.setLayoutX(-spriteWidth / 2);
        this.setLayoutY(-spriteHeight / 2);
    });
    this.passengersPositions = passengersPositions;
    this.freePassengersPositionsIndex = new LinkedList<>();
    for(int i = 0; i < this.passengersPositions.size(); ++i) {
        this.freePassengersPositionsIndex.add(i);
    }
    this.passengerViewFactory = passengerViewFactory;
}
项目:MagicMetro    文件:ConcretePassengerCarView.java   
/**
 * Instantiates a new ConcretePassengerCarView.
 *
 * @param sprite               the sprite
 * @param spriteWidth          the sprite width
 * @param spriteHeight         the sprite height
 * @param passengersPositions  the passengers positions
 * @param passengerViewFactory the passenger view factory
 */
public ConcretePassengerCarView(Shape sprite,
                                int spriteWidth,
                                int spriteHeight,
                                List<Point2d> passengersPositions,
                                PassengerViewFactory passengerViewFactory) {
    this.sprite = sprite;
    Platform.runLater(() -> {
        this.getChildren().add(this.sprite);
        this.sprite.setTranslateX(0);
        this.sprite.setTranslateY(0);
        this.setLayoutX(-spriteWidth / 2);
        this.setLayoutY(-spriteHeight / 2);
    });
    this.passengersPositions = passengersPositions;
    this.freePassengersPositionsIndex = new LinkedList<>();
    for(int i = 0; i < this.passengersPositions.size(); ++i) {
        this.freePassengersPositionsIndex.add(i);
    }
    this.passengerViewFactory = passengerViewFactory;
    //TODO
}
项目:Sprint-JavaFX-Animation    文件:Sprint.java   
/**
 * Animates the element's color to the new one given. CAN ONLY BE APPLIED TO SHAPES.
 * @param duration Duration of the animation
 * @param color The color to animate to.
 */
public Sprint fillTo(double duration, Color color) {

    KeyValue keyValueX;

    if (node instanceof Shape) {
        Shape shape = (Shape) node;
        keyValueX = new KeyValue(shape.fillProperty(), color, interpolator);
    } else {
        return this;
    }

    KeyFrame keyFrame = new KeyFrame(Duration.seconds(duration), keyValueX);
    timeline.getKeyFrames().add(keyFrame);

    return this;
}
项目:Sprint-JavaFX-Animation    文件:Sprint.java   
/**
 * Animates the element's color from the given rotation to the existing one. CAN ONLY BE APPLIED TO SHAPES.
 * @param duration Duration of the animation
 * @param color The color to animate from
 */
public Sprint fillFrom(double duration, Color color) {

    KeyValue keyValueX;

    if (node instanceof Shape) {
        Shape shape = (Shape) node;
        keyValueX = new KeyValue(shape.fillProperty(), shape.getFill(), interpolator);

        shape.setFill(color);
    } else {
        return this;
    }

    KeyFrame keyFrame = new KeyFrame(Duration.seconds(duration), keyValueX);
    timeline.getKeyFrames().add(keyFrame);

    return this;
}
项目:Sprint-JavaFX-Animation    文件:Sprint.java   
/**
 * Animates the element's border color to the new one given. CAN ONLY BE APPLIED TO SHAPES.
 * @param duration Duration of the animation
 * @param color The color to animate to.
 */
public Sprint strokeTo(double duration, Color color) {

    KeyValue keyValueX;

    if (node instanceof Shape) {
        Shape shape = (Shape) node;
        keyValueX = new KeyValue(shape.strokeProperty(), color, interpolator);
    } else {
        return this;
    }

    KeyFrame keyFrame = new KeyFrame(Duration.seconds(duration), keyValueX);
    timeline.getKeyFrames().add(keyFrame);

    return this;
}
项目:Sprint-JavaFX-Animation    文件:Sprint.java   
/**
 * Animates the element's border color from the given rotation to the existing one. CAN ONLY BE APPLIED TO SHAPES.
 * @param duration Duration of the animation
 * @param color The color to animate from
 */
public Sprint strokeFrom(double duration, Color color) {

    KeyValue keyValueX;

    if (node instanceof Shape) {
        Shape shape = (Shape) node;
        keyValueX = new KeyValue(shape.strokeProperty(), shape.getStroke(), interpolator);

        shape.setStroke(color);
    } else {
        return this;
    }

    KeyFrame keyFrame = new KeyFrame(Duration.seconds(duration), keyValueX);
    timeline.getKeyFrames().add(keyFrame);

    return this;
}
项目:Specvis    文件:ViewStimulusAndBackgroundController.java   
@FXML
private void setLookForPanePreview() {

    // 1. Set background color.
    int hueForBackground = (int) functions.round(luminanceScaleForBackground.getHue(), 0);
    int saturationForBackground = (int) functions.round(luminanceScaleForBackground.getSaturation(), 0);
    int brightnessForBackground = Integer.valueOf(spinnerBackgroundBrightness.getValue().toString());
    String colorForBackground = "-fx-background-color: hsb(" + hueForBackground + ", " + saturationForBackground + "%, " + brightnessForBackground + "%);";

    // 2. Create stimulus.
    Shape stimulus;
    if (comboBoxStimulusShape.getSelectionModel().getSelectedItem().equals("Ellipse")) {
        stimulus = createEllipseStimulus();
    } else {
        stimulus = createPolygonStimulus();
    }

    // 3. Set panePreview.
    if (panePreview.getChildren().size() > 0) {
        panePreview.getChildren().remove(panePreview.getChildren().size() - 1);
    }
    panePreview.setStyle(colorForBackground);
    panePreview.getChildren().add(stimulus);
}
项目:Specvis    文件:ViewFixationAndOtherController.java   
private void setLookForPanePreview() {

            // 1. Set background color.
        int hueForBackground = (int) functions.round(luminanceScaleForBackground.getHue(), 0);
        int saturationForBackground = (int) functions.round(luminanceScaleForBackground.getSaturation(), 0);
        int brightnessForBackground = uiSettingsStimulusAndBackground.getBackgroundBrightness();
        String colorForBackground = "-fx-background-color: hsb(" + hueForBackground + ", " + saturationForBackground + "%, " + brightnessForBackground + "%);";

        // 2. Create fixation point.
        Shape fixationPoint = createEllipseFixationPoint();

        // 3. Set panePreview.
        if (panePreview.getChildren().size() > 0) {
            panePreview.getChildren().remove(panePreview.getChildren().size() - 1);
        }
        panePreview.setStyle(colorForBackground);
        panePreview.getChildren().add(fixationPoint);
    }
项目:Specvis    文件:ViewFixMonitorBlindspotController.java   
@FXML
private void setLookForPanePreview() {

    // 1. Set background color.
    int hueForBackground = (int) functions.round(luminanceScaleForBackground.getHue(), 0);
    int saturationForBackground = (int) functions.round(luminanceScaleForBackground.getSaturation(), 0);
    int brightnessForBackground = StartApplication.getSpecvisData().getUiSettingsStimulusAndBackground().getBackgroundBrightness();
    String colorForBackground = "-fx-background-color: hsb(" + hueForBackground + ", " + saturationForBackground + "%, " + brightnessForBackground + "%);";

    // 2. Create monitor stimulus.
    Shape monitorStimulus = createEllipseStimulus();

    // 3. Set panePreview.
    if (panePreview.getChildren().size() > 0) {
        panePreview.getChildren().remove(panePreview.getChildren().size() - 1);
    }
    panePreview.setStyle(colorForBackground);
    panePreview.getChildren().add(monitorStimulus);
}
项目:Specvis    文件:ViewFixMonitorBothController.java   
@FXML
private void setLookForPaneChangedFixPointPreview() {

    // 1. Set background color.
    int hueForBackground = (int) functions.round(luminanceScaleForBackground.getHue(), 0);
    int saturationForBackground = (int) functions.round(luminanceScaleForBackground.getSaturation(), 0);
    int brightnessForBackground = StartApplication.getSpecvisData().getUiSettingsStimulusAndBackground().getBackgroundBrightness();
    String colorForBackground = "-fx-background-color: hsb(" + hueForBackground + ", " + saturationForBackground + "%, " + brightnessForBackground + "%);";

    // 2. Create changed fix point.
    Shape changedFixPoint = createEllipseStimulus(
            Double.valueOf(spinnerChangedFixPointSizeInDgX.getValue().toString()),
            Double.valueOf(spinnerChangedFixPointSizeInDgY.getValue().toString()),
            colorPickerChangedFixPoint.getValue(),
            paneChangedFixPointPreview
    );

    // 3. Set panePreview.
    if (paneChangedFixPointPreview.getChildren().size() > 0) {
        paneChangedFixPointPreview.getChildren().remove(paneChangedFixPointPreview.getChildren().size() - 1);
    }
    paneChangedFixPointPreview.setStyle(colorForBackground);
    paneChangedFixPointPreview.getChildren().add(changedFixPoint);
}
项目:Specvis    文件:ViewFixMonitorFixPointChangeController.java   
@FXML
private void setLookForPanePreview() {

    // 1. Set background color.
    int hueForBackground = (int) functions.round(luminanceScaleForBackground.getHue(), 0);
    int saturationForBackground = (int) functions.round(luminanceScaleForBackground.getSaturation(), 0);
    int brightnessForBackground = StartApplication.getSpecvisData().getUiSettingsStimulusAndBackground().getBackgroundBrightness();
    String colorForBackground = "-fx-background-color: hsb(" + hueForBackground + ", " + saturationForBackground + "%, " + brightnessForBackground + "%);";

    // 2. Create changed fix point.
    Shape changedFixPoint = createEllipseStimulus();

    // 3. Set panePreview.
    if (panePreview.getChildren().size() > 0) {
        panePreview.getChildren().remove(panePreview.getChildren().size() - 1);
    }
    panePreview.setStyle(colorForBackground);
    panePreview.getChildren().add(changedFixPoint);
}
项目:ColorSelector    文件:ColorSelector.java   
private void initGraphics() {
    gradient = new ConicalGradient(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, gradientLookup.getStops());

    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, center),
                          new Circle(center, center, PREFERRED_WIDTH * 0.28813559));
    ring.setFill(gradient.getImagePattern(ring.getLayoutBounds()));

    mainCircle = new Circle();
    mainCircle.setStrokeType(StrokeType.INSIDE);
    mainCircle.setMouseTransparent(true);

    pane = new Pane(ring, mainCircle);

    getChildren().setAll(pane);
}
项目:FXGraphs    文件:DynamicArrowView.java   
public DynamicArrowView(Shape source, Shape target) {
    Polygon polygon = new Polygon(0, 0, 30, 0, 15, 15);
    transformArrow(source, target, polygon);

    source.translateXProperty().addListener(getChangeListener(source, target, polygon));
    target.translateXProperty().addListener(getChangeListener(source, target, polygon));
    source.translateYProperty().addListener(getChangeListener(source, target, polygon));
    target.translateYProperty().addListener(getChangeListener(source, target, polygon));

    polygon.getTransforms().addAll(trans1, rot, trans2);
    trans2.setX(-15);
    trans2.setY(-15);
    polygon.setFill(Color.GRAY);

    getChildren().add(polygon);
}
项目:FXGraphs    文件:DynamicArrowView.java   
private Point2D findIntersectionPoint(Point2D a, Point2D b, Shape target) {
    Point2D middle = new Point2D((a.getX() + b.getX()) / 2, (a.getY() + b.getY()) / 2);
    System.out.println(middle.getX() + " " + middle.getY());
    if (a.distance(b) < 1) {
        System.out.println("A: " + a.getX() + " " + a.getY());
        System.out.println("B: " + b.getX() + " " + b.getY());
        System.out.println("Middle: " + middle.getX() + " " + middle.getY());
        return middle;
    }
    Point2D local = target.parentToLocal(middle);
    System.out.println("contains2222 " + local.getX() + " " + local.getY());
    if (target.contains(local)) {
        System.out.println("contains " + local.getX() + " " + local.getY());
        return findIntersectionPoint(a, middle, target);
    } else {
        return findIntersectionPoint(middle, b, target);
    }
}
项目:marlin-fx    文件:ShapeOutlineBugCirclePath.java   
@Override
public void start(Stage stage) throws Exception {
    double r = SMALL ? 100 : 1843200.0;
    double c = D - r / sqrt2;

    Circle circle = new Circle(c, c, r, Color.GREY);
    Circle littlecircle = new Circle(c, c, 10, Color.GREY);
    Shape shape = Shape.union(circle, littlecircle);
    printShape(shape);

    shape.setFill(Color.BLUE);
    shape.setStroke(Color.RED);
    shape.setStrokeWidth(2.0);
    shape.getStrokeDashArray().addAll(10.0, 5.0);

    Pane root = new Pane();
    root.getChildren().add(shape);

    stage.setScene(new Scene(root, SIZE, SIZE));
    stage.show();
}
项目:javafx-dpi-scaling    文件:ShapeAdjuster.java   
@Override
public Node adjust(Node node, double scale) {
    requireNonNull(node);
    requireValidScale(scale);

    if (node instanceof Shape) {
        Shape shape = (Shape) node;
        shape.strokeDashOffsetProperty().set(shape.strokeDashOffsetProperty().multiply(scale).get());
        shape.strokeWidthProperty().set(shape.strokeWidthProperty().multiply(scale).get());
        shape.strokeMiterLimitProperty().set(shape.strokeMiterLimitProperty().multiply(scale).get());
        shape.translateXProperty().set(shape.translateXProperty().multiply(scale).get());
        shape.translateYProperty().set(shape.translateYProperty().multiply(scale).get());
        shape.translateZProperty().set(shape.translateZProperty().multiply(scale).get());
    }
    return super.adjust(node, scale);
}
项目:FXGL    文件:TestLoadingScene.java   
public TestLoadingScene() {

        getText().setFont(Font.font("Segoe UI", 24));
        getText().setTranslateY(50);

        Circle circle = new Circle(50, 50, 50);

        Shape shape = Shape.subtract(new Rectangle(100, 100), circle);
        shape.setFill(Color.BLUE);
        shape.setStroke(Color.YELLOW);

        RotateTransition rt = new RotateTransition(Duration.seconds(2), shape);
        rt.setByAngle(360);
        rt.setCycleCount(15);
        rt.play();

        shape.setTranslateX(700);
        shape.setTranslateY(500);

        getContentRoot().getChildren().set(1, shape);
    }
项目:iso-game-engine    文件:Tile.java   
/**
 * Create or destroy the highlight node as necessary.
 * */
private void setHighlight0(final CameraAngle angle) {
    final ObservableList<Node> graph = subGraph.getChildren();

    if (highlightColor.isPresent()) {
        final Shape n = highlightNode.orElseGet(() -> {
            final Shape r = getHighlightShape(angle);
            r.setCache(true);

            // the highlighter goes in the second to last position, so that it
            // always appears behind the debug text
            graph.add(graph.size() - 1, r);
            highlightNode = Optional.of(r);
            return r;
        });

        n.setFill(highlightColor.get());
    } else {
        highlightNode.ifPresent(n -> {
            graph.remove(n);
            highlightNode = Optional.empty();
        });
    }
}
项目:mars-sim    文件:SlideDemo.java   
/**
 * Generate the path transition.
 * 
 * @param shape Shape to travel along path.
 * @param path Path to be traveled upon.
 * @param duration Duration of single animation.
 * @param delay Delay before beginning first animation.
 * @param orientation Orientation of shape during animation.
 * @return PathTransition.
 */
private PathTransition generatePathTransition(
   final Shape shape, final Path path,
   final Duration duration, final Duration delay,
   final OrientationType orientation)
{
   final PathTransition pathTransition = new PathTransition();
   pathTransition.setDuration(duration);
   pathTransition.setDelay(delay);
   pathTransition.setPath(path);
   pathTransition.setNode(shape);
   pathTransition.setOrientation(orientation);
   pathTransition.setCycleCount(Timeline.INDEFINITE);
   pathTransition.setAutoReverse(true);
   return pathTransition;
}
项目:LifeTiles    文件:TestSunburstRingSegment.java   
@Test
public void testDefaultColor() throws InterruptedException {
    DegreeRange degreeRange = Mockito.mock(DegreeRange.class);
    Point2D center = Mockito.mock(Point2D.class);

    //dirty hack to get around javafx threading issues in tests
    Platform.runLater(() -> {
        SunburstRingSegment test = new SunburstRingSegment(new PhylogeneticTreeItem(),
                0, degreeRange, center, 1d);
        testColor = (Shape)test.getChildren().get(0);
    });
    Thread.sleep(1000);

    assertNotNull("color was null", testColor.getFill());
    assertTrue("color was not a Color", testColor.getFill() instanceof Color);
}
项目:LifeTiles    文件:TestSunburstRingSegment.java   
@Test
public void testSequenceColor() throws InterruptedException {
    PhylogeneticTreeItem node = new PhylogeneticTreeItem();
    Sequence sequence = Mockito.mock(Sequence.class);
    Mockito.when(sequence.getIdentifier()).thenReturn("A");
    node.setSequence(sequence);

    DegreeRange degreeRange = Mockito.mock(DegreeRange.class);
    Point2D center = Mockito.mock(Point2D.class);

  //dirty hack to get around javafx threading issues in tests
    Platform.runLater(() -> {
        SunburstRingSegment test = new SunburstRingSegment(new PhylogeneticTreeItem(),
                0, degreeRange, center, 1d);
        testColor = (Shape)test.getChildren().get(0);
    });

    Thread.sleep(1000);
    assertNotNull("color was null", testColor.getFill());
    assertTrue("color was not a Color", testColor.getFill() instanceof Color);
}
项目:Elegit    文件:Highlighter.java   
/**
 * First requests the focus of the MatchedScrollPanes, then
 * sets the state of the given cell to emphasized, and fianlly
 * performs an animation on it. Currently, the animation is
 * a repeated scaling.
 * Cells being emphasized are blocked from other highlighting.
 * @param c the cell to emphasize
 */
public static void emphasizeCell(Cell c){
    if(!blockedCellIDs.contains(c.getCellId())){
        blockedCellIDs.add(c.getCellId());
    }

    Platform.runLater(() -> {
        CommitTreeScrollPane.scrollTo(c.rowLocationProperty.doubleValue());
        c.setCellState(CellState.EMPHASIZED);

        Shape s = (Shape) c.view;

        ScaleTransition sct = new ScaleTransition(Duration.millis(425), s);
        sct.setByX(0.3f);
        sct.setByY(0.3f);
        sct.setCycleCount(6);
        sct.setAutoReverse(true);

        c.view.setScaleX(1.0);
        c.view.setScaleY(1.0);

        sct.play();

        sct.setOnFinished(event -> endEmphasisOnCell(c));
    });
}