Example usage for javafx.scene.shape Rectangle setHeight

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

Introduction

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

Prototype

public final void setHeight(double value) 

Source Link

Usage

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  w  w. j  a va 2 s.  co  m*/
        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:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iNumZone numero de la zone//from   w  w  w. j a v a  2 s  .  c  om
 * @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;
}