Example usage for javafx.scene.shape Rectangle setY

List of usage examples for javafx.scene.shape Rectangle setY

Introduction

In this page you can find the example usage for javafx.scene.shape Rectangle setY.

Prototype

public final void setY(double value) 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);//from  w ww . j a  v  a  2s .  co  m

    Group g = new Group();
    PerspectiveTransform pt = new PerspectiveTransform();
    pt.setUlx(10.0);
    pt.setUly(10.0);
    pt.setUrx(310.0);
    pt.setUry(40.0);
    pt.setLrx(310.0);
    pt.setLry(60.0);
    pt.setLlx(10.0);
    pt.setLly(90.0);

    g.setEffect(pt);
    g.setCache(true);

    Rectangle r = new Rectangle();
    r.setX(10.0);
    r.setY(10.0);
    r.setWidth(280.0);
    r.setHeight(80.0);
    r.setFill(Color.BLUE);

    Text t = new Text();
    t.setX(20.0);
    t.setY(65.0);
    t.setText("JavaFX");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font(null, FontWeight.BOLD, 36));

    g.getChildren().add(r);
    g.getChildren().add(t);

    scene.setRoot(g);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    int w = 220;//from   ww w . j a v a  2  s .c  o m
    int h = 100;
    FloatMap map = new FloatMap();
    map.setWidth(w);
    map.setHeight(h);

    for (int i = 0; i < w; i++) {
        double v = (Math.sin(i / 20.0 * Math.PI) - 0.5) / 40.0;
        for (int j = 0; j < h; j++) {
            map.setSamples(i, j, 0.0f, (float) v);
        }
    }

    Group g = new Group();
    DisplacementMap dm = new DisplacementMap();
    dm.setMapData(map);

    g.setEffect(dm);
    g.setCache(true);

    Rectangle r = new Rectangle();
    r.setX(20.0);
    r.setY(20.0);
    r.setWidth(w);
    r.setHeight(h);
    r.setFill(Color.BLUE);

    g.getChildren().add(r);

    Text t = new Text();
    t.setX(40.0);
    t.setY(80.0);
    t.setText("Wavy Text");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font(null, FontWeight.BOLD, 36));

    g.getChildren().add(t);

    root.getChildren().add(g);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:User.java

