当前位置: 首页>>代码示例>>Java>>正文


Java Node.resizeRelocate方法代码示例

本文整理汇总了Java中javafx.scene.Node.resizeRelocate方法的典型用法代码示例。如果您正苦于以下问题:Java Node.resizeRelocate方法的具体用法?Java Node.resizeRelocate怎么用?Java Node.resizeRelocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.Node的用法示例。


在下文中一共展示了Node.resizeRelocate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: layoutChildren

import javafx.scene.Node; //导入方法依赖的package包/类
@Override protected void layoutChildren() {
    double top = getPadding().getTop();
    double left = getPadding().getLeft();
    double right = getPadding().getRight();
    double w = getWidth() - left - right;
    double y = top;
    for(Node child:getChildren()) {
        double prefH = child.prefHeight(w);
        child.resizeRelocate(
            snapPosition(left),
            snapPosition(y),
            snapSize(w),
            snapSize(prefH)
        );
        y += vgap + prefH;
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:FlowSafeVBox.java

示例2: layoutPlotChildren

import javafx.scene.Node; //导入方法依赖的package包/类
/** @inheritDoc */
@Override
protected void layoutPlotChildren() {
	// update symbol positions
	for (int seriesIndex = 0; seriesIndex < getDataSize(); seriesIndex++) {
		MultiAxisChart.Series<X, Y> series = getData().get(seriesIndex);
		for (Iterator<Data<X, Y>> it = getDisplayedDataIterator(series); it.hasNext();) {
			Data<X, Y> item = it.next();
			double x = getXAxis().getDisplayPosition(item.getCurrentX());
			double y = -1;
			if (item.getExtraValue() == null || (int) item.getExtraValue() == MultiAxisChart.Y1_AXIS) {
				y = getY1Axis().getDisplayPosition(item.getCurrentY());
			} else {
				if (getY2Axis() != null) {
					if (getY2Axis().isVisible()) {
						y = getY2Axis().getDisplayPosition(item.getCurrentY());
					} else {
						continue;
					}
				} else {
					throw new NullPointerException(
							"Data found with Y2_Axis as Y axis while Y2 axis is not defined.");
				}
			}

			if (Double.isNaN(x) || Double.isNaN(y)) {
				continue;
			}
			Node symbol = item.getNode();
			if (symbol != null) {
				final double w = symbol.prefWidth(-1);
				final double h = symbol.prefHeight(-1);
				symbol.resizeRelocate(x - (w / 2), y - (h / 2), w, h);
			}
		}
	}



}
 
开发者ID:JKostikiadis,项目名称:MultiAxisCharts,代码行数:41,代码来源:MultiAxisScatterChart.java

示例3: layoutPlotChildren

import javafx.scene.Node; //导入方法依赖的package包/类
/** @inheritDoc */
@Override
protected void layoutPlotChildren() {
	List<LineTo> constructedPath = new ArrayList<>(getDataSize());
	for (int seriesIndex = 0; seriesIndex < getDataSize(); seriesIndex++) {
		MultiAxisChart.Series<X, Y> series = getData().get(seriesIndex);
		DoubleProperty seriesYAnimMultiplier = seriesYMultiplierMap.get(series);
		double lastX = 0;
		final ObservableList<Node> children = ((Group) series.getNode()).getChildren();
		ObservableList<PathElement> seriesLine = ((Path) children.get(1)).getElements();
		ObservableList<PathElement> fillPath = ((Path) children.get(0)).getElements();
		seriesLine.clear();
		fillPath.clear();
		constructedPath.clear();
		for (Iterator<Data<X, Y>> it = getDisplayedDataIterator(series); it.hasNext();) {
			Data<X, Y> item = it.next();
			double x = getXAxis().getDisplayPosition(item.getCurrentX());
			
			double y = -1;
			if (item.getExtraValue() == null || (int) item.getExtraValue() == MultiAxisChart.Y1_AXIS) {
				y = getY1Axis().getDisplayPosition(getY1Axis().toRealValue(
						getY1Axis().toNumericValue(item.getCurrentY()) * seriesYAnimMultiplier.getValue()));
			} else {
				if (getY2Axis() != null) {
					if (getY2Axis().isVisible()) {
						y = getY2Axis().getDisplayPosition(getY2Axis().toRealValue(
								getY2Axis().toNumericValue(item.getCurrentY()) * seriesYAnimMultiplier.getValue()));
					} else {
						continue;
					}
				} else {
					throw new NullPointerException("Y2 axis is not defined.");
				}
			}
			
			constructedPath.add(new LineTo(x, y));
			if (Double.isNaN(x) || Double.isNaN(y)) {
				continue;
			}
			lastX = x;
			Node symbol = item.getNode();
			if (symbol != null) {
				final double w = symbol.prefWidth(-1);
				final double h = symbol.prefHeight(-1);
				symbol.resizeRelocate(x - (w / 2), y - (h / 2), w, h);
			}
		}

		if (!constructedPath.isEmpty()) {
			Collections.sort(constructedPath, (e1, e2) -> Double.compare(e1.getX(), e2.getX()));
			LineTo first = constructedPath.get(0);

			final double displayYPos = first.getY();
			final double numericYPos = getY1Axis().toNumericValue(getY1Axis().getValueForDisplay(displayYPos));

			// RT-34626: We can't always use getZeroPosition(), as it may be the case
			// that the zero position of the y-axis is not visible on the chart. In these
			// cases, we need to use the height between the point and the y-axis line.
			final double yAxisZeroPos = getY1Axis().getZeroPosition();
			final boolean isYAxisZeroPosVisible = !Double.isNaN(yAxisZeroPos);
			final double yAxisHeight = getY1Axis().getHeight();
			final double yFillPos = isYAxisZeroPosVisible ? yAxisZeroPos
					: numericYPos < 0 ? numericYPos - yAxisHeight : yAxisHeight;

			seriesLine.add(new MoveTo(first.getX(), displayYPos));
			fillPath.add(new MoveTo(first.getX(), yFillPos));

			seriesLine.addAll(constructedPath);
			fillPath.addAll(constructedPath);
			fillPath.add(new LineTo(lastX, yFillPos));
			fillPath.add(new ClosePath());
		}
	}
}
 
开发者ID:JKostikiadis,项目名称:MultiAxisCharts,代码行数:75,代码来源:MultiAxisAreaChart.java

示例4: layoutPlotChildren

import javafx.scene.Node; //导入方法依赖的package包/类
/** @inheritDoc */
@Override
protected void layoutPlotChildren() {
	List<LineTo> constructedPath = new ArrayList<>(getDataSize());
	for (int seriesIndex = 0; seriesIndex < getDataSize(); seriesIndex++) {
		Series<X, Y> series = getData().get(seriesIndex);
		final DoubleProperty seriesYAnimMultiplier = seriesYMultiplierMap.get(series);
		if (series.getNode() instanceof Path) {
			final ObservableList<PathElement> seriesLine = ((Path) series.getNode()).getElements();
			seriesLine.clear();
			constructedPath.clear();
			for (Iterator<Data<X, Y>> it = getDisplayedDataIterator(series); it.hasNext();) {
				Data<X, Y> item = it.next();
				double x = getXAxis().getDisplayPosition(item.getCurrentX());

				double y = -1;
				if (item.getExtraValue() == null || (int) item.getExtraValue() == MultiAxisChart.Y1_AXIS) {
					y = getY1Axis().getDisplayPosition(getY1Axis().toRealValue(
							getY1Axis().toNumericValue(item.getCurrentY()) * seriesYAnimMultiplier.getValue()));
				} else {
					if (getY2Axis() != null) {
						if (getY2Axis().isVisible()) {
							y = getY2Axis().getDisplayPosition(
									getY2Axis().toRealValue(getY2Axis().toNumericValue(item.getCurrentY())
											* seriesYAnimMultiplier.getValue()));
						} else {
							continue;
						}
					} else {
						throw new NullPointerException("Y2 axis is not defined.");
					}
				}

				if (Double.isNaN(x) || Double.isNaN(y)) {
					continue;
				}
				constructedPath.add(new LineTo(x, y));

				Node symbol = item.getNode();
				if (symbol != null) {
					final double w = symbol.prefWidth(-1);
					final double h = symbol.prefHeight(-1);
					symbol.resizeRelocate(x - (w / 2), y - (h / 2), w, h);
				}
			}
			switch (getAxisSortingPolicy()) {
			case X_AXIS:
				Collections.sort(constructedPath, (e1, e2) -> Double.compare(e1.getX(), e2.getX()));
				break;
			case Y_AXIS:
				Collections.sort(constructedPath, (e1, e2) -> Double.compare(e1.getY(), e2.getY()));
				break;
			}

			if (!constructedPath.isEmpty()) {
				LineTo first = constructedPath.get(0);
				seriesLine.add(new MoveTo(first.getX(), first.getY()));
				seriesLine.addAll(constructedPath);
			}
		}
	}
}
 
开发者ID:JKostikiadis,项目名称:MultiAxisCharts,代码行数:63,代码来源:MultiAxisLineChart.java

示例5: layoutPlotChildren

import javafx.scene.Node; //导入方法依赖的package包/类
/** @inheritDoc */
@Override
protected void layoutPlotChildren() {
	double catSpace = categoryAxis.getCategorySpacing();
	// calculate bar spacing
	final double avilableBarSpace = catSpace - (getCategoryGap() + getBarGap());
	double barWidth = (avilableBarSpace / getSeriesSize()) - getBarGap();
	final double barOffset = -((catSpace - getCategoryGap()) / 2);
	final double zeroPos = (valueAxis.getLowerBound() > 0) ? valueAxis.getDisplayPosition(valueAxis.getLowerBound())
			: valueAxis.getZeroPosition();
	// RT-24813 : if the data in a series gets too large, barWidth can get negative.
	if (barWidth <= 0)
		barWidth = 1;
	// update bar positions and sizes
	int catIndex = 0;
	for (String category : categoryAxis.getCategories()) {
		int index = 0;
		for (Iterator<Series<X, Y>> sit = getDisplayedSeriesIterator(); sit.hasNext();) {
			Series<X, Y> series = sit.next();
			final Data<X, Y> item = getDataItem(series, index, catIndex, category);
			if (item != null) {
				final Node bar = item.getNode();
				final double categoryPos;
				final double valPos;

				categoryPos = getXAxis().getDisplayPosition(item.getCurrentX());

				if (item.getExtraValue() == null || (int) item.getExtraValue() == MultiAxisChart.Y1_AXIS) {
					valPos = getY1Axis().getDisplayPosition(item.getCurrentY());
				} else {
					if (getY2Axis() != null) {
						if (getY2Axis().isVisible()) {
							valPos = getY2Axis().getDisplayPosition(item.getCurrentY());
						} else {
							continue;
						}
					} else {
						throw new NullPointerException("Y2 axis is not defined.");
					}
				}

				if (Double.isNaN(categoryPos) || Double.isNaN(valPos)) {
					continue;
				}
				final double bottom = Math.min(valPos, zeroPos);
				final double top = Math.max(valPos, zeroPos);
				bottomPos = bottom;
				if (orientation == Orientation.VERTICAL) {
					bar.resizeRelocate(categoryPos + barOffset + (barWidth + getBarGap()) * index, bottom, barWidth,
							top - bottom);
				} else {
					// noinspection SuspiciousNameCombination
					bar.resizeRelocate(bottom, categoryPos + barOffset + (barWidth + getBarGap()) * index,
							top - bottom, barWidth);
				}

				index++;
			}
		}
		catIndex++;
	}
}
 
开发者ID:JKostikiadis,项目名称:MultiAxisCharts,代码行数:63,代码来源:MultiAxisBarChart.java


注:本文中的javafx.scene.Node.resizeRelocate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。