Example usage for org.jfree.chart.plot XYPlot setDomainAxisLocation

List of usage examples for org.jfree.chart.plot XYPlot setDomainAxisLocation

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setDomainAxisLocation.

Prototype

public void setDomainAxisLocation(AxisLocation location) 

Source Link

Document

Sets the location of the primary domain axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:net.sf.maltcms.chromaui.charts.tools.ChartTools.java

/**
 *
 * @param plot/* w w w .ja  v a2 s .  co  m*/
 * @return
 */
public static XYPlot getPlot2(XYPlot plot) {
    plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
    return plot;
}

From source file:net.sf.maltcms.chromaui.charts.tools.ChartTools.java

/**
 *
 * @param plot//from   w  w w  .  ja  v  a2s  .  c om
 * @return
 */
public static XYPlot getPlot3(XYPlot plot) {
    XYPlot p = new XYPlot(plot.getDataset(), new NumberAxis(plot.getRangeAxis().getLabel()),
            new NumberAxis(plot.getDomainAxis().getLabel()), plot.getRenderer());
    p.setOrientation(PlotOrientation.HORIZONTAL);
    p.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    Logger.getLogger(ChartTools.class.getName()).log(Level.INFO, "fixed auto range: {0}",
            plot.getRangeAxis().getRange().getUpperBound());
    p.getDomainAxis().setFixedAutoRange(500);

    return p;
}

From source file:atencionurgencia.evolucion.grafic_sVitales.java

private void graficar() {
    final TimeSeriesCollection dataset1 = axisTaFC.createDatasetTA();
    final JFreeChart chart2 = ChartFactory.createTimeSeriesChart("", // chart title
            "HORA", // domain axis label
            "Tensin Arterial - TA (ppm)", // range axis label
            dataset1, // data

            true, // include legend
            true, // tooltips?
            false // URL generator?  Not required...
    );//from w w  w  . jav  a 2  s  . c o  m
    chart2.setBackgroundPaint(Color.white);
    final XYPlot plot = chart2.getXYPlot();
    plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF));
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    //        plot.set

    //        
    ////        final CategoryDataset dataset2 = axisTaFC.createDatasetFC();
    ////        plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 0);
    //        
    //        final DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
    //        domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    ////        final ValueAxis axis2 = new NumberAxis("Frecuencia Cardiaca - FC (ppm)");
    ////        plot.setRangeAxis(1, axis2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    //        
    //        
    //        
    final ChartPanel chartPanel = new ChartPanel(chart2);
    chartPanel.setPreferredSize(new java.awt.Dimension(444, 358));//[598, 358][444, 358]
    jPanel4.removeAll();
    jPanel4.setLayout(new BorderLayout());
    jPanel4.add(chartPanel, BorderLayout.NORTH);
    jPanel4.repaint();
}

From source file:daylightchart.daylightchart.chart.DaylightChart.java

private void adjustForChartOrientation(final ChartOrientation chartOrientation) {
    if (chartOrientation == null) {
        return;/*from   w w  w .  jav  a 2s .com*/
    }

    final XYPlot plot = getXYPlot();
    final ValueAxis hoursAxis = plot.getRangeAxis();
    final ValueAxis monthsAxis = plot.getDomainAxis();

    switch (chartOrientation) {
    case STANDARD:
        hoursAxis.setInverted(true);
        plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
        break;
    case CONVENTIONAL:
        break;
    case VERTICAL:
        plot.setOrientation(PlotOrientation.HORIZONTAL);
        monthsAxis.setInverted(true);
        break;
    default:
        break;
    }
}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapPlotPanel.java

