Example usage for org.jfree.ui RectangleAnchor TOP

List of usage examples for org.jfree.ui RectangleAnchor TOP

Introduction

In this page you can find the example usage for org.jfree.ui RectangleAnchor TOP.

Prototype

RectangleAnchor TOP

To view the source code for org.jfree.ui RectangleAnchor TOP.

Click Source Link

Document

Top.

Usage

From source file:biz.ixnay.pivot.charts.skin.jfree.HistogramViewSkin.java

private void createMarkers(JFreeChart chart, ChartView chartView) {
    for (org.apache.pivot.charts.content.ValueMarker valueMarker : chartView.getValueMarkers()) {
        final Marker target = new ValueMarker(valueMarker.getValue());
        target.setPaint(valueMarker.getColor());
        target.setLabel(valueMarker.getLabel());
        target.setLabelAnchor(RectangleAnchor.TOP);
        target.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        ((XYPlot) chart.getPlot()).addDomainMarker(target);
    }/*from w w w . j  a  va 2  s . co m*/
}

From source file:com.mgmtp.perfload.perfalyzer.reportpreparation.PlotCreator.java

public JFreeChart createPlot(final AxisType xAxisType, final AxisType yAxisType,
        final RendererType rendererType, final DisplayData displayData, final DataRange dataRange,
        boolean showMarkers, final NumberDataSet... dataSets) {

    NumberAxis xAxis = createAxis(xAxisType, resourceBundle.getString(displayData.getUnitX()));

    XYPlot plot;/* w  ww .jav  a2s  .  c  o  m*/
    if (dataSets.length == 1) {
        NumberAxis yAxis = createAxis(yAxisType, resourceBundle.getString(displayData.getUnitY()));
        plot = new XYPlot(dataSets[0], xAxis, yAxis, rendererType.createRenderer());
    } else {
        CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(xAxis);
        for (int i = 0; i < dataSets.length; ++i) {
            NumberDataSet dataSet = dataSets[i];
            // no range for y-axis!
            NumberAxis yAxis = createAxis(yAxisType,
                    resourceBundle.getString(displayData.getUnitYList().get(i)));
            XYPlot subPlot = new XYPlot(dataSet, null, yAxis, rendererType.createRenderer());
            combinedPlot.add(subPlot);
            formatPlot(subPlot);
        }
        plot = combinedPlot;
    }

    JFreeChart chart = new JFreeChart(plot);
    CHART_THEME.apply(chart);

    formatPlot(plot);

    if (showMarkers) {
        for (Marker marker : markers) {
            IntervalMarker im = new IntervalMarker(marker.getLeftMillis() / 1000L,
                    marker.getRightMillis() / 1000L);
            im.setLabel(marker.getName());
            im.setLabelFont(new Font("Sans Serif", Font.ITALIC | Font.BOLD, 14));
            im.setLabelAnchor(RectangleAnchor.TOP);
            im.setLabelOffset(new RectangleInsets(8d, 0d, 0d, 0d));
            im.setLabelPaint(Color.BLACK);
            im.setAlpha(.2f);
            im.setPaint(Color.WHITE);
            im.setOutlinePaint(Color.BLACK);
            im.setOutlineStroke(new BasicStroke(1.0f));
            plot.addDomainMarker(im, Layer.BACKGROUND);
        }
    }

    LegendTitle legend = chart.getLegend();
    legend.setBackgroundPaint(new Color(229, 229, 229));
    legend.setFrame(
            new LineBorder(new Color(213, 213, 213), new BasicStroke(1.0f), legend.getFrame().getInsets()));

    // only for non-logarithmic axes
    // range must be set after plot is created, otherwise nothing is drawn
    if (dataRange != null && !xAxisType.equals(AxisType.LOGARITHMIC)) {
        xAxis.setRange(dataRange.getLowerSeconds(), dataRange.getUpperSeconds());
    }

    return chart;
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void preparePropertiesVsOwnAllPropertiesJFreeChart(JFreeChart jfchart,
        CategoryDataset categoryModel) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    categoryPlot.getRangeAxis().resizeRange(1.2);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);

    renderer.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10));
    renderer.setItemLabelAnchorOffset(15);

    renderer.setSeriesStroke(0, new BasicStroke(1));
    renderer.setSeriesStroke(1, new BasicStroke(1));
    renderer.setSeriesStroke(2, new BasicStroke(1));
    renderer.setSeriesStroke(3, new BasicStroke(1));
    renderer.setSeriesStroke(4, new BasicStroke(1));
    renderer.setSeriesStroke(5, new BasicStroke(1));
    renderer.setSeriesPaint(0, new Color(0x77, 0x77, 0xFF));
    renderer.setSeriesPaint(1, new Color(0xCC, 0xCC, 0xFF));
    renderer.setSeriesPaint(2, new Color(0x00, 0x00, 0xFF));
    renderer.setSeriesPaint(3, new Color(0xFF, 0x77, 0x77));
    renderer.setSeriesPaint(4, new Color(0xFF, 0xCC, 0xCC));
    renderer.setSeriesPaint(5, new Color(0xFF, 0x00, 0x00));
    for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) {
        String label = (String) categoryModel.getColumnKey(i);
        CategoryMarker marker = new CategoryMarker(label);
        marker.setLabel("");
        marker.setPaint(Color.cyan);
        marker.setOutlinePaint(Color.cyan);
        marker.setAlpha(0.1f);//from w ww  . j  a v  a 2s.com
        marker.setLabelAnchor(RectangleAnchor.TOP);
        marker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
        marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
        categoryPlot.addDomainMarker(marker, Layer.BACKGROUND);
    }
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setItemMargin(.1);
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_RIGHT));
    renderer.setBaseNegativeItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.BOTTOM_RIGHT));
}

