类javafx.scene.paint.Color源码实例Demo

下面列出了怎么用javafx.scene.paint.Color的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: charts   文件: XYPane.java
public XYPane(final Paint BACKGROUND, final int BANDS, final XYSeries<T>... SERIES) {
    getStylesheets().add(XYPane.class.getResource("chart.css").toExternalForm());
    aspectRatio        = PREFERRED_HEIGHT / PREFERRED_WIDTH;
    keepAspect         = false;
    _chartBackground   = BACKGROUND;
    listOfSeries       = FXCollections.observableArrayList(SERIES);
    scaleX             = 1;
    scaleY             = 1;
    symbolSize         = 2;
    noOfBands          = clamp(1, 5, BANDS);
    _lowerBoundX       = 0;
    _upperBoundX       = 100;
    _lowerBoundY       = 0;
    _upperBoundY       = 100;
    referenceZero      = true;
    _thresholdY        = 100;
    _thresholdYVisible = false;
    _thresholdYColor   = Color.RED;
    _polarTickStep     = PolarTickStep.FOURTY_FIVE;

    initGraphics();
    registerListeners();
}
 
源代码2 项目: mars-sim   文件: DotMatrix.java
public DotMatrix(final double PREFERRED_WIDTH, final double PREFERRED_HEIGHT, final int COLS, final int ROWS, final Color DOT_ON_COLOR, final Color DOT_OFF_COLOR, final DotShape DOT_SHAPE, final MatrixFont FONT) {
    preferredWidth         = PREFERRED_WIDTH;
    preferredHeight        = PREFERRED_HEIGHT;
    dotOnColor             = convertToInt(DOT_ON_COLOR);
    dotOffColor            = convertToInt(DOT_OFF_COLOR);
    dotShape               = DOT_SHAPE;
    cols                   = COLS;
    rows                   = ROWS;
    matrix                 = new int[cols][rows];
    matrixFont             = FONT;
    characterWidth         = matrixFont.getCharacterWidth();
    characterHeight        = matrixFont.getCharacterHeight();
    characterWidthMinusOne = characterWidth - 1;
    initGraphics();
    registerListeners();
}
 
源代码3 项目: marathonv5   文件: HBoxSample.java
public static Node createIconContent() {
    StackPane sp = new StackPane();
    HBox hbox = new HBox(3);
    hbox.setAlignment(Pos.CENTER);

    Rectangle rectangle = new Rectangle(70, 25, Color.LIGHTGREY);
    rectangle.setStroke(Color.BLACK);
    hbox.setPrefSize(rectangle.getWidth(), rectangle.getHeight());

    Rectangle r1 = new Rectangle(14, 14, Color.web("#1c89f4"));
    Rectangle r2 = new Rectangle(14, 14, Color.web("#349b00"));
    Rectangle r3 = new Rectangle(18, 14, Color.web("#349b00"));

    hbox.getChildren().addAll(r1, r2, r3);
    sp.getChildren().addAll(rectangle, hbox);

    return new Group(sp);
}
 
源代码4 项目: phoebus   文件: ImageScaling.java
@Override
public void start(final Stage stage)
{
    // Image with red border
    final WritableImage image = new WritableImage(WIDTH, HEIGHT);
    final PixelWriter writer = image.getPixelWriter();
    for (int x=0; x<WIDTH; ++x)
    {
        writer.setColor(x, 0, Color.RED);
        writer.setColor(x, HEIGHT-1, Color.RED);
    }
    for (int y=0; y<HEIGHT; ++y)
    {
        writer.setColor(0, y, Color.RED);
        writer.setColor(WIDTH-1, y, Color.RED);
    }

    // Draw into canvas, scaling 'up'
    final Canvas canvas = new Canvas(800, 600);
    canvas.getGraphicsContext2D().drawImage(image, 0, 0, canvas.getWidth(), canvas.getHeight());

    final Scene scene = new Scene(new Group(canvas), canvas.getWidth(), canvas.getHeight());
    stage.setScene(scene);
    stage.show();
}
 
