Example usage for java.awt Color YELLOW

List of usage examples for java.awt Color YELLOW

Introduction

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

Prototype

Color YELLOW

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

Click Source Link

Document

The color yellow.

Usage

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

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

    final JFreeChart chart = ChartFactory.createLineChart("Line Chart Demo 5", // chart title
            "Type", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

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

    final Shape[] shapes = new Shape[3];
    int[] xpoints;
    int[] ypoints;

    // right-pointing triangle
    xpoints = new int[] { -3, 3, -3 };
    ypoints = new int[] { -3, 0, 3 };
    shapes[0] = new Polygon(xpoints, ypoints, 3);

    // vertical rectangle
    shapes[1] = new Rectangle2D.Double(-2, -3, 3, 6);

    // left-pointing triangle
    xpoints = new int[] { -3, 3, 3 };
    ypoints = new int[] { 0, -3, 3 };
    shapes[2] = new Polygon(xpoints, ypoints, 3);

    final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, shapes);
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setDrawingSupplier(supplier);

    chart.setBackgroundPaint(Color.yellow);

    // set the stroke for each series...
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] { 6.0f, 6.0f }, 0.0f));
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] { 2.0f, 6.0f }, 0.0f));

    // customise the renderer...
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    //        renderer.setDrawShapes(true);
    renderer.setItemLabelsVisible(true);
    //      renderer.setLabelGenerator(new StandardCategoryLabelGenerator());

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setUpperMargin(0.12);

    return chart;

}

From source file:avoking.com.documentos.scheduler.core.Core.java

