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


Java MoveTo.setY方法代码示例

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


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

示例1: calcRegression

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
private Path calcRegression(Series<X, Y> s, int yAxisIndex, int polyDegree) {
	PolynomialFitter quadraticPolyFilter = new PolynomialFitter(polyDegree);

	if (yAxisIndex == Y2_AXIS && y2Axis == null)
		throw new NullPointerException("Y2 Axis is not defind.");

	ArrayList<Point> regressionPoints = new ArrayList<>();

	double index = 0;
	for (Iterator<Data<X, Y>> it = getDisplayedDataIterator(s); it.hasNext();) {
		Data<X, Y> item = it.next();

		if ((yAxisIndex == Y1_AXIS && item.getExtraValue() == null) || (int) item.getExtraValue() == yAxisIndex) {
			if (getXAxis() instanceof NumberAxis) {
				regressionPoints.add(new MultiAxisChart.Point(item.getCurrentX(), item.getCurrentY()));
				double x = (int) item.getCurrentX();
				double y = (int) item.getCurrentY();
				quadraticPolyFilter.addPoint(x, y);
			} else {
				regressionPoints.add(new MultiAxisChart.Point(index++, item.getCurrentY()));
				quadraticPolyFilter.addPoint((double) index++, (double) item.getCurrentY());
			}
		}
	}

	double xMax = Double.MIN_VALUE;
	double xMin = Double.MAX_VALUE;

	for (Point p : regressionPoints) {
		double currentX = getValue(p.getX());
		if (currentX > xMax) {
			xMax = currentX;
		}
		if (currentX < xMin) {
			xMin = currentX;
		}
	}

	Polynomial polynomial = quadraticPolyFilter.getBestFit();

	if (regressionPoints.size() < 2) {
		return null;
	} else {

		Path path = new Path();
		path.setStrokeWidth(2);

		MoveTo moveTo = new MoveTo();

		moveTo.setX(findXChartCord(xMin));
		moveTo.setY(findYChartCord(polynomial.getY(xMin), y1Axis));

		path.getElements().add(moveTo);

		for (double x = xMin + 1; x < xMax; x = x + getXAxis().getTickLabelGap() / 5.0) {
			LineTo lineTo = new LineTo();
			lineTo.setX(findXChartCord(x));
			lineTo.setY(findYChartCord(polynomial.getY(x), y1Axis));

			path.getElements().add(lineTo);
		}
		return path;
	}
}
 
开发者ID:JKostikiadis,项目名称:MultiAxisCharts,代码行数:65,代码来源:MultiAxisChart.java

示例2: handleCurrentValue

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
@Override protected void handleCurrentValue(final double VALUE) {
    low  = Statistics.getMin(dataList);
    high = Statistics.getMax(dataList);
    if (Helper.equals(low, high)) {
        low  = minValue;
        high = maxValue;
    }
    range = high - low;

    double minX           = graphBounds.getX();
    double maxX           = minX + graphBounds.getWidth();
    double minY           = graphBounds.getY();
    double maxY           = minY + graphBounds.getHeight();
    double stepX          = graphBounds.getWidth() / (noOfDatapoints - 1);
    double stepY          = graphBounds.getHeight() / range;
    double referenceValue = tile.getReferenceValue();

    if(!dataList.isEmpty()) {
        MoveTo begin = (MoveTo) pathElements.get(0);
        begin.setX(minX);
        begin.setY(maxY - Math.abs(low - dataList.get(0)) * stepY);
        for (int i = 1; i < (noOfDatapoints - 1); i++) {
            LineTo lineTo = (LineTo) pathElements.get(i);
            lineTo.setX(minX + i * stepX);
            lineTo.setY(maxY - Math.abs(low - dataList.get(i)) * stepY);
        }
        LineTo end = (LineTo) pathElements.get(noOfDatapoints - 1);
        end.setX(maxX);
        end.setY(maxY - Math.abs(low - dataList.get(noOfDatapoints - 1)) * stepY);

        dot.setCenterX(maxX);
        dot.setCenterY(end.getY());

        updateState(VALUE, referenceValue);

        referenceLine.setStartY(maxY - Math.abs(low - referenceValue) * stepY);
        referenceLine.setEndY(maxY - Math.abs(low - referenceValue) * stepY);

        changeText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE - referenceValue)));
        changePercentageText.setText(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE / referenceValue * 100.0) - 100.0)).append("\u0025").toString());

        RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
        rotateTransition.setFromAngle(triangle.getRotate());
        rotateTransition.setToAngle(state.angle);

        FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
        fillIndicatorTransition.setFromValue((Color) triangle.getFill());
        fillIndicatorTransition.setToValue(state.color);

        FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), changePercentageText);
        fillReferenceTransition.setFromValue((Color) triangle.getFill());
        fillReferenceTransition.setToValue(state.color);

        ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition);
        parallelTransition.play();
    }
    valueText.setText(String.format(locale, formatString, VALUE));

    highText.setText(String.format(locale, formatString, high));
    lowText.setText(String.format(locale, formatString, low));

    if (!tile.isTextVisible() && null != movingAverage.getTimeSpan()) {
        timeSpanText.setText(createTimeSpanText());
        text.setText(timeFormatter.format(movingAverage.getLastEntry().getTimestampAsDateTime(tile.getZoneId())));

    }
    resizeDynamicText();
}
 