private PortHeatMapPlotPanel(OMS_Collection history, ArrayList<IB_Vertex> includedNodes,
        EnumSet<IB_Depth> includedDepths) {
    super(new BorderLayout());

    // creates the main chart panel, which creates the PortHeatMapDataSet
    // (so all the data has been initialized here, available for all subsequent actions)
    overallDimension = new java.awt.Dimension(900, 500);
    heatPanel = (ChartPanel) createHeatPanel(history, includedNodes, includedDepths);
    heatPanel.setPreferredSize(overallDimension);

    // add the vertical and horizontal crosshairs
    CrosshairOverlay overlay = new CrosshairOverlay();
    TimeXhair = new Crosshair(0);
    TimeXhair.setPaint(TimeSliceColor); // vertical slice (single timestamp) for dataset1, SingleTimeChart plot 1, slider 2, etc
    PortXhair = new Crosshair(0);
    PortXhair.setPaint(PortSliceColor); // horizontal slice (single port) for dataset2, SinglePortChart, slider 1
    overlay.addDomainCrosshair(TimeXhair);
    overlay.addRangeCrosshair(PortXhair);
    heatPanel.addOverlay(overlay);//ww w . j  a v  a  2  s.c o m
    TimeXhair.setLabelVisible(true);
    TimeXhair.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    TimeXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100));
    PortXhair.setLabelVisible(true);
    PortXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100));

    add(heatPanel);

    JPanel PortSliderPanel = new JPanel(new BorderLayout());

    // all ports, single timestamp (right vertical plot) - uses TimeXhair and slider 2 from the horizontal panel (TimeSliderPanel)
    XYSeriesCollection dataset1 = new XYSeriesCollection();
    SingleTimeChart = ChartFactory.createXYLineChart("Vertical Cross-section (all ports single timestamp)",
            PortAxisLabel, UtilizationAxisLabel, dataset1, PlotOrientation.HORIZONTAL, false, false, false);
    XYPlot plot1 = (XYPlot) SingleTimeChart.getPlot();
    plot1.getDomainAxis().setLowerMargin(0.0);
    plot1.getDomainAxis().setUpperMargin(0.0);
    plot1.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    plot1.getRenderer().setSeriesPaint(0, TimeSliceColor);

    // this is the right
    ChartPanel SingleTimeChartPanel = new ChartPanel(SingleTimeChart);
    SingleTimeChartPanel.setMinimumDrawWidth(0);
    SingleTimeChartPanel.setMinimumDrawHeight(0);

    SingleTimeChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getWidth() / 3)));
    ((XYPlot) SingleTimeChart.getPlot()).getRangeAxis().setRange(new Range(0, 1));
    ((XYPlot) SingleTimeChart.getPlot()).getDomainAxis().setRange(new Range(0, 1));

    // this slider panel holds the slider and the Single Time Snapshot of all ports, on the right or EAST (for use with plot2)
    PortSlider = new JSlider(0, 1, 0);
    PortSlider.addChangeListener(this);
    PortSlider.setOrientation(JSlider.VERTICAL);

    PortSliderPanel.add(SingleTimeChartPanel);
    PortSliderPanel.add(PortSlider, BorderLayout.WEST);

    TimeSliderPanel = new JPanel(new BorderLayout());

    // single port, all timestamps (lower horizontal plot) - uses PortXhair and slider 1 from the vertical panel (PortSliderPanel)
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    SinglePortChart = ChartFactory.createXYLineChart("Horizontal Cross-section (single port over time)",
            TimeAxisLabel, UtilizationAxisLabel, dataset2, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot2 = (XYPlot) SinglePortChart.getPlot();
    plot2.getDomainAxis().setLowerMargin(0.0);
    plot2.getDomainAxis().setUpperMargin(0.0);
    plot2.getRenderer().setSeriesPaint(0, PortSliceColor);

    ChartPanel SinglePortChartPanel = new ChartPanel(SinglePortChart);
    SinglePortChartPanel.setMinimumDrawWidth(0);
    SinglePortChartPanel.setMinimumDrawHeight(0);

    SinglePortChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getHeight() / 3)));
    ((XYPlot) SinglePortChart.getPlot()).getRangeAxis().setRange(new Range(0, 1));
    ((XYPlot) SinglePortChart.getPlot()).getDomainAxis().setRange(new Range(0, 1));

    DepthPanel = new HeatMapDepthPanel(null);
    DepthPanel.setPreferredSize(
            new Dimension((int) (overallDimension.getWidth() / 4), (int) (overallDimension.getHeight() / 3)));
    TimeSliderPanel.add(DepthPanel, BorderLayout.EAST);

    // this slider panel holds the slider and the Single Port for all times, in the BOTTOM (for use with plot1)
    TimeSlider = new JSlider(0, 1, 0);
    TimeSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 200));
    TimeSlider.addChangeListener(this);

    TimeSliderPanel.add(SinglePortChartPanel);
    TimeSliderPanel.add(TimeSlider, BorderLayout.NORTH);
    add(PortSliderPanel, BorderLayout.EAST);
    add(TimeSliderPanel, BorderLayout.SOUTH);
    heatChart.setNotify(true);
}

From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java

