Example usage for java.awt Color green

List of usage examples for java.awt Color green

Introduction

In this page you can find the example usage for java.awt Color green.

Prototype

Color green

To view the source code for java.awt Color green.

Click Source Link

Document

The color green.

Usage

From source file:edu.ucla.stat.SOCR.chart.demo.LayeredBarChartDemo2.java

protected JFreeChart createLegend(CategoryDataset dataset) {

    //  JFreeChart chart = ChartFactory.createAreaChart(
    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/*from w  ww.  j  av a2  s  . c o m*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = chart.getCategoryPlot();

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);
    // renderer.setDrawOutlines(true);
    // renderer.setUseFillPaint(true);
    // renderer.setFillPaint(Color.white);
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    return chart;

}

From source file:org.zaproxy.zap.extension.ascan.ScanProgressDialog.java

/**
 * //from ww w. ja  v a 2  s .c  o m
 */
private void initialize() {
    this.setSize(new Dimension(580, 504));

    if (site != null) {
        this.setTitle(MessageFormat.format(Constant.messages.getString("ascan.progress.title"), site));
    }

    JTabbedPane tabbedPane = new JTabbedPane();
    JPanel tab1 = new JPanel();
    tab1.setLayout(new GridBagLayout());

    JPanel hostPanel = new JPanel();
    hostPanel.setLayout(new GridBagLayout());
    hostPanel.add(new JLabel(Constant.messages.getString("ascan.progress.label.host")),
            LayoutHelper.getGBC(0, 0, 1, 0.4D));
    hostPanel.add(getHostSelect(), LayoutHelper.getGBC(1, 0, 1, 0.6D));
    tab1.add(hostPanel, LayoutHelper.getGBC(0, 0, 3, 1.0D, 0.0D));

    tab1.add(getJScrollPane(), LayoutHelper.getGBC(0, 1, 3, 1.0D, 1.0D));

    tab1.add(new JLabel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 0.0D)); // spacer
    tab1.add(getCloseButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D, 0.0D));
    tab1.add(new JLabel(), LayoutHelper.getGBC(2, 1, 1, 1.0D, 0.0D)); // spacer

    tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.progress"), null, tab1, null, 0);
    this.add(tabbedPane);

    int mins = extension.getScannerParam().getMaxChartTimeInMins();
    if (mins > 0) {
        // Treat zero mins as disabled
        JPanel tab2 = new JPanel();
        tab2.setLayout(new GridBagLayout());

        this.seriesTotal = new TimeSeries("TotalResponses"); // Name not shown, so no need to i18n
        final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesTotal);

        this.series100 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.1xx"));
        this.series200 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.2xx"));
        this.series300 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.3xx"));
        this.series400 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.4xx"));
        this.series500 = new TimeSeries(Constant.messages.getString("ascan.progress.chart.5xx"));

        this.seriesTotal.setMaximumItemAge(mins * 60);
        this.series100.setMaximumItemAge(mins * 60);
        this.series200.setMaximumItemAge(mins * 60);
        this.series300.setMaximumItemAge(mins * 60);
        this.series400.setMaximumItemAge(mins * 60);
        this.series500.setMaximumItemAge(mins * 60);

        dataset.addSeries(series100);
        dataset.addSeries(series200);
        dataset.addSeries(series300);
        dataset.addSeries(series400);
        dataset.addSeries(series500);

        chart = createChart(dataset);
        // Set up some vaguesly sensible colours
        chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK); // Totals
        chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.GRAY); // 100: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN); // 200: OK
        chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE); // 300: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.MAGENTA); // 400: Bad req
        chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED); // 500: Internal error

        final ChartPanel chartPanel = new ChartPanel(chart);
        tab2.add(chartPanel, LayoutHelper.getGBC(0, 0, 1, 1.0D, 1.0D));

        tabbedPane.insertTab(Constant.messages.getString("ascan.progress.tab.chart"), null, tab2, null, 1);
    }

    // Stop the updating thread when the window is closed
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            stopThread = true;
        }
    });
}