源代码5 项目: marathonv5   文件: PathSample.java
public static Node createIconContent() {
    Path path = new Path();
           path.getElements().addAll(
            new MoveTo(25, 25),
            new HLineTo(45),
            new ArcTo(20, 20, 0, 80, 25, true, true)
            );
    path.setStroke(Color.web("#b9c0c5"));
    path.setStrokeWidth(5);
    path.getStrokeDashArray().addAll(15d,15d);
    path.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    path.setEffect(effect);
    return path;
}
 
源代码6 项目: fxgraph   文件: CellGestures.java
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty widthProperty = region.prefWidthProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleSE = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSE.xProperty().bind(xProperty.add(widthProperty).subtract(handleRadius / 2));
	resizeHandleSE.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSE, mouseLocation, Cursor.SE_RESIZE);

	resizeHandleSE.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragEast(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSE;
}
 
源代码7 项目: netbeans   文件: KeyStrokeMotion.java
private void createLetter(String c) {
    final Text letter = new Text(c);
    letter.setFill(Color.BLACK);
    letter.setFont(FONT_DEFAULT);
    letter.setTextOrigin(VPos.TOP);
    letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
    letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
    getChildren().add(letter);
    // over 3 seconds move letter to random position and fade it out
    final Timeline timeline = new Timeline();
    timeline.getKeyFrames().add(
            new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
                @Override public void handle(ActionEvent event) {
                    // we are done remove us from scene
                    getChildren().remove(letter);
                }
            },
            new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
            new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
            new KeyValue(letter.opacityProperty(), 0f)
    ));
    timeline.play();
}
 
源代码8 项目: phoebus   文件: TreeModelItemCell.java
@Override
protected void updateItem(final TreeModelItem item, final boolean empty)
{
    super.updateItem(item, empty);
    if (empty  ||  item == null)
    {
        setText(null);
        setGraphic(null);
    }
    else
    {
        setText(item.toString());
        final AlarmSeverity severity = item.getSeverity();
        if (severity == null)
        {
            setGraphic(new ImageView(NO_ICON));
            setTextFill(Color.BLACK);
        }
        else
        {
            final int ordinal = severity.ordinal();
            setGraphic(new ImageView(ALARM_ICONS[ordinal]));
            setTextFill(SeverityColors.getTextColor(severity));
        }
    }
}
 
源代码9 项目: jbox2d   文件: DebugDrawJavaFX.java
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  Color f = cpool.getColor(color.x, color.y, color.z, .4f);
  Color s = cpool.getColor(color.x, color.y, color.z, 1f);
  GraphicsContext g = getGraphics();
  saveState(g);
  double[] xs = xDoublePool.get(vertexCount);
  double[] ys = yDoublePool.get(vertexCount);
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], temp);
    xs[i] = temp.x;
    ys[i] = temp.y;
  }
  g.setLineWidth(stroke);
  g.setFill(f);
  g.fillPolygon(xs, ys, vertexCount);
  g.setStroke(s);
  g.strokePolygon(xs, ys, vertexCount);
  restoreState(g);
}
 
源代码10 项目: JavaFX   文件: KeyboardExample.java
public Node createNode() {
	final StackPane keyNode = new StackPane();
	keyNode.setFocusTraversable(true);
	installEventHandler(keyNode);

	final Rectangle keyBackground = new Rectangle(50, 50);
	keyBackground.fillProperty().bind(
			Bindings.when(pressedProperty)
					.then(Color.RED)
					.otherwise(
							Bindings.when(keyNode.focusedProperty())
									.then(Color.LIGHTGRAY)
									.otherwise(Color.WHITE)));
	keyBackground.setStroke(Color.BLACK);
	keyBackground.setStrokeWidth(2);
	keyBackground.setArcWidth(12);
	keyBackground.setArcHeight(12);

	final Text keyLabel = new Text(keyCode.getName());
	keyLabel.setFont(Font.font("Arial", FontWeight.BOLD, 20));

	keyNode.getChildren().addAll(keyBackground, keyLabel);

	return keyNode;
}
 