From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHelper.java

public static RectangleAnchor getRectangleAnchor(ChartDataItem item) {
    RectangleAnchor ta;//from  w w w  .j  a v a  2s . com

    switch (item.getIconPosition()) {
    case LEADING:
    case LEFT:
        ta = RectangleAnchor.LEFT;

        break;

    case TRAILING:
    case RIGHT:
        ta = RectangleAnchor.RIGHT;

        break;

    case TOP_CENTER:
        ta = RectangleAnchor.TOP;

        break;

    case BOTTOM_CENTER:
        ta = RectangleAnchor.BOTTOM;

        break;

    default:
        ta = RectangleAnchor.CENTER;

        break;
    }

    return ta;
}

From source file:com.griddynamics.jagger.monitoring.reporting.SystemUnderTestPlotsGeneralProvider.java

public Map<String, List<MonitoringReporterData>> createTaskPlots() {
    log.info("BEGIN: Create general task plots");

    Map<String, List<MonitoringReporterData>> taskPlots = new LinkedHashMap<String, List<MonitoringReporterData>>();
    GeneralStatistics generalStatistics = getStatistics();

    Set<String> taskIds = generalStatistics.findTaskIds();
    Set<String> boxIdentifiers = generalStatistics.findBoxIdentifiers();
    Set<String> sutUrls = generalStatistics.findSutUrls();
    for (GroupKey groupName : plotGroups.getPlotGroups().keySet()) {
        log.info("    Create general task plots for group '{}'", groupName);

        if (showPlotsByGlobal) {
            log.info("        Create general global task plots");

            List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>();
            XYSeriesCollection chartsCollection = new XYSeriesCollection();
            LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>();
            for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) {
                log.info("            Create general global task plots for parameter '{}'", parameterId);

                MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId);
                if (generalStatistics.hasGlobalStatistics(param)) {
                    XYSeries values = new XYSeries(param.getDescription());
                    long timeShift = 0;
                    int taskNum = 0;
                    for (String taskId : taskIds) {
                        log.info("                Create general global task plots for task '{}'", taskId);

                        long maxTime = 0;
                        for (MonitoringStatistics monitoringStatistics : generalStatistics
                                .findGlobalStatistics(taskId, param)) {
                            long time = monitoringStatistics.getTime();
                            double t = timeShift + time;
                            values.add(t, monitoringStatistics.getAverageValue());

                            if (time > maxTime) {
                                maxTime = time;
                            }/* w  w w .j a v a2  s. co m*/

                            if (showNumbers) {
                                IntervalMarker marker = markers.get(taskId);
                                if (marker == null) {
                                    marker = new IntervalMarker(t, t);
                                    marker.setLabel(monitoringStatistics.getTaskData().getNumber().toString());
                                    marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f);

                                    int mod = taskNum % 3;
                                    if (mod == 0) {
                                        marker.setLabelAnchor(RectangleAnchor.CENTER);
                                    } else if (mod == 1) {
                                        marker.setLabelAnchor(RectangleAnchor.TOP);
                                    } else if (mod == 2) {
                                        marker.setLabelAnchor(RectangleAnchor.BOTTOM);
                                    }

                                    marker.setLabelFont(
                                            marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD));
                                    markers.put(taskId, marker);
                                } else {
                                    if (t < marker.getStartValue()) {
                                        marker.setStartValue(t);
                                    }
                                    if (t > marker.getEndValue()) {
                                        marker.setEndValue(t);
                                    }
                                }
                            }
                        }
                        timeShift += maxTime;
                        taskNum++;
                    }
                    if (values.isEmpty()) {
                        values.add(0, 0);
                    }
                    chartsCollection.addSeries(values);
                }
            }

            log.debug("group name \n{} \nparams {}]\n", groupName,
                    Lists.newArrayList(plotGroups.getPlotGroups().get(groupName)));

            Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection, markers.values());

            chartsCollection = pair.getSecond();

            String name = groupName.getUpperName();

            if (chartsCollection.getSeriesCount() > 0) {
                JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection,
                        "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1,
                        ChartHelper.ColorTheme.LIGHT);

                XYPlot plot = (XYPlot) chart.getPlot();
                for (IntervalMarker marker : markers.values()) {
                    plot.addDomainMarker(marker);
                }

                MonitoringReporterData monitoringReporterData = new MonitoringReporterData();
                monitoringReporterData.setParameterName(name);
                monitoringReporterData.setTitle(name);
                monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart));
                plots.add(monitoringReporterData);
            }

            if (!plots.isEmpty()) {
                taskPlots.put(name, plots);
            }
        }

        if (showPlotsByBox) {
            log.info("        Create general box task plots");

            for (String boxIdentifier : boxIdentifiers) {
                log.info("            Create general box task plots for box '{}'", boxIdentifier);

                List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>();
                XYSeriesCollection chartsCollection = new XYSeriesCollection();
                LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>();
                for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) {
                    log.info("                Create general box task plots for parameter '{}'", parameterId);

                    MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId);
                    if (generalStatistics.hasBoxStatistics(param, boxIdentifier)) {
                        XYSeries values = new XYSeries(param.getDescription());
                        long timeShift = 0;
                        int taskNum = 0;
                        for (String taskId : taskIds) {
                            log.info("                    Create general box task plots for task '{}'", taskId);

                            long maxTime = 0;
                            for (MonitoringStatistics monitoringStatistics : generalStatistics
                                    .findBoxStatistics(taskId, param, boxIdentifier)) {
                                long time = monitoringStatistics.getTime();
                                double t = timeShift + time;
                                values.add(t, monitoringStatistics.getAverageValue());

                                if (time > maxTime) {
                                    maxTime = time;
                                }

                                if (showNumbers) {
                                    IntervalMarker marker = markers.get(taskId);
                                    if (marker == null) {
                                        marker = new IntervalMarker(t, t);
                                        marker.setLabel(
                                                monitoringStatistics.getTaskData().getNumber().toString());
                                        marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f);

                                        int mod = taskNum % 3;
                                        if (mod == 0) {
                                            marker.setLabelAnchor(RectangleAnchor.CENTER);
                                        } else if (mod == 1) {
                                            marker.setLabelAnchor(RectangleAnchor.TOP);
                                        } else if (mod == 2) {
                                            marker.setLabelAnchor(RectangleAnchor.BOTTOM);
                                        }

                                        marker.setLabelFont(
                                                marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD));
                                        markers.put(taskId, marker);
                                    } else {
                                        if (t < marker.getStartValue()) {
                                            marker.setStartValue(t);
                                        }
                                        if (t > marker.getEndValue()) {
                                            marker.setEndValue(t);
                                        }
                                    }
                                }
                            }
                            timeShift += maxTime;
                            taskNum++;
                        }
                        if (values.isEmpty()) {
                            values.add(0, 0);
                        }
                        chartsCollection.addSeries(values);
                    }
                }

                log.debug("group name \n{} \nparams {}]\n", groupName,
                        Lists.newArrayList(plotGroups.getPlotGroups().get(groupName)));

                Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection,
                        markers.values());

                chartsCollection = pair.getSecond();

                String name = groupName.getUpperName() + " on " + boxIdentifier;

                if (chartsCollection.getSeriesCount() > 0) {
                    JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection,
                            "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1,
                            ChartHelper.ColorTheme.LIGHT);

                    XYPlot plot = (XYPlot) chart.getPlot();
                    for (IntervalMarker marker : markers.values()) {
                        plot.addDomainMarker(marker);
                    }

                    MonitoringReporterData monitoringReporterData = new MonitoringReporterData();
                    monitoringReporterData.setParameterName(name);
                    monitoringReporterData.setTitle(name);
                    monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart));
                    plots.add(monitoringReporterData);
                }

                if (!plots.isEmpty()) {
                    taskPlots.put(name, plots);
                }
            }
        }

        if (showPlotsBySuT) {
            log.info("        Create general sut task plots");

            for (String sutUrl : sutUrls) {
                log.info("            Create general sut task plots for sut '{}'", sutUrl);

                List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>();
                XYSeriesCollection chartsCollection = new XYSeriesCollection();
                LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>();
                for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) {
                    log.info("                Create general sut task plots for parameter '{}'", parameterId);

                    MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId);
                    if (generalStatistics.hasSutStatistics(param, sutUrl)) {
                        XYSeries values = new XYSeries(param.getDescription());
                        long timeShift = 0;
                        int taskNum = 0;
                        for (String taskId : taskIds) {
                            log.info("                    Create general sut task plots for task '{}'", taskId);

                            long maxTime = 0;
                            for (MonitoringStatistics monitoringStatistics : generalStatistics
                                    .findSutStatistics(taskId, param, sutUrl)) {
                                long time = monitoringStatistics.getTime();
                                double t = timeShift + time;
                                values.add(t, monitoringStatistics.getAverageValue());

                                if (time > maxTime) {
                                    maxTime = time;
                                }

                                if (showNumbers) {
                                    IntervalMarker marker = markers.get(taskId);
                                    if (marker == null) {
                                        marker = new IntervalMarker(t, t);
                                        marker.setLabel(
                                                monitoringStatistics.getTaskData().getNumber().toString());
                                        marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f);

                                        int mod = taskNum % 3;
                                        if (mod == 0) {
                                            marker.setLabelAnchor(RectangleAnchor.CENTER);
                                        } else if (mod == 1) {
                                            marker.setLabelAnchor(RectangleAnchor.TOP);
                                        } else if (mod == 2) {
                                            marker.setLabelAnchor(RectangleAnchor.BOTTOM);
                                        }

                                        marker.setLabelFont(
                                                marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD));
                                        markers.put(taskId, marker);
                                    } else {
                                        if (t < marker.getStartValue()) {
                                            marker.setStartValue(t);
                                        }
                                        if (t > marker.getEndValue()) {
                                            marker.setEndValue(t);
                                        }
                                    }
                                }
                            }
                            timeShift += maxTime;
                            taskNum++;
                        }
                        if (values.isEmpty()) {
                            values.add(0, 0);
                        }
                        chartsCollection.addSeries(values);
                    }
                }

                log.debug("group name \n{} \nparams {}]\n", groupName,
                        Lists.newArrayList(plotGroups.getPlotGroups().get(groupName)));

                Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection,
                        markers.values());

                chartsCollection = pair.getSecond();

                String name = groupName.getUpperName() + " on " + sutUrl;

                if (chartsCollection.getSeriesCount() > 0) {
                    JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection,
                            "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1,
                            ChartHelper.ColorTheme.LIGHT);

                    XYPlot plot = (XYPlot) chart.getPlot();
                    for (IntervalMarker marker : markers.values()) {
                        plot.addDomainMarker(marker);
                    }

                    MonitoringReporterData monitoringReporterData = new MonitoringReporterData();
                    monitoringReporterData.setParameterName(name);
                    monitoringReporterData.setTitle(name);
                    monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart));
                    plots.add(monitoringReporterData);
                }

                if (!plots.isEmpty()) {
                    taskPlots.put(name, plots);
                }
            }
        }
    }

    clearStatistics();

    log.info("END: Create general task plots");

    return taskPlots;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java

