Example usage for java.awt Color gray

List of usage examples for java.awt Color gray

Introduction

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

Prototype

Color gray

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

Click Source Link

Document

The color gray.

Usage

From source file:org.agmip.ui.afsirs.frames.GraphOutput.java

public void addEvaporationAndTranspiration() {

    XYSeries etSeries = new XYSeries("ET");
    double[][] ET = utils.getET();
    for (int i = 0; i < 10/*ET.length*/; i++) {
        for (int j = 0; j < 10/*ET[0].length*/; j++) {
            etSeries.add(i * ET[0].length + j, ET[i][j]);
        }/*  ww  w . j  a v a 2  s  .  com*/
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(etSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Evaporation Transpiration", "Days", "Inches",
            dataset/*,
                   PlotOrientation.VERTICAL, true, true, false*/);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartPanel panel = new ChartPanel(chart);
    jTabbedPane1.addTab("Evaporation Transpiration", panel);

}

From source file:edu.ucla.stat.SOCR.chart.util.MixtureEMExperiment.java

protected void initResutlsTable() {

    String[] resultsHeading = new String[2];
    resultsHeading[0] = "Kernel";
    resultsHeading[1] = "Resutls";

    Object[][] dataObject = new Object[10][2];

    tModel_results = new DefaultTableModel(dataObject, resultsHeading);

    resultsTable = new CustomJTable(tModel_results);

    /*{//from  ww  w  . ja va2  s.co  m
      public Component prepareRenderer(TableCellRenderer renderer,
      int rowIndex, int vColIndex) {
        Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
       // 
        if (rowIndex % 2 == 0) {
     c.setBackground(Color.yellow);
        } else {
        // If not shaded, match the table's background
     c.setBackground(getBackground());
        }
        return c;
     }
    };*/
    resultsTable.setGridColor(Color.gray);
    resultsTable.setShowGrid(true);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        resultsTable.setDragEnabled(true);
    } catch (Exception e) {
    }
    //columnModel = resultsTable.getColumnModel();
    //resultsTable.setTableHeader(new EditableHeader(columnModel));
    resultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    resultsTable.setCellSelectionEnabled(true);
    resultsTable.setColumnSelectionAllowed(true);
    resultsTable.setRowSelectionAllowed(true);
}

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

/**
 * /*from   w  ww  .  jav a  2s  . com*/
 */
private void initialize() {
    this.setSize(new Dimension(580, 504));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

From source file:fxts.stations.trader.ui.dialogs.ABusinessDataComboBox.java

/**
 * Set status of combo box enabled or disbled. That doesn't means that it become
 * enabled/diasbled control, the only color is changed. Aditional it made enabled or
 * disabled default button of dialog//  w  w w . j  a  va2s .c  o m
 */
public void setStatusEnabled(boolean aStatusEnabled) {
    setForeground(aStatusEnabled ? Color.BLACK : Color.GRAY);
    if (mDefaultActor != null) {
        mDefaultActor.setEnabled(aStatusEnabled);
    }
    mStatusEnabled = aStatusEnabled;
}

From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java

public XYPlot drawYIntervalPlot() {
    // Create the plot renderer
    YIntervalRenderer renderer = new YIntervalRenderer() {
        private static final long serialVersionUID = 1L;

        public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea,
                PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis,
                XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {

            // setup for collecting optional entity info...
            Shape entityArea = null;
            EntityCollection entities = null;
            if (info != null) {
                entities = info.getOwner().getEntityCollection();
            }/*from   w  ww.ja  v  a 2  s .co  m*/

            IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset;

            double x = intervalDataset.getXValue(series, item);
            double yLow = intervalDataset.getStartYValue(series, item);
            double yHigh = intervalDataset.getEndYValue(series, item);

            RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
            RectangleEdge yAxisLocation = plot.getRangeAxisEdge();

            double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
            double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, yAxisLocation);
            double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, yAxisLocation);

            Paint p = getItemPaint(series, item);
            Stroke s = getItemStroke(series, item);

            Line2D line = null;
            PlotOrientation orientation = plot.getOrientation();
            if (orientation == PlotOrientation.HORIZONTAL) {
                line = new Line2D.Double(yyLow, xx, yyHigh, xx);
            } else if (orientation == PlotOrientation.VERTICAL) {
                line = new Line2D.Double(xx, yyLow, xx, yyHigh);
            }
            g2.setPaint(p);
            g2.setStroke(s);
            g2.draw(line);

            // add an entity for the item...
            if (entities != null && line != null) {
                if (entityArea == null) {
                    entityArea = line.getBounds();
                }
                String tip = null;
                XYToolTipGenerator generator = getToolTipGenerator(series, item);
                if (generator != null) {
                    tip = generator.generateToolTip(dataset, series, item);
                }
                XYItemEntity entity = new XYItemEntity(entityArea, dataset, series, item, tip, null);
                entities.add(entity);
            }

        }

    };
    renderer.setAdditionalItemLabelGenerator(null);
    renderer.setBaseShape(new Rectangle());
    renderer.setAutoPopulateSeriesShape(false);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBasePaint(Color.GRAY);

    // Create the plot
    XYPlot plot = new XYPlot(null, null, new NumberAxis(), renderer);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    plot.getRangeAxis().setVisible(false);

    return plot;
}

