Example usage for org.jfree.chart.axis AxisLocation TOP_OR_RIGHT

List of usage examples for org.jfree.chart.axis AxisLocation TOP_OR_RIGHT

Introduction

In this page you can find the example usage for org.jfree.chart.axis AxisLocation TOP_OR_RIGHT.

Prototype

AxisLocation TOP_OR_RIGHT

To view the source code for org.jfree.chart.axis AxisLocation TOP_OR_RIGHT.

Click Source Link

Document

Axis at the top or right.

Usage

From source file:com.jaspersoft.studio.components.chart.model.enums.JFreeChartAxisLocationEnum.java

public static JFreeChartAxisLocationEnum getValue(AxisLocation ha) {
    if (ha != null) {
        if (ha.equals(AxisLocation.TOP_OR_LEFT))
            return TOP_OR_LEFT;
        if (ha.equals(AxisLocation.TOP_OR_RIGHT))
            return TOP_OR_RIGHT;
        if (ha.equals(AxisLocation.BOTTOM_OR_LEFT))
            return BOTTOM_OR_LEFT;
        if (ha.equals(AxisLocation.BOTTOM_OR_RIGHT))
            return BOTTOM_OR_RIGHT;
    }// ww w . ja v a2 s  . co m
    return BOTTOM_OR_RIGHT;
}

From source file:net.sf.jasperreports.chartthemes.simple.handlers.AxisLocationHandler.java

@Override
public Object convertUponSet(Object value) {
    if (value == null) {
        return null;
    }/* w  w w  .j av  a2  s .  c  om*/
    return AxisLocation.BOTTOM_OR_LEFT.toString().equals(value) ? AxisLocation.BOTTOM_OR_LEFT
            : AxisLocation.BOTTOM_OR_RIGHT.toString().equals(value) ? AxisLocation.BOTTOM_OR_RIGHT
                    : AxisLocation.TOP_OR_LEFT.toString().equals(value) ? AxisLocation.TOP_OR_LEFT
                            : AxisLocation.TOP_OR_RIGHT.toString().equals(value) ? AxisLocation.TOP_OR_RIGHT
                                    : null;
}

From source file:net.sf.fspdfs.chartthemes.simple.handlers.AxisLocationHandler.java

/**
 *
 *//*from   w  ww.j a v a2 s  . co m*/
public Object convertUponSet(Object value) {
    if (value == null) {
        return null;
    }
    return AxisLocation.BOTTOM_OR_LEFT.toString().equals(value) ? AxisLocation.BOTTOM_OR_LEFT
            : AxisLocation.BOTTOM_OR_RIGHT.toString().equals(value) ? AxisLocation.BOTTOM_OR_RIGHT
                    : AxisLocation.TOP_OR_LEFT.toString().equals(value) ? AxisLocation.TOP_OR_LEFT
                            : AxisLocation.TOP_OR_RIGHT.toString().equals(value) ? AxisLocation.TOP_OR_RIGHT
                                    : null;
}

From source file:com.jaspersoft.studio.components.chart.model.enums.JFreeChartAxisLocationEnum.java

public AxisLocation getJFreeChartValue() {
    if (value == 0)
        return AxisLocation.TOP_OR_LEFT;
    if (value == 1)
        return AxisLocation.TOP_OR_RIGHT;
    if (value == 2)
        return AxisLocation.BOTTOM_OR_LEFT;
    if (value == 3)
        return AxisLocation.BOTTOM_OR_RIGHT;
    return null;//from w w w  . j  a v a 2s .  co m
}

From source file:org.jstockchart.area.VolumeArea.java

/**
 * Returns the volume axis location that is determined by the plot
 * orientation.//from   ww w  .  j a v a 2  s. co  m
 * 
 * @return the volume axis location.
 */
public AxisLocation getVolumeAxisLocation() {
    PlotOrientation orientation = getOrientation();
    AxisLocation result = null;
    if (orientation.equals(PlotOrientation.VERTICAL)) {
        result = AxisLocation.BOTTOM_OR_LEFT;
    } else if (orientation.equals(PlotOrientation.HORIZONTAL)) {
        result = AxisLocation.TOP_OR_RIGHT;
    }

    return result;
}

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

/**
 *
 * @param plot// w  ww . j  ava 2s.  co m
 * @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:org.sonar.server.charts.jruby.TrendsChart.java

public void initSerie(Long serieId, String legend, boolean isPercent) {
    TimeSeries series = new TimeSeries(legend);

    int index = seriesById.size();
    seriesById.put(serieId, series);//from w  w w .  j ava  2 s . c om

    TimeSeriesCollection timeSeriesColl = new TimeSeriesCollection();
    timeSeriesColl.addSeries(series);
    plot.setDataset(index, timeSeriesColl);

    if (isPercent) {
        if (percentAxisId == -1) {
            NumberAxis rangeAxis = new NumberAxis();
            rangeAxis.setNumberFormatOverride(new DecimalFormat("0'%'"));
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setUpperBound(100.0);
            rangeAxis.setLowerBound(0.0);
            plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_LEFT);
            plot.setRangeAxis(index, rangeAxis);
            plot.mapDatasetToRangeAxis(index, index);
            percentAxisId = index;

        } else {
            plot.mapDatasetToRangeAxis(index, percentAxisId);
        }
    } else {
        NumberAxis rangeAxis = new NumberAxis(displayLegend ? legend : null);
        rangeAxis.setAutoRangeIncludesZero(false);
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setAutoRangeMinimumSize(2.0);
        plot.setRangeAxisLocation(index, AxisLocation.TOP_OR_RIGHT);
        plot.setRangeAxis(index, rangeAxis);
        plot.mapDatasetToRangeAxis(index, index);
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesPaint(0, COLORS[index % COLORS.length]);
    plot.setRenderer(index, renderer);
}

From source file:de.fub.maps.project.detector.model.inference.ui.charts.ClassificationBarChart.java

/**
 * Creates new form ClassificationBarChart
 *///  ww  w . j  a  v a2 s  . c  o m
