类javafx.scene.canvas.Canvas源码实例Demo

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

源代码1 项目: Enzo   文件: SimpleLineChartSkin.java
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.06 * PREFERRED_HEIGHT)); // "OpenSans"

    canvasBkg = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxBkg    = canvasBkg.getGraphicsContext2D();

    canvasFg  = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxFg     = canvasFg.getGraphicsContext2D();

    pane      = new Pane();
    pane.getChildren().setAll(canvasBkg, canvasFg);

    getChildren().setAll(pane);
    resize();
    drawBackground();
    drawForeground();
}
 
源代码2 项目: jace   文件: Watch.java
public Watch(int address, final MetacheatUI outer) {
    super();
    this.outer = outer;
    this.address = address;
    cell = outer.cheatEngine.getMemoryCell(address);
    redraw = outer.animationTimer.scheduleAtFixedRate(this::redraw, MetacheatUI.FRAME_RATE, MetacheatUI.FRAME_RATE, TimeUnit.MILLISECONDS);
    setBackground(new Background(new BackgroundFill(Color.NAVY, CornerRadii.EMPTY, Insets.EMPTY)));
    Label addrLabel = new Label("$" + Integer.toHexString(address));
    addrLabel.setOnMouseClicked((evt)-> outer.inspectAddress(address));
    addrLabel.setTextAlignment(TextAlignment.CENTER);
    addrLabel.setMinWidth(GRAPH_WIDTH);
    addrLabel.setFont(new Font(Font.getDefault().getFamily(), 14));
    addrLabel.setTextFill(Color.WHITE);
    graph = new Canvas(GRAPH_WIDTH, GRAPH_HEIGHT);
    getChildren().add(addrLabel);
    getChildren().add(graph);
    CheckBox hold = new CheckBox("Hold");
    holding = hold.selectedProperty();
    holding.addListener((prop, oldVal, newVal) -> this.updateHold());
    getChildren().add(hold);
    hold.setTextFill(Color.WHITE);
}
 
源代码3 项目: chart-fx   文件: DragResizerUtilTests.java
@Test
public void testResizeHandler() {
    final Rectangle rect = new Rectangle(/* minX */ 0.0, /* minY */ 0.0, /* width */ 100.0, /* height */ 50.0);

    assertDoesNotThrow(() -> DragResizerUtil.DEFAULT_LISTENER.onDrag(rect, 0, 0, 10, 20));
    assertEquals(10, rect.getWidth());
    assertEquals(20, rect.getHeight());
    assertDoesNotThrow(() -> DragResizerUtil.DEFAULT_LISTENER.onResize(rect, 0, 0, 11, 21));
    assertEquals(11, rect.getWidth());
    assertEquals(21, rect.getHeight());

    final Canvas canvas = new Canvas(100, 50);
    assertDoesNotThrow(() -> DragResizerUtil.DEFAULT_LISTENER.onDrag(canvas, 0, 0, 10, 20));
    assertEquals(10, canvas.getWidth());
    assertEquals(20, canvas.getHeight());

    final Region region = new Region();
    region.setMinSize(100, 50);
    assertDoesNotThrow(() -> DragResizerUtil.DEFAULT_LISTENER.onDrag(region, 0, 0, 10, 20));
    assertEquals(10, region.getPrefWidth());
    assertEquals(20, region.getPrefHeight());
}
 
