當前位置: 首頁>>代碼示例>>Java>>正文


Java Circle類代碼示例

本文整理匯總了Java中javafx.scene.shape.Circle的典型用法代碼示例。如果您正苦於以下問題:Java Circle類的具體用法?Java Circle怎麽用?Java Circle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Circle類屬於javafx.scene.shape包,在下文中一共展示了Circle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import javafx.scene.shape.Circle; //導入依賴的package包/類
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 250, 90));

    //create circles by method createMovingCircle listed below
    Circle circle1 = createMovingCircle(Interpolator.LINEAR); //default interpolator
    circle1.setOpacity(0.7);
    Circle circle2 = createMovingCircle(Interpolator.EASE_BOTH); //circle slows down when reached both ends of trajectory
    circle2.setOpacity(0.45);
    Circle circle3 = createMovingCircle(Interpolator.EASE_IN);
    Circle circle4 = createMovingCircle(Interpolator.EASE_OUT);
    Circle circle5 = createMovingCircle(Interpolator.SPLINE(0.5, 0.1, 0.1, 0.5)); //one can define own behaviour of interpolator by spline method
    
    root.getChildren().addAll(
            circle1,
            circle2,
            circle3,
            circle4,
            circle5
    );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:TimelineInterpolator.java

示例2: initializeIcon

import javafx.scene.shape.Circle; //導入依賴的package包/類
private void initializeIcon() {
    final Circle circle = (Circle) lookup("#iconBackground");
    final FontIcon icon = (FontIcon) lookup("#icon");

    component.get().colorProperty().addListener((obs, oldColor, newColor) -> {
        circle.setFill(newColor.getColor(component.get().getColorIntensity()));
        icon.setFill(newColor.getTextColor(component.get().getColorIntensity()));
    });

    circle.setFill(component.get().getColor().getColor(component.get().getColorIntensity()));
    icon.setFill(component.get().getColor().getTextColor(component.get().getColorIntensity()));

    component.get().isMainProperty().addListener((obs, oldIsMain, newIsMain) -> {
        if (newIsMain) {
            icon.setIconLiteral("gmi-star");
            icon.setIconSize(22);
        } else {
            icon.setIconLiteral("gmi-description");
            icon.setIconSize(22);
        }
    });
}
 
開發者ID:ulriknyman,項目名稱:H-Uppaal,代碼行數:23,代碼來源:FilePresentation.java

示例3: createMovingCircle

import javafx.scene.shape.Circle; //導入依賴的package包/類
private Circle createMovingCircle(Interpolator interpolator, Color color){
    Circle circle = new Circle(25,25,35,color);
    circle.setOpacity(0.0);
    //add effect
    circle.setEffect(new Lighting());

    //create a timeline for moving the circle
       
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //create a keyValue for horizontal translation of circle to the position 155px with given interpolator
    KeyValue keyValue = new KeyValue(circle.translateXProperty(), 155, interpolator);

    //create a keyFrame with duration 4s
    KeyFrame keyFrame = new KeyFrame(Duration.seconds(4), keyValue);
    
    //add the keyframe to the timeline
    timeline.getKeyFrames().add(keyFrame);
    
    return circle;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:23,代碼來源:InterpolatorSample.java

示例4: TimelineSample

import javafx.scene.shape.Circle; //導入依賴的package包/類
public TimelineSample() {
    super(280,120);

    //create a circle
    final Circle circle = new Circle(25,25, 20,  Color.web("1c89f4"));
    circle.setEffect(new Lighting());

    //create a timeline for moving the circle
    timeline = new Timeline();        
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);

    //one can start/pause/stop/play animation by
    //timeline.play();
    //timeline.pause();
    //timeline.stop();
    //timeline.playFromStart();
    
    //add the following keyframes to the timeline
    timeline.getKeyFrames().addAll
        (new KeyFrame(Duration.ZERO,
                      new KeyValue(circle.translateXProperty(), 0)),
         new KeyFrame(new Duration(4000),
                      new KeyValue(circle.translateXProperty(), 205)));


    getChildren().add(createNavigation());
    getChildren().add(circle);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d)
            //TODO it is possible to do it for integer?
    );
    // END REMOVE ME
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:36,代碼來源:TimelineSample.java

示例5: CircleSample

import javafx.scene.shape.Circle; //導入依賴的package包/類
public CircleSample() {
    super(180,90);
    // Simple red filled circle
    Circle circle1 = new Circle(45,45,40, Color.RED);
    // Blue stroked circle
    Circle circle2 = new Circle(135,45,40);
    circle2.setStroke(Color.DODGERBLUE);
    circle2.setFill(null);
    // Create a group to show all the circles);
    getChildren().add(new Group(circle1,circle2));
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Circle 1 Fill", circle1.fillProperty()),
            new SimplePropertySheet.PropDesc("Circle 1 Radius", circle1.radiusProperty(), 10d, 40d),
            new SimplePropertySheet.PropDesc("Circle 2 Stroke", circle2.strokeProperty()),
            new SimplePropertySheet.PropDesc("Circle 2 Stroke Width", circle2.strokeWidthProperty(), 1d, 5d),
            new SimplePropertySheet.PropDesc("Circle 2 Radius", circle2.radiusProperty(), 10d, 40d)
    );
    // END REMOVE ME
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:21,代碼來源:CircleSample.java

