List of usage examples for org.jfree.chart.axis ValueAxis getLabel
public String getLabel()
From source file:no.met.jtimeseries.netcdf.plot.SimplePlotProvider.java
/** * Create range axes for all values to be used. * /*from w w w . j a v a 2 s . co m*/ * @param dataList List to create axes from * @param plot The plot render data on * * @return A map pointing from unit name to axis index */ private Map<String, Integer> createRangeAxes(List<NumberPhenomenon> dataList, XYPlot plot) { HashMap<String, Integer> ret = new HashMap<String, Integer>(); int i = 0; for (ValueAxis va : getRangeAxis(dataList)) { String unit = va.getLabel(); plot.setRangeAxis(i, va); ret.put(unit, i++); } return ret; }
From source file:net.sourceforge.processdash.ui.web.reports.snippets.EstErrorScatterChart.java
private TruncatedNumberAxis truncAxis(ValueAxis va, double maxValue) { NumberAxis axis = (NumberAxis) va;/*w w w . j a v a 2s.co m*/ double upper = Math.max(100, Math.min(maxValue, axis.getUpperBound())); return new TruncatedNumberAxis(va.getLabel(), upper); }
From source file:org.jfree.chart.demo.XYTickLabelDemo.java
/** * When a checkbox is changed .../* w w w.ja v a 2 s. com*/ * * @param event the event. */ public void actionPerformed(final ActionEvent event) { final ValueAxis[] axes = new ValueAxis[4]; final XYPlot plot = this.chart.getXYPlot(); axes[0] = plot.getDomainAxis(); axes[1] = plot.getRangeAxis(); axes[2] = plot.getDomainAxis(1); axes[3] = plot.getRangeAxis(1); final Object source = event.getSource(); if (source == this.symbolicAxesCheckBox) { final boolean val = this.symbolicAxesCheckBox.isSelected(); for (int i = 0; i < axes.length; i++) { ValueAxis axis = axes[i]; final String label = axis.getLabel(); final int maxTick = (int) axis.getUpperBound(); final String[] tickLabels = new String[maxTick]; final Font ft = axis.getTickLabelFont(); for (int itk = 0; itk < maxTick; itk++) { tickLabels[itk] = "Label " + itk; } axis = val ? new SymbolicAxis(label, tickLabels) : new NumberAxis(label); axis.setTickLabelFont(ft); axes[i] = axis; } plot.setDomainAxis(axes[0]); plot.setRangeAxis(axes[1]); plot.setDomainAxis(1, axes[2]); plot.setRangeAxis(1, axes[3]); } if (source == this.symbolicAxesCheckBox || source == this.verticalTickLabelsCheckBox) { final boolean val = this.verticalTickLabelsCheckBox.isSelected(); for (int i = 0; i < axes.length; i++) { axes[i].setVerticalTickLabels(val); } } else if (source == this.symbolicAxesCheckBox || source == this.horizontalPlotCheckBox) { final PlotOrientation val = this.horizontalPlotCheckBox.isSelected() ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL; this.chart.getXYPlot().setOrientation(val); } else if (source == this.symbolicAxesCheckBox || source == this.fontSizeTextField) { final String s = this.fontSizeTextField.getText(); if (s.length() > 0) { final float sz = Float.parseFloat(s); for (int i = 0; i < axes.length; i++) { final ValueAxis axis = axes[i]; Font ft = axis.getTickLabelFont(); ft = ft.deriveFont(sz); axis.setTickLabelFont(ft); } } } }
From source file:com.rapidminer.gui.new_plotter.gui.dialog.AddParallelLineDialog.java
/** * Updates the preselected y-value.// ww w.ja va 2s. c om */ private void updateYFieldValue() { // update preselected y value because range axis has been changed if (mousePosition != null) { Rectangle2D plotArea = engine.getChartPanel().getScreenDataArea(); if (engine.getChartPanel().getChart().getPlot() instanceof XYPlot) { XYPlot plot = (XYPlot) engine.getChartPanel().getChart().getPlot(); // calculate y value for (int i = 0; i < plot.getRangeAxisCount(); i++) { ValueAxis config = plot.getRangeAxis(i); if (config != null && config.getLabel() != null) { if (config.getLabel() .equals(String.valueOf(rangeAxisSelectionCombobox.getSelectedItem()))) { double chartY = config.java2DToValue(mousePosition.getY(), plotArea, plot.getRangeAxisEdge()); yField.setText(String.valueOf(chartY)); } } } } } }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
@Override public void getModelCoordinatesInfo(final int xOnScreen, final int yOnScreen, final IDisplaySurface g, final Point positionInPixels, final StringBuilder sb) { final int x = xOnScreen - positionInPixels.x; final int y = yOnScreen - positionInPixels.y; final ChartEntity entity = info.getEntityCollection().getEntity(x, y); // getChart().handleClick(x, y, info); if (entity instanceof XYItemEntity) { final XYDataset data = ((XYItemEntity) entity).getDataset(); final int index = ((XYItemEntity) entity).getItem(); final int series = ((XYItemEntity) entity).getSeriesIndex(); final double xx = data.getXValue(series, index); final double yy = data.getYValue(series, index); final XYPlot plot = (XYPlot) getJFChart().getPlot(); final ValueAxis xAxis = plot.getDomainAxis(series); final ValueAxis yAxis = plot.getRangeAxis(series); final boolean xInt = xx % 1 == 0; final boolean yInt = yy % 1 == 0; String xTitle = xAxis.getLabel(); if (StringUtils.isBlank(xTitle)) { xTitle = "X"; }//from w ww. j a v a2 s . c o m String yTitle = yAxis.getLabel(); if (StringUtils.isBlank(yTitle)) { yTitle = "Y"; } sb.append(xTitle).append(" ").append(xInt ? (int) xx : String.format("%.2f", xx)); sb.append(" | ").append(yTitle).append(" ").append(yInt ? (int) yy : String.format("%.2f", yy)); return; } else if (entity instanceof PieSectionEntity) { final String title = ((PieSectionEntity) entity).getSectionKey().toString(); final PieDataset data = ((PieSectionEntity) entity).getDataset(); final int index = ((PieSectionEntity) entity).getSectionIndex(); final double xx = data.getValue(index).doubleValue(); final boolean xInt = xx % 1 == 0; sb.append(title).append(" ").append(xInt ? (int) xx : String.format("%.2f", xx)); return; } else if (entity instanceof CategoryItemEntity) { final Comparable<?> columnKey = ((CategoryItemEntity) entity).getColumnKey(); final String title = columnKey.toString(); final CategoryDataset data = ((CategoryItemEntity) entity).getDataset(); final Comparable<?> rowKey = ((CategoryItemEntity) entity).getRowKey(); final double xx = data.getValue(rowKey, columnKey).doubleValue(); final boolean xInt = xx % 1 == 0; sb.append(title).append(" ").append(xInt ? (int) xx : String.format("%.2f", xx)); return; } }
From source file:org.bhavaya.ui.view.ChartView.java
private JFreeChart createScatterChart() { JFreeChart chart;//from w ww . j a v a2 s.com GroupedXYDataSet dataset = new GroupedXYDataSet(beanCollection); HashSet allLocators = new HashSet(); allLocators.addAll(configuration.getDomainAxisLocators()); allLocators.addAll(configuration.getRangeAxisLocators()); dataset.setColumnLocators(allLocators); chart = ChartFactory.createScatterPlot("", getDomainName(), getRangeName(), dataset, PlotOrientation.VERTICAL, true, true, false); Plot plot = chart.getPlot(); if (plot instanceof XYPlot && dataset.isXAxisDateAxis()) { ValueAxis axis = ((XYPlot) plot).getDomainAxis(); DateAxis dateAxis = new DateAxis(axis.getLabel()); /*dateAxis.setAutoRange(true); dateAxis.setAutoTickUnitSelection(true);*/ //dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy")); ((XYPlot) plot).setDomainAxis(dateAxis); } return chart; }
From source file:SciTK.Plot.java
/** * Set the logarithmic state of the range axis. * @param enabled true enables log mode, false disables */// w w w. j a v a 2 s .co m public void setRangeAxisLog(boolean enabled) { // get current limits of the axis: XYPlot p = chart.getXYPlot(); // get the domain axis for this plot: ValueAxis current = p.getRangeAxis(); // set new axis type based on enabled boolean: ValueAxis newAxis; if (enabled) newAxis = new LogAxis(current.getLabel()); else newAxis = new NumberAxis(current.getLabel()); // update axis: p.setRangeAxis(newAxis); }
From source file:SciTK.Plot.java
/** * Set the logarithmic state of the domain axis. * @param enabled true enables log mode, false disables *///from w w w . ja v a 2 s .c o m public void setDomainAxisLog(boolean enabled) { // get current limits of the axis: XYPlot p = chart.getXYPlot(); // get the domain axis for this plot: ValueAxis current = p.getDomainAxis(); // set new axis type based on enabled boolean: ValueAxis newAxis; if (enabled) newAxis = new LogAxis(current.getLabel()); else newAxis = new NumberAxis(current.getLabel()); // update axis: p.setDomainAxis(newAxis); }
From source file:org.squale.squaleweb.util.graph.ScatterMaker.java
/** * Construit (ou reconstruit) le diagramme puis le retourne * //w w w. j av a 2 s. c om * @return le diagramme JFreeChart. */ protected JFreeChart getChart() { LOG.debug(WebMessages.getString("method.entry")); JFreeChart retChart = super.getChart(); if (null == retChart) { // Gnration du Scatterplot retChart = ChartFactory.createScatterPlot(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL, mShowLegend, false, false); ValueAxis domainAxis = retChart.getXYPlot().getDomainAxis(); ValueAxis rangeAxis = retChart.getXYPlot().getRangeAxis(); // Dtermination des bornes en abscisse et en ordonne double maxDomain = Math.max(domainAxis.getUpperBound(), DEFAULT_VERTICAL_AXIS_POS + DEFAULT_AXIS_MARGIN); double minDomain = Math.min(domainAxis.getLowerBound(), DEFAULT_VERTICAL_AXIS_POS - DEFAULT_AXIS_MARGIN); double maxRange = Math.max(rangeAxis.getUpperBound(), DEFAULT_HORIZONTAL_AXIS_POS + DEFAULT_AXIS_MARGIN); double minRange = Math.min(rangeAxis.getLowerBound(), DEFAULT_HORIZONTAL_AXIS_POS - DEFAULT_AXIS_MARGIN); // Mise l'chelle logarithmique des axes LogarithmicAxis newDomainAxis = new LogarithmicAxis(domainAxis.getLabel()); LogarithmicAxis newRangeAxis = new LogarithmicAxis(rangeAxis.getLabel()); // Affectation des bornes en abscisse et en ordonne newDomainAxis.setLowerBound(minDomain); newDomainAxis.setUpperBound(maxDomain); newRangeAxis.setLowerBound(minRange); newRangeAxis.setUpperBound(maxRange); retChart.getXYPlot().setDomainAxis(newDomainAxis); retChart.getXYPlot().setRangeAxis(newRangeAxis); // Le point a une taille fixe Shape shape = new Rectangle(DEFAULT_POINT_SIZE, DEFAULT_POINT_SIZE); retChart.getXYPlot().getRenderer().setShape(shape); // Annotations XYLineAnnotation horizontalAxis = new XYLineAnnotation(minDomain, DEFAULT_HORIZONTAL_AXIS_POS, maxDomain, DEFAULT_HORIZONTAL_AXIS_POS); XYLineAnnotation verticalAxis = new XYLineAnnotation(DEFAULT_VERTICAL_AXIS_POS, minRange, DEFAULT_VERTICAL_AXIS_POS, maxRange); retChart.getXYPlot().addAnnotation(horizontalAxis); retChart.getXYPlot().addAnnotation(verticalAxis); super.setChart(retChart); } LOG.debug(WebMessages.getString("method.exit")); return retChart; }
From source file:org.squale.squaleweb.util.graph.BubbleMaker.java
/** * Factorisation du code commun la gnration du graphe * //from w w w . ja v a 2 s. co m * @return graphe de type Bubble */ private JFreeChart getCommonChart() { // Cration du graphe de type Bubble JFreeChart chart = ChartFactory.createBubbleChart(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL, mShowLegend, true, false); ValueAxis domainAxis = chart.getXYPlot().getDomainAxis(); ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis(); // Dtermination des bornes en abscisse et en ordonne double maxDomain = Math.max(domainAxis.getUpperBound(), DEFAULT_VERTICAL_AXIS_POS + DEFAULT_AXIS_MARGIN) + 1; double minDomain = 0; double maxRange = Math.max(rangeAxis.getUpperBound(), DEFAULT_HORIZONTAL_AXIS_POS + DEFAULT_AXIS_MARGIN) + 1; double minRange = 0; // Mise l'chelle logarithmique des axes LogarithmicAxis newDomainAxis = new LogarithmicAxis(domainAxis.getLabel()); LogarithmicAxis newRangeAxis = new LogarithmicAxis(rangeAxis.getLabel()); // Affectation des bornes en abscisse et en ordonne newDomainAxis.setLowerBound(minDomain); newDomainAxis.setUpperBound(maxDomain); newRangeAxis.setLowerBound(minRange); newRangeAxis.setUpperBound(maxRange); chart.getXYPlot().setDomainAxis(newDomainAxis); chart.getXYPlot().setRangeAxis(newRangeAxis); // Affichage de la rpartition des mthodes selon les critres displayRepartitionSubtitles(chart); // Annotations XYLineAnnotation horizontalAxis = new XYLineAnnotation(minDomain, DEFAULT_HORIZONTAL_AXIS_POS, maxDomain, DEFAULT_HORIZONTAL_AXIS_POS); XYLineAnnotation verticalAxis = new XYLineAnnotation(DEFAULT_VERTICAL_AXIS_POS, minRange, DEFAULT_VERTICAL_AXIS_POS, maxRange); chart.getXYPlot().addAnnotation(horizontalAxis); chart.getXYPlot().addAnnotation(verticalAxis); return chart; }