From source file:TextBouncer.java

protected void setPaint(Graphics2D g2) {
    if (mGradient) {
        GradientPaint gp = new GradientPaint(0, 0, Color.blue, 50, 25, Color.green, true);
        g2.setPaint(gp);//  ww w  .  j av a2 s  .c om
    } else
        g2.setPaint(Color.orange);
}

From source file:org.mars_sim.msp.ui.swing.demo.BarChartDemo7.java

/**
 * Creates a sample chart./* w w  w.j a v a 2s. c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
*/
private JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 7", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final IntervalMarker target = new IntervalMarker(4.5, 7.5);
    target.setLabel("Target Range");
    target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    target.setLabelAnchor(RectangleAnchor.LEFT);
    target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    target.setPaint(new Color(222, 222, 255, 128));
    plot.addRangeMarker(target, Layer.BACKGROUND);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    //renderer.setItemMargin(0.10);
    renderer.setMaximumBarWidth(.5); // set maximum width to 35% of chart

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    //      renderer.setLabelGenerator(new BarChartDemo7.LabelGenerator());
    renderer.setDefaultItemLabelsVisible(true);
    final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT,
            TextAnchor.CENTER_RIGHT, -Math.PI / 2.0);
    renderer.setDefaultPositiveItemLabelPosition(p);

    final ItemLabelPosition p2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT,
            TextAnchor.CENTER_LEFT, -Math.PI / 2.0);
    renderer.setPositiveItemLabelPositionFallback(p2);
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet.java

public JFreeChart getChart(CategoryDataset dataset) {
    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart3D(" ", // chart title
            "", // domain axis label
            " (.)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from  ww w . j av a  2s  .  c  om

    //      #44639C;

    TextTitle title = new TextTitle("  ", labelFont);
    //      Paint paint = title.getPaint();
    title.setPaint(new Color(68, 99, 156));
    chart.setTitle(title);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // final IntervalMarker target = new IntervalMarker(2000000, 3000000);
    // target.setLabel(" ");
    // target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    // target.setLabelAnchor(RectangleAnchor.LEFT);
    // target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    // target.setPaint(new Color(222, 222, 255, 128));
    // plot.addRangeMarker(target, Layer.BACKGROUND);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setTickLabelFont(labelFont);

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setItemMargin(0.10);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)
    // CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
    );
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
}

From source file:org.psystems.dicom.browser.server.stat.UseagStoreChartServlet.java

