Java Code Examples for org.jfree.chart.axis.NumberAxis#setAutoRange()

The following examples show how to use org.jfree.chart.axis.NumberAxis#setAutoRange() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatisticChartStyling.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
static ValueAxis updateScalingOfAxis(boolean logScaled, ValueAxis oldAxis, final boolean autoRangeIncludesZero) {
    ValueAxis newAxis = oldAxis;
    if (logScaled) {
        if (!(oldAxis instanceof CustomLogarithmicAxis)) {
            final CustomLogarithmicAxis logarithmicAxis = createLogarithmicAxis(oldAxis.getLabel());
            logarithmicAxis.setAutoRange(oldAxis.isAutoRange());
            newAxis = logarithmicAxis;
        }
    } else {
        if (oldAxis instanceof CustomLogarithmicAxis) {
            final NumberAxis numberAxis = createNumberAxis(oldAxis.getLabel(), autoRangeIncludesZero);
            numberAxis.setAutoRange(oldAxis.isAutoRange());
            newAxis = numberAxis;
        }
    }
    newAxis.setLabelFont(oldAxis.getLabelFont());
    newAxis.setLabelPaint(oldAxis.getLabelPaint());
    newAxis.setTickLabelFont(oldAxis.getTickLabelFont());
    newAxis.setTickLabelPaint(oldAxis.getTickLabelPaint());
    return newAxis;
}
 
Example 2
Source File: SWTNumberAxisEditor.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match 
 * the properties defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (!this.autoRange) {
        numberAxis.setRange(this.minimumValue, this.maximumValue);
    }
}
 
Example 3
Source File: SingleTimestepRegressionExample.java    From dl4j-tutorials with MIT License 5 votes vote down vote up
/**
 * Generate an xy plot of the datasets provided.
 */
private static void plotDataset(XYSeriesCollection c) {

    String title = "Regression example";
    String xAxisLabel = "Timestep";
    String yAxisLabel = "Number of passengers";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean legend = true;
    boolean tooltips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, c, orientation, legend, tooltips, urls);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Auto zoom to fit time series in initial window
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);

    JPanel panel = new ChartPanel(chart);

    JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setTitle("Training Data");

    RefineryUtilities.centerFrameOnScreen(f);
    f.setVisible(true);
}
 
Example 4
Source File: MultiTimestepRegressionExample.java    From dl4j-tutorials with MIT License 5 votes vote down vote up
/**
 * Generate an xy plot of the datasets provided.
 */
private static void plotDataset(XYSeriesCollection c) {

    String title = "Regression example";
    String xAxisLabel = "Timestep";
    String yAxisLabel = "Number of passengers";
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean legend = true;
    boolean tooltips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, c, orientation, legend, tooltips, urls);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Auto zoom to fit time series in initial window
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);

    JPanel panel = new ChartPanel(chart);

    JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setTitle("Training Data");

    RefineryUtilities.centerFrameOnScreen(f);
    f.setVisible(true);
}
 
Example 5
Source File: DefaultNumberAxisEditor.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (!this.autoRange) {
        numberAxis.setRange(this.minimumValue, this.maximumValue);
    }
}
 
Example 6
Source File: SWTNumberAxisEditor.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match 
 * the properties defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (!this.autoRange) {
        numberAxis.setRange(this.minimumValue, this.maximumValue);
    }
}
 
Example 7
Source File: SWTNumberAxisEditor.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match 
 * the properties defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (! this.autoRange)
        numberAxis.setRange(this.minimumValue, this.maximumValue);
}
 
Example 8
Source File: DefaultNumberAxisEditor.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (!this.autoRange) {
        numberAxis.setRange(this.minimumValue, this.maximumValue);
    }
}
 
Example 9
Source File: TimeSeriesGraphModel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private NumberAxis createValueAxis(String aliasName) {
    String unit = getUnit(displayAxisMapping, aliasName);
    String axisLabel = getAxisLabel(aliasName, unit);
    NumberAxis valueAxis = new NumberAxis(axisLabel);
    valueAxis.setAutoRange(true);
    return valueAxis;
}
 
Example 10
Source File: SWTNumberAxisEditor.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match 
 * the properties defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (!this.autoRange) {
        numberAxis.setRange(this.minimumValue, this.maximumValue);
    }
}
 
Example 11
Source File: SWTNumberAxisEditor.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match
 * the properties defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (! this.autoRange)
        numberAxis.setRange(this.minimumValue, this.maximumValue);
}
 
