Example usage for java.awt Color cyan

List of usage examples for java.awt Color cyan

Introduction

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

Prototype

Color cyan

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

Click Source Link

Document

The color cyan.

Usage

From source file:msi.gama.outputs.layers.ChartLayerStatement.java

public void updateseries(final IScope scope) throws GamaRuntimeException {
    // datas=dataswithoutlists;
    datasfromlists = new ArrayList<ChartData>();
    for (int dl = 0; dl < datalists.size(); dl++) {
        ChartDataList datalist = datalists.get(dl);

        Object val = datalist.valuelistexp.resolveAgainst(scope).value(scope);
        if (!(val instanceof GamaList)) {
            // GuiUtils.debug("chart list with no list...");
            return;
        }// w w w.j a v a  2 s. c o  m
        List<List> values = Cast.asList(scope, val);
        if (datalist.doreverse) {
            List tempvalues = Cast.asList(scope, val);
            values = new ArrayList<List>();
            if (tempvalues.get(0) instanceof GamaList) {
                IList nval = Cast.asList(scope, tempvalues.get(0));
                for (int j = 0; j < nval.size(); j++) {
                    List nl = new ArrayList();
                    nl.add(nval.get(j));
                    values.add(nl);
                }
            } else {
                // GuiUtils.debug("Reverse series but not list of list..." + tempvalues);
                return;

            }
            if (tempvalues.size() > 1) {
                for (int i = 1; i < tempvalues.size(); i++) {
                    if (tempvalues.get(i) instanceof GamaList) {
                        IList nval = Cast.asList(scope, tempvalues.get(i));
                        for (int j = 0; j < nval.size(); j++) {
                            // Cast.asList(scope, values.get(j)).add(nval.get(j));

                            values.get(j).add(nval.get(j));

                        }
                    } else {
                        // GuiUtils.debug("Reverse series but not list of list..." + tempvalues);
                        return;

                    }
                }
            }

            // GuiUtils.debug("New Values"+values);
        }

        List defaultnames = new ArrayList<String>();
        List defaultcolors = new ArrayList<GamaColor>();
        for (int i = 0; i < values.size() + 1; i++) {
            defaultnames.add("data" + i);
            // defaultcolors.add(GamaColor.array[i]);
            if (i < 10) {

                if (i == 0) {
                    defaultcolors.add(Cast.asColor(scope, Color.CYAN));
                }
                if (i == 1) {
                    defaultcolors.add(Cast.asColor(scope, Color.RED));
                }
                if (i == 2) {
                    defaultcolors.add(Cast.asColor(scope, Color.YELLOW));
                }
                if (i == 3) {
                    defaultcolors.add(Cast.asColor(scope, Color.GREEN));
                }
                if (i == 4) {
                    defaultcolors.add(Cast.asColor(scope, Color.BLUE));
                }
                if (i == 5) {
                    defaultcolors.add(Cast.asColor(scope, Color.PINK));
                }
                if (i == 6) {
                    defaultcolors.add(Cast.asColor(scope, Color.MAGENTA));
                }
                if (i == 7) {
                    defaultcolors.add(Cast.asColor(scope, Color.ORANGE));
                }
                if (i == 8) {
                    defaultcolors.add(Cast.asColor(scope, Color.LIGHT_GRAY));
                }
                if (i == 9) {
                    defaultcolors.add(Cast.asColor(scope, Color.DARK_GRAY));
                }
            }
            if (i >= 10) {
                if (i < GamaColor.colors.size()) {
                    defaultcolors.add(GamaColor.int_colors.values()[i]);
                } else {
                    defaultcolors.add(GamaColor.getInt(Random.opRnd(scope, 10000)));
                }
            }

        }

        if (datalist.colorlistexp != null) {
            Object valcol = datalist.colorlistexp.resolveAgainst(scope).value(scope);
            if (valcol instanceof GamaList) {
                for (int c = 0; c < ((GamaList) valcol).size(); c++) {
                    // if ( type == SERIES_CHART)
                    // defaultcolors.set(c+1, Cast.asColor(scope, ((GamaList)valcol).get(c)));
                    // else
                    defaultcolors.set(c, Cast.asColor(scope, ((GamaList) valcol).get(c)));

                }

            }
        }

        boolean dynamicseriesnames = false;
        List<String> seriesnames = new ArrayList();

        if (datalist.legendlistexp != null) {
            Object valc = datalist.legendlistexp.resolveAgainst(scope).value(scope);

            if (valc instanceof GamaList) {
                dynamicseriesnames = true;
                seriesnames = (GamaList) valc;
                for (int i = 0; i < Math.min(values.size(), seriesnames.size()); i++) {
                    defaultnames.set(i, seriesnames.get(i) + "(" + i + ")");
                    if (type == SERIES_CHART && ((XYPlot) chart.getPlot()).getDataset(i + 1) != null) {
                        if (((DefaultTableXYDataset) ((XYPlot) chart.getPlot()).getDataset(i + 1))
                                .getSeriesCount() > 0) {
                            ((DefaultTableXYDataset) ((XYPlot) chart.getPlot()).getDataset(i + 1)).getSeries(0)
                                    .setKey(seriesnames.get(i) + "(" + i + ")");
                        }

                    }
                }
                if (values.size() > seriesnames.size()) {
                    for (int i = seriesnames.size(); i < values.size(); i++) {
                        defaultnames.set(i, "(" + i + ")");
                    }
                }
            } else {
                for (int i = values.size(); i < values.size(); i++) {
                    defaultnames.set(i, "(" + i + ")");
                }
            }
        }

        int nbseries = values.size();
        // if ( type==SERIES_CHART ) nbseries++;
        // ChartData first=datas.get(0);
        if (type == HISTOGRAM_CHART) {
            ((DefaultCategoryDataset) dataset).clear();
        }
        if (type == PIE_CHART) {
            ((DefaultPieDataset) dataset).clear();
        }
        if (nbseries > datalist.previoussize) {

            for (int i = datalist.previoussize; i < nbseries; i++) {
                AbstractRenderer r;
                try {
                    r = datalist.renderer.getClass().newInstance();
                    if (XYLineAndShapeRenderer.class.isAssignableFrom(r.getClass())) {
                        ((XYLineAndShapeRenderer) r).setBaseShapesFilled(
                                ((XYLineAndShapeRenderer) datalist.renderer).getBaseShapesFilled());
                        ((XYLineAndShapeRenderer) r).setBaseShapesVisible(
                                ((XYLineAndShapeRenderer) datalist.renderer).getBaseShapesVisible());
                        ((XYLineAndShapeRenderer) r).setSeriesLinesVisible(0,
                                ((XYLineAndShapeRenderer) datalist.renderer).getSeriesLinesVisible(0));
                    }
                    ChartData newdata;
                    newdata = ChartDataListStatement.newChartData(scope, r,
                            Cast.asString(scope, defaultnames.get(i)),
                            Cast.asColor(scope, defaultcolors.get(i)), values.get(i));

                    datas.add(newdata);
                    datasfromlists.add(newdata);

                    if (type == SERIES_CHART || type == XY_CHART || type == SCATTER_CHART) {
                        final XYPlot plot = (XYPlot) chart.getPlot();
                        final String legend = newdata.getName();
                        // if (dataset==null)
                        // dataset = new XYDataset();
                        if (type == SERIES_CHART || type == XY_CHART) {
                            dataset = new DefaultTableXYDataset();
                            final XYSeries serie = new XYSeries(legend, false, false);
                            ((DefaultTableXYDataset) dataset).addSeries(serie);

                        } else {
                            dataset = new XYSeriesCollection();
                            final XYSeries serie = new XYSeries(legend, false, true);
                            ((XYSeriesCollection) dataset).addSeries(serie);

                        }
                        expressions_index.put(legend, datas.size() - 1);
                        plot.setRenderer(datas.size() - 1, (XYItemRenderer) newdata.getRenderer(), false);
                        final Color c = newdata.getColor();
                        plot.getRenderer(datas.size() - 1).setSeriesPaint(0, c);
                        // if ((i>0)||(type==XY_CHART))
                        plot.setDataset(datas.size() - 1, (XYDataset) dataset);
                        history.append(legend);
                        history.append(',');
                    }

                    if (type == HISTOGRAM_CHART) {
                        final CategoryPlot plot = (CategoryPlot) chart.getPlot();
                        int l = 0;
                        for (final ChartData e : datas) {
                            // String legend = e.getName();
                            // ((DefaultCategoryDataset) dataset).setValue(0d, new Integer(0), legend/* , legend
                            // */);

                            final String legend = e.getName();
                            if (!CategoryItemRenderer.class.isInstance(e.getRenderer())) {
                                e.renderer = new BarRenderer();
                            }
                            plot.setRenderer(l, (CategoryItemRenderer) e.getRenderer(), false);
                            final Color c = e.getColor();
                            plot.getRenderer(l).setSeriesPaint(0, c);
                            // plot.setDataset(i, (DefaultCategoryDataset) dataset);
                            // }
                            l++;
                            history.append(legend);
                            history.append(',');

                        }
                        if (history.length() > 0) {
                            history.deleteCharAt(history.length() - 1);
                        }
                        history.append(Strings.LN);
                        // plot.setDataset((DefaultCategoryDataset) dataset);

                    }
                    if (type == PIE_CHART) {
                        int l = 0;
                        // dataset = new DefaultPieDataset();
                        final PiePlot plot = (PiePlot) chart.getPlot();
                        for (final ChartData e : datas) {
                            final String legend = e.getName();
                            ((DefaultPieDataset) dataset).insertValue(l++, legend, null);
                            history.append(legend);
                            history.append(',');
                        }
                        if (history.length() > 0) {
                            history.deleteCharAt(history.length() - 1);
                        }
                        history.append(Strings.LN);
                        history.append(Strings.LN);
                        // plot.setDataset((DefaultPieDataset) dataset);
                        l = 0;
                        for (final ChartData e : datas) {
                            plot.setSectionPaint(l++, e.getColor());
                        }
                        plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} ({2})"));
                        if (exploded) {
                            for (final Object c : ((DefaultPieDataset) dataset).getKeys()) {
                                plot.setExplodePercent((Comparable) c, 0.20);
                            }
                        }
                    }

                } catch (InstantiationException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
            datalist.previoussize = nbseries;
        }

        boolean dynamiccategorynames = false;
        List<String> categorynames = new ArrayList<String>();
        /*
         * if (datalist.categlistexp!=null)
         * {
         * Object valc=datalist.categlistexp.resolveAgainst(scope).value(scope);
         * if ((valc instanceof GamaList))
         * {
         * dynamiccategorynames=true;
         * categorynames=(GamaList)valc;
         * }
         *
         * if (type==HISTOGRAM_CHART)
         * {
         * for ( int i=0; i<values.size(); i++ ) {
         * GamaList x = new GamaList();
         * Object obj = values.get(i);
         * if ( obj instanceof GamaList ) {
         * x = (GamaList) obj;
         * // clearvalues=true;
         * if (dynamiccategorynames)
         * {
         * for (int j=0;j<x.length(scope);j++)
         * if (j<categorynames.size())
         * {
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope,
         * x.get(j)).doubleValue(),(String)defaultnames.get(i),categorynames.get(j).toString()+"("+j+")");
         * }
         * else
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope,
         * x.get(j)).doubleValue(),(String)defaultnames.get(i),"("+j+")");
         * }
         * else
         * {
         * for (int j=0;j<x.length(scope);j++)
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope,
         * x.get(j)).doubleValue(),(String)defaultnames.get(i), new Integer(j));
         *
         * }
         * } else {
         * ((DefaultCategoryDataset) dataset).setValue(Cast.asFloat(scope, obj).doubleValue(), new
         * Integer(0),(String)defaultnames.get(i));
         * }
         * }
         * }
         * }
         */
        if (chart.getLegend() == null) {
            chart.addLegend(new LegendTitle(chart.getPlot()));
        }
        // LegendTitle legend = chart.getLegend();
        // GuiUtils.debug("dyncateg:"+defaultnames);
        // GuiUtils.debug("legend:"+legend);
        for (int i = 0; i < nbseries; i++) {
            ChartData first = datas.get(i);
            if (type == SERIES_CHART) {
                first = datas.get(i + 1);
            }
            first.lastvalue = values.get(i);

        }

    }
}

From source file:gov.llnl.lustre.lwatch.PlotFrame2.java

/**
 * Initialize the curve colors used in the chart.
 *//*from  w w w.j  ava2  s .  co m*/

void initColors() {

    curveColor[0] = Color.green;
    curveColor[1] = Color.yellow;
    curveColor[2] = Color.red;
    curveColor[3] = Color.blue;
    curveColor[4] = Color.white;
    curveColor[5] = Color.orange;
    curveColor[6] = Color.cyan;
    curveColor[7] = Color.magenta;
    curveColor[8] = Color.pink;

}

From source file:net.nikr.eve.jeveasset.gui.tabs.tracker.TrackerTab.java

private void updateShown() {
    //Remove All/* w w w.ja v  a2s.  c  o m*/
    while (dataset.getSeriesCount() != 0) {
        dataset.removeSeries(0);
    }
    render.clear();
    if (jTotal.isSelected()) { //Update total
        TimePeriodValues total = new TimePeriodValues(TabsTracker.get().total());
        for (Map.Entry<SimpleTimePeriod, Value> entry : cache.entrySet()) {
            double t = 0;
            if (jWalletBalance.isSelected() && walletBalance != null) {
                t += entry.getValue().getBalanceTotal();
            }
            if (jAssets.isSelected() && assets != null) {
                t += entry.getValue().getAssetsTotal();
            }
            if (jSellOrders.isSelected() && sellOrders != null) {
                t += entry.getValue().getSellOrders();
            }
            if (jEscrows.isSelected() && escrows != null) {
                t += entry.getValue().getEscrows();
            }
            //Escrows To Cover is not money you own, It's technically money you owe
            //Therefor it's not included in the total
            //See: https://forums.eveonline.com/default.aspx?g=posts&m=6607898#post6607898
            //if (jEscrowsToCover.isSelected() && escrowsToCover != null) {
            //   t += entry.getValue().getEscrowsToCover();
            //}
            if (jManufacturing.isSelected() && manufacturing != null) {
                t += entry.getValue().getManufacturing();
            }
            if (jContractCollateral.isSelected() && contractCollateral != null) {
                t += entry.getValue().getContractCollateral();
            }
            if (jContractValue.isSelected() && contractValue != null) {
                t += entry.getValue().getContractValue();
            }
            total.add(entry.getKey(), t);
        }
        dataset.addSeries(total);
        Integer minColumn = null;
        if (jWalletBalance.isSelected() && walletColumn != null) {
            minColumn = walletColumn;
        }
        if (jAssets.isSelected() && assetColumn != null) {
            if (minColumn != null) {
                minColumn = Math.min(minColumn, assetColumn);
            } else {
                minColumn = assetColumn;
            }
        }
        render.add(dataset.getSeriesCount() - 1, minColumn);
        updateRender(dataset.getSeriesCount() - 1, Color.RED.darker());
    }
    if (jWalletBalance.isSelected() && walletBalance != null) {
        dataset.addSeries(walletBalance);
        render.add(dataset.getSeriesCount() - 1, walletColumn);
        updateRender(dataset.getSeriesCount() - 1, Color.BLUE.darker());

    }
    if (jAssets.isSelected() && assets != null) {
        dataset.addSeries(assets);
        render.add(dataset.getSeriesCount() - 1, assetColumn);
        updateRender(dataset.getSeriesCount() - 1, Color.GREEN.darker().darker());
    }
    if (jSellOrders.isSelected() && sellOrders != null) {
        dataset.addSeries(sellOrders);
        updateRender(dataset.getSeriesCount() - 1, Color.CYAN.darker());
    }
    if (jEscrows.isSelected() && escrows != null) {
        dataset.addSeries(escrows);
        updateRender(dataset.getSeriesCount() - 1, Color.BLACK);
    }
    if (jEscrowsToCover.isSelected() && escrowsToCover != null) {
        dataset.addSeries(escrowsToCover);
        updateRender(dataset.getSeriesCount() - 1, Color.GRAY);
    }
    if (jManufacturing.isSelected() && manufacturing != null) {
        dataset.addSeries(manufacturing);
        updateRender(dataset.getSeriesCount() - 1, Color.MAGENTA);
    }
    if (jContractCollateral.isSelected() && contractCollateral != null) {
        dataset.addSeries(contractCollateral);
        updateRender(dataset.getSeriesCount() - 1, Color.PINK);
    }
    if (jContractValue.isSelected() && contractValue != null) {
        dataset.addSeries(contractValue);
        updateRender(dataset.getSeriesCount() - 1, Color.ORANGE);
    }
    //Add empty dataset
    if (dataset.getSeriesCount() == 0) {
        TimePeriodValues timePeriodValues = new TimePeriodValues(TabsTracker.get().empty());
        dataset.addSeries(timePeriodValues);
        updateRender(dataset.getSeriesCount() - 1, Color.BLACK);
    }
    jNextChart.getXYPlot().getRangeAxis().setAutoRange(true);
    jNextChart.getXYPlot().getDomainAxis().setAutoRange(true);
    Number maxNumber = DatasetUtilities.findMaximumRangeValue(dataset);
    NumberAxis rangeAxis = (NumberAxis) jNextChart.getXYPlot().getRangeAxis();
    rangeAxis.setNumberFormatOverride(Formater.LONG_FORMAT); //Default
    if (maxNumber != null && (maxNumber instanceof Double)) {
        double max = (Double) maxNumber;
        if (max > 1000000000000.0) { //Higher than 1 Trillion
            rangeAxis.setNumberFormatOverride(Formater.TRILLIONS_FORMAT);
        } else if (max > 1000000000.0) { //Higher than 1 Billion
            rangeAxis.setNumberFormatOverride(Formater.BILLIONS_FORMAT);
        } else if (max > 1000000.0) { //Higher than 1 Million
            rangeAxis.setNumberFormatOverride(Formater.MILLIONS_FORMAT);
        }
    }
}

From source file:com.manydesigns.portofino.actions.admin.appwizard.ApplicationWizard.java

protected void setupCalendar(List<ChildPage> childPages) throws Exception {
    List<List<String>> calendarDefinitions = new ArrayList<List<String>>();
    Color[] colors = { Color.RED, new Color(64, 128, 255), Color.CYAN.darker(), Color.GRAY,
            Color.GREEN.darker(), Color.ORANGE, Color.YELLOW.darker(), Color.MAGENTA.darker(), Color.PINK };
    int colorIndex = 0;
    for (Table table : allTables) {
        List<Column> dateColumns = new ArrayList<Column>();
        for (Column column : table.getColumns()) {
            if (column.getActualJavaType() != null && Date.class.isAssignableFrom(column.getActualJavaType())) {
                dateColumns.add(column);
            }/*from w w w  .ja v  a2 s .c  o m*/
        }
        if (!dateColumns.isEmpty()) {
            // ["Cal 1", "db1.schema1.table1", ["column1", "column2"], Color.RED]
            Color color = colors[colorIndex++ % colors.length];
            List<String> calDef = new ArrayList<String>();
            calDef.add('"' + Util.guessToWords(table.getActualEntityName()) + '"');
            calDef.add('"' + table.getQualifiedName() + '"');
            String cols = "[";
            boolean first = true;
            for (Column column : dateColumns) {
                if (first) {
                    first = false;
                } else {
                    cols += ", ";
                }
                cols += '"' + column.getActualPropertyName() + '"';
            }
            cols += "]";
            calDef.add(cols);
            calDef.add("new java.awt.Color(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue()
                    + ")");
            calendarDefinitions.add(calDef);
        }
    }
    if (!calendarDefinitions.isEmpty()) {
        String calendarDefinitionsStr = "[";
        calendarDefinitionsStr += StringUtils.join(calendarDefinitions, ", ");
        calendarDefinitionsStr += "]";
        String baseName = "calendar-" + connectionProvider.getDatabase().getDatabaseName();
        File dir = new File(pagesDir, baseName);
        int retries = 1;
        while (dir.exists()) {
            retries++;
            dir = new File(pagesDir, baseName + "-" + retries);
        }
        if (dir.mkdirs()) {
            CalendarConfiguration configuration = new CalendarConfiguration();
            DispatcherLogic.saveConfiguration(dir, configuration);

            Page page = new Page();
            page.setId(RandomUtil.createRandomId());
            String calendarTitle = "Calendar (" + connectionProvider.getDatabase().getDatabaseName() + ")";
            if (retries > 1) {
                calendarTitle += " - " + retries;
            }
            page.setTitle(calendarTitle);
            page.setDescription(calendarTitle);

            DispatcherLogic.savePage(dir, page);
            File actionFile = new File(dir, "action.groovy");
            try {
                TemplateEngine engine = new SimpleTemplateEngine();
                Template template = engine
                        .createTemplate(ApplicationWizard.class.getResource("CalendarPage.groovy"));
                Map<String, Object> bindings = new HashMap<String, Object>();
                bindings.put("calendarDefinitions", calendarDefinitionsStr);
                FileWriter fw = new FileWriter(actionFile);
                template.make(bindings).writeTo(fw);
                IOUtils.closeQuietly(fw);
            } catch (Exception e) {
                logger.warn("Couldn't create calendar", e);
                SessionMessages.addWarningMessage("Couldn't create calendar: " + e);
                return;
            }

            ChildPage childPage = new ChildPage();
            childPage.setName(dir.getName());
            childPage.setShowInNavigation(true);
            childPages.add(childPage);
        } else {
            logger.warn("Couldn't create directory {}", dir.getAbsolutePath());
            SessionMessages.addWarningMessage(
                    ElementsThreadLocals.getText("couldnt.create.directory", dir.getAbsolutePath()));
        }
    }
}

From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link ColorEnum}.
 *///from   ww  w .j  a v a  2s .c  om