源代码11 项目: FXGLGames   文件: SpaceInvadersFactory.java
@Spawns("LaserBeam")
public Entity newLaserBeam(SpawnData data) {
    Rectangle view = new Rectangle(10, Config.HEIGHT - 25, Color.color(1.0, 1.0, 1.0, 0.86));
    view.setArcWidth(15);
    view.setArcHeight(15);
    view.setStroke(Color.BLUE);
    view.setStrokeWidth(1);

    return entityBuilder()
            .from(data)
            .type(LASER_BEAM)
            .viewWithBBox(view)
            .with(new CollidableComponent(true))
            .with(new LaserBeamComponent())
            .build();
}
 
源代码12 项目: mars-sim   文件: MainScene.java
/**
 * Creates the new ticker billboard
 */
public void createBillboard() {

	matrix = DotMatrixBuilder.create().prefSize(925, 54).colsAndRows(196, 11).dotOnColor(Color.rgb(255, 55, 0))
			.dotOffColor(Color.rgb(64, 64, 64)).dotShape(DotShape.ROUND).matrixFont(MatrixFont8x8.INSTANCE).build();

	billboard = new StackPane(matrix);
	// billboard.setPadding(new Insets(1));
	billboard.setBackground(
			new Background(new BackgroundFill(Color.rgb(20, 20, 20), CornerRadii.EMPTY, Insets.EMPTY)));
	// billboard.setBorder(new Border(new BorderStroke(Color.DARKCYAN,
	// BorderStrokeStyle.DOTTED, CornerRadii.EMPTY, BorderWidths.FULL)));
	dragNode = new DraggableNode(billboard, stage, 925, 54);

	dragNode.setCache(true);
	dragNode.setCacheShape(true);
	dragNode.setCacheHint(CacheHint.SPEED);
}
 
源代码13 项目: FXGLGames   文件: StarsComponent.java
private void respawn(Rectangle star) {
    star.setWidth(random(0.5f, 2.5f));
    star.setHeight(random(0.5f, 2.5f));
    star.setArcWidth(random(0.5f, 2.5f));
    star.setArcHeight(random(0.5f, 2.5f));

    star.setFill(Color.color(
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.75, 1.0),
            random(0.5f, 1.0f)
    ));

    star.setTranslateX(random(0, FXGL.getAppWidth()));
    star.setTranslateY(-random(10, FXGL.getAppHeight()));
}
 
源代码14 项目: cssfx   文件: CSSFXTesterApp.java
private Group buildCirclePane(int prefWidth, int prefHeight) {
    Group freePlacePane = new Group();
    int defaultShapeSize = 50;
    int shapeNumber = 10;
    Random r = new Random();

    for (int i = 0; i < shapeNumber; i++) {
        Circle c = new Circle(Math.max(10, defaultShapeSize * r.nextInt(100) / 100));
        c.getStyleClass().add("circle");
        if (i % 2 == 0) {
            c.getStyleClass().add("even");
        } else {
            c.getStyleClass().add("odd");
        }
        c.setCenterX(r.nextInt(prefWidth));
        c.setCenterY(r.nextInt(prefHeight));
        c.setFill(Color.BLUE);
        freePlacePane.getChildren().add(c);
    }

    freePlacePane.getStyleClass().add("circles");
    freePlacePane.prefWidth(250);
    freePlacePane.prefWidth(200);
    return freePlacePane;
}
 
源代码15 项目: fxgraph   文件: CellGestures.java
@Override
public Node apply(Region region, Wrapper<Point2D> mouseLocation) {
	final DoubleProperty xProperty = region.layoutXProperty();
	final DoubleProperty yProperty = region.layoutYProperty();
	final ReadOnlyDoubleProperty heightProperty = region.prefHeightProperty();

	final Rectangle resizeHandleSW = new Rectangle(handleRadius, handleRadius, Color.BLACK);
	resizeHandleSW.xProperty().bind(xProperty.subtract(handleRadius / 2));
	resizeHandleSW.yProperty().bind(yProperty.add(heightProperty).subtract(handleRadius / 2));

	setUpDragging(resizeHandleSW, mouseLocation, Cursor.SW_RESIZE);

	resizeHandleSW.setOnMouseDragged(event -> {
		if(mouseLocation.value != null) {
			dragSouth(event, mouseLocation, region, handleRadius);
			dragWest(event, mouseLocation, region, handleRadius);
			mouseLocation.value = new Point2D(event.getSceneX(), event.getSceneY());
		}
	});
	return resizeHandleSW;
}
 