Example 12
Source File: SWTChartEditor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match the properties defined on this panel.
 *
 * @param axis
 *            the axis.
 */
@Override
public void setAxisProperties(final Axis axis) {
	super.setAxisProperties(axis);
	final NumberAxis numberAxis = (NumberAxis) axis;
	numberAxis.setAutoRange(this.autoRange);
	if (!this.autoRange) {
		numberAxis.setRange(this.minimumValue, this.maximumValue);
	}
}
 
Example 13
Source File: AWSDeviceFarmGraph.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Create graph based on the given dataset and constraints.
 *
 * @return The JFreeChart graph.
 */
protected JFreeChart createGraph() {
    // Create chart.
    JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.WHITE);

    // Create chart legend.
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    // Create chart plot.
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.7f);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.darkGray);

    // Create domain (x) axis.
    CategoryAxis domain = new ShiftedCategoryAxis(xLabel);
    domain.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setCategoryMargin(0.0);
    plot.setDomainAxis(domain);

    // Create range (y) axis.
    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setAutoRange(true);
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // Create renderer and paint the chart.
    CategoryItemRenderer renderer = plot.getRenderer();
    plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));

    // Set chart colors for sections.
    for (int i = 0; i < colors.length; i++) {
        renderer.setSeriesPaint(i, colors[i]);
    }
    return chart;
}
 
Example 14
Source File: SWTNumberAxisEditor.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the properties of the specified axis to match 
 * the properties defined on this panel.
 *
 * @param axis  the axis.
 */
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    numberAxis.setAutoRange(this.autoRange);
    if (!this.autoRange) {
        numberAxis.setRange(this.minimumValue, this.maximumValue);
    }
}
 