源代码4 项目: medusademo   文件: CustomGaugeSkin.java
private void initGraphics() {
    backgroundCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    backgroundCtx    = backgroundCanvas.getGraphicsContext2D();

    foregroundCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    foregroundCtx    = foregroundCanvas.getGraphicsContext2D();

    ledInnerShadow   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 0.2 * PREFERRED_WIDTH, 0, 0, 0);
    ledDropShadow    = new DropShadow(BlurType.TWO_PASS_BOX, getSkinnable().getBarColor(), 0.3 * PREFERRED_WIDTH, 0, 0, 0);

    pane = new Pane(backgroundCanvas, foregroundCanvas);
    pane.setBorder(new Border(new BorderStroke(getSkinnable().getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(1))));
    pane.setBackground(new Background(new BackgroundFill(getSkinnable().getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
源代码5 项目: FXTutorials   文件: DrawingApp.java
private Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(800, 600);

    Canvas canvas = new Canvas(800, 600);
    g = canvas.getGraphicsContext2D();

    AnimationTimer timer = new AnimationTimer() {
        @Override
        public void handle(long now) {
            t += 0.017;
            draw();
        }
    };
    timer.start();

    root.getChildren().add(canvas);
    return root;
}
 
源代码6 项目: Project-16x16   文件: SideScroller.java
/**
 * Called by Processing after settings().
 */
@Override
protected PSurface initSurface() {
	surface = (PSurfaceFX) super.initSurface();
	canvas = (Canvas) surface.getNative();
	canvas.widthProperty().unbind(); // used for scaling
	canvas.heightProperty().unbind(); // used for scaling
	scene = canvas.getScene();
	stage = (Stage) scene.getWindow();
	stage.setTitle("Project-16x16");
	stage.setResizable(false); // prevent abitrary user resize
	stage.setFullScreenExitHint(""); // disable fullscreen toggle hint
	stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); // prevent ESC toggling fullscreen
	scene.getWindow().addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, this::closeWindowEvent);
	return surface;
}
 
源代码7 项目: mcaselector   文件: TileImage.java
static void createMarkedChunksImage(Tile tile, int zoomLevel) {
	WritableImage wImage = new WritableImage(Tile.SIZE / zoomLevel, Tile.SIZE / zoomLevel);

	Canvas canvas = new Canvas(Tile.SIZE / (float) zoomLevel, Tile.SIZE / (float) zoomLevel);
	GraphicsContext ctx = canvas.getGraphicsContext2D();
	ctx.setFill(Config.getChunkSelectionColor().makeJavaFXColor());

	for (Point2i markedChunk : tile.markedChunks) {
		Point2i regionChunk = markedChunk.mod(Tile.SIZE_IN_CHUNKS);
		if (regionChunk.getX() < 0) {
			regionChunk.setX(regionChunk.getX() + Tile.SIZE_IN_CHUNKS);
		}
		if (regionChunk.getY() < 0) {
			regionChunk.setY(regionChunk.getY() + Tile.SIZE_IN_CHUNKS);
		}

		ctx.fillRect(regionChunk.getX() * Tile.CHUNK_SIZE / (float) zoomLevel, regionChunk.getY() * Tile.CHUNK_SIZE / (float) zoomLevel, Tile.CHUNK_SIZE / (float) zoomLevel, Tile.CHUNK_SIZE / (float) zoomLevel);
	}

	SnapshotParameters params = new SnapshotParameters();
	params.setFill(Color.TRANSPARENT.makeJavaFXColor());

	canvas.snapshot(params, wImage);

	tile.markedChunksImage = wImage;
}
 
源代码8 项目: JetUML   文件: StateTransitionEdgeViewer.java
@Override
public Canvas createIcon(Edge pEdge)
{   //CSOFF: Magic numbers
	Canvas canvas = new Canvas(BUTTON_SIZE, BUTTON_SIZE);
	GraphicsContext graphics = canvas.getGraphicsContext2D();
	graphics.scale(0.6, 0.6);
	Line line = new Line(new Point(2,2), new Point(40,40));
	final double tangent = Math.tan(Math.toRadians(DEGREES_10));
	double dx = (line.getX2() - line.getX1()) / 2;
	double dy = (line.getY2() - line.getY1()) / 2;
	Point control = new Point((int)((line.getX1() + line.getX2()) / 2 + tangent * dy), 
			(int)((line.getY1() + line.getY2()) / 2 - tangent * dx));         
	
	Path path = new Path();
	MoveTo moveTo = new MoveTo(line.getPoint1().getX(), line.getPoint1().getY());
	QuadCurveTo curveTo = new QuadCurveTo(control.getX(), control.getY(), line.getPoint2().getX(), line.getPoint2().getY());
	path.getElements().addAll(moveTo, curveTo);
	
	ToolGraphics.strokeSharpPath(graphics, path, LineStyle.SOLID);
	ArrowHead.V.view().draw(graphics, control, new Point(40, 40));
	return canvas;
}
 
