Example usage for org.jfree.chart.plot DefaultDrawingSupplier DEFAULT_SHAPE_SEQUENCE

List of usage examples for org.jfree.chart.plot DefaultDrawingSupplier DEFAULT_SHAPE_SEQUENCE

Introduction

In this page you can find the example usage for org.jfree.chart.plot DefaultDrawingSupplier DEFAULT_SHAPE_SEQUENCE.

Prototype

Shape[] DEFAULT_SHAPE_SEQUENCE

To view the source code for org.jfree.chart.plot DefaultDrawingSupplier DEFAULT_SHAPE_SEQUENCE.

Click Source Link

Document

The default shape sequence.

Usage

From source file:org.matsim.contrib.dvrp.util.chart.RouteChartUtils.java

public static JFreeChart chartRoutesByStatus(List<? extends Vehicle> vehicles) {
    CoordDataset nData = new CoordDataset();

    for (int i = 0; i < vehicles.size(); i++) {
        Schedule<?> schedule = vehicles.get(i).getSchedule();
        Map<TaskStatus, CoordSource> vsByStatus = createLinkSourceByStatus(schedule);
        nData.addSeries(i + "-PR", vsByStatus.get(TaskStatus.PERFORMED));
        nData.addSeries(i + "-ST", vsByStatus.get(TaskStatus.STARTED));
        nData.addSeries(i + "-PL", vsByStatus.get(TaskStatus.PLANNED));
    }//w w  w.ja  v a  2  s .co  m

    JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", nData, PlotOrientation.VERTICAL,
            false, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setBackgroundPaint(Color.white);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesItemLabelsVisible(0, true);

    renderer.setBaseItemLabelGenerator(new LabelGenerator());

    Paint[] paints = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE;
    Shape[] shapes = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE;

    for (int i = 0; i < vehicles.size(); i++) {
        int s = 3 * i;

        renderer.setSeriesItemLabelsVisible(s + 1, true);
        renderer.setSeriesItemLabelsVisible(s + 2, true);
        renderer.setSeriesItemLabelsVisible(s + 3, true);

        renderer.setSeriesShapesVisible(s + 1, true);
        renderer.setSeriesShapesVisible(s + 2, true);
        renderer.setSeriesShapesVisible(s + 3, true);

        renderer.setSeriesLinesVisible(s + 1, true);
        renderer.setSeriesLinesVisible(s + 2, true);
        renderer.setSeriesLinesVisible(s + 3, true);

        renderer.setSeriesPaint(s + 1, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 2, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 3, paints[(i + 1) % paints.length]);

        renderer.setSeriesShape(s + 1, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 2, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 3, shapes[(i + 1) % shapes.length]);

        renderer.setSeriesStroke(s + 2, new BasicStroke(3));
        renderer.setSeriesStroke(s + 3, new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1,
                new float[] { 5f, 5f }, 0));
    }

    return chart;
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartFactory.java