示例6: RadialGradientSample

import javafx.scene.shape.Circle; //導入依賴的package包/類
public RadialGradientSample() {
    //create simple radial gradient
    RadialGradient gradient1 = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(1, Color.BLACK)
    });
    Circle circle1 = new Circle(45, 45, 40, gradient1);

    //create complex radial gradient
    RadialGradient gradient2 = new RadialGradient(20, 1, 0.5, 0.5, 0.6, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0,  Color.TRANSPARENT),
        new Stop(0.5,  Color.DARKGRAY),
        new Stop(0.64, Color.WHITESMOKE),
        new Stop(0.65, Color.YELLOW),
        new Stop(1, Color.GOLD)
    });
    Circle circle2 = new Circle(145, 45, 40, gradient2);

    HBox hb = new HBox(10);
    hb.getChildren().addAll(circle1, circle2);
    
    // show the circles
    getChildren().addAll(hb);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:25,代碼來源:RadialGradientSample.java

示例7: lollipop

import javafx.scene.shape.Circle; //導入依賴的package包/類
public static void lollipop(double x, double y) {
    Circle circle = new Circle(x, y, 2);
    circle.setFill(randomColor());
    FrameController.instance.hover.getChildren().add(circle);
    FadeTransition fadeTransition = new FadeTransition(Duration.millis(500), circle);
    fadeTransition.setAutoReverse(true);
    fadeTransition.setCycleCount(2);
    fadeTransition.setFromValue(0.0);
    fadeTransition.setToValue(1.0);
    ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(1000), circle);
    scaleTransition.setToX(10.0);
    scaleTransition.setToY(10.0);
    scaleTransition.setCycleCount(1);
    ParallelTransition parallelTransition = new ParallelTransition(fadeTransition, scaleTransition);
    parallelTransition.play();
    executorService.schedule(() -> Platform.runLater(() ->
            FrameController.instance.hover.getChildren().remove(circle)), 1000, TimeUnit.MILLISECONDS);
}
 
開發者ID:IzzelAliz,項目名稱:LCL,代碼行數:19,代碼來源:Transition.java

示例8: TranslateTransitionSample