public static Map getColorMap() {
    if (colorMap == null) {
        Map map = new HashMap(35);
        map.put(COLOR_BLACK, Color.black);
        map.put(COLOR_BLUE, Color.blue);
        map.put(COLOR_CYAN, Color.cyan);
        map.put(COLOR_DARK_GRAY, Color.darkGray);
        map.put(COLOR_GRAY, Color.gray);
        map.put(COLOR_GREEN, Color.green);
        map.put(COLOR_LIGHT_GRAY, Color.lightGray);
        map.put(COLOR_MAGENTA, Color.magenta);
        map.put(COLOR_ORANGE, Color.orange);
        map.put(COLOR_PINK, Color.pink);
        map.put(COLOR_RED, Color.red);
        map.put(COLOR_YELLOW, Color.yellow);
        map.put(COLOR_WHITE, Color.white);
        map.put(Color.black, COLOR_BLACK);
        map.put(Color.blue, COLOR_BLUE);
        map.put(Color.cyan, COLOR_CYAN);
        map.put(Color.darkGray, COLOR_DARK_GRAY);
        map.put(Color.gray, COLOR_GRAY);
        map.put(Color.green, COLOR_GREEN);
        map.put(Color.lightGray, COLOR_LIGHT_GRAY);
        map.put(Color.magenta, COLOR_MAGENTA);
        map.put(Color.orange, COLOR_ORANGE);
        map.put(Color.pink, COLOR_PINK);
        map.put(Color.red, COLOR_RED);
        map.put(Color.yellow, COLOR_YELLOW);
        map.put(Color.white, COLOR_WHITE);
        colorMap = Collections.unmodifiableMap(map);
    }

    return colorMap;
}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private byte[] createMonthlyLoginChart(int width, int height) {
    IntervalXYDataset dataset1 = getMonthlyLoginsDataSet();
    IntervalXYDataset dataset3 = getMonthlySiteUserDataSet();

    if ((dataset1 == null) || (dataset3 == null)) {
        return generateNoDataChart(width, height);
    }//from   w w  w. j  av  a 2  s. co  m

    // create plot ...
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.RED);

    DateAxis domainAxis = new DateAxis("");
    domainAxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, new SimpleDateFormat("yyyy-MM")));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setLowerMargin(0.01);
    domainAxis.setUpperMargin(0.01);

    NumberAxis axis1 = new NumberAxis("Total Logins");
    axis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    axis1.setLabelPaint(Color.RED);
    axis1.setTickLabelPaint(Color.RED);

    XYPlot plot1 = new XYPlot(dataset1, null, axis1, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // AXIS 2
    /*
    NumberAxis axis2 = new NumberAxis("Total Unique Users");
    axis2.setStandardTickUnits (NumberAxis.createIntegerTickUnits ());
    axis2.setLabelPaint(Color.BLUE);
    axis2.setTickLabelPaint(Color.BLUE);
    plot1.setRangeAxis(1, axis2);
            
    plot1.setDataset(1, dataset2);
    plot1.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f, 
        BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesPaint (0, Color.BLUE);
    plot1.setRenderer(1, renderer2);
    */

    // add a third dataset and renderer...
    XYItemRenderer renderer3 = new XYLineAndShapeRenderer(true, false);
    renderer3.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer3.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer3.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer3.setSeriesPaint(0, Color.GREEN);
    renderer3.setSeriesPaint(1, Color.BLACK);
    renderer3.setSeriesPaint(2, Color.CYAN);

    axis1 = new NumberAxis("count");
    axis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot2 = new XYPlot(dataset3, null, axis1, renderer3);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);

    // set background
    chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set anti alias
    chart.setAntiAlias(true);

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        log.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}