public static JFreeChart createDiveProfileChartPanel(DiveProfile diveProfile, Locale locale,
        LengthUnit lengthUnit) {//from  w w  w . j a  v a2s  . c om
    XYSeries depthSerie = new XYSeries(SERIE_DEPTH);
    XYSeriesCollection depthCollection = new XYSeriesCollection();
    depthCollection.addSeries(depthSerie);

    JFreeChart chart = ChartFactory.createXYAreaChart(null, getDomainLegend(locale),
            getRangeLegend(locale, lengthUnit), depthCollection, PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyp = chart.getXYPlot();

    Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f,
            UIAgent.getInstance().getColorWaterSurface(), false);
    xyp.setBackgroundPaint(p);
    xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid());
    xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid());
    ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat());

    XYAreaRenderer renderer0 = new XYAreaRenderer();
    renderer0.setOutline(true);
    renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom());

    Color baseColor = UIAgent.getInstance().getColorBaseBackground();
    renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50));
    xyp.setRenderer(0, renderer0);

    int i = 1;

    XYSeriesCollection decoEntriesCollection = new XYSeriesCollection();
    XYSeries decoEntriesSerie = new XYSeries(SERIE_DECO_ENTRY);
    decoEntriesCollection.addSeries(decoEntriesSerie);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorDecoEntries());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_ENTRY]);
    xyp.setDataset(i, decoEntriesCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection ascentTooFastCollection = new XYSeriesCollection();
    XYSeries ascentTooFastSerie = new XYSeries(SERIE_WARNING_ASCENT_TOO_FAST);
    ascentTooFastCollection.addSeries(ascentTooFastSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningAscentTooFast());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_ASCENT_TOO_FAST_WARNING]);
    xyp.setDataset(i, ascentTooFastCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection decoWarningCollection = new XYSeriesCollection();
    XYSeries decoWarningSerie = new XYSeries(SERIE_DECO_STOP);
    decoWarningCollection.addSeries(decoWarningSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningDecoCeiling());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_WARNING]);
    xyp.setDataset(i, decoWarningCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection remainBottomTimeCollection = new XYSeriesCollection();
    XYSeries remainBottomTimeSerie = new XYSeries(SERIE_REMAINING_BOTTOM_TIME);
    remainBottomTimeCollection.addSeries(remainBottomTimeSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningRemainingBottomTime());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_REMAINING_BOTTOM_TIME_WARNING]);
    xyp.setDataset(i, remainBottomTimeCollection);
    xyp.setRenderer(i, renderer2);

    Map<Double, Double> depthEntries = diveProfile.getDepthEntries();
    Set<Double> ascentWarning = diveProfile.getAscentWarnings();
    Set<Double> decoWarnings = diveProfile.getDecoCeilingWarnings();
    Set<Double> remainBottomTime = diveProfile.getRemainingBottomTimeWarnings();
    Set<Double> decoEntryTime = diveProfile.getDecoEntries();

    if (depthEntries.size() > 0 && depthEntries.get(0d) == null) {
        depthEntries.put(0d, 0d);
    }

    for (Double seconds : depthEntries.keySet()) {
        double d = UnitsAgent.getInstance().convertLengthFromModel(depthEntries.get(seconds), lengthUnit);
        depthSerie.add(seconds, Double.valueOf(d));
    }

    if (null != ascentWarning) {
        for (Double seconds : ascentWarning) {
            ascentTooFastSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != decoWarnings) {
        for (Double seconds : decoWarnings) {
            decoWarningSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != remainBottomTime) {
        for (Double seconds : remainBottomTime) {
            remainBottomTimeSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != decoEntryTime) {
        for (Double seconds : decoEntryTime) {
            decoEntriesSerie.add(seconds, depthEntries.get(seconds));
        }
    }
    return chart;
}

From source file:net.sourceforge.processdash.ui.lib.chart.DrawingSupplierFactory.java

public DrawingSupplierFactory() {
    this.paintSequence = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE;
    this.fillPaintSequence = DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE;
    this.outlinePaintSequence = DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE;
    this.strokeSequence = DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE;
    this.outlineStrokeSequence = DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE;
    this.shapeSequence = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE;
}

From source file:edu.scripps.fl.curves.plot.CurvePlot.java

protected void addCurve(Curve curve, YIntervalSeries validSeries, YIntervalSeries invalidSeries,
        FitFunction fitFunction, double min, double max) {
    MyXYErrorRenderer renderer = (MyXYErrorRenderer) plot.getRenderer();
    Paint paint = plot.getDrawingSupplier().getNextPaint();
    addSeries(validSeries, paint, true, true);
    if (isDisplayInvalidPoints() && invalidSeries.getItemCount() > 0) {
        int idx = addSeries(invalidSeries, paint, true, false);
        float size = (float) DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[0].getBounds().getWidth();
        DrawingSupplier ds = this.getDrawingSupplier();
        if (ds instanceof CurvePlotDrawingSupplier)
            size = (float) ((CurvePlotDrawingSupplier) ds).getShapeSize() / 2;
        size = (float) Math.floor((size - 1) / 2);
        renderer.setSeriesShape(idx, ShapeUtilities.createDiagonalCross(size, size));
    }/* w  ww.j  ava2s .c  o m*/
    if (null != fitFunction)
        try {
            YIntervalSeries functionSeries = sampleFunction2DToSeries(curve, fitFunction, min, max, getWidth(),
                    (Comparable<?>) (dataset.getSeriesCount() + 1));
            addSeries(functionSeries, paint, false, false);
        } catch (NullPointerException ex) {
            ex.printStackTrace();
        }
}

From source file:com.bitplan.vzjava.Plot.java

/**
 * Creates a chart./*  w w w .  java  2s .  co m*/
 * 
 * @param dataset
 *          a dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final ColoredDataSet cdataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "Time", "Power", cdataset.dataSet, true,
            true, false);

    chart.setBackgroundPaint(Color.white);

    // final StandardLegend sl = (StandardLegend) chart.getLegend();
    // sl.setDisplaySeriesShapes(true);

    final XYPlot plot = chart.getXYPlot();
    // plot.setOutlinePaint(null);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(false);

    final XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer) {
        renderer.setSeriesStroke(0, new BasicStroke(3.0f));
        renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    // http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/chart/plot/DefaultDrawingSupplier-source.html
    DrawingSupplier supplier = new DefaultDrawingSupplier(cdataset.paintSequence,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    chart.getPlot().setDrawingSupplier(supplier);
    return chart;
}

From source file:org.matsim.contrib.dvrp.util.chart.RouteCharts.java

public static JFreeChart chartRoutesByStatus(List<? extends Vehicle> vehicles) {
    CoordDataset nData = new CoordDataset();

    for (int i = 0; i < vehicles.size(); i++) {
        Schedule schedule = vehicles.get(i).getSchedule();
        Map<TaskStatus, CoordSource> vsByStatus = createLinkSourceByStatus(schedule);
        nData.addSeries(i + "-PR", vsByStatus.get(TaskStatus.PERFORMED));
        nData.addSeries(i + "-ST", vsByStatus.get(TaskStatus.STARTED));
        nData.addSeries(i + "-PL", vsByStatus.get(TaskStatus.PLANNED));
    }//from   w ww.  ja v  a  2 s.c om

    JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", nData, PlotOrientation.VERTICAL,
            false, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setBackgroundPaint(Color.white);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesItemLabelsVisible(0, true);

    renderer.setBaseItemLabelGenerator(new LabelGenerator());

    Paint[] paints = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE;
    Shape[] shapes = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE;

    for (int i = 0; i < vehicles.size(); i++) {
        int s = 3 * i;

        renderer.setSeriesItemLabelsVisible(s + 1, true);
        renderer.setSeriesItemLabelsVisible(s + 2, true);
        renderer.setSeriesItemLabelsVisible(s + 3, true);

        renderer.setSeriesShapesVisible(s + 1, true);
        renderer.setSeriesShapesVisible(s + 2, true);
        renderer.setSeriesShapesVisible(s + 3, true);

        renderer.setSeriesLinesVisible(s + 1, true);
        renderer.setSeriesLinesVisible(s + 2, true);
        renderer.setSeriesLinesVisible(s + 3, true);

        renderer.setSeriesPaint(s + 1, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 2, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 3, paints[(i + 1) % paints.length]);

        renderer.setSeriesShape(s + 1, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 2, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 3, shapes[(i + 1) % shapes.length]);

        renderer.setSeriesStroke(s + 2, new BasicStroke(3));
        renderer.setSeriesStroke(s + 3, new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1,
                new float[] { 5f, 5f }, 0));
    }

    return chart;
}