private JFreeChart createXYPlot(PlotOrientation orient, AxisLocation axLoc, double[] axisValues, JPanel panel,
        boolean domInvert, CrosshairOverlay overlay) {
    JFreeChart subchart;/*  w w w .  j  av a  2 s.c  om*/
    XYSeriesCollection chartDataset = new XYSeriesCollection();
    subchart = ChartFactory.createXYLineChart(null, null, null, chartDataset, orient, false, false, false);
    if (axisValues[axisValues.length - 1] < axisValues[0]) {
        subchart.getXYPlot().getDomainAxis().setUpperBound(axisValues[0]);
        subchart.getXYPlot().getDomainAxis().setInverted(domInvert);
    } else {
        subchart.getXYPlot().getDomainAxis().setUpperBound(axisValues[axisValues.length - 1]);
    }

    XYPlot plot = (XYPlot) subchart.getPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.getDomainAxis().setAutoRange(true);
    plot.setDomainAxisLocation(axLoc);
    plot.setRangeAxisLocation(axLoc);
    plot.getDomainAxis().setInverted(domInvert);

    GraphPanel subchartPanel = new GraphPanel(subchart);
    if (overlay != null) {
        subchartPanel.addOverlay(overlay);
    }
    panel.removeAll();
    panel.setLayout(new BorderLayout());
    subchartPanel.setMinimumDrawHeight(0);
    subchartPanel.setMinimumDrawWidth(0);
    panel.add(subchartPanel);
    return subchart;

}

From source file:com.jtstand.swing.StatsPanel.java

public JFreeChart getChartDistribution(boolean horizontal) {
    //        System.out.println("Min: " + minValue());
    //        System.out.println("Max: " + maxValue());
    XYIntervalSeriesCollection datasetDistribution = createIntervalXYDatasetDistribution(horizontal);
    XYSeriesCollection dataset2 = createXYDatasetGauss(horizontal);
    // create the chart...
    NumberAxis xAxis = new NumberAxis(getValueString());
    xAxis.setAutoRangeIncludesZero(false);
    //        NumberAxis yAxis = new NumberAxis("Distribution");
    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(true);
    //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer = new MyBarRenderer();
    XYPlot plot = new XYPlot(datasetDistribution, xAxis, yAxis, renderer);
    plot.setOrientation(horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, isGrouping());
    chart.setBackgroundPaint((Paint) UIManager.get("Panel.background"));
    //        plot.setBackgroundPaint(Color.white);
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    StandardXYItemLabelGenerator itemlabels = new StandardXYItemLabelGenerator();
    renderer.setBaseItemLabelGenerator(itemlabels);
    renderer.setBaseItemLabelsVisible(true);
    plot.setDataset(1, dataset2);/*from   w  w  w  . j  a v  a  2  s. c o m*/
    plot.mapDatasetToRangeAxis(1, 1);
    //        ValueAxis domainAxis = plot.getDomainAxis();
    //domainAxis.setCategoryLabelPositions(horizontal?CategoryLabelPositions.STANDARD:CategoryLabelPositions.UP_90);
    ValueAxis axis2 = new NumberAxis("Gaussian");
    plot.setRangeAxis(1, axis2);
    axis2.setVisible(false);
    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    //renderer2.setShapesVisible(false);
    //renderer2.setSeriesVisibleInLegend(false);
    renderer2.setBaseSeriesVisibleInLegend(false);
    //renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(1, renderer2);
    renderer.setUseYInterval(true);
    renderer.setBaseSeriesVisibleInLegend(false);
    /* coloring */
    Color c;
    if (isMultipleCategorization()) {
        //            TreeMap<String, Color> cmap = new TreeMap<String, Color>();
        int i = 0;
        for (Iterator<String> it = catstats.keySet().iterator(); it.hasNext(); i++) {
            String groupName = it.next();
            c = ChartCategories.getColor(i);
            for (int j = 0; j < datasetDistribution.getSeriesCount(); j++) {
                XYIntervalSeries s = datasetDistribution.getSeries(j);
                if (s.getKey().equals(groupName)) {
                    GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker());
                    renderer.setSeriesPaint(j, gp);
                }
            }
            for (int j = 0; j < dataset2.getSeriesCount(); j++) {
                XYSeries s = dataset2.getSeries(j);
                if (s.getKey().equals(groupName)) {
                    renderer2.setSeriesPaint(j, c);
                    renderer2.setSeriesShapesVisible(j, false);
                    renderer2.setSeriesStroke(j, myStroke);
                }
            }
        }
        c = Color.black;
    } else {
        c = ChartCategories.getColor(0);
        GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker());
        renderer.setSeriesPaint(0, gp);
    }
    renderer2.setSeriesPaint(0, c);
    renderer2.setSeriesShapesVisible(0, false);
    renderer2.setSeriesStroke(0, myStroke);

    placeLimitMarkers(plot, false);
    //        renderer.setAutoPopulateSeriesOutlinePaint(true);
    //        renderer.setBaseOutlinePaint(Color.black);
    //        renderer.setSeriesOutlinePaint(0, Color.black, true);
    //        renderer.setDrawBarOutline(true);

    renderer.setHighlightedItem(0, 0);
    yAxis.setAutoRange(false);
    yAxis.setAutoRange(true);
    xAxis.setRange(leftValue(0), rightValue(numberOfCategories - 1));
    chart.setTextAntiAlias(false);
    return chart;
}