Example usage for org.jfree.chart.plot PlotOrientation VERTICAL

List of usage examples for org.jfree.chart.plot PlotOrientation VERTICAL

Introduction

In this page you can find the example usage for org.jfree.chart.plot PlotOrientation VERTICAL.

Prototype

PlotOrientation VERTICAL

To view the source code for org.jfree.chart.plot PlotOrientation VERTICAL.

Click Source Link

Document

For a plot where the range axis is vertical.

Usage

From source file:lu.lippmann.cdb.lab.mds.MDSViewBuilder.java

/**
 * /*from w ww  .j  av a 2  s .  c  o m*/
 */
public static JXPanel buildMDSViewFromDataSet(final Instances instances, final MDSResult mdsResult,
        final int maxInstances, final Listener<Instances> listener, final String... attrNameToUseAsPointTitle)
        throws Exception {

    final XYSeriesCollection dataset = new XYSeriesCollection();

    final JFreeChart chart = ChartFactory.createScatterPlot("", // title 
            "X", "Y", // axis labels 
            dataset, // dataset 
            PlotOrientation.VERTICAL, attrNameToUseAsPointTitle.length == 0, // legend? 
            true, // tooltips? yes 
            false // URLs? no 
    );

    final XYPlot xyPlot = (XYPlot) chart.getPlot();

    xyPlot.setBackgroundPaint(Color.WHITE);
    xyPlot.getDomainAxis().setTickLabelsVisible(false);
    xyPlot.getRangeAxis().setTickLabelsVisible(false);

    //FIXME : should be different for Shih
    if (!mdsResult.isNormalized()) {
        String stress = FormatterUtil.DECIMAL_FORMAT
                .format(ClassicMDS.getKruskalStressFromMDSResult(mdsResult));
        chart.setTitle(mdsResult.getCInstances().isCollapsed()
                ? "Collapsed MDS(Instances=" + maxInstances + ",Stress=" + stress + ")"
                : "MDS(Stress=" + stress + ")");
    } else {
        chart.setTitle(mdsResult.getCInstances().isCollapsed() ? "Collapsed MDS(Instances=" + maxInstances + ")"
                : "MDS");
    }

    final SimpleMatrix coordinates = mdsResult.getCoordinates();
    buildFilteredSeries(mdsResult, xyPlot, attrNameToUseAsPointTitle);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(new Dimension(1200, 900));
    chartPanel.setBorder(new TitledBorder("MDS Projection"));
    chartPanel.setBackground(Color.WHITE);

    final JButton selectionButton = new JButton("Select data");
    selectionButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final org.jfree.data.Range XDomainRange = xyPlot.getDomainAxis().getRange();
            final org.jfree.data.Range YDomainRange = xyPlot.getRangeAxis().getRange();
            final Instances cInstances = mdsResult.getCollapsedInstances();
            final Instances selectedInstances = new Instances(cInstances, 0);
            List<Instances> clusters = null;
            if (mdsResult.getCInstances().isCollapsed()) {
                clusters = mdsResult.getCInstances().getCentroidMap().getClusters();
            }
            for (int i = 0; i < cInstances.numInstances(); i++) {
                final Instance centroid = instances.instance(i);
                if (XDomainRange.contains(coordinates.get(i, 0))
                        && YDomainRange.contains(coordinates.get(i, 1))) {
                    if (mdsResult.getCInstances().isCollapsed()) {
                        if (clusters != null) {
                            final Instances elementsOfCluster = clusters.get(i);
                            final int nbElements = elementsOfCluster.numInstances();
                            for (int k = 0; k < nbElements; k++) {
                                selectedInstances.add(elementsOfCluster.get(k));
                            }
                        }
                    } else {
                        selectedInstances.add(centroid);
                    }
                }
            }
            if (listener != null) {
                listener.onAction(selectedInstances);
            }
        }
    });

    final JXPanel allPanel = new JXPanel();
    allPanel.setLayout(new BorderLayout());
    allPanel.add(chartPanel, BorderLayout.CENTER);
    final JXPanel southPanel = new JXPanel();
    southPanel.add(selectionButton);
    allPanel.add(southPanel, BorderLayout.SOUTH);
    return allPanel;
}

From source file:geneticonreinas.data.Grafica.java

public void mostrarGrafica() {
    // Crear la serie con los datos

    grafica = ChartFactory.createXYLineChart(this.tituloGrafica, this.axisXlabel, this.axisYlabel, coleccion,
            PlotOrientation.VERTICAL, true, false, false);

    ChartFrame panel = new ChartFrame(null, grafica);
    panel.pack();/*from w ww.  ja  v  a  2s.c  om*/
    panel.setVisible(true);
}