public ClassificationBarChart() {
    super();
    initComponents();
    plot = new CustomCategoryPlot();
    barChart = new JFreeChart(NbBundle.getMessage(ClassificationBarChart.class, "CLT_Chart_Classify_Name"),
            null, plot, true);
    ChartFactory.getChartTheme().apply(barChart);
    plot.setDomainAxis(new CategoryAxis());
    plot.getDomainAxis().setLabel(NbBundle.getMessage(ClassificationBarChart.class, "CLT_Doman_Axis_Name"));
    plot.setOrientation(PlotOrientation.VERTICAL);

    Font font = new JLabel().getFont().deriveFont(Font.BOLD, 14);
    barChart.getTitle().setFont(font);
    barChart.getTitle().setPaint(new Color(153, 153, 153));

    plot.setDataset(0, relDataset);
    plot.setDataset(1, absDataset);
    plot.mapDatasetToRangeAxis(0, 0);
    plot.mapDatasetToRangeAxis(1, 1);

    NumberAxis relAxis = new NumberAxis(
            NbBundle.getMessage(ClassificationBarChart.class, "CLT_Value_Axis_Name"));
    relAxis.setAutoRange(true);
    relAxis.setUpperMargin(.20);
    NumberAxis absAxis = new NumberAxis(
            NbBundle.getMessage(ClassificationBarChart.class, "CLT_Value_Rel_Axis_Name"));
    absAxis.setAutoRange(true);
    absAxis.setUpperMargin(.20);

    plot.setRangeAxis(0, relAxis);
    plot.setRangeAxis(1, absAxis);
    plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);
    plot.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT);

    BarRenderer relRenderer = new BarRenderer();
    relRenderer.setBasePaint(relColor);
    relRenderer.setAutoPopulateSeriesPaint(false);
    relRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    relRenderer.setBarPainter(new StandardBarPainter());
    relRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    relRenderer.setBaseItemLabelsVisible(true);

    BarRenderer absRenderer = new BarRenderer();
    absRenderer.setBasePaint(absColor);
    absRenderer.setAutoPopulateSeriesPaint(false);
    absRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    absRenderer.setBarPainter(new StandardBarPainter());
    absRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    absRenderer.setBaseItemLabelsVisible(true);

    plot.setRenderer(0, relRenderer);
    plot.setRenderer(1, absRenderer);

    plot.setBackgroundPaint(Color.white);
    barChart.setBackgroundPaint(Color.white);
    plot.setRangeGridlinesVisible(false);
    chartPanel = new ChartPanel(barChart, false);
    chartPanel.setVerticalAxisTrace(false);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setBackground(Color.white);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:org.jstockchart.area.PriceArea.java

/**
 * Returns the price axis location that is determined by the plot
 * orientation.//ww w .  j a  v  a 2 s .c o  m
 * 
 * @return the price axis location.
 */
public AxisLocation getPriceAxisLocation() {
    PlotOrientation orientation = getOrientation();
    AxisLocation result = null;
    if (orientation.equals(PlotOrientation.VERTICAL)) {
        result = AxisLocation.BOTTOM_OR_LEFT;
    } else if (orientation.equals(PlotOrientation.HORIZONTAL)) {
        result = AxisLocation.TOP_OR_RIGHT;
    }

    return result;
}

From source file:com.algodefu.yeti.data.Pass.java

private void calculateEquityChartImg() throws IOException {
    int i = 0;// w  ww  .  ja v a 2 s  .co m
    double sum = 0;
    TimeSeries equity = new TimeSeries("Equity");

    // save values in temp array first, then use System.arraycopy to copy non empty values to this.equityArray
    double[][] tempEquityArr = new double[this.getTrades().length][4];

    for (Trade trade : this.getTrades()) {
        if (trade.getCloseDateTime() != null) {
            sum += trade.getProfit();
            equity.add(new Millisecond(Date.from(trade.getCloseDateTime().toInstant(ZoneOffset.UTC))), sum);
            tempEquityArr[i][0] = (double) trade.getCloseDateTime().toInstant(ZoneOffset.UTC).toEpochMilli();
            tempEquityArr[i][1] = sum;
            tempEquityArr[i][2] = trade.getTradeID();
            tempEquityArr[i][3] = trade.getProfit();
            i++;
        }
    }
    this.equityArray = new double[i][4];
    System.arraycopy(tempEquityArr, 0, this.equityArray, 0, i);

    TimeSeriesCollection dataset = new TimeSeriesCollection(equity);
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false);
    chart.getXYPlot().getDomainAxis().setTickLabelsVisible(false);
    chart.setBorderVisible(true);
    chart.getXYPlot().setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    chart.getXYPlot().getRenderer().setSeriesPaint(0, Color.blue);
    chart.getXYPlot().setBackgroundPaint(Color.white);
    chart.getXYPlot().setRangeGridlinePaint(Color.gray);
    chart.getXYPlot().setDomainGridlinePaint(Color.gray);
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
        ChartUtilities.writeChartAsPNG(baos, chart, 320, 180);
        baos.flush();
        this.equityChartByteArray = baos.toByteArray();
    } catch (IOException e) {
        throw e;
    }

}