源代码9 项目: Enzo   文件: RoundLcdClock.java
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/digital.ttf"), (0.5833333333 * PREFERRED_HEIGHT));         // "Digital-7"
    //Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/digitalreadout.ttf"), (0.5833333333 * PREFERRED_HEIGHT));  // "Digital Readout Upright"


    canvasBkg = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxBkg    = canvasBkg.getGraphicsContext2D();

    canvasFg  = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctxFg     = canvasFg.getGraphicsContext2D();

    pane      = new Pane();
    pane.getChildren().setAll(canvasBkg, canvasFg);

    getChildren().setAll(pane);
    resize();
}
 
源代码10 项目: JetUML   文件: ViewerUtilities.java
/**
 * @param pElement The element for which we want an icon
 * @return An icon that represents this element
 * @pre pElement != null
 */
public static Canvas createIcon(DiagramElement pElement)
{
	/* 
	 * This method exists to cover the case where we wish to create an icon 
	 * for a diagram element without knowing whether it's a node or an edge.
	 */
	assert pElement != null;
	if( pElement instanceof Node )
	{
		return NodeViewerRegistry.createIcon((Node)pElement);
	}
	else
	{
		assert pElement instanceof Edge;
		return EdgeViewerRegistry.createIcon((Edge)pElement);
	}
}
 
源代码11 项目: 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();
}
 
源代码12 项目: charts   文件: CoxcombChart.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    getStyleClass().add("coxcomb-chart");

    popup = new InfoPopup();

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    ctx.setLineCap(StrokeLineCap.BUTT);
    ctx.setTextBaseline(VPos.CENTER);
    ctx.setTextAlign(TextAlignment.CENTER);

    pane = new Pane(canvas);

    getChildren().setAll(pane);
}
 
源代码13 项目: charts   文件: ComparisonRingChart.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    getStyleClass().add("comparison-ring-chart");

    canvas = new Canvas(size * 0.9, 0.9);
    ctx    = canvas.getGraphicsContext2D();

    pane = new Pane(canvas);

    getChildren().setAll(pane);
}
 
源代码14 项目: charts   文件: GraphPanel.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(width, height);
    ctx    = canvas.getGraphicsContext2D();

    pane = new Pane(canvas);
    getChildren().setAll(pane);
}
 
源代码15 项目: charts   文件: ConcentricRingChart.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    getStyleClass().add("concentric-ring-chart");

    canvas = new Canvas(size * 0.9, 0.9);
    ctx    = canvas.getGraphicsContext2D();

    pane = new Pane(canvas);

    getChildren().setAll(pane);
}
 
源代码16 项目: charts   文件: CircularPlot.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    ctx.setLineCap(StrokeLineCap.BUTT);

    tooltip = new Tooltip();
    tooltip.setAutoHide(true);

    getChildren().setAll(canvas);
}
 
源代码17 项目: charts   文件: LegendItem.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();
    ctx.setTextAlign(TextAlignment.LEFT);
    ctx.setTextBaseline(VPos.CENTER);

    pane   = new Pane(canvas);

    getChildren().setAll(pane);
}
 