源代码16 项目: paintera   文件: ImagePane.java
/**
	 * @param width
	 * 		preferred component width.
	 * @param height
	 * 		preferred component height.
	 */
	public ImagePane(
			final int width,
			final int height)
	{
		super();
		super.getChildren().add(imageView);
		this.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
		setWidth(width);
		setHeight(height);
//		super.getChildren().setAll(this.imageView);
	}
 
源代码17 项目: Intro-to-Java-Programming   文件: Exercise_16_03.java
/** Return a circle */
private Circle getCircle() {
	Circle c = new Circle(10);
	c.setFill(Color.WHITE);
	c.setStroke(Color.BLACK);
	return c;
}
 
源代码18 项目: Quelea   文件: MultimediaPanel.java
/**
 * Create a new image panel.
 */
public MultimediaPanel() {
    this.controlPanel = new MultimediaControls();
    controlPanel.setDisableControls(true);
    drawer = new MultimediaDrawer(controlPanel);
    imgView = new ImageView(new Image("file:icons/vid preview.png"));
    BorderPane.setMargin(controlPanel, new Insets(30));
    setCenter(controlPanel);
    VBox centerBit = new VBox(5);
    centerBit.setAlignment(Pos.CENTER);
    previewText = new Text();
    previewText.setFont(Font.font("Verdana", 20));
    previewText.setFill(Color.WHITE);
    BorderPane.setMargin(centerBit, new Insets(10));
    centerBit.getChildren().add(previewText);
    imgView.fitHeightProperty().bind(heightProperty().subtract(200));
    imgView.fitWidthProperty().bind(widthProperty().subtract(20));
    centerBit.getChildren().add(imgView);
    setBottom(centerBit);
    setMinWidth(50);
    setMinHeight(50);
    setStyle("-fx-background-color:grey;");
    
    addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent t) -> {
        if (t.getCode().equals(KeyCode.PAGE_DOWN) || t.getCode().equals(KeyCode.DOWN)) {
            t.consume();
            QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().advance();
        } else if (t.getCode().equals(KeyCode.PAGE_UP) || t.getCode().equals(KeyCode.UP)) {
            t.consume();
            QueleaApp.get().getMainWindow().getMainPanel().getLivePanel().previous();
        }
    });
    
    DisplayCanvas dummyCanvas = new DisplayCanvas(false, false, false, this::updateCanvas, DisplayCanvas.Priority.LOW);
    registerDisplayCanvas(dummyCanvas);
}
 
源代码19 项目: restfb-examples   文件: LoginJavaFXExample.java
public void start(Stage stage) {
  // parse arguments
  appId = getParameters().getRaw().get(0);
  appSecret = getParameters().getRaw().get(1);

  WebView webView = new WebView();
  WebEngine webEngine = webView.getEngine();

  // create the scene
  stage.setTitle("Facebook Login Example");
  // use quite a wide window to handle cookies popup nicely
  stage.setScene(new Scene(new VBox(webView), 1000, 600, Color.web("#666970")));
  stage.show();

  // obtain Facebook access token by loading login page
  DefaultFacebookClient facebookClient = new DefaultFacebookClient(Version.LATEST);
  String loginDialogUrl = facebookClient.getLoginDialogUrl(appId, SUCCESS_URL, new ScopeBuilder());
  webEngine.load(loginDialogUrl + "&display=popup&response_type=code");
  webEngine.locationProperty().addListener((property, oldValue, newValue) -> {
        if (newValue.startsWith(SUCCESS_URL)) {
          // extract access token
          CLIENT_LOGGER.debug(newValue);
          int codeOffset = newValue.indexOf("code=");
          String code = newValue.substring(codeOffset + "code=".length());
          AccessToken accessToken = facebookClient.obtainUserAccessToken(
              appId, appSecret, SUCCESS_URL, code);

          // trigger further code's execution
          consumeAccessToken(accessToken);

          // close the app as goal was reached
          stage.close();

        } else if ("https://www.facebook.com/dialog/close".equals(newValue)) {
          throw new IllegalStateException("dialog closed");
        }
      }
  );
}
 
