Example usage for org.jfree.chart.block LineBorder LineBorder

List of usage examples for org.jfree.chart.block LineBorder LineBorder

Introduction

In this page you can find the example usage for org.jfree.chart.block LineBorder LineBorder.

Prototype

public LineBorder() 

Source Link

Document

Creates a default border.

Usage

From source file:org.encog.workbench.tabs.visualize.scatter.LegendPanel.java

public LegendPanel(LegendItemSource source) {
    this.legend = new LegendTitle(source);
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    setPreferredSize(new Dimension(1024, 35));
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java

/**
 * Creates a legend item block.//from w ww .  j ava 2 s. com
 * 
 * @param item
 *            the legend item.
 * 
 * @return The block.
 */
protected void createLegendBlock(BlockContainer blockcontainerLabel) {

    XYPlot xyplot = (XYPlot) report.getPlot();

    int nbRenderer = xyplot.getDatasetCount();
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    if (nbRenderer > 1) {
        BlockContainer oldLegendBlockContainer = new BlockContainer(
                new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 2.0D, 2.0D));
        for (int i = 0; i < nbRenderer; i++) {
            LegendTitle legendtitle = new LegendTitle(xyplot.getRenderer(i));
            legendtitle.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
            legendtitle.setFrame(new LineBorder());
            legendtitle.setBackgroundPaint(ChartColor.WHITE);
            oldLegendBlockContainer.add(legendtitle);
        }

        blockcontainer.add(oldLegendBlockContainer, RectangleEdge.LEFT);
    } else {
        LegendTitle legendtitle = new LegendTitle(xyplot.getRenderer(0));
        legendtitle.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
        legendtitle.setFrame(new LineBorder());
        legendtitle.setBackgroundPaint(ChartColor.WHITE);
        blockcontainer.add(legendtitle, RectangleEdge.LEFT);
    }

    LegendTitle legendtitle1 = new LegendTitle(xyplot.getRenderer());
    legendtitle1.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legendtitle1.setFrame(new LineBorder());
    legendtitle1.setBackgroundPaint(ChartColor.WHITE);
    legendtitle1.setWrapper(blockcontainerLabel);

    blockcontainer.add(legendtitle1, RectangleEdge.RIGHT);
    blockcontainer.add(new EmptyBlock(1000D, 0.0D));

    CompositeTitle compositetitle = new CompositeTitle(blockcontainer);
    compositetitle.setPosition(RectangleEdge.BOTTOM);
    report.clearSubtitles();
    report.addSubtitle(compositetitle);
}

From source file:ecosim.gui.SummaryPane.java

/**
 *  Private method to build the binning chart.
 *
 *  @return A ChartPanel containing the binning chart.
 *//*  www . j  a  v  a 2s  .co  m*/
private ChartPanel makeBinningChart() {
    final DefaultXYDataset binData = new DefaultXYDataset();
    final NumberFormat nf = NumberFormat.getInstance();
    final NumberAxis xAxis = new NumberAxis("Sequence identity criterion");
    nf.setMinimumFractionDigits(2);
    xAxis.setLowerBound(Binning.binLevels[0]);
    xAxis.setUpperBound(1.0D);
    xAxis.setTickUnit(new NumberTickUnit(0.05D, nf));
    LogAxis yAxis = new LogAxis("Number of bins");
    yAxis.setBase(2.0D);
    yAxis.setNumberFormatOverride(NumberFormat.getInstance());
    yAxis.setTickUnit(new NumberTickUnit(2.0D));
    yAxis.setMinorTickMarksVisible(true);
    yAxis.setAutoRangeMinimumSize(4.0D);
    yAxis.setSmallestValue(1.0D);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    for (int i = 0; i < seriesColors.length; i++) {
        renderer.setSeriesPaint(i, seriesColors[i]);
        renderer.setSeriesStroke(i, new BasicStroke(seriesStroke[i]));
    }
    XYPlot plot = new XYPlot(binData, xAxis, yAxis, renderer);
    JFreeChart binChart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    binChart.setPadding(new RectangleInsets(0.0D, 0.0D, 0.0D, 10.0D));
    LegendTitle legend = new LegendTitle(plot);
    legend.setMargin(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    plot.addAnnotation(new XYTitleAnnotation(0.001D, 0.999D, legend, RectangleAnchor.TOP_LEFT));
    final ChartPanel pane = new ChartPanel(binChart, false, true, true, false, false);
    // Watch for changes to the Summary object.
    summary.addObserver(new Observer() {
        public void update(Observable o, Object obj) {
            Summary s = (Summary) obj;
            ParameterEstimate estimate = s.getEstimate();
            ArrayList<BinLevel> bins = s.getBins();
            if (bins.size() > 0) {
                double[][] values = new double[2][bins.size()];
                Double low = 1.0d;
                for (int i = 0; i < bins.size(); i++) {
                    BinLevel bin = bins.get(i);
                    values[0][i] = bin.getCrit();
                    values[1][i] = bin.getLevel();
                    if (values[0][i] < low)
                        low = values[0][i];
                }
                binData.addSeries("sequences", values);
                xAxis.setLowerBound(low);
                if (low > 0.95d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.005D, nf));
                } else if (low > 0.90d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.010D, nf));
                } else if (low > 0.80d - MasterVariables.EPSILON) {
                    xAxis.setTickUnit(new NumberTickUnit(0.025D, nf));
                }
                if (estimate != null) {
                    double[][] omega = new double[2][bins.size()];
                    double[][] sigma = new double[2][bins.size()];
                    double[] omegaLine = estimate.getOmega();
                    double[] sigmaLine = estimate.getSigma();
                    for (int i = 0; i < bins.size(); i++) {
                        double crit = 1.0D - values[0][i];
                        double snp = s.getLength() * crit;
                        omega[0][i] = values[0][i];
                        sigma[0][i] = values[0][i];
                        omega[1][i] = Math.pow(2.0D, snp * omegaLine[0] + omegaLine[1]);
                        sigma[1][i] = Math.pow(2.0D, snp * sigmaLine[0] + sigmaLine[1]);
                    }
                    if (-1.0D * omegaLine[0] > MasterVariables.EPSILON) {
                        binData.addSeries("omega", omega);
                    }
                    if (-1.0D * sigmaLine[0] > MasterVariables.EPSILON) {
                        binData.addSeries("sigma", sigma);
                    }
                }
                // Repaint the summary pane.
                pane.repaint();
            }
        }
    });
    return pane;
}