源代码18 项目: Medusa   文件: DigitalClockSkin.java
@Override protected void initGraphics() {
    // Set initial size
    if (Double.compare(clock.getPrefWidth(), 0.0) <= 0 || Double.compare(clock.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(clock.getWidth(), 0.0) <= 0 || Double.compare(clock.getHeight(), 0.0) <= 0) {
        if (clock.getPrefWidth() > 0 && clock.getPrefHeight() > 0) {
            clock.setPrefSize(clock.getPrefWidth(), clock.getPrefHeight());
        } else {
            clock.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx = canvas.getGraphicsContext2D();

    pane = new Pane(canvas);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
源代码19 项目: charts   文件: Grid.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    pane   = new Pane(canvas);

    getChildren().setAll(pane);
}
 
源代码20 项目: charts   文件: XYPane.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    getStyleClass().setAll("chart", "xy-chart");

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    getChildren().setAll(canvas);
}
 
源代码21 项目: charts   文件: StreamChart.java
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();

    tooltip = new Tooltip();
    tooltip.setAutoHide(true);

    getChildren().setAll(canvas);
}
 
源代码22 项目: Aidos   文件: Sandbox.java
private static void init() {
    root = new Group();
    s = new Scene(root, SCENE_WIDTH, SCENE_HEIGHT);
    c = new Canvas(CANVAS_WIDTH, CANVAS_HEIGHT);
    root.getChildren().add(c);
    gc = c.getGraphicsContext2D();
    gc.setStroke(Color.BLUE);
    gc.setLineWidth(2);
    gc.setFill(Color.BLUE);
    Renderer.init();
    GameLoop.start(gc);

    //load map
    try
    {
        loadMap(new File("Resources/maps/sandbox_map.txt"));
    } catch (IOException e)
    {
        System.err.println("Unable to load map file.");
        System.exit(1);
    }

    //should be called at last it based on player
    EventHandler.attachEventHandlers(s);

}
 
源代码23 项目: Solitaire   文件: DeckView.java
private Canvas createNewGameImage()
{
	double width = CardImages.getBack().getWidth();
	double height = CardImages.getBack().getHeight();
	Canvas canvas = new Canvas( width, height );
	GraphicsContext context = canvas.getGraphicsContext2D();
	
	// The reset image
	context.setStroke(Color.DARKGREEN);
	context.setLineWidth(IMAGE_NEW_LINE_WIDTH);
	context.strokeOval(width/4, height/2-width/4 + IMAGE_FONT_SIZE, width/2, width/2);

	// The text
	
	context.setTextAlign(TextAlignment.CENTER);
	context.setTextBaseline(VPos.CENTER);
	context.setFill(Color.DARKKHAKI);
	context.setFont(Font.font(Font.getDefault().getName(), IMAGE_FONT_SIZE));
	
	
	
	if( GameModel.instance().isCompleted() )
	{
		context.fillText("You won!", Math.round(width/2), IMAGE_FONT_SIZE);
	}
	else
	{
		context.fillText("Give up?", Math.round(width/2), IMAGE_FONT_SIZE);
	}
	context.setTextAlign(TextAlignment.CENTER);
	return canvas;
}
 
@Override
public void start(Stage theStage) 
{
    theStage.setTitle( "Canvas Example" );
    
    Group root = new Group();
    Scene theScene = new Scene( root );
    theStage.setScene( theScene );
    
    Canvas canvas = new Canvas( 400, 200 );
    root.getChildren().add( canvas );
    
    GraphicsContext gc = canvas.getGraphicsContext2D();
    
    gc.setFill( Color.RED );
    gc.setStroke( Color.BLACK );
    gc.setLineWidth(2);
    Font theFont = Font.font( "Times New Roman", FontWeight.BOLD, 48 );
    gc.setFont( theFont );
    gc.fillText( "Hello, World!", 60, 50 );
    gc.strokeText( "Hello, World!", 60, 50 );
    
    Image earth = new Image( "earth.png" );
    gc.drawImage( earth, 180, 100 );
    
    theStage.show();
}
 
源代码25 项目: Medusa   文件: DigitalSkin.java
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    backgroundCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    backgroundCtx    = backgroundCanvas.getGraphicsContext2D();
    
    barCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    barCtx    = barCanvas.getGraphicsContext2D();

    valueBkgText = new Text();
    valueBkgText.setStroke(null);
    valueBkgText.setFill(Helper.getTranslucentColorFrom(valueColor, 0.1));

    valueText = new Text();
    valueText.setStroke(null);
    valueText.setFill(valueColor);
    Helper.enableNode(valueText, gauge.isValueVisible());

    pane = new Pane(backgroundCanvas, barCanvas, valueBkgText, valueText);
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth()))));

    getChildren().setAll(pane);
}
 
