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:org.jfree.chart.demo.MultipleAxisDemo1.java

/**
 * Creates the demo chart./*from   w w w. j  a v  a  2s  .  co  m*/
 * 
 * @return The chart.
 */
private JFreeChart createChart() {

    final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Time of Day",
            "Primary Range Axis", dataset1, true, true, false);

    chart.setBackgroundPaint(Color.white);
    chart.addSubtitle(new TextTitle("Four datasets and four range axes."));
    final XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    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));

    final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    renderer.setPaint(Color.black);

    // AXIS 2
    final NumberAxis axis2 = new NumberAxis("Range Axis 2");
    axis2.setAutoRangeIncludesZero(false);
    axis2.setLabelPaint(Color.red);
    axis2.setTickLabelPaint(Color.red);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.red);
    plot.setRenderer(1, renderer2);

    // AXIS 3
    final NumberAxis axis3 = new NumberAxis("Range Axis 3");
    axis3.setLabelPaint(Color.blue);
    axis3.setTickLabelPaint(Color.blue);
    plot.setRangeAxis(2, axis3);

    final XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170);
    plot.setDataset(2, dataset3);
    plot.mapDatasetToRangeAxis(2, 2);
    XYItemRenderer renderer3 = new StandardXYItemRenderer();
    renderer3.setSeriesPaint(0, Color.blue);
    plot.setRenderer(2, renderer3);

    // AXIS 4        
    final NumberAxis axis4 = new NumberAxis("Range Axis 4");
    axis4.setLabelPaint(Color.green);
    axis4.setTickLabelPaint(Color.green);
    plot.setRangeAxis(3, axis4);

    final XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200);
    plot.setDataset(3, dataset4);
    plot.mapDatasetToRangeAxis(3, 3);

    XYItemRenderer renderer4 = new StandardXYItemRenderer();
    renderer4.setSeriesPaint(0, Color.green);
    plot.setRenderer(3, renderer4);

    return chart;
}

From source file:edu.ucsd.hep.slhaviewer.view.MassGraphPanel.java

public void setParticles(SLHAdata slhaData) {
    MassBlock massBlock = slhaData.getMassBlock();

    dataset.removeAllSeries();//from   ww  w  .jav  a 2  s .com

    // five Higgs bosons
    addParticle(massBlock, 25, 0.9, Color.BLUE); // h
    addParticle(massBlock, 35, 0.9, Color.BLUE); // H
    addParticle(massBlock, 36, 0.9, Color.BLUE); // A
    addParticle(massBlock, 37, 1.1, Color.RED); // H+

    // sleptons and sneutrinos
    addParticle(massBlock, 2000011, 1.9, Color.BLUE); // ~e_R
    addParticle(massBlock, 1000012, 1.9, Color.BLUE); // ~nu_eL
    addParticle(massBlock, 1000013, 1.9, Color.BLUE); // ~mu_L
    addParticle(massBlock, 2000013, 1.9, Color.BLUE); // ~mu_R
    addParticle(massBlock, 1000014, 1.9, Color.BLUE); // ~nu_muL
    addParticle(massBlock, 1000015, 2.1, Color.RED); // ~tau_1
    addParticle(massBlock, 2000015, 2.1, Color.RED); // ~tau_2
    addParticle(massBlock, 1000016, 2.1, Color.RED); // ~nu_tauL

    // neutralinos and charginos
    addParticle(massBlock, 1000022, 2.9, Color.BLUE); // ~chi_10
    addParticle(massBlock, 1000023, 2.9, Color.BLUE); // ~chi_20
    addParticle(massBlock, 1000025, 2.9, Color.BLUE); // ~chi_30
    addParticle(massBlock, 1000035, 2.9, Color.BLUE); // ~chi_40
    addParticle(massBlock, 1000024, 3.1, Color.RED); // ~chi_1+
    addParticle(massBlock, 1000037, 3.1, Color.RED); // ~chi_2+

    // gluino and squarks
    addParticle(massBlock, 1000021, 3.8, Color.GREEN); // ~g

    addParticle(massBlock, 1000001, 3.9, Color.BLUE); // ~d_L
    addParticle(massBlock, 2000001, 3.9, Color.BLUE); // ~d_R
    addParticle(massBlock, 1000002, 3.9, Color.BLUE); // ~u_L
    addParticle(massBlock, 2000002, 3.9, Color.BLUE); // ~u_R
    addParticle(massBlock, 1000003, 3.9, Color.BLUE); // ~s_L
    addParticle(massBlock, 2000003, 3.9, Color.BLUE); // ~s_R
    addParticle(massBlock, 1000004, 3.9, Color.BLUE); // ~c_L
    addParticle(massBlock, 2000004, 3.9, Color.BLUE); // ~c_R

    addParticle(massBlock, 1000005, 4.1, Color.GREEN); // ~b_1
    addParticle(massBlock, 2000005, 4.1, Color.GREEN); // ~b_2
    addParticle(massBlock, 1000006, 4.1, Color.RED); // ~t_1
    addParticle(massBlock, 2000006, 4.1, Color.RED); // ~t_2   
}