From source file:ec.nbdemetra.ui.chart3d.functions.Functions2DChart.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    plot.setDataset(0, Charts.emptyXYDataset());
    plot.setRenderer(0, functionRenderer);
    plot.mapDatasetToDomainAxis(0, 0);//from w w  w.  j av a  2 s  .c o  m
    plot.mapDatasetToRangeAxis(0, 0);

    plot.setDataset(1, Charts.emptyXYDataset());
    plot.setRenderer(1, optimumRenderer);
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false);

    LegendTitle legend = new LegendTitle(result.getPlot());
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    result.addLegend(legend);

    result.setPadding(TsCharts.CHART_PADDING);
    return result;
}

From source file:com.hmsinc.epicenter.webapp.chart.ChartService.java

/**
 * @param chart/*from w w  w .  ja  v a2s.  co m*/
 * @return
 */
private static void configureTitleAndLegend(final JFreeChart chart, final AbstractChart adapter) {

    final TextTitle title = chart.getTitle();
    if (title != null) {
        title.setFont(new Font("Arial", Font.BOLD, 12));
        // title.setBackgroundPaint(Color.CYAN);
        title.setTextAlignment(HorizontalAlignment.LEFT);
        title.setHorizontalAlignment(HorizontalAlignment.CENTER);
        title.setMargin(0, 4, 5, 6);
    }

    if (chart.getLegend() != null) {
        chart.removeLegend();

        final LegendTitle legend = new LegendTitle(chart.getPlot(), new SNColumnArrangement(0, 0),
                new ColumnArrangement(HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 0, 0));

        legend.setItemFont(LEGEND_FONT);
        legend.setPosition(RectangleEdge.BOTTOM);
        legend.setHorizontalAlignment(HorizontalAlignment.CENTER);
        legend.setBackgroundPaint(Color.WHITE);
        legend.setFrame(new LineBorder());
        legend.setMargin(0, 4, 5, 6);

        chart.addLegend(legend);

        // Now we'll try to remove any duplicate items from the legend..
        final Map<String, Integer> keys = new HashMap<String, Integer>();
        final LegendItemCollection items = new LegendItemCollection();

        for (LegendItemSource source : legend.getSources()) {

            for (int i = 0; i < source.getLegendItems().getItemCount(); i++) {

                final LegendItem item = source.getLegendItems().get(i);
                if (!keys.containsKey(item.getLabel())) {
                    keys.put(item.getLabel(), i);
                    items.add(item);
                }
            }
        }

        legend.setSources(new LegendItemSource[] { new LegendItemSource() {

            /*
             * (non-Javadoc)
             * 
             * @see org.jfree.chart.LegendItemSource#getLegendItems()
             */
            public LegendItemCollection getLegendItems() {
                return items;
            }

        } });
    }
}

From source file:org.martus.client.swingui.actions.ActionMenuCharts.java

private LegendTitle createLegend(JFreeChart chart) {
    LegendTitle legend = new LegendTitle(chart.getPlot());
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    legend.addChangeListener(chart);//w w  w  . j  ava 2s .  c  o  m
    legend.setItemFont(FontHandler.getDefaultFont());
    return legend;
}

From source file:MWC.GUI.JFreeChart.NewFormattedJFreeChart.java