From source file:edu.harvard.mcz.imagecapture.PositionTemplateEditor.java

/**
 * Draw boxes delimiting the various parts of the template on the current image.
 * Public so that it can be invoked from ButtonEditor().
 *///from ww  w .j  a v  a 2 s.  c om
public void drawLayers() {
    // draw the image bounds in black.
    if (template != null) {
        imagePanelForDrawing.clearOverlay();
        imagePanelForDrawing.drawBox(new Dimension(0, 0), template.getImageSize(), Color.BLACK,
                new BasicStroke(2F));
        // draw each template layer in a distinct color (keyed to UI text).
        imagePanelForDrawing.drawBox(template.getBarcodeULPosition(), template.getBarcodeSize(), Color.RED);
        imagePanelForDrawing.drawBox(template.getTextPosition(), template.getTextSize(), Color.BLUE);
        imagePanelForDrawing.drawBox(template.getSpecimenPosition(), template.getSpecimenSize(), Color.ORANGE);
        imagePanelForDrawing.drawBox(template.getUTLabelsPosition(), template.getUTLabelsSize(), Color.CYAN);
        imagePanelForDrawing.drawBox(template.getLabelPosition(), template.getLabelSize(), Color.MAGENTA);
        imagePanelForDrawing.drawBox(template.getUtBarcodePosition(), template.getUtBarcodeSize(), Color.BLACK);
    }
}