From source file:org.cytoscape.dyn.internal.graphMetrics.GenerateChart.java

public JFreeChart generateTimeSeries() {

    dataset = new XYSeriesCollection();
    XYSeries[] attributeSeries = new XYSeries[(selectedNodes.size() + selectedEdges.size())
            * (checkedAttributes.size() + edgeCheckedAttributes.size())];
    int j = 0;//  w w w .  j a v  a  2s.c  o m
    /*creating dataseries for each node and its checked attribute and
    adding it to the dataset*/
    for (CyNode node : selectedNodes) {
        // System.out.println(checkedAttributes.size());
        for (int i = 0; i < checkedAttributes.size(); i++) {
            attributeSeries[j] = new XYSeries(dynamicNetwork.getNodeLabel(node) + checkedAttributes.get(i),
                    false, true);
            // System.out.println(dynamicNetwork.getDynAttribute(node,
            // checkedAttributes.get(i)).getKey().getColumn());

            for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(node, checkedAttributes.get(i))
                    .getIntervalList()) {
                // System.out.println(interval.getOnValue());
                double value;
                if (interval.getOnValue() instanceof Double)
                    value = (Double) interval.getOnValue();
                else
                    value = ((Integer) interval.getOnValue()).doubleValue();
                // System.out.println(value);
                attributeSeries[j].add(interval.getStart(), value);
                attributeSeries[j].add(interval.getEnd(), value);
                //System.out.println("interval start ="+interval.getStart());
                //System.out.println("interval end ="+interval.getEnd());
                //System.out.println("--------");
            }
            dataset.addSeries(attributeSeries[j++]);
        }
    }
    /*creating dataseries for each edge and its checked attribute and
    adding it to the dataset*/
    for (CyEdge edge : selectedEdges) {
        // System.out.println(checkedAttributes.size());
        for (int i = 0; i < edgeCheckedAttributes.size(); i++) {
            attributeSeries[j] = new XYSeries(dynamicNetwork.getEdgeLabel(edge) + edgeCheckedAttributes.get(i),
                    false, true);
            // System.out.println(dynamicNetwork.getDynAttribute(node,
            // checkedAttributes.get(i)).getKey().getColumn());

            for (DynInterval<T> interval : dynamicNetwork.getDynAttribute(edge, edgeCheckedAttributes.get(i))
                    .getIntervalList()) {
                // System.out.println(interval.getOnValue());
                double value;
                if (interval.getOnValue() instanceof Double)
                    value = (Double) interval.getOnValue();
                else if (interval.getOnValue() instanceof Integer)
                    value = ((Integer) interval.getOnValue()).doubleValue();
                else if (interval.getOnValue() instanceof Short)
                    value = ((Short) interval.getOnValue()).doubleValue();
                else
                    value = ((Long) interval.getOnValue()).doubleValue();
                // System.out.println(value);
                attributeSeries[j].add(interval.getStart(), value);
                attributeSeries[j].add(interval.getEnd(), value);

            }
            dataset.addSeries(attributeSeries[j++]);
        }
    }

    String title = "Dynamic Graph Metrics";
    String xAxisLabel = "Time";
    String yAxisLabel = "Centrality Value";
    JFreeChart chart = ChartFactory.createXYStepChart(title, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, // legend
            true, // tooltips
            false // urls
    );

    NumberAxis xaxis = new NumberAxis();
    xaxis.setAutoRangeMinimumSize(1.0);
    xaxis.setLabel("Time");
    chart.getXYPlot().setDomainAxis(xaxis);
    NumberAxis yaxis = new NumberAxis();
    yaxis.setAutoRangeIncludesZero(true);
    yaxis.setLabel("Centrality/Attribute Value");
    chart.getXYPlot().setRangeAxis(yaxis);
    chart.setBackgroundPaint(Color.white);
    //chart.setPadding(new RectangleInsets(20,20,20,20));
    chart.getXYPlot().setBackgroundPaint(Color.white);
    chart.getXYPlot().setDomainGridlinePaint(Color.gray);
    chart.getXYPlot().setRangeGridlinePaint(Color.gray);
    return chart;
}

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