From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeFactory.java

public static EStandardChartTheme createBlackNWhiteTheme() {
    EStandardChartTheme theme = new EStandardChartTheme(THEME.BNW_PRINT, "BnW");
    // Fonts/*from  ww  w.  jav  a  2  s. co  m*/
    theme.setExtraLargeFont(new Font("Arial", Font.BOLD, 16));
    theme.setLargeFont(new Font("Arial", Font.BOLD, 11));
    theme.setRegularFont(new Font("Arial", Font.PLAIN, 11));
    theme.setSmallFont(new Font("Arial", Font.PLAIN, 11));

    // Paints
    theme.setTitlePaint(Color.black);
    theme.setSubtitlePaint(Color.black);
    theme.setLegendItemPaint(Color.black);
    theme.setPlotOutlinePaint(Color.black);
    theme.setBaselinePaint(Color.black);
    theme.setCrosshairPaint(Color.black);
    theme.setLabelLinkPaint(Color.black);
    theme.setTickLabelPaint(Color.black);
    theme.setAxisLabelPaint(Color.black);
    theme.setShadowPaint(Color.black);
    theme.setItemLabelPaint(Color.black);

    theme.setLegendBackgroundPaint(Color.white);
    theme.setChartBackgroundPaint(Color.white);
    theme.setPlotBackgroundPaint(Color.white);

    // paint sequence: add black
    Paint[] colors = new Paint[] { Color.BLACK, new Color(0xFF, 0x55, 0x55), new Color(0x55, 0x55, 0xFF),
            new Color(0x55, 0xFF, 0x55), new Color(0xFF, 0xFF, 0x55), new Color(0xFF, 0x55, 0xFF),
            new Color(0x55, 0xFF, 0xFF), Color.pink, Color.gray, ChartColor.DARK_RED, ChartColor.DARK_BLUE,
            ChartColor.DARK_GREEN, ChartColor.DARK_YELLOW, ChartColor.DARK_MAGENTA, ChartColor.DARK_CYAN,
            Color.darkGray, ChartColor.LIGHT_RED, ChartColor.LIGHT_BLUE, ChartColor.LIGHT_GREEN,
            ChartColor.LIGHT_YELLOW, ChartColor.LIGHT_MAGENTA, ChartColor.LIGHT_CYAN, Color.lightGray,
            ChartColor.VERY_DARK_RED, ChartColor.VERY_DARK_BLUE, ChartColor.VERY_DARK_GREEN,
            ChartColor.VERY_DARK_YELLOW, ChartColor.VERY_DARK_MAGENTA, ChartColor.VERY_DARK_CYAN,
            ChartColor.VERY_LIGHT_RED, ChartColor.VERY_LIGHT_BLUE, ChartColor.VERY_LIGHT_GREEN,
            ChartColor.VERY_LIGHT_YELLOW, ChartColor.VERY_LIGHT_MAGENTA, ChartColor.VERY_LIGHT_CYAN };

    theme.setDrawingSupplier(
            new DefaultDrawingSupplier(colors, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    theme.setErrorIndicatorPaint(Color.black);
    theme.setGridBandPaint(new Color(255, 255, 255, 20));
    theme.setGridBandAlternatePaint(new Color(255, 255, 255, 40));

    // axis
    Color transp = new Color(0, 0, 0, 200);
    theme.setRangeGridlinePaint(transp);
    theme.setDomainGridlinePaint(transp);

    theme.setAxisLinePaint(Color.black);

    // axis offset
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));

    return theme;
}

