Example usage for org.jfree.chart.renderer.xy XYBarRenderer setBaseItemLabelsVisible

List of usage examples for org.jfree.chart.renderer.xy XYBarRenderer setBaseItemLabelsVisible

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYBarRenderer setBaseItemLabelsVisible.

Prototype

public void setBaseItemLabelsVisible(boolean visible) 

Source Link

Document

Sets the base flag that controls whether or not item labels are visible, and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:pisco.batch.visu.BatchingChartFactory.java

public static XYPlot createLatenessPlot(Batch[] batches) {
    final Paint[] palette = makePalette(batches.length);
    XYBarRenderer renderer = new XYBarRendererPaletteBySeries(palette);
    renderer.setUseYInterval(true);//  www.  ja  v a 2 s. c o m
    renderer.setDrawBarOutline(true);
    final LatenessLabelToolTipGenerator bpg = new LatenessLabelToolTipGenerator(batches);
    renderer.setBaseItemLabelGenerator(bpg);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseToolTipGenerator(bpg);
    renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    XYPlot plot = new XYPlot(createLatenessDataset(batches), null, createIntegerAxis("Batches"), renderer);
    plot.setRangeGridlinesVisible(false);
    makeDueDateMarkers(plot, batches, palette);
    return plot;
}

From source file:pisco.batch.visu.BatchingChartFactory.java

public static XYPlot createBatchPlot(Batch[] batches, int capacity) {
    final XYBarRenderer renderer = new StackedXYBarRendererPaletteByItems(makePalette(batches.length));
    renderer.setShadowVisible(false);//from ww  w  .j av  a  2s. co  m
    renderer.setShadowXOffset(0);
    renderer.setDrawBarOutline(true);
    renderer.setBaseOutlineStroke(new BasicStroke(2));
    final BatchLabelToolTipGenerator lpg = new BatchLabelToolTipGenerator();
    renderer.setBaseItemLabelGenerator(lpg);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseToolTipGenerator(lpg);
    XYPlot plot = new XYPlot(new BatchProcessingDataset(batches), null, createIntegerAxis("Load"), renderer);

    if (capacity > 0) {
        Marker capaMarker = createCapacityMarker(capacity, "Capacity", B_RED);
        plot.addRangeMarker(0, capaMarker, Layer.FOREGROUND);
    }
    return plot;
}

From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java