public void resetExample() {
    //  System.out.println("resetExample get called");
    XYDataset dataset = createDataset1(true);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();/* w  w w  . j a  va2  s .c o m*/

    hasExample = true;

    //  System.out.println("row_count="+row_count);
    //  System.out.println("raw+x="+raw_x[0]);
    convertor.Y2Table(raw_x, row_count);
    //convertor.dataset2Table(dataset);            
    JTable tempDataTable = convertor.getTable();

    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(tempDataTable.getColumnCount());

    for (int i = 0; i < tempDataTable.getColumnCount(); i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }

    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);
    dataTable.doLayout();
    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    addButtonIndependent();//Y
    updateStatus(url);
}

From source file:no.uio.medicine.virsurveillance.charts.StackedChart_AWT.java

private Color getColor(int index) {
    int index2 = index + this.colorOffset;
    switch (index2) {
    case 0:/*from w  ww  .ja  va 2 s. c om*/
        return Color.RED;
    case 1:
        return Color.BLUE;
    case 2:
        return Color.GREEN;
    case 3:
        return Color.YELLOW;
    case 4:
        return Color.DARK_GRAY;
    case 5:
        return Color.ORANGE;
    case 6:
        return Color.BLACK;
    case 7:
        return Color.CYAN;
    case 8:
        return Color.GRAY;
    case 9:
        return Color.LIGHT_GRAY;
    case 10:
        return Color.MAGENTA;
    case 11:
        return Color.PINK;
    case 12:
        return Color.WHITE;
    default:
        return getColor((int) Math.floor(Math.random() * 14));
    }

}

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

/**
 * reset dataTable to default (demo data), and refesh chart
 *//*from  w  w w .j ava2  s. co  m*/
public void resetExample() {
    isDemo = true;
    IntervalXYDataset dataset = createDataset(isDemo);

    JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart, false);
    setChart();

    hasExample = true;

    convertor.dataset2Table((TimeSeriesCollection) dataset);
    JTable tempDataTable = convertor.getTable();
    int seriesCount = tempDataTable.getColumnCount() / 2;
    resetTableRows(tempDataTable.getRowCount() + 1);
    resetTableColumns(seriesCount * 2);

    for (int i = 0; i < seriesCount * 2; i++) {
        columnModel.getColumn(i).setHeaderValue(tempDataTable.getColumnName(i));
        //  System.out.println("updateExample tempDataTable["+i+"] = " +tempDataTable.getColumnName(i));
    }

    columnModel = dataTable.getColumnModel();
    dataTable.setTableHeader(new EditableHeader(columnModel));

    for (int i = 0; i < tempDataTable.getRowCount(); i++)
        for (int j = 0; j < tempDataTable.getColumnCount(); j++) {
            dataTable.setValueAt(tempDataTable.getValueAt(i, j), i, j);
        }
    dataPanel.removeAll();
    dataPanel.add(new JScrollPane(dataTable));
    dataTable.setGridColor(Color.gray);
    dataTable.setShowGrid(true);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        dataTable.setDragEnabled(true);
    } catch (Exception e) {
    }

    dataPanel.validate();

    // do the mapping
    for (int i = 0; i < seriesCount; i++) {
        addButtonIndependent();
        addButtonDependent();
    }

    updateStatus(url);
}

From source file:ucar.unidata.idv.control.chart.RangeFilter.java

/**
 * Draws the annotation.//from  w w w . ja  v  a  2s  . co m
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  an optional info object that will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis,
        int rendererIndex, PlotRenderingInfo info) {
    super.setGraphicsState(g2);
    if (!getPlotWrapper().okToDraw(this)) {
        return;
    }
    g2.setStroke(new BasicStroke());
    boolean selected = getSelected();
    if (attached != null) {
        selected |= attached.getSelected();
    }

    if (selected) {
        g2.setColor(COLOR_SELECTED);
    } else {
        g2.setColor(getColor());
    }
    y = (int) rangeAxis.valueToJava2D(rangeValue, dataArea, RectangleEdge.LEFT);

    int width = (int) ANNOTATION_WIDTH;
    int width2 = (int) (ANNOTATION_WIDTH / 2);
    x = (int) dataArea.getX();
    //        System.err.println("x/y:" + x +"/" +y);

    int[] xs;
    int[] ys;
    if (type == TYPE_LESSTHAN) {
        xs = new int[] { x, x + width, x + width2, x };
        ys = new int[] { y, y, y + width, y };
    } else {
        xs = new int[] { x, x + width, x + width2, x };
        ys = new int[] { y, y, y - width, y };

    }
    g2.fillPolygon(xs, ys, xs.length);

    g2.setColor(Color.gray);
    g2.drawLine(x + width, y, (int) (dataArea.getX() + dataArea.getWidth()), y);

    if ((attached != null) && (type == TYPE_LESSTHAN)) {
        int otherY = (int) rangeAxis.valueToJava2D(attached.rangeValue, dataArea, RectangleEdge.LEFT);

        g2.drawLine(x + width2, y + width, x + width2, otherY - width);
    }
}