源代码20 项目: tilesfx   文件: SmoothedChart.java
public void setSelectorStrokeColor(final Color COLOR) {
    if (null == selectorStrokeColor) {
        _selectorStrokeColor = COLOR;
        selector.setStroke(_selectorStrokeColor);
        layoutPlotChildren();
    } else {
        selectorStrokeColor.set(COLOR);
    }
}
 
源代码21 项目: charts   文件: InfoPopup.java
private void updateTextColor(final Color COLOR) {
    seriesText.setFill(COLOR);
    seriesSumText.setFill(COLOR);
    itemText.setFill(COLOR);
    valueText.setFill(COLOR);
    line.setStroke(COLOR);
    seriesNameText.setFill(COLOR);
    seriesValueText.setFill(COLOR);
    itemNameText.setFill(COLOR);
    itemValueText.setFill(COLOR);
}
 
源代码22 项目: tuxguitar   文件: JFXStyleableColor.java
public ObjectProperty<Color> colorProperty() {
	if( this.color == null) {
		this.color = new StyleableObjectProperty<Color>(DEFAULT_COLOR) {

			@Override
			protected void invalidated() {
				super.invalidated();
			}

			@Override
			public CssMetaData<? extends Styleable, Color> getCssMetaData() {
				return StyleableProperties.COLOR;
			}

			@Override
			public Object getBean() {
				return JFXStyleableColor.this;
			}

			@Override
			public String getName() {
				return "color";
			}
		};
	}
	return this.color;
}
 
源代码23 项目: CPUSim   文件: FontData.java
public void setFontAndBackground(TableCell region) {
    if(region.getTableView().getSelectionModel().isSelected(region.getIndex())) {
        //if the row is selected, set the background to the selection color
        region.setBackground(new Background(new BackgroundFill(Color.web(
                            selection), null, null)));
    }
    else {
        region.setBackground(new Background(new BackgroundFill(Color.web(
                            background), null, null)));
    }
    String optQuote = font.contains(" ") ? "\"" : "";
    region.setStyle("-fx-font-size:" + fontSize + "; "
            + "-fx-font-family:" + optQuote + font + optQuote);
}
 
源代码24 项目: OEE-Designer   文件: SmoothedChart.java
public void setXAxisBorderColor(final Paint FILL) {
    if (Side.BOTTOM == getXAxis().getSide()) {
        getXAxis().setBorder(new Border(
            new BorderStroke(FILL, Color.TRANSPARENT, Color.TRANSPARENT, Color.TRANSPARENT, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID,
                             BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY)));
    } else {
        getXAxis().setBorder(new Border(
            new BorderStroke(Color.TRANSPARENT, Color.TRANSPARENT, FILL, Color.TRANSPARENT, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID,
                             BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY)));
    }
}
 
源代码25 项目: mars-sim   文件: StarfieldFX.java
public void generate() {

        for (int i=0; i<STAR_COUNT; i++) {
        	
        	int hex = 0;
        	
        	int randColor = RandomUtil.getRandomInt(31);
        	
        	if (randColor == 0)
        		hex = 0xe7420b; // red orange	
        	else if (randColor == 1)
        		hex = 0xd0d0f9;  // light blue
        	else if (randColor == 2)
        		hex = 0xf4df0d; // FFFFE0; // yellow
        	else 
        		hex = 0xffffff; // white
        	
        	if (hex != 0xffffff) {
	        	int rand = RandomUtil.getRandomInt(127);
	        	hex = hex + rand;
        	}
        	
        	String hexString = Integer.toHexString(hex);
         	
        	Color c = Color.web(hexString, 1.0);
     		
       		nodes[i] = new Rectangle(1, 1, c);
        	
        	angles[i] = 2.0 * Math.PI * random.nextDouble();
            //start[i] = random.nextInt(2000000000);
            start[i] = random.nextInt(2000000000);

        }
        
    }
 