From source file:com.mxgraph.examples.swing.chart.BarChartDemo1.java

/**
 * Creates a sample chart./*from   w w  w.  jav  a 2s .  com*/
 *
 * @param dataset  the dataset.
 *
 * @return The chart.
 */
public static JFreeChart createChart(final CategoryDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("", // chart title
            "X-value", // domain axis label
            "Y-value", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, false);
    chart.addSubtitle(new TextTitle("http://www.bupt.edu.cn", new Font("", Font.ITALIC, 10)));
    //   chart.setBackgroundPaint(Color.white);
    //   chart.setBackgroundPaint(Color.getHSBColor(2, 29, 100));
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setBaseItemLabelsVisible(true);

    //
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setCategoryMargin(0.1);//
    categoryAxis.setUpperMargin(0.02);
    categoryAxis.setLowerMargin(0.02);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.10);

    // 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);

    chart.getTitle().setFont(new Font("", Font.PLAIN, 16));//

    CategoryAxis domainAxis = plot.getDomainAxis();
    //
    domainAxis.setLabelFont(new Font("", Font.PLAIN, 14));
    //
    domainAxis.setTickLabelFont(new Font("", Font.PLAIN, 10));

    //
    rangeAxis.setLabelFont(new Font("", Font.PLAIN, 15));

    chart.getLegend().setItemFont(new Font("", Font.PLAIN, 15));

    return chart;
}

From source file:com.mugarov.neview.view.GraphPanel.java

public void setValues(ArrayList<DotBag> dotBags, ArrayList<Median> lines, String name) {

    CoordinateSeries ser;//w  w  w. j  a va  2 s .  c om
    for (DotBag db : dotBags) {

        ser = new CoordinateSeries(db.getName());
        for (Dot d : db) {

            ser.add(d.getCoordinates(), d.getName(), d.getScaffoldName());
            //                System.out.println("New dot:"+d.getLogX()+", "+d.getLogY());
        }

        this.dotSeries.add(ser);
    }

    for (Median med : lines) {
        ser = new CoordinateSeries(med.getName());

        ser.add(med.getStart(), med.getName(), null);
        ser.add(med.getEnd(), med.getName(), null);
        //            System.out.println("New line from " + med.getStart().getX()+","+ med.getStart().getY()+" to "+med.getEnd().getX()+","+ med.getEnd().getY());
        this.lineSeries.add(ser);
    }

    this.seriesCollection = new CoordinateSeriesCollection();

    for (CoordinateSeries dotSeries : this.dotSeries) {
        this.seriesCollection.addSeries(dotSeries);
    }
    for (CoordinateSeries line : this.lineSeries) {
        this.seriesCollection.addSeries(line);
    }

    this.chart = ChartFactory.createXYLineChart(name, GraphPanel.XAxis, GraphPanel.YAxis, this.seriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    this.chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();

    ExpAxis x1Axis = new ExpAxis(GraphPanel.XAxis);
    ExpAxis y1Axis = new ExpAxis(GraphPanel.YAxis);

    NumberAxis x2Axis = new NumberAxis("Proportion to max of " + GraphPanel.XAxis);
    NumberAxis y2Axis = new NumberAxis("Proportion to max of " + GraphPanel.YAxis);

    plot.setDomainAxis(0, x1Axis);
    plot.setDomainAxis(1, x2Axis);
    plot.setRangeAxis(0, y1Axis);
    plot.setRangeAxis(1, y2Axis);
    //        plot.setDomainAxis(1, yAxis);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    for (int i = 0; i < this.dotSeries.size(); i++) {
        renderer.setSeriesLinesVisible(i, false);
        renderer.setSeriesPaint(i, this.colorGen.get(i));
    }

    for (int i = this.dotSeries.size(); i < this.lineSeries.size() + this.dotSeries.size(); i++) {
        renderer.setSeriesShapesVisible(i, false);
        //             renderer.setSeriesPaint(i, Color.black);
        renderer.setSeriesPaint(i, this.colorGen.get(i - this.dotSeries.size()));
    }

    renderer.setBaseToolTipGenerator(new ItemGenerator());

    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);

    plot.setDomainGridlinePaint(Color.MAGENTA);
    plot.setRangeGridlinePaint(Color.MAGENTA);

    boolean add = (this.chartPanel == null);
    this.chartPanel = new ChartPanel(chart);

    if (add) {
        this.content.add(this.chartPanel, BorderLayout.CENTER);
        this.scroll.setViewportView(this.chartPanel);
    }

    this.setBackground(Color.green);
    this.chartPanel.setBackground(Color.MAGENTA);
    this.updateUI();
}