From source file:org.jfree.chart.demo.BarChartDemo9.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 9", null, "Value", categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    TextTitle texttitle = jfreechart.getTitle();
    texttitle.setBorder(0.0D, 0.0D, 1.0D, 0.0D);
    texttitle.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.red, 350F, 0.0F, Color.white, true));
    texttitle.setExpandToFitSpace(true);
    jfreechart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.yellow, 350F, 0.0F, Color.white, true));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");
    categoryplot.setBackgroundPaint(null);
    categoryplot.setInsets(new RectangleInsets(10D, 5D, 5D, 5D));
    categoryplot.setOutlinePaint(Color.black);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    Paint apaint[] = createPaint();
    CustomBarRenderer custombarrenderer = new CustomBarRenderer(apaint);
    custombarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    categoryplot.setRenderer(custombarrenderer);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setRange(0.0D, 800D);/*w w w  .  j a  v a  2 s  .  c o  m*/
    numberaxis.setTickMarkPaint(Color.black);
    return jfreechart;
}

From source file:paquete.Graficas.java

public void terminar() {
    datos.addValue(tcp, "TCP", "Paquetes");
    datos.addValue(udp, "UDP", "Paquetes");
    datos.addValue(icmp, "ICMP", "Paquetes");
    datos.addValue(igmp, "IGMP", "Paquetes");
    datos.addValue(arp, "ARP", "Paquetes");
    datos.addValue(llc, "LLC", "Paquetes");

    grafica = ChartFactory.createBarChart("Paquetes analizados", "", "", datos, PlotOrientation.VERTICAL, true,
            false, false);/* w w  w  .j av  a2 s. c  om*/
    ChartPanel panel = new ChartPanel(grafica);

    JFrame Ventana = new JFrame("JFreeChart");
    Ventana.getContentPane().add(panel);
    Ventana.pack();
    Ventana.setVisible(true);
    Ventana.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

From source file:is2pr3.HistogramDisplay.java

private JFreeChart createChart(DefaultCategoryDataset dataSet) {
    JFreeChart chart = ChartFactory.createBarChart("Histogram", "Domain", "N emails", dataSet,
            PlotOrientation.VERTICAL, false, rootPaneCheckingEnabled, rootPaneCheckingEnabled);
    return chart;
}

From source file:OilDrop.GraphTest.java

public JFreeChart getResultChart() {

    XYSeries series1 = new XYSeries("Particle Velocity");

    for (double i = 0; i < 10; i++) {
        caculate(i / 1000.);//from  w  w  w  .jav  a2s .  c  o  m
        series1.add(i, position);//pow(v,-10));
    }

    XYSeriesCollection data1 = new XYSeriesCollection(series1);

    final JFreeChart chart = ChartFactory.createXYLineChart("Time-Voltage Graph", "Time", "Voltage", data1,
            PlotOrientation.VERTICAL, true, false, false);
    chart.setBackgroundPaint(null);
    XYPlot plot = chart.getXYPlot();

    //        plot.getRangeAxis().setRange(-20, 20);

    return chart;
}

From source file:view.FuzzySetView.java

/**
 *
 * @param fuzzySet/*from ww w  .j  av a 2 s .  c o  m*/
 * @param tickUnit
 */
public FuzzySetView(FuzzySet fuzzySet, double tickUnit) {
    super(ChartFactory.createXYLineChart(fuzzySet.getName(), fuzzySet.getVariableName(),
            MICRO_SIGN + "(" + fuzzySet.getVariableName() + ")", fuzzySet, PlotOrientation.VERTICAL, true, true,
            false));

    TICK_UNIT = tickUnit;

    setPreferredSize(new Dimension(450, 200));

    initColors();
    setupRenderer();
}

From source file:net.sourceforge.processdash.ui.web.reports.LineChart.java

/** Create a  line chart. */
public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createLineChart(null, null, null, data.catDataSource(),
            PlotOrientation.VERTICAL, true, true, false);
    setupCategoryChart(chart);//from   w  ww .  jav  a2 s  .c om

    return chart;
}

From source file:chart.XYChart.java

public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic,
        double[] YDataNumerical1, double[] YDataNumerical2) {

    super(applicationTitle);

    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "",
            createDatasetForThree(xData, YDataAnalitic, YDataNumerical1, YDataNumerical2),
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.BLUE);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer.setSeriesStroke(2, new BasicStroke(1.0f));
    renderer.setSeriesStroke(3, new BasicStroke(1.0f));
    plot.setRenderer(renderer);/*w  w w .  j av  a 2  s . c o m*/
    setContentPane(chartPanel);

    // panel.removeAll();
    //  panel.add(chartPanel);
    //  panel.validate();

}

From source file:org.matsim.contrib.dvrp.util.chart.RouteChartUtils.java

public static JFreeChart chartRoutes(List<? extends Vehicle> vehicles) {
    CoordDataset lData = new CoordDataset();

    for (int i = 0; i < vehicles.size(); i++) {
        Schedule<?> schedule = vehicles.get(i).getSchedule();
        lData.addSeries(Integer.toString(i), LinkSources.createLinkSource(schedule));
    }/*from  w w  w .j  av a  2s .  c o  m*/

    JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", lData, PlotOrientation.VERTICAL, true,
            true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setBackgroundPaint(Color.white);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesItemLabelsVisible(0, true);

    renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() {
        public String generateLabel(XYDataset dataset, int series, int item) {
            return ((CoordDataset) dataset).getText(series, item);
        }
    });

    for (int i = 1; i <= vehicles.size(); i++) {
        renderer.setSeriesShapesVisible(i, true);
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesItemLabelsVisible(i, true);
    }

    return chart;
}