源代码26 项目: chart-fx   文件: GridDrawer.java
public void draw(final Canvas canvas) {
    // registerCanvasMouseLiner(canvas); // TODO move elsewhere

    final GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.clearRect(0, 0, gc.getCanvas().getWidth(), gc.getCanvas().getHeight());

    for (final Hexagon hexagon : map.getAllHexagons()) {
        // draw hexagon according to Node specifications
        hexagon.draw(gc);

        if (map.renderCoordinates) {
            hexagon.renderCoordinates(gc);
        }
    }
}
 
源代码27 项目: chart-fx   文件: GridDrawer.java
public void drawContour(final Canvas canvas) {
    // registerCanvasMouseLiner(canvas); // TODO move elsewhere

    final GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.clearRect(0, 0, gc.getCanvas().getWidth(), gc.getCanvas().getHeight());

    for (final Hexagon hexagon : map.getAllHexagons()) {
        // draw hexagon contour according to Node specifications
        hexagon.drawContour(gc);

        if (map.renderCoordinates) {
            hexagon.renderCoordinates(gc);
        }
    }
}
 
源代码28 项目: JetUML   文件: SegmentedEdgeViewer.java
@Override
public Canvas createIcon(Edge pEdge) 
{
	Canvas canvas = new Canvas(BUTTON_SIZE, BUTTON_SIZE);
	Path path = new Path();
	path.getElements().addAll(new MoveTo(OFFSET, OFFSET), new LineTo(BUTTON_SIZE-OFFSET, BUTTON_SIZE-OFFSET));
	ToolGraphics.strokeSharpPath(canvas.getGraphicsContext2D(), path, aLineStyleExtractor.apply(pEdge));
	aArrowEndExtractor.apply(pEdge).view().draw(canvas.getGraphicsContext2D(), 
			new Point(OFFSET, OFFSET), new Point(BUTTON_SIZE-OFFSET, BUTTON_SIZE - OFFSET));
	aArrowStartExtractor.apply(pEdge).view().draw(canvas.getGraphicsContext2D(), 
			new Point(BUTTON_SIZE-OFFSET, BUTTON_SIZE - OFFSET), new Point(OFFSET, OFFSET));
	return canvas;
}
 
源代码29 项目: JetUML   文件: DiagramTabToolBar.java
private static Canvas createSelectionIcon()
{
	int offset = AbstractNodeViewer.OFFSET + 3;
	Canvas canvas = new Canvas(AbstractNodeViewer.BUTTON_SIZE, AbstractNodeViewer.BUTTON_SIZE);
	GraphicsContext graphics = canvas.getGraphicsContext2D();
	ToolGraphics.drawHandles(graphics, new Rectangle(offset, offset, 
			AbstractNodeViewer.BUTTON_SIZE - (offset*2), AbstractNodeViewer.BUTTON_SIZE-(offset*2) ));
	return canvas;
}
 
源代码30 项目: chart-fx   文件: SidesPaneSkin.java
/**
 * Sets the preferred width of the generic node object by casting it onto the known Region, ... object
 *
 * @param node the node to be adapted
 * @param prefWidth the desired preferred height
 */
private static void setPrefWidth(final Node node, final double prefWidth) {
    if (node instanceof Region) {
        ((Region) node).setPrefWidth(prefWidth);
        return;
    } else if (node instanceof Canvas) {
        ((Canvas) node).setWidth(prefWidth);
        return;
    }
    // add other derivative of 'Node'
    throw new InvalidParameterException("no prefWidth for class type:" + node.getClass().getCanonicalName());
}
 
 类所在包
 同包方法