Example 15
Source File: ChartJFreeChartOutputHistogram.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void resetAxes(final IScope scope) {
	final CategoryPlot pp = (CategoryPlot) this.chart.getPlot();
	NumberAxis rangeAxis = (NumberAxis) ((CategoryPlot) this.chart.getPlot()).getRangeAxis();
	if (getY_LogScale(scope)) {
		final LogarithmicAxis logAxis = new LogarithmicAxis(rangeAxis.getLabel());
		logAxis.setAllowNegativesFlag(true);
		((CategoryPlot) this.chart.getPlot()).setRangeAxis(logAxis);
		rangeAxis = logAxis;
	}

	if (!useyrangeinterval && !useyrangeminmax) {
		rangeAxis.setAutoRange(true);
	}

	if (this.useyrangeinterval) {
		rangeAxis.setFixedAutoRange(yrangeinterval);
		rangeAxis.setAutoRangeMinimumSize(yrangeinterval);
		rangeAxis.setAutoRange(true);

	}
	if (this.useyrangeminmax) {
		rangeAxis.setRange(yrangemin, yrangemax);

	}

	resetDomainAxis(scope);

	final CategoryAxis domainAxis = ((CategoryPlot) this.chart.getPlot()).getDomainAxis();

	pp.setDomainGridlinePaint(axesColor);
	pp.setRangeGridlinePaint(axesColor);
	pp.setRangeCrosshairVisible(true);

	pp.getRangeAxis().setAxisLinePaint(axesColor);
	pp.getRangeAxis().setLabelFont(getLabelFont());
	pp.getRangeAxis().setTickLabelFont(getTickFont());
	if (textColor != null) {
		pp.getRangeAxis().setLabelPaint(textColor);
		pp.getRangeAxis().setTickLabelPaint(textColor);
	}
	if (getYTickUnit(scope) > 0) {
		((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(getYTickUnit(scope)));
	}

	if (getYLabel(scope) != null && !getYLabel(scope).isEmpty()) {
		pp.getRangeAxis().setLabel(getYLabel(scope));
	}
	if (this.series_label_position.equals("yaxis")) {
		pp.getRangeAxis().setLabel(this.getChartdataset().getDataSeriesIds(scope).iterator().next());
		chart.getLegend().setVisible(false);
	}

	if (getXLabel(scope) != null && !getXLabel(scope).isEmpty()) {
		pp.getDomainAxis().setLabel(getXLabel(scope));
	}

	if (this.useSubAxis) {
		for (final String serieid : chartdataset.getDataSeriesIds(scope)) {
			((SubCategoryAxis) domainAxis).addSubCategory(serieid);
		}

	}
	if (!this.getYTickLineVisible(scope)) {
		pp.setDomainGridlinesVisible(false);
	}

	if (!this.getYTickLineVisible(scope)) {
		pp.setRangeCrosshairVisible(false);

	}

	if (!this.getYTickValueVisible(scope)) {
		pp.getRangeAxis().setTickMarksVisible(false);
		pp.getRangeAxis().setTickLabelsVisible(false);

	}

}
 
Example 16
Source File: ChartJFreeChartOutputHeatmap.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void resetSerie(final IScope scope, final String serieid) {
	// TODO Auto-generated method stub
	this.createNewSerie(scope, serieid);
	final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, serieid);
	final MatrixSeries serie =
			((MatrixSeriesCollection) jfreedataset.get(IdPosition.get(dataserie.getSerieId(scope)))).getSeries(0);
	final ArrayList<Double> XValues = dataserie.getXValues(scope);
	final ArrayList<Double> YValues = dataserie.getYValues(scope);
	final ArrayList<Double> SValues = dataserie.getSValues(scope);
	final NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
	if (XValues.size() == 0) {
		if (!usexrangeinterval && !usexrangeminmax) {
			domainAxis.setAutoRange(false);
			domainAxis.setRange(-0.5, XValues.size() + 0.5);
		}

	}
	final NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis();
	if (YValues.size() == 0) {
		if (!useyrangeinterval && !useyrangeminmax) {
			rangeAxis.setAutoRange(false);
			rangeAxis.setRange(-0.5, YValues.size() + 0.5);
		}

	}
	// final NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
	// final NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis();

	if (XValues.size() > 0) {
		domainAxis.setAutoRange(false);
		rangeAxis.setAutoRange(false);
		domainAxis.setTickLabelsVisible(this.getXTickValueVisible(scope));
		domainAxis.setTickMarksVisible(this.getXTickValueVisible(scope));
		rangeAxis.setTickLabelsVisible(this.getYTickValueVisible(scope));
		rangeAxis.setTickMarksVisible(this.getYTickValueVisible(scope));
		for (int i = 0; i < XValues.size(); i++) {

			if (XValues.get(i) > domainAxis.getUpperBound()) {
				if (!usexrangeinterval && !usexrangeminmax) {
					domainAxis.setAutoRange(false);
					domainAxis.setRange(-0.5, YValues.get(i) + 0.5);
				}

			}
			if (YValues.get(i) > rangeAxis.getUpperBound()) {
				if (!useyrangeinterval && !useyrangeminmax) {
					rangeAxis.setAutoRange(false);
					rangeAxis.setRange(-0.5, YValues.get(i) + 0.5);
				}

			}

			serie.update(YValues.get(i).intValue(), XValues.get(i).intValue(), SValues.get(i).doubleValue());
		}
	}
	this.resetRenderer(scope, serieid);

}
 