开发者ID:HanSolo,项目名称:tilesfx,代码行数:69,代码来源:StockTileSkin.java

示例3: resize

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
private void resize() {
    width  = getWidth() - getInsets().getLeft() - getInsets().getRight();
    height = getHeight() - getInsets().getTop() - getInsets().getBottom();

    if (aspectRatio * width > height) {
        width = 1 / (aspectRatio / height);
    } else if (1 / (aspectRatio / height) > width) {
        height = aspectRatio * width;
    }

    if (width > 0 && height > 0) {
        pane.setMaxSize(width, height);
        pane.setPrefSize(width, height);
        pane.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);

        centerX = width * 0.5;
        centerY = height * 0.94736842;

        int    noOfSections = sections.size();
        double radius       = width * 0.43831169;
        double sinValue;
        double cosValue;
        Color  sectionColor;
        for (int i = 0 ; i < noOfSections ; i++) {
            sinValue     = Math.sin(Math.toRadians(-sectionAngle * (i + 0.5) + model.getStartAngle() + 270));
            cosValue     = Math.cos(Math.toRadians(-sectionAngle * (i + 0.5) + model.getStartAngle() + 270));
            sectionColor = model.getSections().get(i).getColor();
            LinearGradient secFill = new LinearGradient(centerX + radius * sinValue, centerY + radius * cosValue,
                                                        centerX, centerY,
                                                        false, CycleMethod.NO_CYCLE,
                                                        new Stop(0.0, sectionColor),
                                                        new Stop(0.2, sectionColor),
                                                        new Stop(0.2, sectionColor.deriveColor(0, 0.8, 1.1, 1)),
                                                        new Stop(1.0, sectionColor.deriveColor(0, 0.8, 1.1, 1)));

            Path sec = sections.get(i);
            sec.setFill(secFill);
            sec.setStrokeWidth(height * 0.01);

            MoveTo moveTo = (MoveTo) sec.getElements().get(0);
            moveTo.setX(centerX); moveTo.setY(centerY);

            sinValue = Math.sin(Math.toRadians(-sectionAngle * i + model.getStartAngle() + 270));
            cosValue = Math.cos(Math.toRadians(-sectionAngle * i + model.getStartAngle() + 270));
            LineTo lineTo1 = (LineTo) sec.getElements().get(1);
            lineTo1.setX(centerX + radius * sinValue); lineTo1.setY(centerY + radius * cosValue);

            sinValue = Math.sin(Math.toRadians(-sectionAngle * (i + 1) + model.getStartAngle() + 270));
            cosValue = Math.cos(Math.toRadians(-sectionAngle * (i + 1) + model.getStartAngle() + 270));
            LineTo lineTo2 = (LineTo) sec.getElements().get(2);
            lineTo2.setX(centerX + radius * sinValue); lineTo2.setY(centerY + radius * cosValue);
        }

        currentQualityRotate.setPivotX(centerX);
        currentQualityRotate.setPivotY(centerY);

        moveTo.setX(centerX); moveTo.setY(centerY);
        lineTo1.setX(centerX + width * 0.06856705); lineTo1.setY(height * 0.12174644);
        cubicCurveTo1.setControlX1(centerX + width * 0.06856705); cubicCurveTo1.setControlY1(height * 0.12174644); cubicCurveTo1.setControlX2(centerX + width * 0.06899351); cubicCurveTo1.setControlY2(height * 0.11400031); cubicCurveTo1.setX(centerX + width * 0.06899351); cubicCurveTo1.setY(height * 0.10990712);
        cubicCurveTo2.setControlX1(centerX + width * 0.06899351); cubicCurveTo2.setControlY1(height * 0.03723715);  cubicCurveTo2.setControlX2(centerX + width * 0.03810455); cubicCurveTo2.setControlY2(-height * 0.02167183); cubicCurveTo2.setX(centerX); cubicCurveTo2.setY(-height * 0.02167183);
        cubicCurveTo3.setControlX1(centerX + -width * 0.03810455); cubicCurveTo3.setControlY1(-height * 0.02167183); cubicCurveTo3.setControlX2(centerX - width * 0.06899351); cubicCurveTo3.setControlY2(height * 0.03723715); cubicCurveTo3.setX(centerX - width * 0.06899351); cubicCurveTo3.setY(height * 0.10990712);
        cubicCurveTo4.setControlX1(centerX - width * 0.06899351); cubicCurveTo4.setControlY1(height * 0.11400031); cubicCurveTo4.setControlX2(centerX - width * 0.06856705); cubicCurveTo4.setControlY2(height * 0.12174644); cubicCurveTo4.setX(centerX - width * 0.06856705); cubicCurveTo4.setY(height * 0.12174644);
        lineTo2.setX(centerX); lineTo2.setY(centerY);
        currentQuality.setStrokeWidth(height * 0.01);

        updateValue();

        knob.setCenterX(width * 0.5); knob.setCenterY(height * 0.94736842); knob.setRadius(height * 0.05572755);
        knob.setStrokeWidth(height * 0.01);

        redraw();
    }
}
 