public JFreeChart getChart() {

    PreparedStatement psSelect = null;

    try {/*  w  ww.j  av a2s.  c o  m*/

        Connection connection = Util.getConnection("main", getServletContext());
        long dcmSizes = 0;
        long imgSizes = 0;
        //
        // ALL_IMAGE_SIZE
        // ALL_DCM_SIZE

        // psSelect = connection
        // .prepareStatement("SELECT ID, METRIC_NAME, METRIC_DATE, METRIC_VALUE_LONG "
        // + " FROM WEBDICOM.DAYSTAT WHERE METRIC_NAME = ?");

        psSelect = connection.prepareStatement(
                "SELECT SUM(METRIC_VALUE_LONG) S " + " FROM WEBDICOM.DAYSTAT WHERE METRIC_NAME = ?");

        psSelect.setString(1, "ALL_DCM_SIZE");
        ResultSet rs = psSelect.executeQuery();
        while (rs.next()) {
            dcmSizes = rs.getLong("S");
        }
        rs.close();

        psSelect.setString(1, "ALL_IMAGE_SIZE");
        rs = psSelect.executeQuery();
        while (rs.next()) {
            imgSizes = rs.getLong("S");
        }
        rs.close();

        String dcmRootDir = getServletContext().getInitParameter("webdicom.dir.src");
        long totalSize = new File(dcmRootDir).getTotalSpace(); //TODO !
        long freeSize = new File(dcmRootDir).getFreeSpace();
        long busySize = totalSize - freeSize;

        //         System.out.println("!!! totalSize=" + totalSize + " freeSize="+freeSize);

        long diskEmpty = freeSize - imgSizes - dcmSizes;

        //         double KdiskEmpty = (double)diskEmpty/(double)totalSize;
        //         System.out.println("!!! " + KdiskEmpty);

        double KdiskBusi = (double) busySize / (double) totalSize * 100;
        //         System.out.println("!!! KdiskBusi=" + KdiskBusi);

        double KdcmSizes = (double) dcmSizes / (double) totalSize * 100;
        //         System.out.println("!!! KdcmSizes=" + KdcmSizes);

        double KimgSizes = (double) imgSizes / (double) totalSize * 100;
        //         System.out.println("!!! KimgSizes=" + KimgSizes);

        double KdiskFree = (double) freeSize / (double) (totalSize - KdcmSizes - KimgSizes) * 100;
        //         System.out.println("!!! KdiskFree=" + KdiskFree);

        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("??? (DCM-) " + dcmSizes / 1000 + " .", KdcmSizes);
        dataset.setValue("? (JPG-) " + imgSizes / 1000 + " .", KimgSizes);
        dataset.setValue("?  " + busySize / 1000 + " .", KdiskBusi);
        dataset.setValue(" " + freeSize / 1000 + " .", KdiskFree);

        boolean legend = true;
        boolean tooltips = false;
        boolean urls = false;

        JFreeChart chart = ChartFactory.createPieChart(
                "? ? ??  ?",
                dataset, legend, tooltips, urls);

        chart.setBorderPaint(Color.GREEN);
        chart.setBorderStroke(new BasicStroke(5.0f));
        // chart.setBorderVisible(true);
        // chart.setPadding(new RectangleInsets(20 ,20,20,20));

        return chart;

    } catch (SQLException e) {
        logger.error(e);
        e.printStackTrace();
    } finally {

        try {
            if (psSelect != null)
                psSelect.close();
        } catch (SQLException e) {
            logger.error(e);
        }
    }
    return null;

}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java

private static JFreeChart createBarChart3D(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart3D("Bar Chart 3D Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//  w w w.j  a va2 s .  c o m

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.5f);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    return chart;

}

From source file:com.github.fabioticconi.roguelite.systems.BootstrapSystem.java

