javafx.geometry.Dimension2D Java Examples

The following examples show how to use javafx.geometry.Dimension2D. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BouncingTargets.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
public void moveTarget() {
	if (maxVelocity == 0) return;

	final Bounds b = target.getBoundsInParent();
	final Point2D p = target.getPosition();
	final Dimension2D d = target.getDimension();
	final CollisionType ct = checkCollision();

	if (b.getMinX() <= 1 || b.getMinX() + d.getWidth() > thisSuper.getArenaWidth()
			|| ct == CollisionType.COLLISION_X || ct == CollisionType.COLLISION_BOTH) {
		dx *= -1;
	}

	if (b.getMinY() <= 1 || b.getMinY() + d.getHeight() > thisSuper.getArenaHeight()
			|| ct == CollisionType.COLLISION_X || ct == CollisionType.COLLISION_BOTH) {
		dy *= -1;
	}

	target.setPosition(p.getX() + dx, p.getY() + dy);
}
 
Example #2
Source File: RectangularImageViewSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private Dimension2D shouldFitIn(double originalWidth, double originalHeight, double toFitWidth, double toFitHeight) {
  double fitRatio = toFitWidth / toFitHeight;
  double originalRatio = originalWidth / originalHeight;

  if (fitRatio > originalRatio) {
    double widthFactor = toFitWidth / originalWidth;
    return new Dimension2D(toFitWidth, originalHeight * widthFactor);
  } else {
    double heightFactor = toFitHeight / originalHeight;
    return new Dimension2D(originalWidth * heightFactor, toFitHeight);
  }
}
 
Example #3
Source File: AndroidDisplayService.java    From attach with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dimension2D getDefaultDimensions() {
    Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
    Dimension2D dimension2D = new Dimension2D(visualBounds.getWidth(), visualBounds.getHeight());
    if (debug) {
        LOG.log(Level.INFO, "Screen default dimensions: " + dimension2D);
    }
    return dimension2D;
}
 
Example #4
Source File: PerspectiveManager.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Starting with a target's real world width and height in mm, as it appears
 * on a projection, calculate a new width and height in pixels to resize the
 * target to such that it appears to be a distance of
 * <code>desiredDistance</code> in mm away. This calculation assumes that
 * the current real world dimensions are the result of the target being
 * <code>realDistance</code> away in mm.
 * 
 * To set the initial real word size of a target, call this method with the
 * desired <code>realWidth</code> and <code>realHeight</code> with
 * <code>realDistance</code> and <code>desiredDistance</code> equal to the
 * target's initial real world distance.
 * 
 * @param realWidth
 *            the current width of the target on the projection in mm
 * @param realHeight
 *            the current height of the target on the projection in mm
 * @param realDistance
 *            the current distance of the target in mm
 * @param desiredDistance
 *            the desired new distance of the target used to derive the new
 *            target dimensions. Value must be > 0
 * @return the new targets dimensions in pixels necessary to make it appear
 *         <code>desiredDistance</code> away given its current real world
 *         dimensions and distance
 */
public Optional<Dimension2D> calculateObjectSize(double realWidth, double realHeight, double desiredDistance) {
	if (!isInitialized()) {
		logger.error("projection manager has unknowns projectionWidth = {}, projectionHeight = {}, "
				+ "shooterDistance = {}, pxPerMMhigh = {}", projectionWidth, projectionHeight,
				shooterDistance, pxPerMMhigh);
		return Optional.empty();
	}

	if (desiredDistance == 0) {
		throw new IllegalArgumentException("desiredDistance cannot be 0");
	}

	// Make it appropriate size for the desired distance
	// Should just cap the result dimensions at the size of the projector

	final double distRatio = shooterDistance / desiredDistance;

	final double adjWidthmm = realWidth * distRatio;
	final double adjHeightmm = realHeight * distRatio;

	final double adjWidthpx = adjWidthmm * pxPerMMwide;
	final double adjHeightpx = adjHeightmm * pxPerMMhigh;

	if (logger.isTraceEnabled()) {
		logger.trace("real w {} h {} d {}", realWidth, realHeight, desiredDistance);
		logger.trace("sD {} dR {} - adjmm {} {} adjpx {} {}", shooterDistance, distRatio, adjWidthmm, adjHeightmm,
				adjWidthpx, adjHeightpx);

	}

	return Optional.of(new Dimension2D(adjWidthpx, adjHeightpx));
}
 
Example #5
Source File: AutoCalibrationManager.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
public void addPaperDimensions(Dimension2D newPaperDimensions, boolean averagePatterns) {
	if (!paperDimensions.isPresent() || !averagePatterns) {
		paperDimensions = Optional.of(newPaperDimensions);

		logger.trace("Found paper dimensions {}", paperDimensions.get());
	} else if (paperDimensions.isPresent()) {
		paperDimensions = Optional.of(averageDimensions(paperDimensions.get(), newPaperDimensions));
		logger.trace("Averaged paper dimensions {}", paperDimensions.get());
	}
}
 