public void procesar(String file) {
    InputStream entradaArch;/*w w  w  .  j av a2s  .c o  m*/
    try {
        entradaArch = new FileInputStream(file);
        String reader = "";

        if (FilenameUtils.getExtension(file).toUpperCase().equals("DOCX")) {
            entradaArch = new FileInputStream(file);
            reader = leerDocx(entradaArch);
        } else {
            entradaArch = new FileInputStream(file);
            reader = leerDoc(entradaArch);
        }

        Docs doc;
        doc = readHeader.read(reader);
        if (doc.getClaveId() == null) {
            err += "Error al obtener la clave del archivo: \n" + file + "\n";
            //                JOptionPane.showMessageDialog(null, , "Error!!!", JOptionPane.ERROR_MESSAGE);
            return;
        }

        try {
            session.save(doc);
            LOGGER.debug("Add: " + doc.getClaveId());
            Main.frmPortal.pnlCores.add(new pnlDocs(Color.yellow, doc));
        } catch (Exception ex) {
            java.util.logging.Logger.getLogger(Core.class.getName()).log(Level.SEVERE, null, ex);
        }
        LOGGER.debug(doc.toString());
    } catch (FileNotFoundException ex) {
        java.util.logging.Logger.getLogger(Core.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        java.util.logging.Logger.getLogger(Core.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.google.code.facebook.graph.sna.applet.FacebookGraphApplet.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features.//from   ww  w  . jav  a  2  s.  c om
 * 
 */
@Override
public void init() {
    super.init();
    // create a simple graph for the demo
    fetchUserGraph();
    final Collection<? extends Entity<FieldEnum, ConnectionEnum>> vertices = graph.getVertices();

    // a Map for the labels
    Map<Entity<FieldEnum, ConnectionEnum>, String> map = new HashMap<Entity<FieldEnum, ConnectionEnum>, String>();
    Iterator<? extends Entity<FieldEnum, ConnectionEnum>> iterator = vertices.iterator();
    while (iterator.hasNext()) {
        Entity<FieldEnum, ConnectionEnum> entity = iterator.next();
        map.put(entity, entity.getLabel());
    }

    FRLayout<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>> layout = new FRLayout<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>(
            (Graph<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>) graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>(layout,
            new Dimension(2000, 2000));

    Transformer<Entity<FieldEnum, ConnectionEnum>, Paint> vpf = new PickableVertexPaintTransformer<Entity<FieldEnum, ConnectionEnum>>(
            vv.getPickedVertexState(), Color.white, Color.yellow);
    vv.getRenderContext().setVertexFillPaintTransformer(vpf);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<EdgeAdapter<ConnectionEnum>>(vv.getPickedEdgeState(), Color.black,
                    Color.cyan));

    vv.setBackground(Color.white);

    // a Map for the Icons
    final Map<Entity<FieldEnum, ConnectionEnum>, Icon> iconMap = new HashMap<Entity<FieldEnum, ConnectionEnum>, Icon>();
    new Thread(new Runnable() {
        public void run() {
            Iterator<? extends Entity<FieldEnum, ConnectionEnum>> iterator = vertices.iterator();
            while (iterator.hasNext()) {
                try {
                    Entity<FieldEnum, ConnectionEnum> entity = iterator.next();
                    //                     Icon icon = 
                    //                        new LayeredIcon(new ImageIcon("http://facebookgraph.appspot.com/proxy?url=" + entity.getPicture(PictureType.SQUARE), "Profile Picture").getImage());
                    //                       iconMap.put(entity, icon);

                    Image image = getImageFromEntity(entity);
                    if (image != null && image.getWidth(null) > 0 && image.getHeight(null) > 0) {
                        Icon icon = new LayeredIcon(image);
                        iconMap.put(entity, icon);
                        if ((iconMap.size() % 5) == 0) {
                            vv.repaint();
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            vv.repaint();
        }

    }).start();

    final Transformer<Entity<FieldEnum, ConnectionEnum>, String> vertexStringerImpl = new VertexStringerImpl<Entity<FieldEnum, ConnectionEnum>>(
            map);
    Transformer<EdgeAdapter<ConnectionEnum>, String> edgeStringerImpl = new Transformer<EdgeAdapter<ConnectionEnum>, String>() {
        public String transform(EdgeAdapter<ConnectionEnum> edge) {
            return edge.toString();
        }
    };
    vv.getRenderContext().setEdgeLabelTransformer(edgeStringerImpl);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
    vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));

    // features on and off. For a real application, use VertexIconAndShapeFunction instead.
    final VertexIconShapeTransformer<Entity<FieldEnum, ConnectionEnum>> vertexImageShapeFunction = new VertexIconShapeTransformer<Entity<FieldEnum, ConnectionEnum>>(
            new EllipseVertexShapeTransformer<Entity<FieldEnum, ConnectionEnum>>());

    final DefaultVertexIconTransformer<Entity<FieldEnum, ConnectionEnum>> vertexIconFunction = new DefaultVertexIconTransformer<Entity<FieldEnum, ConnectionEnum>>();

    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);

    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);

    // Get the pickedState and add a listener that will decorate the
    // Vertex images with a checkmark icon when they are picked
    PickedState<Entity<FieldEnum, ConnectionEnum>> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener(vertexIconFunction));

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new Transformer<Entity<FieldEnum, ConnectionEnum>, String>() {
        @Override
        public String transform(Entity<FieldEnum, ConnectionEnum> entity) {
            return entity.getDescription();
        }
    });

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JComboBox modeBox = graphMouse.getModeComboBox();
    JPanel modePanel = new JPanel();
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);

    controls.add(modePanel);
    content.add(controls, BorderLayout.SOUTH);

    this.viewSupport = new MagnifyImageLensSupport<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>(
            vv);
    //           new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, 
    //              vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), 
    //                new ModalLensGraphMouse());

    this.modelSupport = new LayoutLensSupport<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>(
            vv);

    graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener());

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (viewSupport != null) {
                viewSupport.deactivate();
            }
            if (modelSupport != null) {
                modelSupport.deactivate();
            }
        }
    });
    none.setSelected(true);

    JRadioButton hyperView = new JRadioButton("View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JRadioButton hyperModel = new JRadioButton("Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    radio.add(none);
    radio.add(hyperView);
    radio.add(hyperModel);

    JMenuBar menubar = new JMenuBar();
    JMenu modeMenu = graphMouse.getModeMenu();
    menubar.add(modeMenu);

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.setBorder(BorderFactory.createTitledBorder("Lens"));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);
    controls.add(lensPanel);
}

From source file:org.etudes.jforum.util.Captcha.java

