當前位置: 首頁>>代碼示例>>Java>>正文


Java LineTo.setX方法代碼示例

本文整理匯總了Java中javafx.scene.shape.LineTo.setX方法的典型用法代碼示例。如果您正苦於以下問題:Java LineTo.setX方法的具體用法?Java LineTo.setX怎麽用?Java LineTo.setX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.shape.LineTo的用法示例。


在下文中一共展示了LineTo.setX方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createFlagWithRopes

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
private void createFlagWithRopes() {

        // Fill the flag with yellow gradient
        LinearGradient textRectGradient = LinearGradientBuilder.create().startX(50).startY(50).endX(100).endY(
                100).proportional(false).stops(new Stop(0.0f, Color.rgb(220, 220, 220, .784)),
                                               new Stop(1.0f, Color.rgb(180, 180, 180, .784))).build();
        m_flagRect.setFill(textRectGradient);

        // Adjust the flags position
        Bounds textBounds = m_flagText.getBoundsInLocal();
        double baseLineOffset = m_flagText.getBaselineOffset();
        m_flagRect.setTranslateX(m_flagText.getTranslateX() - FLAG_PADDING);
        m_flagRect.setTranslateY(m_flagText.getTranslateY() - baseLineOffset - FLAG_PADDING);
        m_flagRect.setWidth(textBounds.getWidth() + FLAG_PADDING * 2);
        m_flagRect.setHeight(textBounds.getHeight() + FLAG_PADDING * 2);

        // Create flag rope #01
        MoveTo moveTo1 = new MoveTo(m_fishSprite.getWidth() / 2, m_fishSprite.getHeight() / 2);
        LineTo lineTo1 = new LineTo(m_flagRect.getTranslateX() + m_flagRect.getWidth(), m_flagRect.getTranslateY());
        if (s_directionInvertedX) {
            lineTo1.setX(m_flagRect.getTranslateX());
        }
        m_flagRope1.getElements().add(moveTo1);
        m_flagRope1.getElements().add(lineTo1);
        m_flagRope1.setStrokeWidth(FLAG_ROPE_STROKE_WIDTH);
        m_flagRope1.setStroke(Color.rgb(0, 0, 0, 0.5));

        // Create flag rope #02
        MoveTo moveTo2 = new MoveTo(m_fishSprite.getWidth() / 2, m_fishSprite.getHeight() / 2);
        LineTo lineTo2 = new LineTo(m_flagRect.getTranslateX() + m_flagRect.getWidth(),
                                    m_flagRect.getTranslateY() + m_flagRect.getHeight());
        if (s_directionInvertedX) {
            lineTo2.setX(m_flagRect.getTranslateX());
        }
        m_flagRope2.getElements().add(moveTo2);
        m_flagRope2.getElements().add(lineTo2);
        m_flagRope2.setStrokeWidth(FLAG_ROPE_STROKE_WIDTH);
        m_flagRope2.setStroke(Color.rgb(0, 0, 0, 0.5));
    }
 
開發者ID:soziotech,項目名稱:Fishification,代碼行數:40,代碼來源:FishEntity.java

示例2: calcRegression

import javafx.scene.shape.LineTo; //導入方法依賴的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

示例3: handleCurrentValue

import javafx.scene.shape.LineTo; //導入方法依賴的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

示例4: resize

import javafx.scene.shape.LineTo; //導入方法依賴的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

示例5: drawChart

import javafx.scene.shape.LineTo; //導入方法依賴的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

示例6: start

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
@Override
public void start(Stage stage) {
    Path p = new Path();
    p.setStroke(Color.BLUE);
    p.setFill(null);

    if (OMIT_OFFSCREEN) {
        p.getElements().add(new MoveTo(-100, 100));
    } else {
        p.getElements().add(new MoveTo(-500, 100));
        for (int i = 0; i < NUM_OFFSCREEN; i++) {
            double x = Math.random() * 400 - 500;
            double y = Math.random() * 200;
            p.getElements().add(new LineTo(x, y));
        }
        p.getElements().add(new LineTo(-100, 100));
    }

    final LineTo lt1 = new LineTo(50, 150);
    final LineTo lt2 = new LineTo(150, 50);
    p.getElements().add(lt1);
    p.getElements().add(lt2);
    p.setCache(false);

    Scene scene = new Scene(new Group(p), 200, 200);
    stage.setScene(scene);
    stage.show();

    AnimationTimer anim = new AnimationTimer() {
        @Override
        public void handle(long now) {
            double x1 = Math.random() * 20 + 40;
            double y1 = Math.random() * 20 + 140;
            double x2 = Math.random() * 20 + 140;
            double y2 = Math.random() * 20 + 40;
            lt1.setX(x1);
            lt1.setY(y1);
            lt2.setX(x2);
            lt2.setY(y2);
        }
    };
    anim.start();
}
 
開發者ID:bourgesl,項目名稱:marlin-fx,代碼行數:44,代碼來源:PolylineClipTest.java

示例7: createOuterCircleSegments

import javafx.scene.shape.LineTo; //導入方法依賴的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

示例8: followMouse

import javafx.scene.shape.LineTo; //導入方法依賴的package包/類
/**
 * Has the line follow the mouse whereever it goes
 *
 * @param event
 * @param line
 */
private void followMouse (MouseEvent event, LineTo line) {
    line.setX(event.getX());
    line.setY(event.getY());
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:11,代碼來源:PathCreator.java


注:本文中的javafx.scene.shape.LineTo.setX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。