@Test
public void testCreateUpRotationCategoryLabelPosition() {
    TestableCategoricalChartExpression e = new TestableCategoricalChartExpression();
    {//from   w  w w  .  ja v a 2 s  . c om
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, 0.0);
        Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM,
                90.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.CENTER_RIGHT, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.CENTER_RIGHT, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM,
                -90.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM,
                180.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor());
    }

    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, 0.0);
        Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.CENTER_RIGHT, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.CENTER_RIGHT, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT,
                90.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT,
                -90.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT,
                180.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor());
    }

    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.TOP, 0.0);
        Assert.assertEquals(RectangleAnchor.BOTTOM, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.TOP,
                90.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.BOTTOM, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor());
    }

    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.RIGHT, 0.0);
        Assert.assertEquals(RectangleAnchor.LEFT, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor());
    }
    {
        CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.RIGHT,
                90.0 * Math.PI / 180.0);
        Assert.assertEquals(RectangleAnchor.LEFT, c.getCategoryAnchor());
        Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor());
        Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor());
    }
}

From source file:nl.vu.nat.jfreechartcustom.XYBlockRenderer.java

/**
 * Updates the offsets to take into account the block width, height and
 * anchor./*  ww  w  .j ava2s .c o m*/
 */
private void updateOffsets() {
    if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
        this.xOffset = 0.0;
        this.yOffset = 0.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) {
        this.xOffset = -this.blockWidth / 2.0;
        this.yOffset = 0.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
        this.xOffset = -this.blockWidth;
        this.yOffset = 0.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) {
        this.xOffset = 0.0;
        this.yOffset = -this.blockHeight / 2.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) {
        this.xOffset = -this.blockWidth / 2.0;
        this.yOffset = -this.blockHeight / 2.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) {
        this.xOffset = -this.blockWidth;
        this.yOffset = -this.blockHeight / 2.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) {
        this.xOffset = 0.0;
        this.yOffset = -this.blockHeight;
    } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) {
        this.xOffset = -this.blockWidth / 2.0;
        this.yOffset = -this.blockHeight;
    } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) {
        this.xOffset = -this.blockWidth;
        this.yOffset = -this.blockHeight;
    }
}