开发者ID:gluonhq,项目名称:javaone2016,代码行数:74,代码来源:QualityGauge.java

示例4: drawChart

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
private void drawChart(final double VALUE) {
    low  = Statistics.getMin(dataList);
    high = Statistics.getMax(dataList);
    if (Double.compare(low, high) == 0) {
        low  = minValue;
        high = maxValue;
    }
    range = high - low;

    double minX  = graphBounds.getX();
    double maxX  = minX + graphBounds.getWidth();
    double minY  = graphBounds.getY();
    double maxY  = minY + graphBounds.getHeight();
    double stepX = graphBounds.getWidth() / (noOfDatapoints - 1);
    double stepY = graphBounds.getHeight() / range;

    if (gauge.isSmoothing()) {
        smooth(dataList);
    } else {
        MoveTo begin = (MoveTo) pathElements.get(0);
        begin.setX(minX);
        begin.setY(maxY - Math.abs(low - dataList.get(0)) * stepY);
        for (int i = 1; i < (noOfDatapoints - 1); i++) {
            LineTo lineTo = (LineTo) pathElements.get(i);
            lineTo.setX(minX + i * stepX);
            lineTo.setY(maxY - Math.abs(low - dataList.get(i)) * stepY);
        }
        LineTo end = (LineTo) pathElements.get(noOfDatapoints - 1);
        end.setX(maxX);
        end.setY(maxY - Math.abs(low - dataList.get(noOfDatapoints - 1)) * stepY);

        dot.setCenterX(maxX);
        dot.setCenterY(end.getY());
    }

    double average = gauge.getAverage();
    double averageY = clamp(minY, maxY, maxY - Math.abs(low - average) * stepY);

    averageLine.setStartX(minX);
    averageLine.setEndX(maxX);
    averageLine.setStartY(averageY);
    averageLine.setEndY(averageY);

    stdDeviationArea.setY(averageLine.getStartY() - (stdDeviation * 0.5 * stepY));
    stdDeviationArea.setHeight(stdDeviation * stepY);

    valueText.setText(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), VALUE));
    averageText.setText(String.format(locale, formatString, average));

    highText.setText(String.format(locale, formatString, high));
    lowText.setText(String.format(locale, formatString, low));
    resizeDynamicText();
}
 
开发者ID:HanSolo,项目名称:Medusa,代码行数:54,代码来源:TileSparklineSkin.java

示例5: start

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
@Override
public void start(Stage palco) throws Exception {
	StackPane painelEmpilhador = new StackPane();
	Rectangle retangulo = new Rectangle(220, 120);
	retangulo.setFill(Color.GREEN);

	Polygon losango = new Polygon();
	losango.getPoints().addAll(new Double[]{
	     50.0, 50.0,
	     150.0, 0.0,
	     250.0, 50.0,
	     150.0, 100.0,
	     50.0, 50.0 });
	losango.setFill(Color.YELLOW);
	Path arco = new Path();
	MoveTo moveTo = new MoveTo();
	moveTo.setX(0.0);
	moveTo.setY(0.0);

	ArcTo arcTo = new ArcTo();
	arcTo.setX(55.0);
	arcTo.setY(0.0);
	arcTo.setRadiusX(50.0);
	arcTo.setRadiusY(50.0);

	arco.getElements().add(moveTo);
	arco.getElements().add(arcTo);
	arco.setStroke(Color.WHITE);

	arco.setRotate(180);
	arco.setStrokeWidth(5);

	Circle circulo = new Circle(30, Color.BLUE);
	  
	painelEmpilhador.getChildren().addAll(retangulo, losango, circulo, arco);
	
	Scene cena = new Scene(painelEmpilhador, 250, 100); 
	palco.setTitle("Testando StackPane"); 
	palco.setScene(cena); 
	palco.show(); 
}
 