public static JFreeChart createBlockingBarChart(String title, HistogramDataset dataset) {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart chart = ChartFactory.createHistogram(null, title, "Key frequency", dataset, //$NON-NLS-1$
            PlotOrientation.VERTICAL, false, true, false);

    XYPlot plot = chart.getXYPlot();//from  ww w  . j  a va2 s  .  com
    plot.getRangeAxis().setUpperMargin(0.08);
    // plot.getRangeAxis().setLowerBound(-0.08);
    decorateCategoryPlot(chart);
    plot.setRangeGridlinesVisible(true);

    XYBarRenderer renderer = new XYBarRenderer() {

        private static final long serialVersionUID = 4168794048090452033L;

        @Override
        public Paint getItemPaint(int row, int column) {
            return ChartDecorator.COLOR_LIST.get(0);
        }
    };
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setBaseNegativeItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setShadowVisible(Boolean.FALSE);
    plot.setRenderer(renderer);

    return chart;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createHistogramChart(String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset) {
    JFreeChart jfreechart = ChartFactory.createHistogram(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(null);// ww w  .j  a v  a 2  s  . c  o m
    xyplot.setOutlinePaint(null);
    xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);
    NumberAxis yAxis = (NumberAxis) xyplot.getRangeAxis();
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setLabelFont(UIConstants.H5_FONT);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xyplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT);
    xyplot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelFont(UIConstants.H5_FONT);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    return jfreechart;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createPlainHistoryChart(IntervalXYDataset dataset,
        XYItemLabelGenerator labelGenerator) {
    if (dataset == null) {
        throw new IllegalArgumentException("No dataset.");
    }//from ww w  .jav a 2s.  c  o  m

    JFreeChart jfreechart = ChartFactory.createXYBarChart(null, null, true, null, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(null);
    xyplot.setOutlinePaint(null);
    XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    if (labelGenerator != null) {
        renderer.setBaseItemLabelGenerator(labelGenerator);
    }
    renderer.setBaseItemLabelFont(UIConstants.H4_FONT);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    // xyplot.getDomainAxis().setVisible(false);
    xyplot.getDomainAxis().setAxisLineVisible(true);
    xyplot.getDomainAxis().setTickLabelsVisible(false);
    NumberAxis axis = (NumberAxis) xyplot.getRangeAxis();
    axis.setRangeType(RangeType.POSITIVE);
    axis.setVisible(false);
    return jfreechart;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createXYBarChart(String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset,
        XYItemLabelGenerator labelGenerator) {
    if (dataset == null) {
        throw new IllegalArgumentException("No dataset.");
    }/*from   w  w w .  j  ava2  s .  c  o m*/

    JFreeChart jfreechart = ChartFactory.createXYBarChart(null, xAxisLabel, false, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(null);
    xyplot.setOutlinePaint(null);
    xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);

    NumberAxis axis = (NumberAxis) xyplot.getRangeAxis();
    axis.setRangeType(RangeType.POSITIVE);
    axis.setLabelFont(UIConstants.H5_FONT);
    xyplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT);
    XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    if (labelGenerator != null) {
        renderer.setBaseItemLabelGenerator(labelGenerator);
    }
    renderer.setBaseItemLabelFont(UIConstants.H5_FONT);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    return jfreechart;
}

From source file:com.signalcollect.sna.gephiconnectors.SignalCollectGephiConnector.java

/**
 * Creates the Chart of the Degree Distribution according to the calculated
 * distribution//  ww  w. ja  v  a  2 s  .com
 * 
 * @param degreeDistribution
 * @return a {@link JFreeChart} containing the distribution of degrees in
 *         the graph
 * @throws IOException
 */
public JFreeChart createDegreeDistributionChart(Map<Integer, Integer> degreeDistribution) throws IOException {
    XYSeries dSeries = new XYSeries("number of occurences");
    for (Iterator it = degreeDistribution.entrySet().iterator(); it.hasNext();) {
        Map.Entry d = (Map.Entry) it.next();
        Number x = (Number) d.getKey();
        Number y = (Number) d.getValue();
        dSeries.add(x, y);
    }
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    dataset.setAutoWidth(true);

    JFreeChart chart = ChartFactory.createHistogram("Degree Distribution", "Degree centrality value",
            "number of occurences", dataset, PlotOrientation.VERTICAL, true, true, true);

    XYPlot plot = chart.getXYPlot();
    XYBarRenderer renderer0 = new XYBarRenderer();
    Font font = new Font("Font", 0, 14);
    renderer0.setMargin(0.2);
    renderer0.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer0.setBaseItemLabelsVisible(true);
    renderer0.setBaseItemLabelFont(font);
    plot.setDataset(0, dataset);
    plot.setRenderer(0, renderer0);
    plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(0, Color.BLUE);
    return chart;
}

From source file:com.signalcollect.sna.gephiconnectors.SignalCollectGephiConnector.java

/**
 * Creates the Chart of the Clustering Distribution according to the
 * calculated distribution// www.  j a  v a 2 s .  co m
 * 
 * @param clusterDistribution
 * @return a {@link JFreeChart} containing the distribution of local cluster
 *         coefficients in the graph
 * @throws IOException
 */
public JFreeChart createClusterDistributionChart(Map<Double, Integer> clusterDistribution) throws IOException {
    XYSeries dSeries = new XYSeries("number of occurences");
    for (Iterator it = clusterDistribution.entrySet().iterator(); it.hasNext();) {
        Map.Entry d = (Map.Entry) it.next();
        Number x = (Number) d.getKey();
        Number y = (Number) d.getValue();
        dSeries.add(x, y);
    }
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(dSeries);
    dataset.setAutoWidth(true);

    JFreeChart chart = ChartFactory.createHistogram("Local Cluster Coefficient Distribution",
            "Local Cluster Coefficient value", "number of occurences", dataset, PlotOrientation.VERTICAL, true,
            true, true);

    XYPlot plot = chart.getXYPlot();
    XYBarRenderer renderer0 = new XYBarRenderer();
    Font font = new Font("Font", 0, 14);
    renderer0.setMargin(0.2);
    renderer0.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer0.setBaseItemLabelsVisible(true);
    renderer0.setBaseItemLabelFont(font);
    plot.setDataset(0, dataset);
    plot.setRenderer(0, renderer0);

    plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(0, Color.BLUE);

    return chart;
}

From source file:de.fub.maps.project.detector.model.statistics.HistogramPanel.java

/**
 * Creates new form histogramPanel/* w w  w  .j  a  v  a2 s.c o m*/
 */
public HistogramPanel() {
    initComponents();
    histogramChart = ChartFactory.createHistogram(null, null, null, dataSet, PlotOrientation.VERTICAL, false,
            true, true);
    plot = histogramChart.getXYPlot();
    chartPanel = new ChartPanel(histogramChart, true);
    add(chartPanel, BorderLayout.CENTER);
    XYBarRenderer barRenderer = new XYBarRenderer(.05);
    barRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    barRenderer.setBarPainter(new StandardXYBarPainter());
    barRenderer.setBarAlignmentFactor(.1);
    barRenderer.setBasePaint(Color.blue);
    //        barRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    barRenderer.setBaseItemLabelGenerator(
            new StandardXYItemLabelGenerator(StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT,
                    new CustomNumberFormat(), new CustomNumberFormat()));
    barRenderer.setBaseItemLabelsVisible(true);
    plot.setRenderer(barRenderer);
    plot.setBackgroundPaint(Color.white);
    histogramChart.setBackgroundPaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    chartPanel.setVerticalAxisTrace(false);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setBackground(Color.white);
}

From source file:it.cnr.istc.iloc.gui.StateVariableVisualizer.java

@Override
public Collection<XYPlot> getPlots(Type type) {
    Collection<IItem> instances = type.getInstances();
    Collection<XYPlot> plots = new ArrayList<>(instances.size());
    Map<IItem, Collection<Atom>> sv_atoms = new IdentityHashMap<>(instances.size());
    for (IItem i : type.getInstances()) {
        sv_atoms.put(i, new ArrayList<>());
    }/*w w  w  . ja v  a 2s . c  o m*/
    for (Atom atom : ((StateVariable) type).getDefinedPredicates().stream()
            .flatMap(p -> p.getInstances().stream()).map(a -> (Atom) a)
            .filter(a -> a.state.evaluate().isSingleton() && a.state.evaluate().contains(AtomState.Active))
            .collect(Collectors.toList())) {
        for (IItem i : ((IEnumItem) atom.get(SCOPE)).getEnumVar().evaluate().getAllowedValues()) {
            if (sv_atoms.containsKey(i)) {
                sv_atoms.get(i).add(atom);
            }
        }
    }

    for (IItem sv : instances) {
        Collection<Atom> atoms = sv_atoms.get(sv);
        // For each pulse the atoms starting at that pulse
        Map<Double, Collection<Atom>> starting_atoms = new HashMap<>(atoms.size());
        // For each pulse the atoms ending at that pulse
        Map<Double, Collection<Atom>> ending_atoms = new HashMap<>(atoms.size());

        // The pulses of the timeline
        Set<Double> c_pulses = new HashSet<>(atoms.size() * 2);

        for (Atom atom : atoms) {
            double start = sv.getCore().evaluate(((IArithItem) atom.get("start")).getArithVar());
            double end = sv.getCore().evaluate(((IArithItem) atom.get("end")).getArithVar());

            if (!starting_atoms.containsKey(start)) {
                starting_atoms.put(start, new ArrayList<>());
            }
            starting_atoms.get(start).add(atom);

            if (!ending_atoms.containsKey(end)) {
                ending_atoms.put(end, new ArrayList<>());
            }
            ending_atoms.get(end).add(atom);

            c_pulses.add(start);
            c_pulses.add(end);
        }

        // we sort current pulses..
        Double[] c_pulses_array = c_pulses.toArray(new Double[c_pulses.size()]);
        Arrays.sort(c_pulses_array);

        XYIntervalSeriesCollection collection = new XYIntervalSeriesCollection();

        ValueXYIntervalSeries undefined = new ValueXYIntervalSeries("Undefined");
        ValueXYIntervalSeries sv_values = new ValueXYIntervalSeries("Values");
        ValueXYIntervalSeries conflicts = new ValueXYIntervalSeries("Conflicts");

        List<Atom> overlapping_atoms = new ArrayList<>();
        for (int i = 0; i < c_pulses_array.length - 1; i++) {
            if (starting_atoms.containsKey(c_pulses_array[i])) {
                overlapping_atoms.addAll(starting_atoms.get(c_pulses_array[i]));
            }
            if (ending_atoms.containsKey(c_pulses_array[i])) {
                overlapping_atoms.removeAll(ending_atoms.get(c_pulses_array[i]));
            }
            switch (overlapping_atoms.size()) {
            case 0:
                undefined.add(c_pulses_array[i], c_pulses_array[i], c_pulses_array[i + 1], 0, 0, 1,
                        new Atom[0]);
                break;
            case 1:
                sv_values.add(c_pulses_array[i], c_pulses_array[i], c_pulses_array[i + 1], 0, 0, 1,
                        overlapping_atoms.toArray(new Atom[overlapping_atoms.size()]));
                break;
            default:
                conflicts.add(c_pulses_array[i], c_pulses_array[i], c_pulses_array[i + 1], 0, 0, 1,
                        overlapping_atoms.toArray(new Atom[overlapping_atoms.size()]));
                break;
            }
        }

        collection.addSeries(undefined);
        collection.addSeries(sv_values);
        collection.addSeries(conflicts);

        XYBarRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.lightGray);
        renderer.setSeriesPaint(1, new Color(100, 250, 100));
        renderer.setSeriesPaint(2, Color.pink);
        renderer.setBarPainter(new ReverseGradientXYBarPainter());
        renderer.setDrawBarOutline(true);
        renderer.setShadowXOffset(2);
        renderer.setShadowYOffset(2);
        renderer.setUseYInterval(true);

        renderer.setBaseItemLabelsVisible(true);
        renderer.setBaseItemLabelPaint(Color.black);
        Font font = new Font("SansSerif", Font.PLAIN, 9);
        renderer.setBaseItemLabelFont(font);
        XYItemLabelGenerator generator = (XYDataset dataset, int series,
                int item) -> toString(((ValueXYIntervalDataItem) ((XYIntervalSeriesCollection) dataset)
                        .getSeries(series).getDataItem(item)).atoms);
        ItemLabelPosition itLabPos = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER);
        renderer.setBasePositiveItemLabelPosition(itLabPos);
        for (int i = 0; i < collection.getSeriesCount(); i++) {
            renderer.setSeriesItemLabelGenerator(i, generator);
            renderer.setSeriesItemLabelsVisible(i, true);
            renderer.setSeriesItemLabelPaint(i, Color.black);
            renderer.setSeriesItemLabelFont(i, font);
            renderer.setSeriesPositiveItemLabelPosition(i, itLabPos);
            renderer.setSeriesToolTipGenerator(i,
                    (XYDataset dataset, int series, int item) -> toString(
                            ((ValueXYIntervalDataItem) ((XYIntervalSeriesCollection) dataset).getSeries(series)
                                    .getDataItem(item)).atoms));
        }

        XYPlot plot = new XYPlot(collection, null, new NumberAxis(""), renderer);
        plot.getRangeAxis().setVisible(false);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

        plots.add(plot);
    }

    return plots;
}