protected void buildInitialFactories() {
    this.backgroundGeneratorList = new ArrayList();
    this.textPasterList = new ArrayList();
    this.fontGeneratorList = new ArrayList();

    int width = SystemGlobals.getIntValue(ConfigKeys.CAPTCHA_WIDTH);
    int height = SystemGlobals.getIntValue(ConfigKeys.CAPTCHA_HEIGHT);
    int minWords = SystemGlobals.getIntValue(ConfigKeys.CAPTCHA_MIN_WORDS);
    int maxWords = SystemGlobals.getIntValue(ConfigKeys.CAPTCHA_MAX_WORDS);
    int minFontSize = SystemGlobals.getIntValue(ConfigKeys.CAPTCHA_MIN_FONT_SIZE);
    int maxFontSize = SystemGlobals.getIntValue(ConfigKeys.CAPTCHA_MAX_FONT_SIZE);

    this.backgroundGeneratorList.add(
            new GradientBackgroundGenerator(new Integer(width), new Integer(height), Color.BLACK, Color.GRAY));
    this.backgroundGeneratorList.add(new FunkyBackgroundGenerator(new Integer(250), new Integer(50)));

    this.textPasterList.add(new RandomTextPaster(new Integer(minWords), new Integer(maxWords), Color.RED));
    this.textPasterList.add(new RandomTextPaster(new Integer(minWords), new Integer(maxWords), Color.ORANGE));
    this.textPasterList.add(new RandomTextPaster(new Integer(minWords), new Integer(maxWords), Color.BLUE));
    this.textPasterList.add(new RandomTextPaster(new Integer(minWords), new Integer(maxWords), Color.WHITE));
    this.textPasterList.add(new RandomTextPaster(new Integer(minWords), new Integer(maxWords), Color.GREEN));
    this.textPasterList.add(new RandomTextPaster(new Integer(minWords), new Integer(maxWords), Color.GRAY));
    this.textPasterList.add(new RandomTextPaster(new Integer(minWords), new Integer(maxWords), Color.YELLOW));

    this.fontGeneratorList
            .add(new TwistedAndShearedRandomFontGenerator(new Integer(minFontSize), new Integer(maxFontSize)));

    // Create a random word generator
    WordGenerator words = new RandomWordGenerator(charsInUse);

    for (Iterator fontIter = this.fontGeneratorList.iterator(); fontIter.hasNext();) {
        FontGenerator fontGeny = (FontGenerator) fontIter.next();

        for (Iterator backIter = this.backgroundGeneratorList.iterator(); backIter.hasNext();) {
            BackgroundGenerator bkgdGeny = (BackgroundGenerator) backIter.next();

            for (Iterator textIter = this.textPasterList.iterator(); textIter.hasNext();) {
                TextPaster textPaster = (TextPaster) textIter.next();

                WordToImage word2image = new ComposedWordToImage(fontGeny, bkgdGeny, textPaster);

                // Creates a ImageCaptcha Factory
                ImageCaptchaFactory factory = new GimpyFactory(words, word2image);

                // Add a factory to the gimpy list (A Gimpy is a ImagCaptcha)
                addFactory(factory);/*  www. j a v  a  2s  . c  o  m*/
            }
        }
    }

}

From source file:com.jolbox.benchmark.BenchmarkMain.java

/**
 * @param results/*w w w .j  ava 2 s . c o  m*/
 * @param delay 
 * @param statementBenchmark 
 * @param noC3P0 
 */
private static void doPlotLineGraph(long[][] results, int delay, boolean statementBenchmark, boolean noC3P0) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int i = 0; i < ConnectionPoolType.values().length; i++) { //
        if (!ConnectionPoolType.values()[i].isEnabled()
                || (noC3P0 && ConnectionPoolType.values()[i].equals(ConnectionPoolType.C3P0))) {
            continue;
        }
        XYSeries series = new XYSeries(ConnectionPoolType.values()[i].toString());

        for (int j = 1 + BenchmarkTests.stepping; j < results[i].length; j += BenchmarkTests.stepping) {
            series.add(j, results[i][j]);
        }
        dataset.addSeries(series);
    }

    //         Generate the graph
    String title = "Multi-Thread test (" + delay + "ms delay)";
    if (statementBenchmark) {
        title += "\n(with PreparedStatements tests)";
    }
    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            "threads", // x-axis Label
            "time (ns)", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setSeriesPaint(1, Color.YELLOW);
    renderer.setSeriesPaint(2, Color.BLACK);
    renderer.setSeriesPaint(3, Color.DARK_GRAY);
    renderer.setSeriesPaint(4, Color.MAGENTA);
    renderer.setSeriesPaint(5, Color.RED);
    renderer.setSeriesPaint(6, Color.LIGHT_GRAY);
    //          renderer.setSeriesShapesVisible(1, true);   
    //          renderer.setSeriesShapesVisible(2, true);   

    try {
        String fname = System.getProperty("java.io.tmpdir") + File.separator + "bonecp-multithread-" + delay
                + "ms-delay";
        if (statementBenchmark) {
            fname += "-with-preparedstatements";
        }
        fname += "-poolsize-" + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads;
        if (noC3P0) {
            fname += "-noC3P0";
        }
        fname += ".png";
        ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768);
        System.out.println("******* Saved chart to: " + fname);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }

}

From source file:GUI.Statistique.java

