/** * Sets a range axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param index the axis index. * @param axis the axis ({@code null} permitted). * * @see #getRangeAxis(int) */ public void setRangeAxis(int index, ValueAxis axis) { setRangeAxis(index, axis, true); }
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; }
/** * Sets a range axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param index the axis index. * @param axis the axis (<code>null</code> permitted). * * @see #getRangeAxis(int) */ public void setRangeAxis(int index, ValueAxis axis) { setRangeAxis(index, axis, true); }
/** * Sets the range axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes (<code>null</code> not permitted). * * @see #setDomainAxes(ValueAxis[]) */ public void setRangeAxes(ValueAxis[] axes) { for (int i = 0; i < axes.length; i++) { setRangeAxis(i, axes[i], false); } fireChangeEvent(); }
/** * Sets the range axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes ({@code null} not permitted). * * @see #setDomainAxes(ValueAxis[]) */ public void setRangeAxes(ValueAxis[] axes) { for (int i = 0; i < axes.length; i++) { setRangeAxis(i, axes[i], false); } fireChangeEvent(); }
private XYPlot createPlot(final XYSeriesCollection problem, XYSeriesCollection shipments, XYSeriesCollection solution) { XYPlot plot = new XYPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); XYLineAndShapeRenderer problemRenderer = getProblemRenderer(problem); plot.setDataset(0, problem); plot.setRenderer(0, problemRenderer); XYItemRenderer shipmentsRenderer = getShipmentRenderer(shipments); plot.setDataset(1, shipments); plot.setRenderer(1, shipmentsRenderer); if (solution != null) { XYItemRenderer solutionRenderer = getRouteRenderer(solution); plot.setDataset(2, solution); plot.setRenderer(2, solutionRenderer); } NumberAxis xAxis = new NumberAxis(); NumberAxis yAxis = new NumberAxis(); if (boundingBox == null) { xAxis.setRangeWithMargins(getDomainRange(problem)); yAxis.setRangeWithMargins(getRange(problem)); } else { xAxis.setRangeWithMargins(new Range(boundingBox.minX, boundingBox.maxX)); yAxis.setRangeWithMargins(new Range(boundingBox.minY, boundingBox.maxY)); } plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); return plot; }
private static XYPlot createPlot(ValueAxis domainAxis, ValueAxis... rangesAxis) { XYPlot plot = new XYPlot(); plot.setDomainAxis(domainAxis); int i = 0; for (ValueAxis rangeAxis : rangesAxis) { plot.setRangeAxis(i++, rangeAxis); } return defaultPlot(plot); }
private void setYAxis() { ValueAxis axis; switch (yAxisScaling) { case LOGARITHMIC: axis = new LogarithmicAxis(xLabel); break; case CONSTANT: default: axis = new NumberAxis(xLabel); break; } graph.getXYPlot().setRangeAxis(0, axis); }
private JFreeChart createChart(TimeTableXYDataset chartData) { DateAxis dateAxis = new DateAxis("Time"); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm")); dateAxis.setTickLabelFont(dateAxis.getTickLabelFont().deriveFont(20f)); NumberAxis yAxis = new NumberAxis("Count"); XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator(); StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2( toolTipGenerator, null); renderer.setOutline(true); XYPlot plot = new XYPlot(chartData, dateAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeAxis(yAxis); // forces recalculation of the axis range JFreeChart chart = new JFreeChart("Dogs and Cats", JFreeChart.DEFAULT_TITLE_FONT, plot, false); new StandardChartTheme("JFree").apply(chart); return chart; }
public XYChartBuilder setYAxis(final boolean showAxisValues, final String valueAxisUnitKey) { final NumberAxis yAxis; if (showAxisValues == true && valueAxisUnitKey != null) { yAxis = new NumberAxis(ThreadLocalUserContext.getLocalizedString(valueAxisUnitKey)); } else { yAxis = new NumberAxis(); } yAxis.setVisible(showAxisValues); plot.setRangeAxis(yAxis); return this; }
/** * The logic which handles the {@link PreferenceId#JMX_PLOTDATASOLVER} events. * * @param preferenceEvent * the event object */ private void processJmxPlotDataSolverEvent(PreferenceEvent preferenceEvent) { PlotDataSolver eDataSolver = (PlotDataSolver) preferenceEvent.getPreferenceMap().get(PreferenceId.JmxPlotDataSolver.DATA_SOLVER); // Update view plotDataSolver = PlotDataSolverFactory.getDataSolver(eDataSolver); subplot.setRangeAxis(plotDataSolver.getAxis()); // Update preferenceStore Map<String, String> dataSolverMap = PreferencesUtils.getObject(PreferencesConstants.JMX_PLOT_DATA_SOLVER); dataSolverMap.put(currentJmxIdent.getDerivedFullName(), eDataSolver.toString()); PreferencesUtils.saveObject(PreferencesConstants.JMX_PLOT_DATA_SOLVER, dataSolverMap, false); }
private void updateScalingOfYAxis() { final boolean logScaled = scatterPlotModel.yAxisLogScaled; final ValueAxis oldAxis = getPlot().getRangeAxis(); ValueAxis newAxis = StatisticChartStyling.updateScalingOfAxis(logScaled, oldAxis, false); getPlot().setRangeAxis(newAxis); finishScalingUpdate(yAxisRangeControl, newAxis, oldAxis); }
private void updateScalingOfYAxis() { final boolean logScaled = scatterPlotModel.yAxisLogScaled; final ValueAxis oldAxis = getPlot().getRangeAxis(); ValueAxis newAxis = StatisticChartStyling.updateScalingOfAxis(logScaled, oldAxis, false); getPlot().setRangeAxis(newAxis); finishScalingUpdate(yAxisRangeControl, newAxis, oldAxis); }
private void updateScalingOfYAxis() { final boolean logScaled = (Boolean) yAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_LOG_SCALED).getPropertyValue(); final XYPlot plot = chart.getXYPlot(); plot.setRangeAxis(StatisticChartStyling.updateScalingOfAxis(logScaled, plot.getRangeAxis(), true)); }
private void updateScalingOfYAxis() { final boolean logScaled = (Boolean) yAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_LOG_SCALED).getPropertyValue(); final XYPlot plot = chart.getXYPlot(); plot.setRangeAxis(StatisticChartStyling.updateScalingOfAxis(logScaled, plot.getRangeAxis(), true)); }
public void setData(TimeseriesData data, TimeseriesMetadataOutput timeMetadata, StyleProperties style) { getXYPlot().setDataset(timeseriesIndex, createTimeseriesCollection(data, style)); ValueAxis rangeAxis = createRangeAxis(timeMetadata); getXYPlot().setRangeAxis(timeseriesIndex, rangeAxis); getXYPlot().mapDatasetToRangeAxis(timeseriesIndex, timeseriesIndex); }
public void setData(Data<QuantityValue> data, DatasetOutput< ? > timeMetadata, StyleProperties style) { getXYPlot().setDataset(timeseriesIndex, createTimeseriesCollection(data, style)); ValueAxis rangeAxis = createRangeAxis(timeMetadata); getXYPlot().setRangeAxis(timeseriesIndex, rangeAxis); getXYPlot().mapDatasetToRangeAxis(timeseriesIndex, timeseriesIndex); }
public void setLogScale(boolean range, boolean domain) { if( domain ) { NumberAxis axis = (NumberAxis)plot.getDomainAxis(); axis = new LogarithmicAxis(axis.getLabel()); plot.setDomainAxis(axis); } if( range ) { NumberAxis axis = (NumberAxis)plot.getRangeAxis(); axis = new LogarithmicAxis(axis.getLabel()); plot.setRangeAxis(axis); } }
/** * Adds the cash flow axis to the plot. * @param plot the plot * @param dataset the cash flow dataset */ private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) { final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio"); cashAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, cashAxis); plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer(); cashFlowRenderer.setSeriesPaint(0, Color.blue); plot.setRenderer(1, cashFlowRenderer); }
private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel, final XYSeriesCollection dataset) { JFreeChart c = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend? false, // tooltips? false // URLs? ); if (this.isLogarithmicAxis){ XYPlot p = (XYPlot) c.getPlot(); LogarithmicAxis axis_x = new LogarithmicAxis(this.xAxisLabel); LogarithmicAxis axis_y = new LogarithmicAxis(this.yAxisLabel); axis_x.setAllowNegativesFlag(false); axis_y.setAllowNegativesFlag(false); p.setDomainAxis(axis_x); p.setRangeAxis(axis_y); } return c; }