From source file:fungus.JungObserver.java

public JungObserver(String name) {
    this.name = name;
    this.hyphadataPid = Configuration.getPid(name + "." + PAR_HYPHADATA_PROTO);
    this.hyphalinkPid = Configuration.getPid(name + "." + PAR_HYPHALINK_PROTO);
    this.mycocastPid = Configuration.getPid(name + "." + PAR_MYCOCAST_PROTO);
    self = this;/* w ww.  j a  va2s .c om*/
    mainThread = Thread.currentThread();

    graph = new DirectedSparseGraph<MycoNode, String>();
    edu.uci.ics.jung.algorithms.layout.SpringLayout<MycoNode, String> layout = new edu.uci.ics.jung.algorithms.layout.SpringLayout<MycoNode, String>(
            graph);
    layout.setSize(new Dimension(650, 650));
    layout.setRepulsionRange(75);
    //layout.setForceMultiplier(0.75);
    layout.setStretch(0.85);

    Dimension preferredSize = new Dimension(650, 650);
    VisualizationModel<MycoNode, String> visualizationModel = new DefaultVisualizationModel<MycoNode, String>(
            layout, preferredSize);
    visualizer = new VisualizationViewer<MycoNode, String>(visualizationModel, preferredSize);
    visualizer.addGraphMouseListener(new InfoFrameVertexListener());

    //visualizer = new BasicVisualizationServer<Node,String>(layout);
    //visualizer.setPreferredSize(new Dimension(650, 650));

    Transformer<MycoNode, String> nodeLabeller = new Transformer<MycoNode, String>() {
        public String transform(MycoNode n) {
            return Long.toString(n.getID());
        }
    };

    final Shape biomassCircle = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f);
    final Shape hyphaCircle = new Ellipse2D.Float(-5.0f, -5.0f, 10.0f, 10.0f);
    Transformer<MycoNode, Shape> shapeTransformer = new Transformer<MycoNode, Shape>() {
        public Shape transform(MycoNode n) {
            HyphaData data = n.getHyphaData();
            if (data.isBiomass()) {
                return biomassCircle;
            } else {
                return hyphaCircle;
            }
        }

    };

    Transformer<MycoNode, Paint> nodeFillRenderer = new Transformer<MycoNode, Paint>() {
        public Paint transform(MycoNode n) {
            HyphaData data = (HyphaData) n.getProtocol(hyphadataPid);
            if (!n.isUp()) {
                return Color.BLACK;
            }
            if (data.isBiomass()) {
                return Color.BLUE;
            } else if (data.isExtending()) {
                return Color.RED;
            } else if (data.isBranching()) {
                return Color.YELLOW;
            } else {
                return Color.GREEN;
            }
        }
    };
    Transformer<MycoNode, Paint> nodeShapeRenderer = new Transformer<MycoNode, Paint>() {
        public Paint transform(MycoNode n) {
            HyphaData data = (HyphaData) n.getProtocol(hyphadataPid);
            if (data.isBiomass()) {
                return Color.BLUE;
            } else if (data.isExtending()) {
                return Color.RED;
            } else if (data.isBranching()) {
                return Color.YELLOW;
            } else {
                return Color.GREEN;
            }
        }
    };

    final Stroke biomassStroke = new BasicStroke(0.25f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f);
    final Stroke hyphalStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f);

    Transformer<String, Stroke> edgeStrokeTransformer = new Transformer<String, Stroke>() {
        public Stroke transform(String s) {
            Pair<MycoNode> vertices = graph.getEndpoints(s);
            HyphaData firstData = vertices.getFirst().getHyphaData();
            HyphaData secondData = vertices.getSecond().getHyphaData();
            if (firstData.isHypha() && secondData.isHypha()) {
                return hyphalStroke;
            } else {
                return biomassStroke;
            }
        }
    };

    visualizer.getRenderContext().setVertexFillPaintTransformer(nodeFillRenderer);
    visualizer.getRenderContext().setVertexShapeTransformer(shapeTransformer);
    visualizer.getRenderContext().setVertexLabelTransformer(nodeLabeller);
    visualizer.setVertexToolTipTransformer(new ToStringLabeller<MycoNode>());
    visualizer.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Container c = frame.getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));

    //JScrollPane scrollPane = new JScrollPane(visualizer);
    //c.add(scrollPane);
    c.add(visualizer);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));

    JButton pauseButton = new JButton("pause");
    ActionListener pauser = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            synchronized (self) {
                stepBlocked = true;
                noBlock = false;
                //self.notifyAll();
            }
        }
    };
    pauseButton.addActionListener(pauser);

    JButton stepButton = new JButton("step");
    ActionListener stepper = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Clicked!\n");
            //e.consume();
            synchronized (self) {
                stepBlocked = false;
                self.notifyAll();
            }
        }
    };
    stepButton.addActionListener(stepper);

    JButton runButton = new JButton("run");
    ActionListener runner = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //e.consume();
            synchronized (self) {
                stepBlocked = false;
                noBlock = true;
                self.notifyAll();
            }
        }
    };
    runButton.addActionListener(runner);

    buttonPane.add(pauseButton);
    buttonPane.add(stepButton);
    buttonPane.add(runButton);
    c.add(buttonPane);

    frame.pack();
    frame.setVisible(true);
}