开发者ID:jesuino,项目名称:livro-javafx-pratico,代码行数:42,代码来源:PraticaStackPane.java

示例6: createOuterCircleSegments

import javafx.scene.shape.MoveTo; //导入方法依赖的package包/类
/**
    * computes the circular ring segments specified by segmentCount 
    * through translation of vector coordinates into local coordinate-space at
    * application runtime <br>
    * Each segment and its associated symbol will be added to a 
    * group-node which will be put into an ObservableList of type Group: segments <br>
    * @see {@link segments}, {@link getSegments}, {@link setSegments}
    */
   private void createOuterCircleSegments()
   {
double segmentRadians = 360/segmentCount*Math.PI/180;

for(int i = 2; i <= segmentCount+1; i++)
{
    Group g = new Group();
    
    Path p = new Path();
    p.setFill(fillColor);
    p.setStroke(strokeColor);
    p.setFillRule(FillRule.EVEN_ODD);
    
    MoveTo firstPoint = new MoveTo();
    firstPoint.setX(centerX + innerRadius*Math.cos(segmentRadians*(i-1)));
    firstPoint.setY(centerY + innerRadius*Math.sin(segmentRadians*(i-1)));
    
    p.getElements().add(firstPoint);
    
    LineTo nextLine = new LineTo();
    nextLine.setX(centerX + outerRadius*Math.cos(segmentRadians*(i-1)));
    nextLine.setY(centerY + outerRadius*Math.sin(segmentRadians*(i-1)));
    
    ArcTo outerArc = new ArcTo();
    outerArc.setSweepFlag(true);
    outerArc.setAbsolute(true);
    outerArc.setX(centerX + outerRadius*Math.cos(2*Math.PI + segmentRadians*i));
    outerArc.setY(centerY + outerRadius*Math.sin(2*Math.PI + segmentRadians*i));
    outerArc.setRadiusX(outerRadius);
    outerArc.setRadiusY(outerRadius);

    LineTo line2 = new LineTo();
    line2.setX(centerX + innerRadius*Math.cos(segmentRadians*(i)));
    line2.setY(centerY + innerRadius*Math.sin(segmentRadians*(i)));
    
    ArcTo innerArc = new ArcTo();
    innerArc.setSweepFlag(false);
    innerArc.setAbsolute(true);
    innerArc.setX(centerX + innerRadius*Math.cos(2*Math.PI + segmentRadians*(i-1)));
    innerArc.setY(centerY + innerRadius*Math.sin(2*Math.PI + segmentRadians*(i-1)));
    innerArc.setRadiusX(innerRadius);
    innerArc.setRadiusY(innerRadius);
    
    MoveTo end = new MoveTo();
    end.setX(centerX + innerRadius*Math.cos(segmentRadians*(i)));
    end.setY(centerY + innerRadius*Math.sin(segmentRadians*(i)));
    
    p.getElements().add(nextLine);
    p.getElements().add(outerArc);
    p.getElements().add(line2);
    p.getElements().add(innerArc);
    p.getElements().add(end);
    
    g.getChildren().add(p);
    
    
    // temporary: for button layout injection
    Rectangle rect = new Rectangle();
    rect.setX(centerX-((outerRadius-innerRadius)*0.35) + (innerRadius + (outerRadius - innerRadius)/2)*Math.cos(segmentRadians*(i-.5)));
    rect.setY(centerY-((outerRadius-innerRadius)*0.35) + (innerRadius + (outerRadius - innerRadius)/2)*Math.sin(segmentRadians*(i-.5)));
    rect.setWidth(((outerRadius-innerRadius)*0.7));
    rect.setHeight(((outerRadius-innerRadius)*0.7));
    rect.setRotate(Math.toDegrees(segmentRadians*(i-.5)));
    rect.setFill(Color.RED);
    
    g.getChildren().add(rect);
    
    segments.add(g);
}

   }
 
开发者ID:nballmann,项目名称:RadialMenuFX,代码行数:80,代码来源:RadialMenu.java


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