From source file:ElectionGUI.java

private void plotResultsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_plotResultsBtnActionPerformed
    if (!generalPreferencesCheckBox.isSelected()) {
        clearGraphPanels();//from w  w  w.  ja  va 2s  .com
        systemTxt.append("-Generating results and graphing scatter plots." + eol);

        committeeSNTV = election2D.singleNonTransferableVote();
        committeeBorda = election2D.kBorda();
        committeeBloc = election2D.bloc();
        committeeSTV = election2D.singleTransferableVote();
        committeeGCC = election2D.greedyCC();
        committeeGM = election2D.greedyMonroe();
        committeeKM = election2D.kMeans();

        consistencyBtn.setEnabled(true);

        ChartPanel chartSNTV = ChartPanelMaker.createChart(election2D.getVoters(), election2D.getCandidates(),
                committeeSNTV, "SNTV");
        plotAreaSNTV.setLayout(new java.awt.BorderLayout());
        plotAreaSNTV.add(chartSNTV, BorderLayout.CENTER);
        plotAreaSNTV.validate();

        ChartPanel chartBorda = ChartPanelMaker.createChart(election2D.getVoters(), election2D.getCandidates(),
                committeeBorda, "k-Borda");
        plotAreaBorda.setLayout(new java.awt.BorderLayout());
        plotAreaBorda.add(chartBorda, BorderLayout.CENTER);
        plotAreaBorda.validate();

        ChartPanel chartBloc = ChartPanelMaker.createChart(election2D.getVoters(), election2D.getCandidates(),
                committeeBloc, "Bloc");
        plotAreaBloc.setLayout(new java.awt.BorderLayout());
        plotAreaBloc.add(chartBloc, BorderLayout.CENTER);
        plotAreaBloc.validate();

        ChartPanel chartSTV = ChartPanelMaker.createChart(election2D.getVoters(), election2D.getCandidates(),
                committeeSTV, "STV");
        plotAreaSTV.setLayout(new java.awt.BorderLayout());
        plotAreaSTV.add(chartSTV, BorderLayout.CENTER);
        plotAreaSTV.validate();

        ChartPanel chartGCC = ChartPanelMaker.createChart(election2D.getVoters(), election2D.getCandidates(),
                committeeGCC, "Greedy-CC");
        plotAreaGCC.setLayout(new java.awt.BorderLayout());
        plotAreaGCC.add(chartGCC, BorderLayout.CENTER);
        plotAreaGCC.validate();

        ChartPanel chartGM = ChartPanelMaker.createChart(election2D.getVoters(), election2D.getCandidates(),
                committeeGM, "Greedy-Monroe");
        plotAreaGM.setLayout(new java.awt.BorderLayout());
        plotAreaGM.add(chartGM, BorderLayout.CENTER);
        plotAreaGM.validate();

        ChartPanel chartKM = ChartPanelMaker.createChart(election2D.getVoters(), election2D.getCandidates(),
                committeeKM, "k-Means");
        plotAreaKM.setLayout(new java.awt.BorderLayout());
        plotAreaKM.add(chartKM, BorderLayout.CENTER);
        plotAreaKM.validate();

        //ProportionalityTest, calculating norms
        double[] vectorSNTV = election2D.getDistanceVector(committeeSNTV);
        systemTxt.append(NormCalculator.getNormText(vectorSNTV, "SNTV"));

        double[] vectorBorda = election2D.getDistanceVector(committeeBorda);
        systemTxt.append(NormCalculator.getNormText(vectorBorda, "k-Borda"));

        double[] vectorBloc = election2D.getDistanceVector(committeeBloc);
        systemTxt.append(NormCalculator.getNormText(vectorBloc, "Bloc"));

        double[] vectorSTV = election2D.getDistanceVector(committeeSTV);
        systemTxt.append(NormCalculator.getNormText(vectorSTV, "STV"));

        double[] vectorGCC = election2D.getDistanceVector(committeeGCC);
        systemTxt.append(NormCalculator.getNormText(vectorGCC, "Greedy-CC"));

        double[] vectorGM = election2D.getDistanceVector(committeeGM);
        systemTxt.append(NormCalculator.getNormText(vectorGM, "Greedy-Monroe"));

        double[] vectorKM = election2D.getDistanceVector(committeeKM);
        systemTxt.append(NormCalculator.getNormText(vectorKM, "k-Means") + eol);

        systemTxt.append("----------------------------------------" + eol);
    } else {
        kTxtField.setBackground(Color.white);
        clearGraphPanels();
        String err = "";
        m = electionGP.getNumberOfCandidates();

        try {
            int x = Integer.parseInt(kTxtField.getText());
            if (x < 1 || x > 100 || x > m) {
                throw (new Exception());
            }
            k = x;
            electionGP.setCommitteeSize(k);
        } catch (Exception e) {
            kTxtField.setBackground(Color.cyan);
            err = "-Error: Value " + kTxtField.getText() + " is not a "
                    + "valid committee size. Maximum size is the minimum "
                    + "between 100 and the candidate population." + eol;
        }

        if (err == "") {
            committeeSNTV = electionGP.singleNonTransferableVote();
            committeeBorda = electionGP.kBorda();
            committeeBloc = electionGP.bloc();
            committeeSTV = electionGP.singleTransferableVote();
            committeeGCC = electionGP.greedyCC();
            committeeGM = electionGP.greedyMonroe();

            consistencyBtn.setEnabled(true);

            systemTxt.append(eol + "SNTV Winning Committee:" + eol);
            for (Candidate c : committeeSNTV) {
                systemTxt.append("        " + c.getName() + eol);
            }

            systemTxt.append(eol + "k-Borda Winning Committee:" + eol);
            for (Candidate c : committeeBorda) {
                systemTxt.append("        " + c.getName() + eol);
            }

            systemTxt.append(eol + "Bloc Winning Committee:" + eol);
            for (Candidate c : committeeBloc) {
                systemTxt.append("        " + c.getName() + eol);
            }

            systemTxt.append(eol + "STV Winning Committee:" + eol);
            for (Candidate c : committeeSTV) {
                systemTxt.append("        " + c.getName() + eol);
            }

            systemTxt.append(eol + "Greedy-CC Winning Committee:" + eol);
            for (Candidate c : committeeGCC) {
                systemTxt.append("        " + c.getName() + eol);
            }

            systemTxt.append(eol + "Greedy-Monroe Winning Committee:" + eol);
            for (Candidate c : committeeGM) {
                systemTxt.append("        " + c.getName() + eol);
            }

            systemTxt.append(eol + "-----------------------------" + eol + eol);
        } else {
            systemTxt.append(err);
            systemTxt.append("-Calculating winning committees cancelled. "
                    + "Please choose a new committee size and try again.");
        }

        //ProportionalityTest, calculating norms
        double[] vectorSNTV = electionGP.getDistanceVector(committeeSNTV);
        systemTxt.append(NormCalculator.getNormText(vectorSNTV, "SNTV"));

        double[] vectorBorda = electionGP.getDistanceVector(committeeBorda);
        systemTxt.append(NormCalculator.getNormText(vectorBorda, "k-Borda"));

        double[] vectorBloc = electionGP.getDistanceVector(committeeBloc);
        systemTxt.append(NormCalculator.getNormText(vectorBloc, "Bloc"));

        double[] vectorSTV = electionGP.getDistanceVector(committeeSTV);
        systemTxt.append(NormCalculator.getNormText(vectorSTV, "STV"));

        double[] vectorGCC = electionGP.getDistanceVector(committeeGCC);
        systemTxt.append(NormCalculator.getNormText(vectorGCC, "Greedy-CC"));

        double[] vectorGM = electionGP.getDistanceVector(committeeGM);
        systemTxt.append(NormCalculator.getNormText(vectorGM, "Greedy-Monroe"));

        systemTxt.append("----------------------------------------" + eol);
    }
}