From source file:Paints.java

/** Draw the example */
public void paint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;
    // Paint the entire background using a GradientPaint.
    // The background color varies diagonally from deep red to pale blue
    g.setPaint(new GradientPaint(0, 0, new Color(150, 0, 0), WIDTH, HEIGHT, new Color(200, 200, 255)));
    g.fillRect(0, 0, WIDTH, HEIGHT); // fill the background

    // Use a different GradientPaint to draw a box.
    // This one alternates between deep opaque green and transparent green.
    // Note: the 4th arg to Color() constructor specifies color opacity
    g.setPaint(new GradientPaint(0, 0, new Color(0, 150, 0), 20, 20, new Color(0, 150, 0, 0), true));
    g.setStroke(new BasicStroke(15)); // use wide lines
    g.drawRect(25, 25, WIDTH - 50, HEIGHT - 50); // draw the box

    // The glyphs of fonts can be used as Shape objects, which enables
    // us to use Java2D techniques with letters Just as we would with
    // any other shape. Here we get some letter shapes to draw.
    Font font = new Font("Serif", Font.BOLD, 10); // a basic font
    Font bigfont = // a scaled up version
            font.deriveFont(AffineTransform.getScaleInstance(30.0, 30.0));
    GlyphVector gv = bigfont.createGlyphVector(g.getFontRenderContext(), "JAV");
    Shape jshape = gv.getGlyphOutline(0); // Shape of letter J
    Shape ashape = gv.getGlyphOutline(1); // Shape of letter A
    Shape vshape = gv.getGlyphOutline(2); // Shape of letter V

    // We're going to outline the letters with a 5-pixel wide line
    g.setStroke(new BasicStroke(5.0f));

    // We're going to fake shadows for the letters using the
    // following Paint and AffineTransform objects
    Paint shadowPaint = new Color(0, 0, 0, 100); // Translucent black
    AffineTransform shadowTransform = AffineTransform.getShearInstance(-1.0, 0.0); // Shear to the right
    shadowTransform.scale(1.0, 0.5); // Scale height by 1/2

    // Move to the baseline of our first letter
    g.translate(65, 270);/*ww  w. ja  v  a  2  s  . co m*/

    // Draw the shadow of the J shape
    g.setPaint(shadowPaint);
    g.translate(15, 20); // Compensate for the descender of the J
    // transform the J into the shape of its shadow, and fill it
    g.fill(shadowTransform.createTransformedShape(jshape));
    g.translate(-15, -20); // Undo the translation above

    // Now fill the J shape with a solid (and opaque) color
    g.setPaint(Color.blue); // Fill with solid, opaque blue
    g.fill(jshape); // Fill the shape
    g.setPaint(Color.black); // Switch to solid black
    g.draw(jshape); // And draw the outline of the J

    // Now draw the A shadow
    g.translate(75, 0); // Move to the right
    g.setPaint(shadowPaint); // Set shadow color
    g.fill(shadowTransform.createTransformedShape(ashape)); // draw shadow

    // Draw the A shape using a solid transparent color
    g.setPaint(new Color(0, 255, 0, 125)); // Transparent green as paint
    g.fill(ashape); // Fill the shape
    g.setPaint(Color.black); // Switch to solid back
    g.draw(ashape); // Draw the outline

    // Move to the right and draw the shadow of the letter V
    g.translate(175, 0);
    g.setPaint(shadowPaint);
    g.fill(shadowTransform.createTransformedShape(vshape));

    // We're going to fill the next letter using a TexturePaint, which
    // repeatedly tiles an image. The first step is to obtain the image.
    // We could load it from an image file, but here we create it
    // ourselves by drawing a into an off-screen image. Note that we use
    // a GradientPaint to fill the off-screen image, so the fill pattern
    // combines features of both Paint classes.
    BufferedImage tile = // Create an image
            new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
    Graphics2D tg = tile.createGraphics(); // Get its Graphics for drawing
    tg.setColor(Color.pink);
    tg.fillRect(0, 0, 50, 50); // Fill tile background with pink
    tg.setPaint(new GradientPaint(40, 0, Color.green, // diagonal gradient
            0, 40, Color.gray)); // green to gray
    tg.fillOval(5, 5, 40, 40); // Draw a circle with this gradient

    // Use this new tile to create a TexturePaint and fill the letter V
    g.setPaint(new TexturePaint(tile, new Rectangle(0, 0, 50, 50)));
    g.fill(vshape); // Fill letter shape
    g.setPaint(Color.black); // Switch to solid black
    g.draw(vshape); // Draw outline of letter

    // Move to the right and draw the shadow of the final A
    g.translate(160, 0);
    g.setPaint(shadowPaint);
    g.fill(shadowTransform.createTransformedShape(ashape));

    g.fill(ashape); // Fill letter A
    g.setPaint(Color.black); // Revert to solid black
    g.draw(ashape); // Draw the outline of the A
}