From source file:anl.verdi.plot.jfree.XYBlockRenderer.java

/**
 * Updates the offsets to take into account the block width, height and
 * anchor./*from  ww w. j  a v a  2s.c om*/
 */
private void updateOffsets() {
    if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
        xOffset = 0.0;
        yOffset = 0.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) {
        xOffset = -this.blockWidth / 2.0;
        yOffset = 0.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
        xOffset = -this.blockWidth;
        yOffset = 0.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) {
        xOffset = 0.0;
        yOffset = -this.blockHeight / 2.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) {
        xOffset = -this.blockWidth / 2.0;
        yOffset = -this.blockHeight / 2.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) {
        xOffset = -this.blockWidth;
        yOffset = -this.blockHeight / 2.0;
    } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) {
        xOffset = 0.0;
        yOffset = -this.blockHeight;
    } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) {
        xOffset = -this.blockWidth / 2.0;
        yOffset = -this.blockHeight;
    } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) {
        xOffset = -this.blockWidth;
        yOffset = -this.blockHeight;
    }
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void prepareJFreeBarChart(JFreeChart jfchart, List<PropertyBook> listOfPropertties,
        CategoryDataset categoryModel) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    categoryPlot.getRangeAxis().resizeRange(1.2);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(false);
    for (int i = 0; i < listOfPropertties.size(); i++) {
        renderer.setSeriesStroke(i, new BasicStroke(1));
    }//from ww w.j  a va2 s . com
    for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) {
        String label = (String) categoryModel.getColumnKey(i);
        CategoryMarker marker = new CategoryMarker(label);
        marker.setLabel("");
        marker.setPaint(Color.cyan);
        marker.setOutlinePaint(Color.cyan);
        marker.setAlpha(0.1f);
        marker.setLabelAnchor(RectangleAnchor.TOP);
        marker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
        marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
        categoryPlot.addDomainMarker(marker, Layer.BACKGROUND);
    }
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setItemMargin(.1);
    renderer.setBarPainter(new StandardBarPainter());

}