@Override
protected void processSystem() {
    // this must be only run once
    setEnabled(false);/*  ww w.  ja  v a 2 s. com*/

    int x;
    int y;

    // add player
    int id = world.create();
    EntityEdit edit = world.edit(id);

    // load the player's data
    try {
        loadBody("data/creatures/player.yaml", edit);
    } catch (final IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    edit.create(Player.class);
    x = Options.MAP_SIZE_X / 2;
    y = Options.MAP_SIZE_Y / 2;
    edit.create(Position.class).set(x, y);
    edit.create(Sprite.class).set('@', Color.WHITE);
    grid.set(x, y, id);
    pManager.setPlayer(world.getEntity(id), "player");
    System.out.println("setPlayer");
    edit.create(Speed.class).value = 0f; // FIXME to remove later, only for debug

    // add a herd of buffalos
    int groupId = sGroup.createGroup();
    IntSet group = sGroup.getGroup(groupId);
    for (int i = 0; i < 5; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/buffalo.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(FleeBehaviour.class));
        ai.behaviours.add(world.getSystem(GrazeBehaviour.class));
        ai.behaviours.add(world.getSystem(FlockBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Group.class).groupId = groupId;
        group.add(id);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('b', Util.BROWN);

        grid.set(x, y, id);
    }

    // add small, independent rabbits/hares
    for (int i = 0; i < 3; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/rabbit.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(FleeBehaviour.class));
        ai.behaviours.add(world.getSystem(GrazeBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('r', Color.LIGHT_GRAY);

        grid.set(x, y, id);
    }

    // add a pack of wolves
    groupId = sGroup.createGroup();
    group = sGroup.getGroup(groupId);
    for (int i = 0; i < 5; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/wolf.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(ChaseBehaviour.class));
        ai.behaviours.add(world.getSystem(FlockBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Group.class).groupId = groupId;
        group.add(id);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('w', Color.DARK_GRAY);

        grid.set(x, y, id);
    }

    // add solitary pumas
    for (int i = 0; i < 3; i++) {
        id = world.create();
        edit = world.edit(id);

        try {
            loadBody("data/creatures/puma.yaml", edit);
        } catch (final IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

        final AI ai = new AI(r.nextFloat() * AISystem.BASE_TICKTIME + 1.0f);
        ai.behaviours.add(world.getSystem(ChaseBehaviour.class));
        ai.behaviours.add(world.getSystem(WanderBehaviour.class));
        edit.add(ai);
        x = (Options.MAP_SIZE_X / 2) + r.nextInt(10) - 5;
        y = (Options.MAP_SIZE_Y / 2) + r.nextInt(10) - 5;
        edit.create(Position.class).set(x, y);
        edit.create(Alertness.class).value = 0.0f;
        edit.create(Sprite.class).set('p', Util.BROWN.darker());

        grid.set(x, y, id);
    }

    // add random trees?
    for (x = 0; x < Options.MAP_SIZE_X; x++) {
        for (y = 0; y < Options.MAP_SIZE_Y; y++) {
            final Cell cell = map.get(x, y);

            if ((cell.equals(Cell.GRASS) && r.nextGaussian() > 3f)
                    || (cell.equals(Cell.HILL_GRASS) && r.nextGaussian() > 2f)
                    || (cell.equals(Cell.HILL) && r.nextGaussian() > 3f)) {
                id = world.create();
                edit = world.edit(id);

                edit.create(Position.class).set(x, y);
                edit.create(Sprite.class).set('T', Color.GREEN.brighter());
                edit.create(Obstacle.class);

                // FIXME: we should only need one or the other to determine if obstacle.
                // ie, the map should be able to get the Obstacle component from the SingleGrid
                // to determine if the cell is obstructed or not.

                grid.set(x, y, id);
                map.setObstacle(x, y);
            }
        }
    }

    System.out.println("Bootstrap done");
}

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;
}

From source file:com.artnaseef.jmeter.report.ResultCodesStackedReport.java

protected void createChart() {
    // create the chart...
    this.chart = ChartFactory.createStackedBarChart("Average Result Codes per Second", // chart title
            this.yAxisLabel, // x axis label
            "Samples", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//from  w w w  .j a v  a 2  s .c om

    //
    // Adjust colors for the chart.
    //
    CategoryPlot categoryPlot;
    categoryPlot = (CategoryPlot) this.chart.getPlot();
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.BLACK);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);

    //
    // Customize the bar colors.
    //
    CategoryItemRenderer renderer = this.chart.getCategoryPlot().getRenderer();
    List rowKeys = this.dataset.getRowKeys();

    int cur = 0;
    Map<Integer, Integer> colorAdjustMap = new HashMap<>();
    while (cur < rowKeys.size()) {
        Integer resultCode = (Integer) rowKeys.get(cur);

        Color color;
        int group = resultCode / 100;
        switch (group) {
        case 2:
            color = Color.GREEN;
            break;

        case 3:
            color = Color.BLUE;
            break;

        case 4:
            color = Color.ORANGE;
            break;

        case 5:
            color = Color.RED;
            break;

        default:
            color = Color.GRAY;
            break;
        }

        color = this.adjustColor(colorAdjustMap, group, color);

        renderer.setSeriesPaint(cur, color);
        renderer.setSeriesOutlinePaint(cur, Color.BLACK);

        cur++;
    }
}