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


Java NumberAxis.setTickUnit方法代碼示例

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


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

示例1: createBarChart

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
private BarChart createBarChart() {
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
    xAxis.setLabel("Year");

    double tickUnit = tableModel.getTickUnit();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickUnit(tickUnit);
    yAxis.setLabel("Units Sold");

    final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
    tableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                final int row = e.getFirstRow();
                final int column = e.getColumn();
                final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);

                Platform.runLater(new Runnable() {
                    public void run() {
                        XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row);
                        BarChart.Data data = s.getData().get(column);
                        data.setYValue(value);
                    }
                });
            }
        }
    });
    return chart;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:33,代碼來源:SwingInterop.java

示例2: updateAxisTickUnit

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
private void updateAxisTickUnit(NumberAxis axis) {
    double size = Math.abs(axis.getUpperBound() - axis.getLowerBound());
    double tick = Math.ceil(size / 10);
    if (tick > 100) {
        tick = tick - (tick % 100);
    } else if (tick > 10) {
        tick = tick - (tick % 10);
    } else if (tick > 5) {
        tick = tick - (tick % 5);
    } else if (tick > 2) {
        tick = tick - (tick % 2);
    }
    axis.setTickUnit(tick);
}
 
開發者ID:yuriy-budiyev,項目名稱:population,代碼行數:15,代碼來源:PrimaryController.java

示例3: setUpChart

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
@Override
public void setUpChart(XYChart<Number, Number> chart, ResourceBundle resources) {
    NumberAxis xAxis = (NumberAxis) chart.getXAxis();
    NumberAxis yAxis = (NumberAxis) chart.getYAxis();
    xAxis.setLabel(resources.getString("photometricdata.period"));
    xAxis.setAutoRanging(false);
    xAxis.setTickUnit(0.25);
    xAxis.setLowerBound(0);
    xAxis.setUpperBound(1);
    yAxis.setLabel(resources.getString("photometricdata.magnitude"));
    yAxis.setAutoRanging(true);
    yAxis.setTickLabelFormatter(invertedNegative(yAxis));
}
 
開發者ID:m-krajcovic,項目名稱:photometric-data-retriever,代碼行數:14,代碼來源:PeriodPhotometricChartData.java

示例4: setUpChart

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
@Override
public void setUpChart(XYChart<Number, Number> chart, ResourceBundle resources) {
    NumberAxis xAxis = (NumberAxis) chart.getXAxis();
    NumberAxis yAxis = (NumberAxis) chart.getYAxis();
    xAxis.setLabel(resources.getString("photometricdata.jd"));
    xAxis.setAutoRanging(true);
    xAxis.setTickUnit(1000);
    yAxis.setLabel(resources.getString("photometricdata.magnitude"));
    yAxis.setAutoRanging(true);
    yAxis.setTickLabelFormatter(invertedNegative(yAxis));
}
 
開發者ID:m-krajcovic,項目名稱:photometric-data-retriever,代碼行數:12,代碼來源:JulianDatePhotometricChartData.java

示例5: createAxis

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
/**
 * create a horizontal axis
 *
 * @param maxReadLength
 * @return axis
 */
public static Pane createAxis(final ReadOnlyIntegerProperty maxReadLength, final ReadOnlyDoubleProperty widthProperty) {
    final Pane pane = new Pane();
    pane.prefWidthProperty().bind(widthProperty);

    final NumberAxis axis = new NumberAxis();
    axis.setSide(Side.TOP);
    axis.setAutoRanging(false);
    axis.setLowerBound(0);
    axis.prefHeightProperty().set(20);
    axis.prefWidthProperty().bind(widthProperty.subtract(60));

    final ChangeListener<Number> changeListener = new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            int minX = Math.round(maxReadLength.get() / 2000.0f); // at most 2000 major ticks
            for (int x = 10; x < 10000000; x *= 10) {
                if (x >= minX && widthProperty.doubleValue() * x >= 50 * maxReadLength.doubleValue()) {
                    axis.setUpperBound(maxReadLength.get());
                    axis.setTickUnit(x);
                    return;
                }
            }
            axis.setTickUnit(maxReadLength.get());
            axis.setUpperBound(maxReadLength.get());
        }
    };

    maxReadLength.addListener(changeListener);
    widthProperty.addListener(changeListener);

    pane.getChildren().add(axis);
    return pane;
}
 
開發者ID:danielhuson,項目名稱:megan-ce,代碼行數:40,代碼來源:LRInspectorController.java