源代码26 项目: mars-sim   文件: Demo.java
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(matrix);
    pane.setPadding(new Insets(10));
    pane.setBackground(new Background(new BackgroundFill(Color.rgb(20, 20, 20), CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setTitle("DotMatrix");
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
源代码27 项目: marathonv5   文件: HeatTabController.java
/**
 * Helper function to convert a color in sRGB space to linear RGB space.
 */
public static Color convertSRGBtoLinearRGB(Color color) {
    double[] colors = new double[] { color.getRed(), color.getGreen(), color.getBlue() };
    for (int i=0; i<colors.length; i++) {
        if (colors[i] <= 0.04045) {
            colors[i] = colors[i] / 12.92;
        } else {
            colors[i] = Math.pow((colors[i] + 0.055) / 1.055, 2.4);
        }
    }
    return Color.color(colors[0], colors[1], colors[2], color.getOpacity());
}
 
源代码28 项目: BowlerStudio   文件: ScriptingWebWidget.java
private void reset() {
	running = false;
	Platform.runLater(() -> {
		runfx.setText("Run");
		runfx.setGraphic(AssetFactory.loadIcon("Run.png"));
		runfx.setBackground(new Background(new BackgroundFill(Color.LIGHTGREEN, CornerRadii.EMPTY, Insets.EMPTY)));

	});

}
 
源代码29 项目: tilesfx   文件: SunburstChart.java
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode<ChartData> NODE) {
    double  startAngleRad = Math.toRadians(START_ANGLE + 90);
    double  endAngleRad   = Math.toRadians(END_ANGLE + 90);
    boolean largeAngle    = Math.abs(END_ANGLE - START_ANGLE) > 180.0;

    double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
    double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);

    double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
    double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);

    double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
    double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);

    double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
    double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);

    MoveTo moveTo1 = new MoveTo(x1, y1);
    LineTo lineTo2 = new LineTo(x2, y2);
    ArcTo  arcTo3  = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
    LineTo lineTo4 = new LineTo(x4, y4);
    ArcTo  arcTo1  = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);

    Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);

    path.setFill(FILL);
    path.setStroke(STROKE);

    String tooltipText = new StringBuilder(NODE.getItem().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getItem().getValue())).toString();
    Tooltip.install(path, new Tooltip(tooltipText));

    path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));

    return path;
}
 
源代码30 项目: charts   文件: CoxcombChart.java
public CoxcombChart(final List<ChartItem> ITEMS) {
    width               = PREFERRED_WIDTH;
    height              = PREFERRED_HEIGHT;
    size                = PREFERRED_WIDTH;
    items               = FXCollections.observableArrayList(ITEMS);
    _textColor          = Color.WHITE;
    _autoTextColor      = true;
    _order              = Order.DESCENDING;
    _equalSegmentAngles = false;
    itemListener        = e -> reorder(getOrder());
    itemListListener    = c -> {
        while (c.next()) {
            if (c.wasAdded()) {
                c.getAddedSubList().forEach(addedItem -> addedItem.setOnItemEvent(itemListener));
                reorder(getOrder());
            } else if (c.wasRemoved()) {
                c.getRemoved().forEach(removedItem -> removedItem.removeItemEventListener(itemListener));
                reorder(getOrder());
            }
        }
        redraw();
    };
    mouseHandler        = e -> handleMouseEvent(e);
    listeners           = new CopyOnWriteArrayList<>();
    initGraphics();
    registerListeners();
}
 
 类所在包
 同包方法