private Rectangle drawRectangleBackground() {
    Rectangle background = new Rectangle(320, 112);
    background.setX(0);/*from   www .  j  a  v  a2  s  .c o m*/
    background.setY(0);
    background.setArcHeight(15);
    background.setArcWidth(15);
    background.setFill(Color.rgb(0, 0, 0, 0.55));
    background.setStrokeWidth(1.5);
    background.setStroke(foregroundColor);

    return background;
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iNumZone numero de la zone//  w  ww  .j  a  v  a2 s .c  o m
 * @param rect rectangle concern
 * @return ancres rectangle
 */
private static ObservableList<AncreForme> olCreeAncresPourRectangle(int iNumZone, Rectangle rect) {
    ObservableList<AncreForme> olAnchors = FXCollections.observableArrayList();

    DoubleProperty xProperty1 = new SimpleDoubleProperty(rect.getX());
    DoubleProperty yProperty1 = new SimpleDoubleProperty(rect.getY());
    DoubleProperty xProperty2 = new SimpleDoubleProperty(rect.getWidth() + rect.getX());
    DoubleProperty yProperty2 = new SimpleDoubleProperty(rect.getHeight() + rect.getY());
    olAnchors.add(new AncreForme(Color.GOLD, xProperty1, yProperty1));
    AncreForme ancrePoint2 = new AncreForme(Color.BLUEVIOLET, xProperty2, yProperty2);
    olAnchors.add(ancrePoint2);
    xProperty1.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> {
        double dX = -rect.getX() + (double) x;
        rect.setX((double) x);
        ancrePoint2.setCenterX(ancrePoint2.getCenterX() + dX);
        String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + ","
                + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + ","
                + Math.round((rect.getY() + rect.getHeight()) * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });

    yProperty1.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> {
        double dY = -rect.getY() + (double) y;
        rect.setY((double) y);
        ancrePoint2.setCenterY(ancrePoint2.getCenterY() + dY);
        String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + ","
                + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + ","
                + Math.round((rect.getY() + rect.getHeight()) * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });
    xProperty2.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> {
        rect.setWidth((double) x - rect.getX());
        String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + ","
                + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + ","
                + Math.round((rect.getY() + rect.getHeight()) * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });

    yProperty2.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> {
        rect.setHeight((double) y - rect.getY());
        String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + ","
                + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + ","
                + Math.round((rect.getY() + rect.getHeight()) * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });

    return olAnchors;
}

From source file:org.nmrfx.processor.gui.spectra.PeakListAttributes.java

private boolean pick2DPeak(Peak peak, double x, double y) {
    double[] ctr = { 0.0, 0.0 };
    double[] bou = { 0.0, 0.0 };
    int[] peakDim = getPeakDim();

    bou[0] = peak.peakDim[peakDim[0]].getBoundsValue();
    bou[1] = peak.peakDim[peakDim[1]].getBoundsValue();
    ctr[0] = peak.peakDim[peakDim[0]].getChemShiftValue();
    ctr[1] = peak.peakDim[peakDim[1]].getChemShiftValue();
    Rectangle box = getBox(ctr, bou);
    boolean result = box.contains(x, y);
    //        System.out.println(box.toString() + " " + x + " " + y + " " + result);

    if (!result) {
        int growWidth = 0;
        int growHeight = 0;
        int width = (int) box.getWidth();
        if (width < minHitSize) {
            growWidth = minHitSize - width;
        }/*from w ww  . j  a  va  2  s.  c om*/
        int height = (int) box.getHeight();
        if (height < minHitSize) {
            growHeight = minHitSize - height;
        }
        // fixme why are we doing this (from old code) and should it grow symmetrically
        // gues we try to hit small rect for selectivity, then expand if no hit
        if ((growWidth > 0) || (growHeight > 0)) {
            box.setWidth(growWidth);
            box.setX(box.getX() - growWidth / 2);
            box.setHeight(growHeight);
            box.setY(box.getY() - growHeight / 2);

            result = box.contains(x, y);
        }
    }
    return result;
}

From source file:snpviewer.SnpViewer.java

private void drawRegionSummary(RegionSummary reg, String currentChrom) {
    if (currentChrom == null) {
        if (reg.getChromosome() != null) {
            currentChrom = reg.getChromosome();
        } else {//  w  w w  . jav  a2 s.  c  om
            return;
        }
    }
    ChromosomeLength chromLength;
    try {
        chromLength = new ChromosomeLength(genomeVersion);
    } catch (Exception ex) {
        chromLength = new ChromosomeLength();
    }
    double x;
    double width;
    double cLength;
    try {
        cLength = chromLength.getLength(currentChrom);
    } catch (Exception ex) {
        ex.printStackTrace();
        return;
    }
    int startPos = reg.getStartPos();
    int rLength = reg.getLength();
    x = chromSplitPane.getWidth() / cLength * startPos;
    width = chromSplitPane.getWidth() / cLength * rLength;

    Rectangle regionRectangle = new Rectangle();
    regionRectangle.setX(x);
    regionRectangle.setWidth(width);
    regionRectangle.setY(0);
    regionRectangle.xProperty().bind(selectionOverlayPane.widthProperty().divide(cLength).multiply(startPos));
    regionRectangle.heightProperty().bind(selectionOverlayPane.heightProperty());
    regionRectangle.widthProperty()
            .bind(selectionOverlayPane.widthProperty().divide(cLength).multiply(rLength));
    regionRectangle.strokeProperty().set(colorComp.get(Colors.saveLine.value));
    regionRectangle.fillProperty().set(colorComp.get(Colors.saveFill.value));
    regionRectangle.setOpacity(0.40);
    regionRectangle.setStrokeWidth(2);
    savedRegionsDisplay.add(regionRectangle);
    savedRegionsReference.add(reg);
}