import javafx.scene.shape.Circle; //導入依賴的package包/類
public TranslateTransitionSample() {
    super(400,40);
    Circle circle = new Circle(20, Color.CRIMSON);
    circle.setTranslateX(20);
    circle.setTranslateY(20);
    getChildren().add(circle);
    translateTransition = new TranslateTransition(Duration.seconds(4),circle);
    translateTransition.setFromX(20);
    translateTransition.setToX(380);
    translateTransition.setCycleCount(Timeline.INDEFINITE);
    translateTransition.setAutoReverse(true);        
    translateTransition = TranslateTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .node(circle)
            .fromX(20)
            .toX(380)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:21,代碼來源:TranslateTransitionSample.java

示例9: buildFragments

import javafx.scene.shape.Circle; //導入依賴的package包/類
private List<Circle> buildFragments(BubbleType bubbleType) {
    List<Circle> fragments = new ArrayList<>(nbFragments);

    for (int i = 0; i < nbFragments; i++) {

        Circle fragment = new Circle();
        fragment.setOpacity(1);
        fragment.setRadius(20);
        fragment.setVisible(true);
        fragment.setCenterX(-100);
        fragment.setCenterY(-100);

        if (bubbleType == BubbleType.COLOR) {
            fragment.setFill(new Color(Math.random(), Math.random(), Math.random(), 1));
        } else {
            fragment.setFill(new ImagePattern(newPhoto(), 0, 0, 1, 1, true));
        }

        fragments.add(fragment);
    }

    return fragments;
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:24,代碼來源:Bubble.java

示例10: addLocation

import javafx.scene.shape.Circle; //導入依賴的package包/類
public void addLocation(final Location LOCATION) {
    double x = (LOCATION.getLongitude() + 180) * (PREFERRED_WIDTH / 360) + MAP_OFFSET_X;
    double y = (PREFERRED_HEIGHT / 2) - (PREFERRED_WIDTH * (Math.log(Math.tan((Math.PI / 4) + (Math.toRadians(LOCATION.getLatitude()) / 2)))) / (2 * Math.PI)) + MAP_OFFSET_Y;

    Circle locationIcon = new Circle(x, y, size * 0.01);
    locationIcon.setFill(null == LOCATION.getColor() ? getLocationColor() : LOCATION.getColor());

    StringBuilder tooltipBuilder = new StringBuilder();
    if (!LOCATION.getName().isEmpty()) tooltipBuilder.append(LOCATION.getName());
    if (!LOCATION.getInfo().isEmpty()) tooltipBuilder.append("\n").append(LOCATION.getInfo());
    String tooltipText = tooltipBuilder.toString();
    if (!tooltipText.isEmpty()) {
        Tooltip tooltip = new Tooltip(tooltipText);
        tooltip.setFont(Font.font(10));
        Tooltip.install(locationIcon, tooltip);
    }

    if (null != LOCATION.getMouseEnterHandler()) locationIcon.setOnMouseEntered(new WeakEventHandler<>(LOCATION.getMouseEnterHandler()));
    if (null != LOCATION.getMousePressHandler()) locationIcon.setOnMousePressed(new WeakEventHandler<>(LOCATION.getMousePressHandler()));
    if (null != LOCATION.getMouseReleaseHandler()) locationIcon.setOnMouseReleased(new WeakEventHandler<>(LOCATION.getMouseReleaseHandler()));
    if (null != LOCATION.getMouseExitHandler()) locationIcon.setOnMouseExited(new WeakEventHandler<>(LOCATION.getMouseExitHandler()));


    locations.put(LOCATION, locationIcon);
}
 
開發者ID:HanSolo,項目名稱:charts,代碼行數:26,代碼來源:World.java

示例11: createPiece

import javafx.scene.shape.Circle; //導入依賴的package包/類
public Node createPiece(int piece, int column, int row) {
	switch (piece) {
	case 0:
		Circle black = new Circle(30, 30, 25);
		black.setFill(Color.BLACK);
		return black;
	case 1:
		Circle white = new Circle(30, 30, 25);
		white.setFill(Color.WHITE);
		return white;
	default:
		Circle transparent = new Circle(30, 30, 25);
		transparent.setFill(Color.TRANSPARENT);
		return transparent;
	}
}
 
開發者ID:edwardxia,項目名稱:board-client,代碼行數:17,代碼來源:Othello.java

示例12: start

import javafx.scene.shape.Circle; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Test");

    primaryStage.setFullScreen(true);

    Group root = new Group();

    Scene scene = new Scene(root, 1200, 700, Color.BLACK);

    Circle circle = new Circle(200, 300, 100, Color.YELLOW);

    root.getChildren().add(circle);

    GazeUtils.addEventFilter(circle);

    primaryStage.setScene(scene);
    primaryStage.show();
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:20,代碼來源:Test.java

示例13: Bubble

import javafx.scene.shape.Circle; //導入依賴的package包/類
public Bubble(Scene scene) {

        this.scene = scene;

        enterEvent = new EventHandler<Event>() {
            @Override
            public void handle(Event e) {

               // System.out.println(e.getEventType() + " " + e.getTarget());
                if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) {

                    //System.out.println(e.getEventType());
                    enter((Circle) e.getTarget());
                }
            }
        };

        for (int i = 0; i < 20; i++) {

            newCircle();
        }
    }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:23,代碼來源:Bubble.java

示例14: moveCircle

import javafx.scene.shape.Circle; //導入依賴的package包/類
private void moveCircle(Circle C) {

        double centerX = (scene.getWidth() - maxRadius) * Math.random() + maxRadius;
        double centerY = scene.getHeight();

        C.setCenterX(centerX);
        //C.setTranslateY((scene.getHeight() - maxRadius) * Math.random() + maxRadius);
        C.setCenterY(centerY);
        double radius = (maxRadius - minRadius) * Math.random() + minRadius;
        C.setFill(new Color(Math.random(), Math.random(), Math.random(), 1));
        C.setRadius(radius);

        Timeline timeline = new Timeline();

        double timelength = ((maxTimeLength - minTimeLength) * Math.random() + minTimeLength) * 1000;

        timeline.getKeyFrames().add(new KeyFrame(new Duration(timelength), new KeyValue(C.centerYProperty(), 0 - maxRadius, Interpolator.EASE_IN)));

       /* SequentialTransition sequence = new SequentialTransition();

        for(int i = 0; i < 10; i++) {
            sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX - 100)));
            sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX + 100)));
        }*/

        timeline.play();

        timeline.setOnFinished(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent actionEvent) {

                //moveCircle(C);
                newCircle();
            }
        });
    }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:38,代碼來源:Bubble.java

示例15: bind

import javafx.scene.shape.Circle; //導入依賴的package包/類
public static void bind(final Link subject, final ArrowHead target) {
    final Circle arrowHeadField = new Circle();
    arrowHeadField.centerXProperty().bind(target.xProperty());
    arrowHeadField.centerYProperty().bind(target.yProperty());
    arrowHeadField.setRadius(target.getHeadHeight());

    final LineBinding lineBinding = LineBinding.getCircleBindings(arrowHeadField, new Point(subject.startXProperty(), subject.startYProperty()));

    if (target.shouldBindToTip()) {
        subject.endXProperty().bind(target.xProperty());
        subject.endYProperty().bind(target.yProperty());
    } else {
        subject.endXProperty().bind(lineBinding.startX);
        subject.endYProperty().bind(lineBinding.startY);
    }
}
 
開發者ID:ulriknyman,項目名稱:H-Uppaal,代碼行數:17,代碼來源:BindingHelper.java


注:本文中的javafx.scene.shape.Circle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。