private ChartPanel calculerBudget() {
    ProduitDAO produitDAO = new ProduitDAO();
    List<Produit> produits = new ArrayList<>();
    produits = produitDAO.findAll();/*from ww w  .  j a va  2  s .  c o m*/
    CommandeDAO commandeDAO = new CommandeDAO();
    List<Commande> commandes = new ArrayList<>();
    commandes = commandeDAO.findAll();
    DefaultPieDataset dSet = new DefaultPieDataset();
    for (Produit produit : produits) {
        dSet.setValue(produit.getNom(), produit.getNbvente());
        System.out.println(produit.getNbvente());
    }
    JFreeChart chart = ChartFactory.createPieChart3D("liste des produits les plus vendus", dSet, true, true,
            true);
    chart.setBackgroundPaint(Color.yellow);
    chart.getTitle().setPaint(Color.RED);
    PiePlot3D p = (PiePlot3D) chart.getPlot();
    ChartPanel cp = new ChartPanel(chart, true, true, true, true, true);
    JFrame f = new JFrame();
    f.setContentPane(cp);
    f.pack();
    jpBudjet.add(cp);
    return cp;
}

From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java

public void updateIndicators() {

    // Update dial button
    synchronized (lock) {

        Element eh = super.model.getRootElement().getChild("HookButton");

        // Get texts from model
        String textSource = DomTools.getAttributeString(eh, "src", "?", false);
        String textDest = DomTools.getAttributeString(eh, "dest", "?", false);

        // Get state from model
        String s = DomTools.getAttributeString(eh, "state", "idle", false);

        String sDial = "DIAL";
        String sHook = "INTERPHONE";
        Color cDial = Color.lightGray;

        if (s.equals("dialing")) {
            sDial = textSource + " > " + textDest;
            sHook = "RELEASE";
            cDial = Color.yellow;
        } else if (s.equals("busy")) {
            sDial = textSource + " ! " + textDest;
            sHook = "RELEASE";
            cDial = Color.red;//from  ww w. ja v  a  2  s. com
        } else if (s.equals("in_call")) {
            sDial = textSource + " - " + textDest;
            sHook = "RELEASE";
            cDial = Color.yellow;
        } else if (s.equals("ringing")) {
            sDial = textDest + " < " + textSource;
            sHook = "ANSWER";
            cDial = Color.yellow;
        }

        phoneOnlyContentPane.getDialLabel().setText(sDial);
        phoneOnlyContentPane.getHookButton().setBackground(cDial);
        phoneOnlyContentPane.getHookButton().setText(sHook);
        log.debug("Setting sDial = " + sDial + " setBackground:" + cDial + " setHook=" + sHook);
    }
}

From source file:org.cytoscape.graph.render.immed.GraphGraphicsTest.java

private long drawOldFull(Random rand) {
    final float nodeSizeFactor = 50f;
    float size = (float) canvasSize;

    long begin = System.nanoTime();
    for (int i = 0; i < numNodes; i++) {
        float x = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
        float y = rand.nextFloat() * (rand.nextBoolean() ? size : -size);
        oldGraphGraphics.drawNodeFull((byte) (i % (int) OldGraphGraphics.s_last_shape), x, y,
                (x + (rand.nextFloat() * nodeSizeFactor)), (y + (rand.nextFloat() * nodeSizeFactor)),
                Color.blue, 1.0f + (i % 10), Color.yellow);
    }/*from   ww  w.  ja  va 2 s . co  m*/
    long end = System.nanoTime();
    long nodeDur = end - begin;

    BasicStroke edgeStroke = new BasicStroke(1f);

    begin = System.nanoTime();
    for (int i = 0; i < numEdges; i++) {
        oldGraphGraphics.drawEdgeFull((byte) ((i % 7) - 8), rand.nextFloat() * (20f), Color.red,
                (byte) ((i % 7) - 8), rand.nextFloat() * (20f), Color.orange,
                rand.nextFloat() * (rand.nextBoolean() ? size : -size),
                rand.nextFloat() * (rand.nextBoolean() ? size : -size), oldGraphGraphics.m_noAnchors,
                rand.nextFloat() * (rand.nextBoolean() ? size : -size),
                rand.nextFloat() * (rand.nextBoolean() ? size : -size), 1f, Color.green, 0f);
    }
    end = System.nanoTime();

    long duration = (end - begin) + nodeDur;
    return duration;
}

From source file:com.mentor.questa.ucdb.jenkins.QuestaCoverageAction.java

