List of usage examples for org.jfree.chart ChartPanel DEFAULT_WIDTH
int DEFAULT_WIDTH
To view the source code for org.jfree.chart ChartPanel DEFAULT_WIDTH.
Click Source Link
From source file:org.cytoscape.dyn.internal.graphMetrics.SaveChartDialog.java
public SaveChartDialog(JFrame frame, JFreeChart chart) { super(frame, "Save Chart to File", false); this.chart = chart; JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4)); sizePanel.setBorder(BorderFactory.createTitledBorder("Image Size")); // Add a spinner for choosing width sizePanel.add(new JLabel("Width:", SwingConstants.RIGHT)); int width = ChartPanel.DEFAULT_WIDTH; int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH; int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH; SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1); sizePanel.add(widthSpinner = new JSpinner(widthSettings)); sizePanel.add(new JLabel("pixels")); // Add a spinner for choosing height sizePanel.add(new JLabel("Height:", SwingConstants.RIGHT)); int height = ChartPanel.DEFAULT_HEIGHT; int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT; int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT; SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1); sizePanel.add(heightSpinner = new JSpinner(heightSettings)); sizePanel.add(new JLabel("pixels")); JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 4, 0)); saveChartButton = new JButton("Save"); saveChartButton.setMaximumSize(new Dimension(Short.MAX_VALUE, saveChartButton.getHeight())); saveChartButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.setMaximumSize(new Dimension(Short.MAX_VALUE, cancelButton.getHeight())); cancelButton.addActionListener(this); buttonsPanel.add(saveChartButton);/*from w w w . j ava 2 s . co m*/ buttonsPanel.add(cancelButton); Box buttonsBox = Box.createHorizontalBox(); buttonsBox.add(Box.createHorizontalGlue()); buttonsBox.add(buttonsPanel); buttonsBox.add(Box.createHorizontalGlue()); Container contentPane = getContentPane(); contentPane.add(sizePanel, BorderLayout.NORTH); contentPane.add(Box.createVerticalStrut(3)); contentPane.add(buttonsBox, BorderLayout.PAGE_END); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getRootPane().setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); pack(); setModal(true); setResizable(false); setLocationRelativeTo(frame); }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.PopulationFitnessView.java
PopulationFitnessView(boolean islands) { super(new BorderLayout()); meanSeries = new XYSeries(islands ? "Global Mean Fitness" : "Population Mean Fitness"); dataSet.addSeries(bestSeries);//from w ww .j a va2 s . co m dataSet.addSeries(meanSeries); chart = ChartFactory.createXYLineChart(islands ? "Global Population Fitness" : "Population Fitness", islands ? "Epochs" : "Generations", "Fitness", dataSet, PlotOrientation.VERTICAL, true, // Legend. false, // Tooltips. false); this.domainAxis = chart.getXYPlot().getDomainAxis(); this.rangeAxis = chart.getXYPlot().getRangeAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setLowerMargin(0); domainAxis.setUpperMargin(0.05); domainAxis.setRangeWithMargins(0, SHOW_FIXED_GENERATIONS); rangeAxis.setRange(minY, maxY); ChartPanel chartPanel = new ChartPanel(chart, ChartPanel.DEFAULT_WIDTH, ChartPanel.DEFAULT_HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, false, // Buffered false, // Properties true, // Save true, // Print false, // Zoom false); // Tooltips add(chartPanel, BorderLayout.CENTER); add(createControls(islands), BorderLayout.SOUTH); }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.IslandsView.java
IslandsView() { super(new BorderLayout()); chart = ChartFactory.createBarChart("Island Population Fitness", "Island No.", "Candidate Fitness", bestDataSet, PlotOrientation.VERTICAL, true, // Legend false, // Tooltips false); // URLs CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.02); plot.getDomainAxis().setUpperMargin(0.02); ((BarRenderer) plot.getRenderer()).setShadowVisible(false); plot.getRangeAxis().setAutoRange(false); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); meanRenderer.setBaseLinesVisible(false); ChartPanel chartPanel = new ChartPanel(chart, ChartPanel.DEFAULT_WIDTH, ChartPanel.DEFAULT_HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, false, // Buffered false, // Properties true, // Save true, // Print false, // Zoom false); // Tooltips add(chartPanel, BorderLayout.CENTER); add(createControls(), BorderLayout.SOUTH); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.SaveChartDialog.java
/** * Creates and lays out the controls inside this dialog's content pane. * <p>//from ww w. j av a 2s . co m * This method is called upon initialization only. * </p> */ private void initControls() { JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4)); sizePanel.setBorder(BorderFactory.createTitledBorder(Messages.DI_IMAGESIZE)); // Add a spinner for choosing width sizePanel.add(new JLabel(Messages.DI_WIDTH, SwingConstants.RIGHT)); int width = ChartPanel.DEFAULT_WIDTH; int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH; int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH; SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1); sizePanel.add(widthSpinner = new JSpinner(widthSettings)); sizePanel.add(new JLabel(Messages.DI_PIXELS)); // Add a spinner for choosing height sizePanel.add(new JLabel(Messages.DI_HEIGHT, SwingConstants.RIGHT)); int height = ChartPanel.DEFAULT_HEIGHT; int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT; int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT; SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1); sizePanel.add(heightSpinner = new JSpinner(heightSettings)); sizePanel.add(new JLabel(Messages.DI_PIXELS)); // Add Save and Cancel buttons JPanel buttons = new JPanel(new GridLayout(1, 2, 4, 0)); buttons.add(btnSave = Utils.createButton(Messages.DI_SAVE, null, this)); buttons.add(btnCancel = Utils.createButton(Messages.DI_CANCEL, null, this)); Box buttonsBox = Box.createHorizontalBox(); buttonsBox.add(Box.createHorizontalGlue()); buttonsBox.add(buttons); buttonsBox.add(Box.createHorizontalGlue()); Container contentPane = getContentPane(); contentPane.add(sizePanel, BorderLayout.NORTH); contentPane.add(Box.createVerticalStrut(Utils.BORDER_SIZE / 2)); contentPane.add(buttonsBox, BorderLayout.PAGE_END); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Utils.setStandardBorder(getRootPane()); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.dec.LeastSquaresLineDecorator.java
/** * Creates a collection of points lying on the line determined by the computed coefficients. * /*from www .ja va2 s.c om*/ * @param aPoints Data points to which the line was fitted. They are used to determine the range * in which the newly created data series will lie. * @param aIsLinear Flag indicating if the points will be drawn on a plot with linear axes only. * If this parameter is <code>true</code>, this method creates only two points. * @return Newly created collection of points that lie on the line determined by the * coefficients in {@link #coefs}. */ private XYSeries createFittingData(Point2D.Double[] aPoints, boolean aIsLinear) { XYSeries series = new XYSeries(LeastSquaresLineDecorator.seriesName, false, false); final Point2D.Double min = new Point2D.Double(); final Point2D.Double max = new Point2D.Double(); ArrayUtils.minMax(aPoints, min, max); final double xmin = min.x; final double xmax = max.x; final double ymin = min.y; final double ymax = max.y; final int resolution = ChartPanel.DEFAULT_WIDTH; final double step = (xmax - xmin) / resolution; if (aIsLinear) { double x = xmin; double y = valueAt(x); if (y < ymin) { y = valueAt(x = pointAt(ymin)); } else if (ymax < y) { y = valueAt(x = pointAt(ymax)); } series.add(x, y); x = xmax; y = valueAt(x); if (y < ymin) { y = valueAt(x = pointAt(ymin)); } else if (ymax < y) { y = valueAt(x = pointAt(ymax)); } series.add(x, y); } else { double x = xmin; for (int i = 0; i < resolution; ++i) { final double y = valueAt(x); if (ymin <= y && y <= ymax) { series.add(x, y); } x += step; } final double y = valueAt(xmax); if (ymin <= y && y <= ymax) { series.add(xmax, y); } } return series; }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.dec.LeastSquaresPowerLawDecorator.java
/** * Creates a collection of points that adhere to the power law with the computed coefficients. * //from ww w.ja va 2 s .co m * @param aPoints Data points to which the power law was fitted. They are used to determine the * range in which the newly created data series will lie. * @param aIsLogLog Flag indicating if the points will be drawn on a log-log plot. If this * parameter is <code>true</code>, this method creates only two points. * @return Newly created collection of points that follow the power law with coefficients in * {@link #coefs}. */ protected XYSeries createFittingData(Point2D.Double[] aPoints, boolean aIsLogLog) { XYSeries series = new XYSeries(seriesName, false, false); final Point2D.Double min = new Point2D.Double(); final Point2D.Double max = new Point2D.Double(); ArrayUtils.minMax(aPoints, min, max); final double xmin = min.x; final double xmax = max.x; final double ymin = min.y; final double ymax = max.y; if (xmin != 0) { final int resolution = ChartPanel.DEFAULT_WIDTH; final double step = (xmax - xmin) / resolution; if (aIsLogLog) { double x = xmin; double y = valueAt(x); if (y < ymin) { y = valueAt(x = pointAt(ymin)); } else if (ymax < y) { y = valueAt(x = pointAt(ymax)); } series.add(x, y); x = xmax; y = valueAt(x); if (y < ymin) { y = valueAt(x = pointAt(ymin)); } else if (ymax < y) { y = valueAt(x = pointAt(ymax)); } series.add(x, y); } else { double x = xmin; for (int i = 0; i < resolution; ++i) { final double y = valueAt(x); if (ymin <= y && y <= ymax) { series.add(x, y); } x += step; } final double y = valueAt(xmax); if (ymin <= y && y <= ymax) { series.add(xmax, y); } } } return series; }