Search in sources :

Example 1 with Glyph

use of org.controlsfx.glyphfont.Glyph in project qupath by qupath.

the class IconFactory method createROIIcon.

/**
 * Create an icon depicting a ROI.
 * @param roi the region of interest
 * @param width the preferred icon width
 * @param height the preferred icon height
 * @param color the icon (line) color
 * @return a node that may be used as an icon resembling the shape of the ROI
 */
public static Node createROIIcon(ROI roi, int width, int height, Color color) {
    double scale = Math.min(width / roi.getBoundsWidth(), height / roi.getBoundsHeight());
    if (roi instanceof RectangleROI) {
        Rectangle rect = new Rectangle(0, 0, roi.getBoundsWidth() * scale, roi.getBoundsHeight() * scale);
        rect.setStroke(color);
        rect.setFill(null);
        return rect;
    } else if (roi instanceof EllipseROI) {
        double w = roi.getBoundsWidth() * scale;
        double h = roi.getBoundsHeight() * scale;
        Ellipse ellipse = new Ellipse(w / 2, height / 2, w / 2, h / 2);
        ellipse.setStroke(color);
        ellipse.setFill(null);
        return ellipse;
    } else if (roi instanceof LineROI) {
        LineROI l = (LineROI) roi;
        double xMin = Math.min(l.getX1(), l.getX2());
        double yMin = Math.min(l.getY1(), l.getY2());
        Line line = new Line((l.getX1() - xMin) * scale, (l.getY1() - yMin) * scale, (l.getX2() - xMin) * scale, (l.getY2() - yMin) * scale);
        line.setStroke(color);
        line.setFill(null);
        return line;
    } else if (roi.isPoint()) {
        // Just show generic points
        Node node = IconFactory.createNode(Math.min(width, height), Math.min(width, height), IconFactory.PathIcons.POINTS_TOOL);
        if (node instanceof Glyph) {
            var glyph = (Glyph) node;
            glyph.textFillProperty().unbind();
            glyph.setColor(color);
        }
        return node;
    } else {
        var path = pathCache.getOrDefault(roi, null);
        if (path == null) {
            var shape = roi.isArea() ? RoiTools.getArea(roi) : RoiTools.getShape(roi);
            if (shape != null) {
                var transform = new AffineTransform();
                transform.translate(-roi.getBoundsX(), -roi.getBoundsY());
                transform.scale(scale, scale);
                PathIterator iterator = shape.getPathIterator(transform, Math.max(0.5, 1.0 / scale));
                path = createShapeIcon(iterator, color);
                pathCache.put(roi, path);
            }
        } else {
            path = new Path(path.getElements());
            path.setStroke(color);
        }
        if (path != null)
            return path;
    }
    logger.warn("Unable to create icon for ROI: {}", roi);
    return null;
}
Also used : Path(javafx.scene.shape.Path) ClosePath(javafx.scene.shape.ClosePath) Ellipse(javafx.scene.shape.Ellipse) PathIterator(java.awt.geom.PathIterator) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle) Line(javafx.scene.shape.Line) RectangleROI(qupath.lib.roi.RectangleROI) EllipseROI(qupath.lib.roi.EllipseROI) Glyph(org.controlsfx.glyphfont.Glyph) AffineTransform(java.awt.geom.AffineTransform) LineROI(qupath.lib.roi.LineROI)

Example 2 with Glyph

use of org.controlsfx.glyphfont.Glyph in project VocabHunter by VocabHunter.

the class IconTool method icon.

public static Glyph icon(final FontAwesome.Glyph icon) {
    Glyph glyph = new Glyph(FONT_AWESOME, icon);
    glyph.getStyleClass().add(STYLE_CLASS);
    return glyph;
}
Also used : Glyph(org.controlsfx.glyphfont.Glyph)

Example 3 with Glyph

use of org.controlsfx.glyphfont.Glyph in project mzmine2 by mzmine.

the class Fx3DStageController method initialize.

public void initialize() {
    rotateX.setPivotZ(SIZE / 2);
    rotateX.setPivotX(SIZE / 2);
    rotateY.setPivotZ(SIZE / 2);
    rotateY.setPivotX(SIZE / 2);
    plot.getTransforms().addAll(rotateX, rotateY);
    translateY.setY(250);
    translateX.setX(170);
    finalNode.getTransforms().addAll(translateX, translateY);
    finalNode.getChildren().add(plot);
    HBox.setHgrow(leftRegion, Priority.ALWAYS);
    HBox.setHgrow(rightRegion, Priority.ALWAYS);
    plot.getChildren().add(axes);
    colorCol.setCellFactory(column -> new ColorTableCell<Fx3DAbstractDataset>(column));
    double minValue = 0;
    double maxValue = 1;
    opacityCol.setCellFactory(column -> new SliderCell<Fx3DAbstractDataset>(column, minValue, maxValue));
    visibilityCol.setCellFactory(column -> new ButtonCell<Fx3DAbstractDataset>(column, new Glyph("FontAwesome", "EYE"), new Glyph("FontAwesome", "EYE_SLASH")));
    axesBtn.setSelected(true);
    lightsBtn.setSelected(true);
    addLights();
    rotateAnimationTimeline = new Timeline(new KeyFrame(Duration.seconds(0), new KeyValue(yRotate.angleProperty(), 360)), new KeyFrame(Duration.seconds(50), new KeyValue(yRotate.angleProperty(), 0)));
    rotateAnimationTimeline.setCycleCount(Timeline.INDEFINITE);
    tableView.setItems(visualizedMeshPlots);
    plot.getChildren().add(meshViews);
    plot.getChildren().add(lights);
    allDataFiles = Arrays.asList(MZmineCore.getProjectManager().getCurrentProject().getDataFiles());
    allPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
    scene3D.widthProperty().bind(root.widthProperty());
    scene3D.heightProperty().bind(root.heightProperty());
    scene3D.setCamera(camera);
    scene3D.setPickOnBounds(true);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Glyph(org.controlsfx.glyphfont.Glyph) KeyFrame(javafx.animation.KeyFrame)

Aggregations

Glyph (org.controlsfx.glyphfont.Glyph)3 AffineTransform (java.awt.geom.AffineTransform)1 PathIterator (java.awt.geom.PathIterator)1 KeyFrame (javafx.animation.KeyFrame)1 KeyValue (javafx.animation.KeyValue)1 Timeline (javafx.animation.Timeline)1 Node (javafx.scene.Node)1 ClosePath (javafx.scene.shape.ClosePath)1 Ellipse (javafx.scene.shape.Ellipse)1 Line (javafx.scene.shape.Line)1 Path (javafx.scene.shape.Path)1 Rectangle (javafx.scene.shape.Rectangle)1 EllipseROI (qupath.lib.roi.EllipseROI)1 LineROI (qupath.lib.roi.LineROI)1 RectangleROI (qupath.lib.roi.RectangleROI)1