Example #6
Source File: HeatMapBuilder.java    From charts with Apache License 2.0 5 votes vote down vote up
public final HeatMap build() {
    double              width               = 400;
    double              height              = 400;
    ColorMapping        colorMapping        = ColorMapping.LIME_YELLOW_RED;
    double              spotRadius          = 15.5;
    boolean             fadeColors          = false;
    double              heatMapOpacity      = 0.5;
    OpacityDistribution opacityDistribution = OpacityDistribution.CUSTOM;

    for (String key : properties.keySet()) {
        if ("prefSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            width  = dim.getWidth();
            height = dim.getHeight();
        } else if ("width".equals(key)) {
            width = ((DoubleProperty) properties.get(key)).get();
        } else if ("height".equals(key)) {
            height = ((DoubleProperty) properties.get(key)).get();
        } else if ("colorMapping".equals(key)) {
            colorMapping = ((ObjectProperty<ColorMapping>) properties.get(key)).get();
        } else if ("spotRadius".equals(key)) {
            spotRadius = ((DoubleProperty) properties.get(key)).get();
        } else if ("fadeColors".equals(key)) {
            fadeColors = ((BooleanProperty) properties.get(key)).get();
        } else if ("heatMapOpacity".equals(key)) {
            heatMapOpacity = ((DoubleProperty) properties.get(key)).get();
        } else if ("opacityDistribution".equals(key)) {
            opacityDistribution = ((ObjectProperty<OpacityDistribution>) properties.get(key)).get();
        }
    }
    return new HeatMap(width,  height, colorMapping, spotRadius, fadeColors, heatMapOpacity, opacityDistribution);
}
 
Example #7
Source File: SmoothedChart.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
public Dimension2D getSymbolSize(final Series<X, Y> SERIES) {
    if (!getData().contains(SERIES)) { return new Dimension2D(0, 0); }
    if (SERIES.getData().isEmpty()) { return new Dimension2D(0, 0); }
    for (XYChart.Data<X, Y> data : SERIES.getData()) {
        StackPane stackPane = (StackPane) data.getNode();
        if (null == stackPane) {
            continue;
        } else {
            return new Dimension2D(stackPane.getLayoutBounds().getWidth(), stackPane.getLayoutBounds().getHeight());
        }
    }
    return new Dimension2D(0, 0);
}
 
Example #8
Source File: PerspectiveManager.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isCameraSupported(final String cameraName, Dimension2D desiredResolution) {
	for (final CameraParameters cam : cameraParameters) {
		if (cameraName.contains(cam.getName())
				&& Math.abs(cam.getValidDimensions().getWidth() - desiredResolution.getWidth()) < .001
				&& Math.abs(cam.getValidDimensions().getHeight() - desiredResolution.getHeight()) < .001) {
			return true;
		}
	}

	return false;
}
 
Example #9
Source File: StableTicksAxis.java    From jfxutils with Apache License 2.0 5 votes vote down vote up
private double getLabelSize() {
	Dimension2D dim = measureTickMarkLabelSize( "-888.88E-88", getTickLabelRotation() );
	if ( getSide().isHorizontal() ) {
		return dim.getWidth();
	} else {
		return dim.getHeight();
	}
}
 
Example #10
Source File: Course.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The dimensions of the arena when the course was saved.
 * 
 * @return Optional.empty for courses saved prior to 3.7
 */
public Optional<Dimension2D> getResolution() {
	if (resolution.isPresent()) {
		return resolution;
	} else {
		return Optional.empty();
	}
}
 
Example #11
Source File: CircularPlotBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final double WIDTH, final double HEIGHT) {
    properties.put("prefSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #12
Source File: ColorRegulatorBuilder.java    From regulators with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #13
Source File: CircularPlotBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #14
Source File: CameraManager.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void calibrate(Bounds arenaBounds, Optional<Dimension2D> perspectivePaperDims, boolean calibratedFromCanvas,
		long delay) {
	autoCalibrateSuccess(arenaBounds, perspectivePaperDims, delay);
}
 
Example #15
Source File: PerspectiveManager.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
public Dimension2D getValidDimensions() {
	return validDims;
}
 
Example #16
Source File: SevenSegmentBuilder.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final double WIDTH, final double HEIGHT) {
    properties.put("prefSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #17
Source File: RadialBargraphBuilder.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final double WIDTH, final double HEIGHT) {
    properties.put("prefSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #18
Source File: SimpleGaugeBuilder.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #19
Source File: AreaHeatMapBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final Dimension2D PREF_SIZE) {
    properties.put("prefSize", new SimpleObjectProperty<>(PREF_SIZE));
    return (B)this;
}
 
Example #20
Source File: OnOffSwitchBuilder.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #21
Source File: OnOffSwitchBuilder.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final double WIDTH, final double HEIGHT) {
    properties.put("prefSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #22
Source File: StreamChartBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final double WIDTH, final double HEIGHT) {
    properties.put("prefSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #23
Source File: CoxcombChartBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final double WIDTH, final double HEIGHT) {
    properties.put("prefSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #24
Source File: SunburstChartBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #25
Source File: SixteenSegmentBuilder.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final B maxSize(final double WIDTH, final double HEIGHT) {
    properties.put("maxSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #26
Source File: NestedBarChartBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #27
Source File: NestedBarChartBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B prefSize(final double WIDTH, final double HEIGHT) {
    properties.put("prefSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #28
Source File: PixelMatrixBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B maxSize(final double WIDTH, final double HEIGHT) {
    properties.put("maxSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #29
Source File: PixelMatrixBuilder.java    From charts with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}
 
Example #30
Source File: MatrixSegmentBuilder.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public final B minSize(final double WIDTH, final double HEIGHT) {
    properties.put("minSize", new SimpleObjectProperty<>(new Dimension2D(WIDTH, HEIGHT)));
    return (B)this;
}