private JFreeChart createBarChart(final StaplerRequest req, final CategoryDataset dataset, final String title) {
    JFreeChart chart = ChartFactory.createBarChart(title, //title
            null, //categoryaxislabel, 
            null, //valueaxislabel    
            dataset, //dataset
            PlotOrientation.HORIZONTAL, //orientation
            false, //legend
            true, //tooltips
            false //urls
    );/*from   w  w  w  .j ava2s.  c om*/

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

    final CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);

    final BarRenderer cir = new BarRenderer() {
        private final Paint[] colors = { Color.red, Color.blue, Color.green, Color.yellow, Color.orange,
                Color.cyan, Color.magenta, Color.blue };

        /**
         * Returns the paint for an item. Overrides the default behavior
         * inherited from AbstractSeriesRenderer.
         *
         * @param row the series.
         * @param column the category.
         *
         * @return The item color.
         */
        @Override
        public Paint getItemPaint(final int row, final int column) {
            return colors[column % colors.length];
        }
    };
    cir.setMaximumBarWidth(0.35);
    plot.setRenderer(cir);

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

From source file:com.view.TimeSeriesChartView.java

public JFreeChart getTimeSeriesChart(Excel theExcel, ReceivingControl theRC) {

    System.out.println(theRC.getNumberOfItem());
    System.out.println(theRC.getNumberOfSite());
    System.out.println(theRC.getNumberOfVendor());
    System.out.println(theRC.getVendorInfo());
    System.out.println(theRC.getSiteInfo());
    System.out.println(theRC.getItemInfo());

    //        TimeSeries item1_xy_data = new TimeSeries("Item1");
    //        TimeSeries item2_xy_data = new TimeSeries("Item2");
    //        TimeSeries item3_xy_data = new TimeSeries("Item3");
    ArrayList<Receiving> theReceiving = theExcel.getSheetReceiving();

    //        HashMap<Month, Integer> item1Map = new HashMap<>();
    //        HashMap<Month, Integer> item2Map = new HashMap<>();
    //        HashMap<Month, Integer> item3Map = new HashMap<>();

    TimeSeries data[] = new TimeSeries[theRC.getNumberOfItem()];
    HashMap<Month, Integer> itemMap[] = new HashMap[theRC.getNumberOfItem()];
    for (int i = 0; i < theRC.getNumberOfItem(); i++) {
        String itemName = "item" + i;
        data[i] = new TimeSeries(itemName);
        itemMap[i] = new HashMap<>();
    }/*from   w  w  w  .j  a v  a2s . c o  m*/
    Calendar cal = Calendar.getInstance();
    for (int i = 0; i < theReceiving.size(); i++) {
        cal.setTime(theReceiving.get(i).getDate());
        int month = cal.get(Calendar.MONTH) + 1;
        int year = cal.get(Calendar.YEAR);
        int quantity = theReceiving.get(i).getQuantity();
        Month theMonth = new Month(month, year);
        int itemNum = theReceiving.get(i).getItem() - 1;
        itemMap[itemNum].put(theMonth, updateItemMap(itemMap[itemNum], theMonth, quantity));
        //            if (theReceiving[i].getItem() == 1)
        //            {
        //                item1Map.put(theMonth, updateItemMap(item1Map, theMonth, quantity));
        //            }
        //            else if (theReceiving[i].getItem() == 2)
        //            {
        //                item2Map.put(theMonth, updateItemMap(item2Map, theMonth, quantity));
        //            }
        //            else if (theReceiving[i].getItem() == 3)
        //            {
        //                item3Map.put(theMonth, updateItemMap(item3Map, theMonth, quantity));
        //            }
    }
    TimeSeriesCollection my_data_series = new TimeSeriesCollection();
    for (int i = 0; i < theRC.getNumberOfItem(); i++) {
        for (Map.Entry<Month, Integer> entry : itemMap[i].entrySet()) {
            data[i].add(entry.getKey(), entry.getValue());
        }
        my_data_series.addSeries(data[i]);
    }

    // add series using addSeries method
    //        my_data_series.addSeries(item1_xy_data);
    //        my_data_series.addSeries(item2_xy_data);
    //        my_data_series.addSeries(item3_xy_data);        
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Receiving", "Month", "Quantity", my_data_series,
            true, true, false);
    chart.setBackgroundPaint(Color.YELLOW);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.GREEN);
    plot.setRangeGridlinePaint(Color.orange);
    plot.setAxisOffset(new RectangleInsets(50, 0, 20, 5));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

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

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MM.yyyy"));
    return chart;
}