public void setShowLegend(final boolean showLegend) {
    if (showLegend) {
        if (!isShowLegend()) {
            LegendTitle legend = new LegendTitle(getPlot());
            legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
            legend.setFrame(new LineBorder());
            legend.setBackgroundPaint(Color.white);
            legend.setPosition(RectangleEdge.BOTTOM);
            addLegend(legend);//from  w w w  .  j a va 2  s  . c  om
        }
    } else {
        if (isShowLegend()) {
            removeLegend();
        }
    }

    this.fireChartChanged();
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.LinePlot.java

@Override
protected void update() {
    XYDataset dataset = null;/*  ww  w  . ja  va 2 s . c o m*/

    //generate the plot data
    if (controller.getShowIndividualTraces()) {
        dataset = new DefaultTableXYDataset();

        for (ResultKey key : frame.getSelectedResults()) {
            generateIndividualSeries(key, (DefaultTableXYDataset) dataset);
        }
    } else {
        dataset = new YIntervalSeriesCollection();

        for (ResultKey key : frame.getSelectedResults()) {
            generateQuantileSeries(key, (YIntervalSeriesCollection) dataset);
        }
    }

    //create the chart
    JFreeChart chart = ChartFactory.createXYLineChart(metric, localization.getString("text.NFE"),
            localization.getString("text.value"), dataset, PlotOrientation.VERTICAL, false, true, false);
    final XYPlot plot = chart.getXYPlot();

    //setup the series renderer
    if (controller.getShowIndividualTraces()) {
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i));

            renderer.setSeriesStroke(i, new BasicStroke(1f, 1, 1));
            renderer.setSeriesPaint(i, paint);
        }

        plot.setRenderer(renderer);
    } else {
        DeviationRenderer renderer = new DeviationRenderer(true, false);

        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i));

            renderer.setSeriesStroke(i, new BasicStroke(3f, 1, 1));
            renderer.setSeriesPaint(i, paint);
            renderer.setSeriesFillPaint(i, paint);
        }

        plot.setRenderer(renderer);
    }

    //create the legend
    final LegendItemCollection items = plot.getLegendItems();
    Iterator<?> iterator = items.iterator();
    Set<ResultKey> uniqueKeys = new HashSet<ResultKey>();

    while (iterator.hasNext()) {
        LegendItem item = (LegendItem) iterator.next();

        if (uniqueKeys.contains(item.getSeriesKey())) {
            iterator.remove();
        } else {
            uniqueKeys.add((ResultKey) item.getSeriesKey());
        }
    }

    LegendItemSource source = new LegendItemSource() {

        @Override
        public LegendItemCollection getLegendItems() {
            return items;
        }

    };

    LegendTitle legend = new LegendTitle(source);
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.WHITE);
    legend.setPosition(RectangleEdge.BOTTOM);
    chart.addLegend(legend);

    //scale the axes
    final NumberAxis domainAxis = new NumberAxis();
    domainAxis.setAutoRange(true);
    plot.setDomainAxis(domainAxis);

    //add overlay
    if (controller.getShowLastTrace() && !controller.getShowIndividualTraces()
            && (controller.getLastAccumulator() != null)
            && controller.getLastAccumulator().keySet().contains(metric)) {
        DefaultTableXYDataset dataset2 = new DefaultTableXYDataset();
        XYSeries series = new XYSeries(localization.getString("text.last"), false, false);

        for (int i = 0; i < controller.getLastAccumulator().size(metric); i++) {
            series.add((Number) controller.getLastAccumulator().get("NFE", i),
                    (Number) controller.getLastAccumulator().get(metric, i));
        }

        dataset2.addSeries(series);

        XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
        renderer2.setSeriesStroke(0, new BasicStroke(1f, 1, 1));
        renderer2.setSeriesPaint(0, Color.BLACK);

        plot.setDataset(1, dataset2);
        plot.setRenderer(1, renderer2);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    //update the chart in the GUI
    removeAll();
    add(new ChartPanel(chart), BorderLayout.CENTER);
    revalidate();
    repaint();
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setLegendStyles(JFreeChart chart, UIChart comp) {
    Boolean showLegend = comp.getShowLegend();
    if (showLegend != null && !showLegend) {
        return;//ww  w  . j  a  va 2 s.co  m
    }

    UILegend legendcomp = comp.getLegend();
    if (legendcomp == null) {
        if (showLegend != null && showLegend) {
            // Create default legend
            LegendTitle legend = new LegendTitle(chart.getPlot());
            legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
            legend.setFrame(new LineBorder());
            legend.setBackgroundPaint(Color.white);
            legend.setPosition(RectangleEdge.BOTTOM);
            chart.addSubtitle(legend);
        }
    } else {
        chart.addSubtitle(createLegend(chart, legendcomp));
    }
}

From source file:SciTK.Plot.java

/** 
 * Set the legend status/*from   w  ww  . j ava  2 s . co  m*/
 * @param enabled true enables legend display, false disables
 */
public void setLegend(boolean enabled) {
    // action taken depends on enabled boolean:
    if (enabled) {
        chart.addLegend(new LegendTitle(chart.getPlot()));
        chart.getLegend().setBackgroundPaint(Color.WHITE);
        chart.getLegend().setFrame(new LineBorder());
    } else {
        chart.removeLegend();
    }
}