Example 17
Source File: ChartJFreeChartOutputScatter.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings ("unchecked")
@Override
protected void resetSerie(final IScope scope, final String serieid) {
	// TODO Auto-generated method stub

	final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, serieid);
	final XYIntervalSeries serie =
			((XYIntervalSeriesCollection) jfreedataset.get(IdPosition.get(dataserie.getSerieId(scope))))
					.getSeries(0);
	serie.clear();
	final ArrayList<Double> XValues = dataserie.getXValues(scope);
	final ArrayList<Double> YValues = dataserie.getYValues(scope);
	final ArrayList<Double> SValues = dataserie.getSValues(scope);
	boolean secondaxis = false;
	if (dataserie.getMysource().getUseSecondYAxis(scope)) {
		secondaxis = true;
		this.setUseSecondYAxis(scope, true);

	}

	if (XValues.size() > 0) {
		final NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis();
		final NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(0);
		final int ids = IdPosition.get(dataserie.getSerieId(scope));
		if (secondaxis) {
			// rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1);
			// ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis);
			// ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis);
			((XYPlot) this.chart.getPlot()).mapDatasetToRangeAxis(ids, 1);
		} else {
			// ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis);
			((XYPlot) this.chart.getPlot()).mapDatasetToRangeAxis(ids, 0);

		}
		domainAxis.setAutoRange(false);
		rangeAxis.setAutoRange(false);
		// domainAxis.setRange(Math.min((double)(Collections.min(XValues)),0),
		// Math.max(Collections.max(XValues),Collections.min(XValues)+1));
		// rangeAxis.setRange(Math.min((double)(Collections.min(YValues)),0),
		// Math.max(Collections.max(YValues),Collections.min(YValues)+1));
		XYIntervalDataItem newval;
		for (int i = 0; i < XValues.size(); i++) {
			if (dataserie.isUseYErrValues()) {
				if (dataserie.isUseXErrValues()) {
					newval = new XYIntervalDataItem(XValues.get(i), dataserie.xerrvaluesmin.get(i),
							dataserie.xerrvaluesmax.get(i), YValues.get(i), dataserie.yerrvaluesmin.get(i),
							dataserie.yerrvaluesmax.get(i));
					// serie.add(XValues.get(i),dataserie.xerrvaluesmin.get(i),dataserie.xerrvaluesmax.get(i),YValues.get(i),dataserie.yerrvaluesmin.get(i),dataserie.yerrvaluesmax.get(i));
				} else {
					newval = new XYIntervalDataItem(XValues.get(i), XValues.get(i), XValues.get(i), YValues.get(i),
							dataserie.yerrvaluesmin.get(i), dataserie.yerrvaluesmax.get(i));
					// serie.add(XValues.get(i),XValues.get(i),XValues.get(i),YValues.get(i),dataserie.yerrvaluesmin.get(i),dataserie.yerrvaluesmax.get(i));
				}

			} else {
				if (dataserie.isUseXErrValues()) {
					newval = new XYIntervalDataItem(XValues.get(i), dataserie.xerrvaluesmin.get(i),
							dataserie.xerrvaluesmax.get(i), YValues.get(i), YValues.get(i), YValues.get(i));
					// serie.add(XValues.get(i),dataserie.xerrvaluesmin.get(i),dataserie.xerrvaluesmax.get(i),YValues.get(i),YValues.get(i),YValues.get(i));
				} else {
					newval = new XYIntervalDataItem(XValues.get(i), XValues.get(i), XValues.get(i), YValues.get(i),
							YValues.get(i), YValues.get(i));
					// serie.add(XValues.get(i),XValues.get(i),XValues.get(i),YValues.get(i),YValues.get(i),YValues.get(i));
				}

			}
			serie.add(newval, false);
		}
		// domainAxis.setAutoRange(true);
		// rangeAxis.setAutoRange(true);
	}
	// resetAutorange(scope);
	if (SValues.size() > 0) {
		MarkerScale.remove(serieid);
		final ArrayList<Double> nscale = (ArrayList<Double>) SValues.clone();
		MarkerScale.put(serieid, nscale);

	}

	this.resetRenderer(scope, serieid);

}
 