示例6: setAxisProperties

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
private static void setAxisProperties(final Axis<Number> axisOrig, final Axis<Number> axisNew) {
	if (axisOrig instanceof NumberAxis && axisNew instanceof NumberAxis) {
		NumberAxis nAxisOrig = (NumberAxis)axisOrig;
		NumberAxis nAxisNew = (NumberAxis)axisNew;
		nAxisNew.setLowerBound(nAxisOrig.getLowerBound());
		nAxisNew.setUpperBound(nAxisOrig.getUpperBound());
		nAxisNew.setTickUnit(nAxisOrig.getTickUnit());
	}
	axisNew.setAutoRanging(axisOrig.isAutoRanging());
	axisNew.setLabel(axisOrig.getLabel());
}
 
開發者ID:qupath,項目名稱:qupath,代碼行數:12,代碼來源:ExportChartPanel.java

示例7: updateHistogram

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
private void updateHistogram() {
		if (table == null || !isInitialized())
			return;
		ChannelDisplayInfo infoSelected = getCurrentInfo();
		Histogram histogram = (imageDisplay == null || infoSelected == null) ? null : imageDisplay.getHistogram(infoSelected);
//		histogram = histogramMap.get(infoSelected);
		if (histogram == null) {
			histogramPanel.getHistogramData().clear();
		}
		else {
			// Any animation is slightly nicer if we can modify the current data, rather than creating a new one
			if (histogramPanel.getHistogramData().size() == 1) {
				Color color = infoSelected.getColor() == null ? ColorToolsFX.TRANSLUCENT_BLACK_FX : ColorToolsFX.getCachedColor(infoSelected.getColor());
				histogramPanel.getHistogramData().get(0).setHistogram(histogram, color);
			} else
				histogramPanel.getHistogramData().setAll(HistogramPanelFX.createHistogramData(histogram, true, infoSelected.getColor()));
		}
		
		
		NumberAxis xAxis = (NumberAxis)histogramPanel.getChart().getXAxis();
		if (infoSelected != null && infoSelected.getMaxAllowed() == 255 && infoSelected.getMinAllowed() == 0) {
			xAxis.setAutoRanging(false);
			xAxis.setLowerBound(0);
			xAxis.setUpperBound(255);
		} else if (infoSelected != null) {
			xAxis.setAutoRanging(false);
			xAxis.setLowerBound(infoSelected.getMinAllowed());
			xAxis.setUpperBound(infoSelected.getMaxAllowed());
//			xAxis.setAutoRanging(true);
		}
		if (infoSelected != null)
			xAxis.setTickUnit(infoSelected.getMaxAllowed() - infoSelected.getMinAllowed());
		
		histogramPanel.getChart().getXAxis().setTickLabelsVisible(true);
		histogramPanel.getChart().getXAxis().setLabel("Pixel value");
		histogramPanel.getChart().getYAxis().setTickLabelsVisible(true);
//		histogramPanel.getChart().getYAxis().setLabel("Frequency");
		
		GridPane pane = new GridPane();
		pane.setHgap(4);
		pane.setVgap(2);
		int r = 0;
		// TODO: Show min & max somewhere - but beware of the need to stay updated!
//		if (infoSelected != null) {
//			pane.add(new Label("Min display"), 0, r);
//			pane.add(new Label(df.format(infoSelected.getMinDisplay())), 1, r);
//			r++;
//			pane.add(new Label("Max display"), 0, r);
//			pane.add(new Label(df.format(infoSelected.getMaxDisplay())), 1, r);
//			r++;
//		}
		if (histogram != null) {
			pane.add(new Label("Min"), 0, r);
			pane.add(new Label(df.format(histogram.getMinValue())), 1, r);
			r++;
			pane.add(new Label("Max"), 0, r);
			pane.add(new Label(df.format(histogram.getMaxValue())), 1, r);
			r++;
			pane.add(new Label("Mean"), 0, r);
			pane.add(new Label(df.format(histogram.getMeanValue())), 1, r);
			r++;
			pane.add(new Label("Std.dev"), 0, r);
			pane.add(new Label(df.format(histogram.getStdDev())), 1, r);
			r++;
		}
		chartTooltip.setGraphic(pane);
		
		if (r == 0)
			Tooltip.uninstall(histogramPanel.getChart(), chartTooltip);
		else
			Tooltip.install(histogramPanel.getChart(), chartTooltip);
		
////	case 0: return columnIndex == 0 ? "Min display" : df.format(channel.getMinDisplay());
////	case 1: return columnIndex == 0 ? "Max display" : df.format(channel.getMaxDisplay());
////	case 2: return columnIndex == 0 ? "Min" : df.format(histogram.getMinValue());
////	case 3: return columnIndex == 0 ? "Max" : df.format(histogram.getMaxValue());
////	case 4: return columnIndex == 0 ? "Mean" : df.format(histogram.getMeanValue());
////	case 5: return columnIndex == 0 ? "Std.dev" : df.format(histogram.getStdDev());
//		
//		histogramTableModel.setHistogram(infoSelected, histogram);
	}
 