From source file:org.jajuk.ui.views.StatView.java

/**
 * Collection size bars./*from   ww  w  . jav a 2 s. c  o  m*/
 * 
 * @return the chart
 */
private ChartPanel createCollectionSize() {
    try {
        final DateFormat additionFormatter = UtilString.getAdditionDateFormatter();
        CategoryDataset cdata = null;
        JFreeChart jfchart = null;
        int iMonthsNumber = 5; // number of mounts we show, mounts
        // before are set together in 'before'
        long lSizeByMonth[] = new long[iMonthsNumber + 1];
        // contains size ( in Go ) for each month, first cell is before
        // data
        int[] iMonths = getMonths(iMonthsNumber);
        ReadOnlyIterator<Track> tracks = TrackManager.getInstance().getTracksIterator();
        while (tracks.hasNext()) {
            Track track = tracks.next();
            int i = Integer.parseInt(additionFormatter.format(track.getDiscoveryDate())) / 100;
            for (int j = 0; j < iMonthsNumber + 1; j++) {
                if (i <= iMonths[j]) {
                    lSizeByMonth[j] += track.getTotalSize();
                }
            }
        }
        double[][] data = new double[1][iMonthsNumber + 1];
        for (int i = 0; i < iMonthsNumber + 1; i++) {
            data[0][i] = (double) lSizeByMonth[i] / 1073741824;
        }
        cdata = DatasetUtilities.createCategoryDataset(new String[] { "" }, getMonthsLabels(iMonthsNumber),
                data);
        // chart, use local copy of method to use better format string for
        // tooltips
        jfchart = createBarChart3D(Messages.getString("StatView.7"), // chart
                // title
                Messages.getString("StatView.8"), // domain axis label
                Messages.getString("StatView.9"), // range axis label
                cdata, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips
                false, // urls
                "{1} = {2} GB");
        CategoryPlot plot = jfchart.getCategoryPlot();
        CategoryAxis axis = plot.getDomainAxis();
        new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT,
                -Math.PI / 8.0, CategoryLabelWidthType.CATEGORY, 0);
        axis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
        // set the background color for the chart...
        plot.setNoDataMessage(Messages.getString("StatView.10"));
        plot.setForegroundAlpha(0.5f);
        plot.setBackgroundAlpha(0.5f);
        // plot.setBackgroundImage(IconLoader.IMAGES_STAT_PAPER).getImage());
        return new ChartPanel(jfchart);
    } catch (Exception e) {
        Log.error(e);
        return null;
    }
}