From source file:UserInterface.SystemAdmin.ReportsJPanel.java

private void buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonActionPerformed
    if (c == null) {
        JOptionPane.showMessageDialog(null, "No Customer");
        return;/*from  w w  w .  jav a 2s.  c  o m*/
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (WaterUsage waterUsage : c.getWaterUsageHistory()) {
        dataset.setValue(waterUsage.getUsageVolume(), waterUsage.getDate(), "Usage Volume");
    }

    JFreeChart chart = ChartFactory.createBarChart("Customer Water Usage Trends over a period of time",
            "Time of Usage", "Gallons", dataset, PlotOrientation.VERTICAL, true, true, true);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.cyan);
    ChartFrame frame = new ChartFrame("Bar Char for Weight", chart);

    frame.setVisible(true);
    frame.setSize(450, 350);

}

From source file:org.sakaiproject.sitestats.impl.ServerWideReportManagerImpl.java

private byte[] createWeeklyLoginChart(int width, int height) {
    IntervalXYDataset dataset1 = getWeeklyLoginsDataSet();
    IntervalXYDataset dataset2 = getWeeklySiteUserDataSet();

    if ((dataset1 == null) || (dataset2 == null)) {
        return generateNoDataChart(width, height);
    }/*from  w ww  .  j a va 2 s .co  m*/

    // create plot ...
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.RED);
    renderer1.setSeriesPaint(0, Color.BLUE);

    DateAxis domainAxis = new DateAxis("");
    domainAxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat("yyyy-MM-dd")));
    domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setLowerMargin(0.01);
    domainAxis.setUpperMargin(0.01);

    NumberAxis rangeAxis = new NumberAxis("count");
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot1 = new XYPlot(dataset1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer2.setSeriesPaint(0, Color.GREEN);
    renderer2.setSeriesPaint(1, Color.BLACK);
    renderer2.setSeriesPaint(2, Color.CYAN);

    rangeAxis = new NumberAxis("count");
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    XYPlot plot2 = new XYPlot(dataset2, null, rangeAxis, renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);

    // set background
    chart.setBackgroundPaint(parseColor(statsManager.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set anti alias
    chart.setAntiAlias(true);

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        log.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}