Example 18
Source File: HistogramChart.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public HistogramChart() {
  super(null, true);

  // initialize the chart by default time series chart from factory
  chart = ChartFactory.createHistogram("", // title
      "", // x-axis label
      "", // y-axis label
      null, // data set
      PlotOrientation.VERTICAL, // orientation
      true, // create legend
      false, // generate tooltips
      false // generate URLs
  );

  // title
  chartTitle = chart.getTitle();
  chartTitle.setFont(titleFont);
  chartTitle.setMargin(5, 0, 0, 0);

  chartSubTitle = new TextTitle();
  chartSubTitle.setFont(subTitleFont);
  chartSubTitle.setMargin(5, 0, 0, 0);
  chart.addSubtitle(chartSubTitle);

  // legend constructed by ChartFactory
  LegendTitle legend = chart.getLegend();
  legend.setItemFont(legendFont);
  legend.setFrame(BlockBorder.NONE);

  chart.setBackgroundPaint(Color.white);
  setChart(chart);

  // disable maximum size (we don't want scaling)
  setMaximumDrawWidth(Integer.MAX_VALUE);
  setMaximumDrawHeight(Integer.MAX_VALUE);

  // set the plot properties
  plot = chart.getXYPlot();
  plot.setBackgroundPaint(Color.white);
  plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
  plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
  plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

  // set grid properties
  plot.setDomainGridlinePaint(gridColor);
  plot.setRangeGridlinePaint(gridColor);

  // set crosshair (selection) properties
  plot.setDomainCrosshairVisible(false);
  plot.setRangeCrosshairVisible(true);

  // set the logarithmic axis
  NumberAxis axisDomain = new HistogramDomainAxis();
  axisDomain.setMinorTickCount(1);
  axisDomain.setAutoRange(true);

  NumberAxis axisRange = new NumberAxis();
  axisRange.setMinorTickCount(1);
  axisRange.setAutoRange(true);

  plot.setDomainAxis(axisDomain);
  plot.setRangeAxis(axisRange);

  ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
  renderer.setMargin(marginSize);
  renderer.setShadowVisible(false);
  plot.setRenderer(renderer);

  this.setMinimumSize(new Dimension(400, 400));
  this.setDismissDelay(Integer.MAX_VALUE);
  this.setInitialDelay(0);


  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 19
Source File: SimpleScatter.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public JFreeChart createChart(DatasetMap datasets) {

		DefaultXYDataset dataset=(DefaultXYDataset)datasets.getDatasets().get("1");

		JFreeChart chart = ChartFactory.createScatterPlot(
				name, yLabel, xLabel, dataset, 
				PlotOrientation.HORIZONTAL, false, true, false);

		Font font = new Font("Tahoma", Font.BOLD, titleDimension);
		//TextTitle title = new TextTitle(name, font);
		TextTitle title =setStyleTitle(name, styleTitle);
		chart.setTitle(title);
		chart.setBackgroundPaint(Color.white);
		if(subName!= null && !subName.equals("")){
			TextTitle subTitle =setStyleTitle(subName, styleSubTitle);
			chart.addSubtitle(subTitle);
		}
		
		XYPlot plot = (XYPlot) chart.getPlot();
		plot.setForegroundAlpha(0.65f);

		XYItemRenderer renderer = plot.getRenderer();


		int seriesN=dataset.getSeriesCount();
		if(colorMap!=null){
			for (int i = 0; i < seriesN; i++) {
				String serieName=(String)dataset.getSeriesKey(i);
				Color color=(Color)colorMap.get(serieName);
				if(color!=null){
					renderer.setSeriesPaint(i, color);
				}	
			}
		}

		// increase the margins to account for the fact that the auto-range 
		// doesn't take into account the bubble size...
		NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
		domainAxis.setAutoRange(true);
		domainAxis.setRange(yMin, yMax);
		NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
		rangeAxis.setAutoRange(true);
		rangeAxis.setRange(xMin,xMax);
		
		if(legend==true){
			drawLegend(chart);
		}
		return chart;
	}
 
Example 20
Source File: HistogramChart.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public HistogramChart() {
  super(ChartFactory.createHistogram("", // title
      "", // x-axis label
      "", // y-axis label
      null, // data set
      PlotOrientation.VERTICAL, // orientation
      true, // create legend
      false, // generate tooltips
      false // generate URLs
  ));

  // initialize the chart by default time series chart from factory
  chart = getChart();

  // title
  chartTitle = chart.getTitle();
  chartTitle.setFont(titleFont);
  chartTitle.setMargin(5, 0, 0, 0);

  chartSubTitle = new TextTitle();
  chartSubTitle.setFont(subTitleFont);
  chartSubTitle.setMargin(5, 0, 0, 0);
  chart.addSubtitle(chartSubTitle);

  // legend constructed by ChartFactory
  LegendTitle legend = chart.getLegend();
  legend.setItemFont(legendFont);
  legend.setFrame(BlockBorder.NONE);

  chart.setBackgroundPaint(Color.white);

  // disable maximum size (we don't want scaling)
  // setMaximumDrawWidth(Integer.MAX_VALUE);
  // setMaximumDrawHeight(Integer.MAX_VALUE);

  // set the plot properties
  plot = chart.getXYPlot();
  plot.setBackgroundPaint(Color.white);
  plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
  plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
  plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

  // set grid properties
  plot.setDomainGridlinePaint(gridColor);
  plot.setRangeGridlinePaint(gridColor);

  // set crosshair (selection) properties
  plot.setDomainCrosshairVisible(false);
  plot.setRangeCrosshairVisible(true);

  // set the logarithmic axis
  NumberAxis axisDomain = new HistogramDomainAxis();
  axisDomain.setMinorTickCount(1);
  axisDomain.setAutoRange(true);

  NumberAxis axisRange = new NumberAxis();
  axisRange.setMinorTickCount(1);
  axisRange.setAutoRange(true);

  plot.setDomainAxis(axisDomain);
  plot.setRangeAxis(axisRange);

  ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
  renderer.setMargin(marginSize);
  renderer.setShadowVisible(false);
  plot.setRenderer(renderer);

  // this.setMinimumSize(new Dimension(400, 400));
  // this.setDismissDelay(Integer.MAX_VALUE);
  // this.setInitialDelay(0);

  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}