From source file:Trabalho.HistogramaHSB.java

public ChartPanel criaHistograma() throws IOException {

    //pega a imagem
    BufferedImage img = pegaImagem();
    //w pega a largura da imagem - h pega a altura da imagem
    int w = img.getWidth();
    int h = img.getHeight();
    //d calcula o tamanho da imagem
    int d = (w * h);
    //red, green e blue iro receber os tons de cor antigo da imagem - u vai receber o RGB da cor 
    int red, green, blue, u;
    //retorna rgb no mtodo
    float[] hsb;/*from  ww w. j a v  a2 s .  c o  m*/
    int[] vetH = new int[256];
    int[] vetS = new int[256];
    int[] vetB = new int[256];
    float hue, sat, bri;
    //cAux e oldColor pegam os tons originais da imagem - newColor pega os tons aps o clculo
    Color oldColor;
    Color newColor;

    //for responsvel por substituir os tons antigos pelos novos; percorrem a imagem por largura e altura
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            u = img.getRGB(i, j); //u vai receber o RGB da posio i, j
            oldColor = new Color(u); //oldColor  instanciado e recebe o valor de u
            //cada cor recebe o valor do tom original
            red = oldColor.getRed();
            green = oldColor.getGreen();
            blue = oldColor.getBlue();
            hsb = Color.RGBtoHSB(red, green, blue, null);
            hue = hsb[0];
            sat = hsb[1];
            bri = hsb[2];
            //                System.out.println("RGB [" + red + "," + green + "," + blue + "] converted to HSB [" + hue + "," + sat + "," + bri + "]");

            //                hue = hue * 360;
            //                int convH = Integer.valueOf(new Float(hue).intValue());
            //                vetH[convH]++;
            //
            //                sat = sat * 100;
            //                int convS = Integer.valueOf(new Float(sat).intValue());
            //                vetS[convS]++;
            //
            //                bri = bri * 100;
            //                int convB = Integer.valueOf(new Float(bri).intValue());
            //                vetB[convB]++;

            newColor = new Color(hue, sat, bri);
            //seta o RGB da imagem nas posies i, j pegando os valores da newColor
            img.setRGB(i, j, newColor.getRGB());
        }
    }

    File ouptut = new File("D:\\ProjetosNetBeans\\PDI\\src\\imagens\\5.jpeg");
    ImageIO.write(img, "png", ouptut);

    dataset = new HistogramDataset();
    //pega o RGB

    r = raster.getSamples(0, 0, w, h, 0, r);
    dataset.addSeries("Red", r, 360);
    r = raster.getSamples(0, 0, w, h, 1, r);
    dataset.addSeries("Green", r, 101);
    r = raster.getSamples(0, 0, w, h, 2, r);
    dataset.addSeries("Blue", r, 101);

    JFreeChart chart = ChartFactory.createHistogram("Histograma", "Pixels", "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    //Plota as cores
    XYPlot plot = (XYPlot) chart.getPlot();
    renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    //vermelho, verde, azul
    Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true),
            new Color(0x800000ff, true) };
    //desenhando o grfico
    plot.setDrawingSupplier(
            new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeFactory.java

/**
 * Creates and returns a theme called "Darkness". In this theme, the charts have a black
 * background and white lines and labels
 *
 * @return The "Darkness" theme./*from ww w . java 2s  .co  m*/
 */
public static EStandardChartTheme createDarknessTheme() {
    EStandardChartTheme theme = new EStandardChartTheme(THEME.DARKNESS, "Darkness");
    // Fonts
    theme.setExtraLargeFont(new Font("Arial", Font.BOLD, 20));
    theme.setLargeFont(new Font("Arial", Font.BOLD, 11));
    theme.setRegularFont(new Font("Arial", Font.PLAIN, 11));
    theme.setSmallFont(new Font("Arial", Font.PLAIN, 11));
    //
    theme.setTitlePaint(Color.white);
    theme.setSubtitlePaint(Color.white);
    theme.setLegendBackgroundPaint(Color.black);
    theme.setLegendItemPaint(Color.white);
    theme.setChartBackgroundPaint(Color.black);
    theme.setPlotBackgroundPaint(Color.black);
    theme.setPlotOutlinePaint(Color.yellow);
    theme.setBaselinePaint(Color.white);
    theme.setCrosshairPaint(Color.red);
    theme.setLabelLinkPaint(Color.lightGray);
    theme.setTickLabelPaint(Color.white);
    theme.setAxisLabelPaint(Color.white);
    theme.setShadowPaint(Color.darkGray);
    theme.setItemLabelPaint(Color.white);
    theme.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.WHITE, Color.decode("0xFFFF00"), Color.decode("0x0036CC"),
                    Color.decode("0xFF0000"), Color.decode("0xFFFF7F"), Color.decode("0x6681CC"),
                    Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), Color.decode("0x99A6CC"),
                    Color.decode("0xFFBFBF"), Color.decode("0xA9A938"), Color.decode("0x2D4587") },
            new Paint[] { Color.decode("0xFFFF00"), Color.decode("0x0036CC") },
            new Stroke[] { new BasicStroke(2.0f) }, new Stroke[] { new BasicStroke(0.5f) },
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    theme.setErrorIndicatorPaint(Color.lightGray);
    theme.setGridBandPaint(new Color(255, 255, 255, 20));
    theme.setGridBandAlternatePaint(new Color(255, 255, 255, 40));

    // axis
    Color transp = new Color(255, 255, 255, 200);
    theme.setRangeGridlinePaint(transp);
    theme.setDomainGridlinePaint(transp);

    theme.setAxisLinePaint(Color.white);

    theme.setMasterFontColor(Color.WHITE);
    // axis offset
    theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
    return theme;
}

From source file:visualizer.datamining.dataanalysis.NeighborhoodHit.java

private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Hit", "Number Neighbors", "Precision",
            xydataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);

    xyplot.setDomainGridlinePaint(Color.BLACK);
    xyplot.setRangeGridlinePaint(Color.BLACK);

    xyplot.setOutlinePaint(Color.BLACK);
    xyplot.setOutlineStroke(new BasicStroke(1.0f));
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    xyplot.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE,
                    Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW },
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    xylineandshaperenderer.setDrawOutlines(true);

    return chart;
}