開發者ID:qupath,項目名稱:qupath,代碼行數:82,代碼來源:BrightnessContrastCommand.java

示例8: createChart

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
private XYChart<Number, Number> createChart() {
	final XYChart.Series<Number, Number> series = new XYChart.Series<>();

	final double divisionWidth = (this.story.getRange().getLength() * 1.0) / (numDivisions * 1.0);

	for (int i = 0; i < numDivisions; ++i) {
		final TextRange range = new TextRange((int) Math.round(i * divisionWidth), (int) Math.round((i + 1) * divisionWidth));
		final double count = getNumOverlaps(range, this.ranges);
		series.getData().add(new Data<Number, Number>(range.getStartIndex(), count));
	}

	final StringConverter<Number> tickLabelFormatter = new StringConverter<Number>() {

		@Override
		public String toString(final Number n) {
			return String.valueOf((int) Math.round(n.doubleValue()));
		}

		@Override
		public Number fromString(final String string) {
			return Double.valueOf(string);
		}
	};

	final NumberAxis xAxis = new NumberAxis(0, this.story.getRange().getLength() - divisionWidth, divisionWidth);
	xAxis.setLabel("Text Position");
	xAxis.setTickLabelsVisible(true);
	xAxis.setTickLabelFormatter(tickLabelFormatter);
	final NumberAxis yAxis = new NumberAxis();
	yAxis.setTickUnit(1);
	yAxis.setLabel("# Found");
	yAxis.setTickLabelsVisible(true);
	yAxis.setTickLabelFormatter(tickLabelFormatter);

	final AreaChart<Number, Number> chart = new AreaChart<>(xAxis, yAxis);
	chart.setAnimated(false);
	chart.getData().add(series);
	chart.setLegendVisible(false);
	chart.setPrefWidth(600);
	chart.setPrefHeight(400);
	chart.setTitle("Heat Map");

	return chart;
}
 
開發者ID:mizitch,項目名稱:story-inspector,代碼行數:45,代碼來源:HeatMapSummaryComponent.java

示例9: initializePercentileChartAxes

import javafx.scene.chart.NumberAxis; //導入方法依賴的package包/類
void initializePercentileChartAxes() {
    checkNotNull(percentileChart);
    final NumberAxis xAxis = (NumberAxis) percentileChart.getXAxis();
    xAxis.setAutoRanging(false);
    xAxis.setTickUnit(1); // log axis -> 10^x steps
    xAxis.setLowerBound(0);
    xAxis.setUpperBound(0);

    // Limit X range to max value to avoid empty space
    percentileChart.getData().addListener((ListChangeListener<XYChart.Series<Number, Number>>) c -> {
        double maxX = percentileChart.getData().stream()
                .flatMap(series -> series.getData().stream())
                .mapToDouble(point -> point.getXValue().doubleValue())
                .max()
                .orElse(0);
        xAxis.setUpperBound(maxX);
    });

    // Format labels such that e.g. 10^6 is shown as 6 nines
    xAxis.setTickLabelFormatter(new StringConverter<Number>() {
        @Override
        public String toString(Number object) {
            int intValue = object.intValue();
            if (object.doubleValue() > intValue)
                return ""; // Only label full 10^x steps
            switch (intValue) {
                case 0:
                    return "0%";
                case 1:
                    return "90%";
                case 2:
                    return "99%";
                default:
                    String percentile = "99.";
                    for (int i = 2; i < intValue; i++) {
                        percentile += "9";
                    }
                    return percentile + "%";
            }

        }

        @Override
        public Number fromString(String string) {
            return null;
        }
    });
}
 
開發者ID:ennerf,項目名稱:HdrHistogramVisualizer,代碼行數:49,代碼來源:VisualizerPresenter.java


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