private ValueAxis configureRangeIndex(int index, int dataType) { ValueAxis axis = createAxis(dataType); axis.setAutoRange(true); Font axisFont = axis.getLabelFont().deriveFont(Font.BOLD); axis.setLabelFont(axisFont); axis.setLabel(String.format("Y%d Samples", index + 1)); xyPlot.setRangeAxis(index, axis); xyPlot.setRangeAxisLocation(index, index == 0 ? AxisLocation.BOTTOM_OR_LEFT : AxisLocation.BOTTOM_OR_RIGHT); return axis; }
private void setPlotUnit(List<DisplayableSpectrum> spectra, XYPlot plot) { String unitToBeDisplayed = spectra.get(0).getUnit(); int i = 1; while (i < spectra.size() && !unitToBeDisplayed.equals(DisplayableSpectrum.MIXED_UNITS)) { DisplayableSpectrum displayableSpectrum = spectra.get(i++); if (displayableSpectrum.hasSelectedBands() && !unitToBeDisplayed.equals(displayableSpectrum.getUnit())) { unitToBeDisplayed = DisplayableSpectrum.MIXED_UNITS; } } isCodeInducedAxisChange = true; plot.getRangeAxis().setLabel(unitToBeDisplayed); isCodeInducedAxisChange = false; }
private void configureDomainAxis(int index, String nameX, int dataType) { ValueAxis axis = createAxis(dataType); axis.setAutoRange(true); axis.setAutoRangeMinimumSize(2); axis.setLabel(nameX); Font axisFont = axis.getLabelFont().deriveFont(Font.BOLD); axis.setLabelFont(axisFont); xyPlot.setDomainAxis(index, axis); }
private void setPlotUnit(List<DisplayableSpectrum> spectra, XYPlot plot) { String unitToBeDisplayed = ""; if (spectra.size() > 0) { unitToBeDisplayed = spectra.get(0).getUnit(); int i = 1; while (i < spectra.size() && !unitToBeDisplayed.equals(DisplayableSpectrum.MIXED_UNITS)) { DisplayableSpectrum displayableSpectrum = spectra.get(i++); if (displayableSpectrum.hasSelectedBands() && !unitToBeDisplayed.equals(displayableSpectrum.getUnit())) { unitToBeDisplayed = DisplayableSpectrum.MIXED_UNITS; } } } isCodeInducedAxisChange = true; plot.getRangeAxis().setLabel(unitToBeDisplayed); isCodeInducedAxisChange = false; }
@Override public void propertyChange(PropertyChangeEvent evt) { final VectorDataNode pointDataSource = scatterPlotModel.pointDataSource; final AttributeDescriptor dataField = scatterPlotModel.dataField; if (dataField != null && pointDataSource != null) { final String dataFieldName = dataField.getLocalName(); getPlot().getDomainAxis().setLabel(dataFieldName); xAxisRangeControl.setTitleSuffix(dataFieldName); } else { getPlot().getDomainAxis().setLabel(""); xAxisRangeControl.setTitleSuffix(""); } } };
private void updateXAxis() { final XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setLabel(getAxisLabel()); }
private void updateXAxis() { final XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setLabel(getAxisLabel()); }
private void updateAxis() { UnitSystem unitSystem = profileModel.getUnitSystem(); YAxisMode yAxisMode = profileModel.getYAxisMode(); String yAxisUnit = yAxisMode.equals(Elevation) ? unitSystem.getElevationName() : unitSystem.getSpeedName(); String yAxisKey = yAxisMode.equals(Elevation) ? "elevation-axis" : "speed-axis"; plot.getRangeAxis().setLabel(format(getBundle().getString(yAxisKey), yAxisUnit)); XAxisMode xAxisMode = profileModel.getXAxisMode(); String xAxisUnit = xAxisMode.equals(Distance) ? unitSystem.getDistanceName() : "s"; String xAxisKey = xAxisMode.equals(Distance) ? "distance-axis" : "time-axis"; plot.getDomainAxis().setLabel(format(getBundle().getString(xAxisKey), xAxisUnit)); chartPanel.setToolTipGenerator(new StandardXYToolTipGenerator( "{2} " + yAxisUnit + " @ {1} " + xAxisUnit, getIntegerInstance(), getIntegerInstance()) { public String generateLabelString(XYDataset dataset, int series, int item) { return super.generateLabelString(dataset, series, item).replaceAll("null", "?"); } }); }
/** * Checks for selections in AttributeName list. */ public void valueChanged(ListSelectionEvent e) { JList list = ((JList) e.getSource()); AttributeNameListModel model = (AttributeNameListModel) list.getModel(); int index = list.getSelectedIndex(); if (index > -1 && !model.isEmpty()) { goButton.setEnabled(true); targetAttributeName = model.getAttributeNameAt(index); chart.getXYPlot().setDataset(createDataset()); String label = targetAttributeName.getFullname(); if (label == null || label.trim().length() == 0) label = targetAttributeName.getId(); chart.getXYPlot().getDomainAxis().setLabel(label); chart.fireChartChanged(); } }
@Override protected void updateComponents() { super.updateComponents(); if (isRasterChanged() || isProductChanged()) { plot.setImage(null); plot.setDataset(null); if (isProductChanged()) { plot.getDomainAxis().setLabel("X"); plot.getRangeAxis().setLabel("Y"); } final ValueSet valueSet = new ValueSet(createAvailableBandList()); xBandProperty.getDescriptor().setValueSet(valueSet); yBandProperty.getDescriptor().setValueSet(valueSet); toggleColorCheckBox.setEnabled(false); if (valueSet.getItems().length > 0) { RasterDataNode currentRaster = getRaster(); try { xBandProperty.setValue(currentRaster); yBandProperty.setValue(currentRaster); } catch (ValidationException ignored) { Debug.trace(ignored); } } } refreshButton.setEnabled(xBandProperty.getValue() != null && yBandProperty.getValue() != null); }
@Override protected void updateComponents() { super.updateComponents(); if (isRasterChanged() || isProductChanged()) { plot.setImage(null); plot.setDataset(null); if (isProductChanged()) { plot.getDomainAxis().setLabel("X"); plot.getRangeAxis().setLabel("Y"); } final ValueSet productValueSet = new ValueSet(createAvailableProductList()); xProductProperty.getDescriptor().setValueSet(productValueSet); yProductProperty.getDescriptor().setValueSet(productValueSet); if (productValueSet.getItems().length > 0) { Product currentProduct = getProduct(); try { xProductProperty.setValue(currentProduct); yProductProperty.setValue(currentProduct); } catch (ValidationException ignored) { Debug.trace(ignored); } } updateBandList(getProduct(), xBandProperty, false); updateBandList(getProduct(), yBandProperty, true); toggleColorCheckBox.setEnabled(false); } refreshButton.setEnabled(xBandProperty.getValue() != null && yBandProperty.getValue() != null); }
/** * {@inheritDoc} */ @Override public void customize(JFreeChart chart, ReportParameters reportParameters) { if (chart.getPlot() instanceof CategoryPlot) { if (chart.getCategoryPlot().getDataset() != null) { CategoryDataset dataset; if (!(chart.getCategoryPlot().getRenderer() instanceof GroupedStackedBarRenderer)) { dataset = new PercentageCategoryDataset(chart.getCategoryPlot().getDataset()); } else { dataset = new PercentageGroupedCategoryDataset(chart.getCategoryPlot().getDataset()); } chart.getCategoryPlot().setDataset(dataset); } if (StringUtils.isBlank(chart.getCategoryPlot().getRangeAxis().getLabel())) { chart.getCategoryPlot().getRangeAxis().setLabel("%"); } } } }
private void configureRangeAxis(int index, MetadataElement metadataElement, String yAttributeName, String[] recordElementNames, String refRecordName, double[] recordIndices) { double[] yAxisData = new double[recordIndices.length]; Arrays.setAll(yAxisData, i -> getDataAsDouble(metadataElement.getElement(recordElementNames[i]).getAttribute(yAttributeName).getData())); DefaultXYDataset dataset2 = new DefaultXYDataset(); dataset2.addSeries(yAttributeName, new double[][]{recordIndices, yAxisData}); xyPlot.setDataset(index, dataset2); xyPlot.mapDatasetToRangeAxis(index, index); int yDataType = getAttributeType(metadataElement.getElement(refRecordName).getAttribute(yAttributeName)); ValueAxis yAxis = configureRangeIndex(index, yDataType); String yUnit = metadataElement.getElement(refRecordName).getAttribute(yAttributeName).getUnit(); yAxis.setLabel(getYAxisLabel(yAttributeName, yUnit)); xyPlot.setRenderer(index, creatItemRenderer(index, yDataType)); }
ValueAxis y1Axis = configureRangeIndex(0, y1DataType); String unitY1 = y1Attribute.getUnit(); y1Axis.setLabel(getYAxisLabel(nameY1, unitY1)); int dataSetCnt = 0; for (int i = 0; i < recordElementNames.length; i++, dataSetCnt++) { ValueAxis y2Axis = configureRangeIndex(1, y2DataType); String unitY2 = y2Attribute.getUnit(); y2Axis.setLabel(getYAxisLabel(nameY2, unitY2));
chart.getXYPlot().getRangeAxis().setLabel(StatisticChartStyling.getAxisLabel(getRaster(), DEFAULT_SAMPLE_DATASET_NAME, false));
chart.getXYPlot().getRangeAxis().setLabel(StatisticChartStyling.getAxisLabel(getRaster(), DEFAULT_SAMPLE_DATASET_NAME, false));
@Override protected void updateComponents() { super.updateComponents(); if (!isVisible()) { return; } final AttributeDescriptor dataField = scatterPlotModel.dataField; xAxisRangeControl.setTitleSuffix(dataField != null ? dataField.getLocalName() : null); final RasterDataNode raster = getRaster(); yAxisRangeControl.setTitleSuffix(raster != null ? raster.getName() : null); if (raster != null) { final Product product = getProduct(); final String rasterName = raster.getName(); final UserSettings userSettings = getUserSettings(product); final VectorDataNode userSelectedPointDataSource = userSettings.getPointDataSource(rasterName); final AttributeDescriptor userSelectedDataField = userSettings.getDataField(rasterName); correlativeFieldSelector.updatePointDataSource(product); correlativeFieldSelector.updateDataField(); if (userSelectedPointDataSource != null) { correlativeFieldSelector.tryToSelectPointDataSource(userSelectedPointDataSource); } if (userSelectedDataField != null) { correlativeFieldSelector.tryToSelectDataField(userSelectedDataField); } } if (isRasterChanged()) { getPlot().getRangeAxis().setLabel(getAxisLabel(raster, "X", false)); computeChartDataIfPossible(); } }
ValueAxis y1Axis = configureRangeIndex(0, y1DataType); String unitY1 = y1Attribute.getUnit(); y1Axis.setLabel(getYAxisLabel(nameY1, unitY1)); double[] y1AxisData = new double[1]; Arrays.setAll(y1AxisData, i -> getDataAsDouble(y1Attribute.getData())); ValueAxis y2Axis = configureRangeIndex(1, y2DataType); String unitY2 = y2Attribute.getUnit(); y2Axis.setLabel(getYAxisLabel(nameY2, unitY2)); double[] y2AxisData = new double[1]; Arrays.setAll(y2AxisData, i -> getDataAsDouble(y2Attribute.getData()));
@Override protected void updateComponents() { super.updateComponents(); if (!isVisible()) { return; } final AttributeDescriptor dataField = scatterPlotModel.dataField; xAxisRangeControl.setTitleSuffix(dataField != null ? dataField.getLocalName() : null); final RasterDataNode raster = getRaster(); yAxisRangeControl.setTitleSuffix(raster != null ? raster.getName() : null); if (raster != null) { final Product product = getProduct(); final String rasterName = raster.getName(); final UserSettings userSettings = getUserSettings(product); final VectorDataNode userSelectedPointDataSource = userSettings.getPointDataSource(rasterName); final AttributeDescriptor userSelectedDataField = userSettings.getDataField(rasterName); correlativeFieldSelector.updatePointDataSource(product); correlativeFieldSelector.updateDataField(); if (userSelectedPointDataSource != null) { correlativeFieldSelector.tryToSelectPointDataSource(userSelectedPointDataSource); } if (userSelectedDataField != null) { correlativeFieldSelector.tryToSelectDataField(userSelectedDataField); } } if (isRasterChanged()) { getPlot().getRangeAxis().setLabel(StatisticChartStyling.getAxisLabel(raster, "X", false)); computeChartDataIfPossible(); } }