From source file:ImageOps.java

/** Draw the example */
public void paint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;
    // Create a BufferedImage big enough to hold the Image loaded
    // in the constructor. Then copy that image into the new
    // BufferedImage object so that we can process it.
    BufferedImage bimage = new BufferedImage(image.getWidth(this), image.getHeight(this),
            BufferedImage.TYPE_INT_RGB);
    Graphics2D ig = bimage.createGraphics();
    ig.drawImage(image, 0, 0, this); // copy the image

    // Set some default graphics attributes
    g.setFont(new Font("SansSerif", Font.BOLD, 12)); // 12pt bold text
    g.setColor(Color.green); // Draw in green
    g.translate(10, 10); // Set some margins

    // Loop through the filters
    for (int i = 0; i < filters.length; i++) {
        // If the filter is null, draw the original image, otherwise,
        // draw the image as processed by the filter
        if (filters[i] == null)
            g.drawImage(bimage, 0, 0, this);
        else/*from ww w  . j ava  2s.c  o m*/
            g.drawImage(filters[i].filter(bimage, null), 0, 0, this);
        g.drawString(filterNames[i], 0, 205); // Label the image
        g.translate(137, 0); // Move over
        if (i % 4 == 3)
            g.translate(-137 * 4, 215); // Move down after 4
    }
}

From source file:plugins.tutorial.chart.ChartTutorial1.java

/**
 * Creates a sample chart.//from   www .jav  a 2 s.  c  o m
 * 
 * @param dataset
 *        the dataset.
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // 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...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // ******************************************************************
    // More than 150 demo applications are included with the JFreeChart
    // Developer Guide...for more information, see:
    //
    // > http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

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

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

    // 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);

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

    return chart;

}

From source file:org.jfree.chart.demo.BarChartDemo4.java

/**
 * Creates a sample chart./*w  w w . j av a2s .co  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", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URLs?
    );

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

    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(0xBBBBDD));

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();

    // 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.setMaxBarWidth(0.10);

    // 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);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:com.seleniumtests.it.driver.TestBrowserSnapshot.java

/**
 * Test page contains fixed header (yellow) and footer (orange) of 5 pixels height. Detect how many
 * pixels of these colors are present in picture
 * Also count red pixels which is a line not to remove when cropping
 * @param picture//from  ww  w.ja  v a2s  .c o m
 * @return
 * @throws IOException 
 */
private int[] getHeaderAndFooterPixels(File picture) throws IOException {
    BufferedImage image = ImageIO.read(picture);

    int topPixels = 0;
    int bottomPixels = 0;
    int securityLine = 0;
    for (int height = 0; height < image.getHeight(); height++) {
        Color color = new Color(image.getRGB(0, height));
        if (color.equals(Color.YELLOW)) {
            topPixels++;
        } else if (color.equals(Color.ORANGE)) {
            bottomPixels++;
        } else if (color.equals(Color.RED) || color.equals(Color.GREEN)) {
            securityLine++;
        }
    }

    return new int[] { topPixels, bottomPixels, securityLine };
}