List of usage examples for org.jfree.chart.plot XYPlot setDomainAxis
public void setDomainAxis(ValueAxis axis)
From source file:com.ivli.roim.controls.VOILUTPanel.java
public VOILUTPanel(LUTControl aP) { iCurveName = java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("VOILUTPANEL.VOI_LUT"); iLUT = LUTControl.create(aP);//from www .j av a 2 s . c o m aP.addWindowChangeListener(this); initComponents(); XYPlot plot = new XYPlot(); plot.setDataset(0, makeLUTCurve()); plot.setRenderer(0, new XYSplineRenderer()); ((XYSplineRenderer) plot.getRenderer()).setShapesVisible(false); plot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_VOI_CURVE"))); XYSeriesCollection col2 = new XYSeriesCollection(); col2.addSeries(makeHistogram()); plot.setDataset(1, col2); plot.setRenderer(1, new XYBarRenderer()); plot.setRangeAxis(1, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_SPACE"))); plot.mapDatasetToRangeAxis(1, 1); plot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_HISTOGRAM"))); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // change the rendering order so the primary dataset appears "behind" the // other datasets... plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); JFreeChart jfc = new JFreeChart(plot); jfc.setBorderVisible(true); jfc.removeLegend(); iPanel = new ChartPanel(jfc); iPanel.setSize(jPanel1.getPreferredSize()); jPanel1.add(iPanel);//, java.awt.BorderLayout.CENTER); iLUT.setSize(jPanel2.getPreferredSize()); jPanel2.add(iLUT); iLabelMin.setText(String.format("%.0f", iLUT.getView().getMin())); iLabelMax.setText(String.format("%.0f", iLUT.getView().getMax())); validate(); }
From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java
private void showDetail(Graphs g) { XYPlot plot = detailChart.getXYPlot(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickLabelPaint(Color.GRAY); plot.setRangeAxis(yAxis);/*from w ww . ja va 2s . c om*/ NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelPaint(Color.GRAY); xAxis.setTickUnit(new NumberTickUnit(10)); xAxis.setRange(horizons.get(0), horizons.get(horizons.size() - 1)); xAxis.setVerticalTickLabels(true); plot.setDomainAxis(xAxis); plot.setDataset(TRUE_DATA_INDEX, new BasicXYDataset(Collections.singletonList(g.S1_))); plot.setDataset(FCTS_INDEX, new BasicXYDataset(Collections.singletonList(g.S2_))); plot.setDataset(ARIMA_DATA_INDEX, new BasicXYDataset(Collections.singletonList(g.S3_))); rescaleAxis((NumberAxis) plot.getRangeAxis()); detailChart.setTitle(g.label_); chartPanel.setChart(detailChart); chartPanel.setToolTipText("Right click to show complete data"); chartPanel.setPopupMenu(buildMenu().getPopupMenu()); onColorSchemeChanged(); selectedGraph = g; }
From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java
private void configureAxis(XYPlot plot, int start, int end) { int nb = graphs_.size(); List<String> names = new ArrayList<>(); for (int i = start; i <= end; i++) { names.add(periods.get(i).toString()); }/* w w w . j a v a2 s . co m*/ NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelPaint(Color.GRAY); xAxis.setTickUnit(new MyTickUnit(names)); xAxis.setRange(-0.5, nb - 0.5); xAxis.setVerticalTickLabels(true); plot.setDomainAxis(xAxis); plot.setDomainGridlinesVisible(false); NumberAxis yaxis = new NumberAxis(); rescaleAxis(yaxis); yaxis.configure(); plot.setRangeAxis(yaxis); for (int i = 0; i < nb; i++) { ValueMarker marker = new ValueMarker(i + 0.5); marker.setStroke(MARKER_STROKE); marker.setPaint(MARKER_PAINT); marker.setAlpha(MARKER_ALPHA); plot.addDomainMarker(marker); } }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * If the chart has not yet been initialized, creates a chart for XY data. * If the chart is already initialized, checks if the chart is for XY data. * //ww w . j a v a2 s. c o m * @throws FrameworkException if the chart does not support XY data */ private void createXYPlot() { if (chart == null) { NumberAxis xAxis = new NumberAxis(""); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator(); XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartFactory.getChartTheme().apply(chart); } else if (!(chart.getPlot() instanceof XYPlot)) { throw new FrameworkException("Can not combine XY plot and categorial plot"); } }
From source file:osh.comdriver.simulation.cruisecontrol.AbstractDrawer.java
/** * Creates a chart./*from ww w . j a v a2 s . c o m*/ * * @param dataset1 a dataset. * * @return A chart. */ private JFreeChart createChart(XYDataset dataset, long lastentry) { JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // title "time", // x-axis label "temperature", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis1 = new NumberAxis(getAxisName()); axis1.setAutoRangeIncludesZero(isIncludeZero()); plot.setRangeAxis(0, axis1); plot.setDataset(0, dataset); plot.mapDatasetToRangeAxis(1, 0); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); //TODO: SHADOWS OFF final StandardXYItemRenderer r1 = new StandardXYItemRenderer(); plot.setRenderer(0, r1); r1.setSeriesPaint(0, Color.BLUE); r1.setSeriesPaint(1, Color.RED); r1.setSeriesPaint(2, Color.GREEN); //plot.setDomainAxis(new NumberAxis("time")); plot.setDomainAxis(new DateAxis()); plot.getDomainAxis().setAutoRange(false); long begin = getRangeBegin(lastentry); long end = getRangeEnd(lastentry); plot.getDomainAxis().setRange(begin, end); return chart; }
From source file:pipeline.parameter_cell_views.FloatRangeSlider.java
@Override protected Component getRendererOrEditorComponent(JTable table0, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { if (currentParameter != null) { currentParameter.removeListener(this); }/*from www . j av a 2 s .com*/ currentParameter = (FloatRangeParameter) value; currentParameter.addGUIListener(this); table = table0; tableRow = row; evenTableRow = (row % 2 == 0); setOpaque(true); if (evenTableRow) { this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); } else this.setBackground(Utils.COLOR_FOR_ODD_ROWS); textValueFrame.setBackground(getBackground()); silenceUpdate = true; readInValuesFromParameter(); if (currentParameter.histogram == null) ;// currentParameter.histogram=new XYSeries(""); if (currentParameter.histogram instanceof XYSeries) { XYSeries xyData = (XYSeries) currentParameter.histogram; if (chart != null && chart.getXYPlot().getDataset() != null) { chart.getXYPlot().getDataset(0).removeChangeListener(chart.getXYPlot()); } chart = ChartFactory.createXYLineChart(null, // chart title null, // "Category", // domain axis label null, // "Value", // range axis label new XYSeriesCollection(xyData), // data PlotOrientation.VERTICAL, false, // include legend true, false); } else if (currentParameter.histogram != null) { // assume for now it's a histogram if (chart != null && chart.getXYPlot().getDataset() != null) { chart.getXYPlot().getDataset(0).removeChangeListener(chart.getXYPlot()); } String plotTitle = "Histogram"; String xaxis = "number"; String yaxis = "value"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; chart = ChartFactory.createHistogram(plotTitle, xaxis, yaxis, (IntervalXYDataset) currentParameter.histogram, orientation, show, toolTips, urls);// dataset } else { if (chart != null && chart.getXYPlot().getDataset() != null) { chart.getXYPlot().getDataset(0).removeChangeListener(chart.getXYPlot()); } chart = null; } if (currentParameter.histogram != null) { add(panelForHistogram, cForHistogram); final XYPlot plot = chart.getXYPlot(); final NumberAxis domainAxis = new NumberAxis(null); domainAxis.setAutoRange(false); domainAxis.setTickLabelFont(new Font("Times", 0, 20)); domainAxis.setLowerBound(minimum); domainAxis.setUpperBound(maximum); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = new NumberAxis(null); rangeAxis.setAutoRange(true); rangeAxis.setVisible(false); plot.setRangeAxis(rangeAxis); chart.setBackgroundPaint(Color.white); chart.setPadding(new RectangleInsets(0, 0, 0, 0)); plot.setBackgroundImage(null); plot.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); if (chartPanel == null) { chartPanel = new ChartPanel(chart); chartPanel.addMouseListener(this); chartPanel.addMouseMotionListener(this); chartPanel.setMouseWheelEnabled(true); chartPanel.setMouseZoomable(false); chartPanel.setRangeZoomable(false); panelForHistogram.add(chartPanel); } else chartPanel.setChart(chart); chartPanel.setSize(panelForHistogram.getSize()); ((XYPlot) chart.getPlot()).getRenderer().setSeriesStroke(0, new BasicStroke(5.0f)); selectionRange = new IntervalMarker(currentValue0, currentValue1); ((XYPlot) chart.getPlot()).addDomainMarker(selectionRange); } else { remove(panelForHistogram); setMaximumSize(new Dimension(700, 50)); setPreferredSize(new Dimension(700, 50)); } updateDisplays(); silenceUpdate = false; return this; }
From source file:org.tolven.web.ChartAction.java
/** * Create Growth Chart//from ww w .jav a 2s . c o m * * @author Suja * added on 02/01/2011 * @param type - 1: Height & 2: Weight * @return */ public JFreeChart createChart(int type) { long patientId = Long.parseLong(getRequestParameter("element").toString().split(":")[1].split("-")[1]); MenuData patMD = getMenuLocal().findMenuDataItem(patientId); int age = 0; int gender = 1; Date dob = null; if (patMD != null) { DateFormat df = new SimpleDateFormat("yyyy"); dob = patMD.getDate01(); Date cur = new Date(); age = Integer.parseInt(df.format(cur)) - Integer.parseInt(df.format(dob)); if (patMD.getString04().equals("Male")) gender = 1; else gender = 2; } // create dataset XYDataset dataset = createDataset(type, gender, age, dob); String title = ""; if (type == 1 && age < 3) title = "Height birth to 36 Months Old " + (gender == 1 ? "Male" : "Female"); else if (type == 1 && age >= 3) title = "Height 2-20 Year Old " + (gender == 1 ? "Male" : "Female"); else if (type == 2 && age < 3) title = "Weight birth to 36 Months Old " + (gender == 1 ? "Male" : "Female"); else if (type == 2 && age >= 3) title = "Weight 2-20 Year Old " + (gender == 1 ? "Male" : "Female"); JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title "X-Value", // x-axis label "Y-Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.lightGray); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 1; i < 10; i++) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); plot.setRenderer(renderer); plot.setDomainAxis(new NumberAxis("Age (Months)")); plot.setRangeAxis(new NumberAxis((type == 1 ? "Height (Centimeters)" : "Weight (Kilograms)"))); return chart; }
From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java
public JFreeChart createXYChart(String expId) { ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance(); long eid = Long.parseLong(expId); log.info("Building experiment chart for eid = " + eid); Experiment exp = edao.findExperiment(eid); final String expName = exp.getExperimentSetup().getBasicProperties().getExperimentName(); final XYSeries series = new XYSeries(expName); for (BatchExecutionRecordImpl batch : exp.getExperimentExecutable().getBatchExecutionRecords()) { int i = 1; for (ExecutionRecordImpl exr : batch.getRuns()) { //log.info("Found Record... "+exr+" stages: "+exr.getStages()); if (exr != null && exr.getStages() != null) { // Look up the object, so we can get the name. DigitalObjectRefBean dh = new DataHandlerImpl().get(exr.getDigitalObjectReferenceCopy()); String dobName = "Object " + i; if (dh != null) dobName = dh.getName(); for (ExecutionStageRecordImpl exsr : exr.getStages()) { Double time = exsr.getDoubleMeasurement(TecRegMockup.PROP_SERVICE_TIME); Double size = exsr.getDoubleMeasurement(TecRegMockup.PROP_DO_SIZE); // Look for timing: if (time != null && size != null && size.doubleValue() > 0.0 && time.doubleValue() > 0.0) { series.add(size, time); /* if( exsr.isMarkedAsSuccessful() ) { dataset.addValue( time, "Succeded", dobName); } else {/*from w w w. j a v a 2 s. c o m*/ dataset.addValue( time, "Failed", dobName); } */ } } } // Increment, for the next run. i++; } } // Create the chart. JFreeChart chart = ChartFactory.createScatterPlot(null, "Size [bytes]", "Time [s]", new XYSeriesCollection(series), PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis xAxis = new LogAxis("Size [bytes]"); // Set the base appropriately: xAxis.setBase(1024.0); // xAxis.setTickUnit( new NumberTickUnit(128.0) ); // xAxis.getTickUnit().getMinorTickCount(); // FIXME This should really be a KB/MB/etc number formatter... xAxis.setNumberFormatOverride(new LogFormat(1024.0, "1024", true)); // LogAxis yAxis = new LogAxis("Y"); // yAxis.setNumberFormatOverride(new LogFormat(10.0, "10", true)); plot.setDomainAxis(xAxis); // plot.setRangeAxis(yAxis); // Add some tool-tips plot.getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator()); return chart; }
From source file:SciTK.Plot.java
/** * Set the logarithmic state of the domain axis. * @param enabled true enables log mode, false disables *//* 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:com.rapidminer.gui.plotter.charts.BubbleChartPlotter.java
@Override public void updatePlotter() { final DataTable dataTable = getDataTable(); prepareData();// w w w .j a v a2s . co m JFreeChart chart = ChartFactory.createBubbleChart(null, // chart title null, // domain axis label null, // range axis label xyzDataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0 && axis[BUBBLE_SIZE_AXIS] >= 0) { if (nominal) { int size = xyzDataSet.getSeriesCount(); chart = ChartFactory.createBubbleChart(null, // chart title null, // domain axis label null, // range axis label xyzDataSet, // data PlotOrientation.VERTICAL, // orientation colorColumn >= 0 && size < 100 ? true : false, // include legend true, // tooltips false // URLs ); // renderer settings XYBubbleRenderer renderer = (XYBubbleRenderer) chart.getXYPlot().getRenderer(); renderer.setBaseOutlinePaint(Color.BLACK); if (size > 1) { for (int i = 0; i < size; i++) { renderer.setSeriesPaint(i, getColorProvider(true).getPointColor(i / (double) (size - 1))); renderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 7, 7)); } } else { renderer.setSeriesPaint(0, getColorProvider().getPointColor(1.0d)); renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 7, 7)); } // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } } else { chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label xyzDataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); // renderer settings ColorizedBubbleRenderer renderer = new ColorizedBubbleRenderer(this.colors); renderer.setBaseOutlinePaint(Color.BLACK); chart.getXYPlot().setRenderer(renderer); // legend settings chart.addLegend(new LegendTitle(renderer) { private static final long serialVersionUID = 1288380309936848376L; @Override public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params) { if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn) || dataTable.isDateTime(colorColumn)) { drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7), dataTable, colorColumn, minColor, maxColor); return new BlockResult(); } else { final String minColorString = Tools.formatNumber(minColor); final String maxColorString = Tools.formatNumber(maxColor); drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 90), (int) (area.getCenterY() + 7), dataTable.getColumnName(colorColumn), minColorString, maxColorString); return new BlockResult(); } } @Override public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) { draw(g2, area, null); } }); } } // GENERAL CHART SETTINGS // set the background colors for the chart... chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.getPlot().setForegroundAlpha(0.7f); XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis if (axis[X_AXIS] >= 0) { if (dataTable.isNominal(axis[X_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[X_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[X_AXIS], i); } plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(axis[X_AXIS]), values)); } else if (dataTable.isDate(axis[X_AXIS]) || dataTable.isDateTime(axis[X_AXIS])) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { if (logScales[X_AXIS]) { LogAxis domainAxis = new LogAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setDomainAxis(domainAxis); } else { plot.setDomainAxis(new NumberAxis(dataTable.getColumnName(axis[X_AXIS]))); } } Range range = getRangeForDimension(axis[X_AXIS]); if (range != null) { plot.getDomainAxis().setRange(range, true, false); } else { plot.getDomainAxis().setAutoRange(true); } } plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } // range axis if (axis[Y_AXIS] >= 0) { if (dataTable.isNominal(axis[Y_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[Y_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[Y_AXIS], i); } plot.setRangeAxis(new SymbolAxis(dataTable.getColumnName(axis[Y_AXIS]), values)); } else if (dataTable.isDate(axis[Y_AXIS]) || dataTable.isDateTime(axis[Y_AXIS])) { DateAxis rangeAxis = new DateAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setRangeAxis(rangeAxis); } else { plot.setRangeAxis(new NumberAxis(dataTable.getColumnName(axis[Y_AXIS]))); } Range range = getRangeForDimension(axis[Y_AXIS]); if (range != null) { plot.getRangeAxis().setRange(range, true, false); } else { plot.getRangeAxis().setAutoRange(true); } } plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); AbstractChartPanel panel = getPlotterPanel(); // Chart Panel Settings if (panel == null) { panel = createPanel(chart); } else { panel.setChart(chart); } // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!! panel.getChartRenderingInfo().setEntityCollection(null); }