Example usage for java.awt Color LIGHT_GRAY

List of usage examples for java.awt Color LIGHT_GRAY

Introduction

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

Prototype

Color LIGHT_GRAY

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

Click Source Link

Document

The color light gray.

Usage

From source file:com.ctsim.dmi.MainFrame.java

private void drawButton(String name, int status, int x, int y, boolean isRequest) {

    FontMetrics metrics = g2.getFontMetrics();
    int strWidth = metrics.stringWidth(name);
    g2.setStroke(new BasicStroke(2));

    if (App.atpStatus == status) {
        g2.setColor(Color.GREEN);
        g2.fillRect(x, y, bttnWidth, bttnHeight);
        g2.setColor(Color.BLACK);

    } else if (isRequest) {
        if (isFlashOn) {
            g2.setStroke(new BasicStroke(4));
            g2.setColor(Color.YELLOW);
        } else {//from w ww. j  a v  a 2  s  .co m
            g2.setStroke(new BasicStroke(2));
            g2.setColor(Color.LIGHT_GRAY);
        }

    } else {
        g2.setStroke(new BasicStroke(2));
        g2.setColor(Color.LIGHT_GRAY);
    }

    g2.drawRect(x, y, bttnWidth, bttnHeight);
    g2.drawString(name, x + (bttnWidth / 2) - strWidth / 2, y + bttnHeight - 5 - metrics.getHeight() / 2);
}

From source file:com.rapidminer.gui.plotter.charts.WebPlotter.java

@Override
public void updatePlotter() {
    final int categoryCount = prepareData();

    SwingUtilities.invokeLater(new Runnable() {

        @Override/*  w  ww  .j av a 2 s  .  co  m*/
        public void run() {
            scrollablePlotterPanel.remove(viewScrollBar);
        }
    });

    if (categoryCount > MAX_CATEGORY_VIEW_COUNT && showScrollbar) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                viewScrollBar.setOrientation(Adjustable.HORIZONTAL);
                scrollablePlotterPanel.add(viewScrollBar, BorderLayout.SOUTH);
            }
        });

        this.slidingCategoryDataSet = new SlidingCategoryDataset(categoryDataSet, 0, MAX_CATEGORY_VIEW_COUNT);
        viewScrollBar.setMaximum(categoryCount);
        viewScrollBar.setValue(0);

    } else {
        this.slidingCategoryDataSet = null;
    }

    if (categoryCount <= MAX_CATEGORIES) {

        SpiderWebPlot plot = new SpiderWebPlot(categoryDataSet);

        plot.setAxisLinePaint(Color.LIGHT_GRAY);
        plot.setOutlinePaint(Color.WHITE);

        plot.setLabelGenerator(new StandardCategoryItemLabelGenerator());

        JFreeChart chart = new JFreeChart("", TextTitle.DEFAULT_FONT, plot, true);

        double[] colorValues = null;
        if (groupByColumn >= 0 && this.dataTable.isNominal(groupByColumn)) {
            colorValues = new double[this.dataTable.getNumberOfValues(groupByColumn)];
        } else {
            colorValues = new double[categoryDataSet.getColumnCount()];
        }
        for (int i = 0; i < colorValues.length; i++) {
            colorValues[i] = i;
        }

        if (panel != null) {
            panel.setChart(chart);
        } else {
            panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN);
            scrollablePlotterPanel.add(panel, BorderLayout.CENTER);
            final ChartPanelShiftController controller = new ChartPanelShiftController(panel);
            panel.addMouseListener(controller);
            panel.addMouseMotionListener(controller);
        }

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

        // legend settings
        LegendTitle legend = chart.getLegend();
        if (legend != null) {
            legend.setPosition(RectangleEdge.TOP);
            legend.setFrame(BlockBorder.NONE);
            legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
            legend.setItemFont(LABEL_FONT);
        }
        if (groupByColumn < 0) {
            // no legend is needed when there is no group-by selection
            chart.removeLegend();
        }
        // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
        panel.getChartRenderingInfo().setEntityCollection(null);
    } else {
        LogService.getRoot().log(Level.INFO,
                "com.rapidminer.gui.plotter.charts.BarChartPlotter.too_many_columns",
                new Object[] { categoryCount, MAX_CATEGORIES });
    }
}

From source file:org.gbif.portal.web.controller.dataset.IndexingHistoryController.java

/**
 * Create a time series graphic to display indexing processes.
 * /*w w w .j a  v  a 2s.  c  o m*/
 * @param dataProvider
 * @param dataResource
 * @param activities
 * @param fileNamePrefix
 * @return
 */
public String timeSeriesTest(DataProviderDTO dataProvider, DataResourceDTO dataResource,
        List<LoggedActivityDTO> loggedActivities, String fileNamePrefix, int minProcessingTimeToRender) {

    List<LoggedActivityDTO> activities = new ArrayList<LoggedActivityDTO>();
    for (LoggedActivityDTO la : loggedActivities) {
        if (la.getDataResourceKey() != null && la.getDataResourceName() != null && la.getEventName() != null)
            activities.add(la);
    }

    //if no activities to render, return
    if (activities.isEmpty())
        return null;

    Map<String, Integer> drActualCount = new HashMap<String, Integer>();
    Map<String, Integer> drCount = new HashMap<String, Integer>();

    //record the actual counts
    for (LoggedActivityDTO laDTO : activities) {
        if (laDTO.getStartDate() != null && laDTO.getEndDate() != null
                && laDTO.getDurationInMillisecs() > minProcessingTimeToRender) {
            if (drActualCount.get(laDTO.getDataResourceName()) == null) {
                drActualCount.put(laDTO.getDataResourceName(), new Integer(4));
                drCount.put(laDTO.getDataResourceName(), new Integer(0));
            } else {
                Integer theCount = drActualCount.get(laDTO.getDataResourceName());
                theCount = new Integer(theCount.intValue() + 4);
                drActualCount.remove(laDTO.getDataResourceName());
                drActualCount.put(laDTO.getDataResourceName(), theCount);
            }
        }
    }

    StringBuffer fileNameBuffer = new StringBuffer(fileNamePrefix);
    if (dataResource != null) {
        fileNameBuffer.append("-resource-");
        fileNameBuffer.append(dataResource.getKey());
    } else if (dataProvider != null) {
        fileNameBuffer.append("-provider-");
        fileNameBuffer.append(dataProvider.getKey());
    }
    fileNameBuffer.append(".png");

    String fileName = fileNameBuffer.toString();
    String filePath = System.getProperty("java.io.tmpdir") + File.separator + fileName;

    File fileToCheck = new File(filePath);
    if (fileToCheck.exists()) {
        return fileName;
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    boolean generateChart = false;

    int count = 1;
    int dataResourceCount = 1;

    Collections.sort(activities, new Comparator<LoggedActivityDTO>() {
        public int compare(LoggedActivityDTO o1, LoggedActivityDTO o2) {
            if (o1 == null || o2 == null || o1.getDataResourceKey() != null || o2.getDataResourceKey() != null)
                return -1;
            return o1.getDataResourceKey().compareTo(o2.getDataResourceKey());
        }
    });

    String currentDataResourceKey = activities.get(0).getDataResourceKey();

    for (LoggedActivityDTO laDTO : activities) {
        if (laDTO.getStartDate() != null && laDTO.getEndDate() != null
                && laDTO.getDurationInMillisecs() > minProcessingTimeToRender) {

            if (currentDataResourceKey != null && !currentDataResourceKey.equals(laDTO.getDataResourceKey())) {
                dataResourceCount++;
                count = count + 1;
                currentDataResourceKey = laDTO.getDataResourceKey();
            }
            TimeSeries s1 = new TimeSeries(laDTO.getDataResourceName(), "Process time period",
                    laDTO.getEventName(), Hour.class);
            s1.add(new Hour(laDTO.getStartDate()), count);
            s1.add(new Hour(laDTO.getEndDate()), count);
            dataset.addSeries(s1);
            generateChart = true;
        }
    }

    if (!generateChart)
        return null;

    // create a pie chart...
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, false, false);

    XYPlot plot = chart.getXYPlot();
    plot.setWeight(10);
    plot.getRangeAxis().setAutoRange(false);
    plot.getRangeAxis().setRange(0, drCount.size() + 1);
    plot.getRangeAxis().setAxisLineVisible(false);
    plot.getRangeAxis().setAxisLinePaint(Color.WHITE);
    plot.setDomainCrosshairValue(1);
    plot.setRangeGridlinesVisible(false);
    plot.getRangeAxis().setVisible(false);
    plot.getRangeAxis().setLabel("datasets");

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setItemLabelsVisible(true);
    MyXYItemLabelGenerator labelGenerator = new MyXYItemLabelGenerator();
    labelGenerator.setDataResourceActualCount(drActualCount);
    labelGenerator.setDataResourceCount(drCount);
    renderer.setItemLabelGenerator(labelGenerator);

    List<TimeSeries> seriesList = dataset.getSeries();
    for (TimeSeries series : seriesList) {
        if (((String) series.getRangeDescription()).startsWith("extraction")) {
            renderer.setSeriesPaint(seriesList.indexOf(series), Color.RED);
        } else {
            renderer.setSeriesPaint(seriesList.indexOf(series), Color.BLUE);
        }
        renderer.setSeriesStroke(seriesList.indexOf(series), new BasicStroke(7f));
    }

    int imageHeight = 30 * dataResourceCount;
    if (imageHeight < 100) {
        imageHeight = 100;
    } else {
        imageHeight = imageHeight + 100;
    }

    final BufferedImage image = new BufferedImage(900, imageHeight, BufferedImage.TYPE_INT_RGB);
    KeypointPNGEncoderAdapter adapter = new KeypointPNGEncoderAdapter();
    adapter.setQuality(1);
    try {
        adapter.encode(image);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    final Graphics2D g2 = image.createGraphics();
    g2.setFont(new Font("Arial", Font.PLAIN, 11));
    final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 900, imageHeight);

    // draw
    chart.draw(g2, chartArea, null, null);

    //styling
    chart.setPadding(new RectangleInsets(0, 0, 0, 0));
    chart.setBorderVisible(false);
    chart.setBackgroundImageAlpha(0);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBorderPaint(Color.LIGHT_GRAY);

    try {
        FileOutputStream fOut = new FileOutputStream(filePath);
        ChartUtilities.writeChartAsPNG(fOut, chart, 900, imageHeight);
        return fileName;
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}

From source file:org.dishevelled.brainstorm.BrainStorm.java

private static Color parse(final String value) {
    if ("black".equals(value)) {
        return Color.BLACK;
    } else {//www .j  av a  2 s.co  m
        return Color.LIGHT_GRAY;
    }
}

From source file:uk.co.moonsit.sockets.GraphClient.java

private Color getSeriesColor(int index) {
    if (index > 10) {
        index = index % 11;//from w w  w . j a  v  a2 s. c  o m
    }
    switch (index) {
    case 0:
        return Color.BLUE.brighter().brighter();
    case 1:
        return Color.RED.brighter();
    case 2:
        return Color.GREEN.darker();
    case 3:
        return Color.CYAN.darker();
    case 4:
        return Color.ORANGE.darker();
    case 5:
        return Color.DARK_GRAY;
    case 6:
        return Color.MAGENTA;
    case 7:
        return Color.BLUE.darker().darker();
    case 8:
        return Color.CYAN.darker().darker();
    case 9:
        return Color.BLACK.brighter();
    case 10:
        return Color.RED.darker();
    }
    return Color.LIGHT_GRAY;
}

From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java

/**
 * @param fi//  w  w w .j  a  v a  2s  .c  om
 * @return
 */
protected FormPanelInfo createPanel(final FormInfo formInfo) {
    CellConstraints cc = new CellConstraints();

    JPanel panel = new JPanel(null);
    int maxWidth = 0;
    int maxHeight = 0;
    int maxCellWidth = 0;
    int maxCellHeight = 0;
    for (FormFieldInfo fi : formInfo.getFields()) {
        System.out.println(fi.getCaption());
        boolean addLbl = true;
        JComponent comp = null;
        switch (fi.getControlTypeNum()) {
        case 4:
            comp = createComboBox(); // 'Picklist'
            break;

        case 5: {
            JComboBox cbx = createComboBox(); //new ValComboBoxFromQuery(DBTableIdMgr.getInstance().getInfoById(1), "catalogNumber","CatalogNumber","CatalogNumber"," "," "," "," "," ",ValComboBoxFromQuery.CREATE_ALL);// 'QueryCombo'
            cbx.setEditable(true);
            cbx.getEditor().setItem(fi.getCaption());
            JPanel cPanel = new JPanel(new BorderLayout());
            cPanel.add(cbx, BorderLayout.CENTER);
            cPanel.add(createElipseBtn(), BorderLayout.EAST);
            comp = cPanel;
            addLbl = false;
            break;
        }

        case 7: {
            String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType());
            FormInfo subForm = formHash.get(uniqueKey);
            if (subForm == null) {
                uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null);
                subForm = formHash.get(uniqueKey);
            }
            if (subForm != null) {
                Vector<String> headers = new Vector<String>();
                for (int i = 0; i < subForm.getFields().size(); i++) {
                    headers.add(subForm.getFields().get(i).getCaption());
                }
                JPanel p = new JPanel(new BorderLayout());
                p.add(UIHelper.createScrollPane(new JTable(new Vector<Vector<Object>>(), headers)),
                        BorderLayout.CENTER); // 'Grid'
                comp = p;
                addLbl = false;
            }
            break;
        }

        case 8: // 'EmbeddedForm'
        {
            String uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", fi.getParent().getFormType());
            FormInfo subForm = formHash.get(uniqueKey);
            if (subForm == null) {
                uniqueKey = getUniqueKey(fi.getRelatedTableName(), "Embedded", null);
                subForm = formHash.get(uniqueKey);
            }
            comp = (subForm != null ? createPanel(subForm).getPanel() : new JPanel());
            addLbl = fi.getControlTypeNum() != 8;
            break;
        }
        case 9: {
            comp = createElipseBtn();
            break;
        }

        case 20:
            comp = createScrollPane(createTextArea()); // 'Memo'
            break;

        case 21:
            comp = null;//createComboBox(); // 'MenuItem'
            break;

        case 46:
            comp = createTextField("URL"); // 'URL'
            break;

        default:
            if (fi.getDataTypeNum() == 4) {
                comp = createCheckBox(" ");
            } else {
                comp = createTextField();
            }
        } // switch

        if (comp != null) {
            String toolTip = "Field: " + fi.getSp5FieldName()
                    + (StringUtils.isNotEmpty(fi.getSp6FieldName())
                            && fi.getSp6FieldName().equalsIgnoreCase(fi.getSp5FieldName())
                                    ? " Sp6: " + fi.getSp6FieldName()
                                    : "");
            comp.setToolTipText(toolTip);

            PanelBuilder pb = new PanelBuilder(new FormLayout("p,1px,f:p:g", "f:p:g,p,f:p:g"));

            pb.getPanel().setToolTipText(toolTip);
            pb.getPanel().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
            if (addLbl) {
                pb.add(createLabel(fi.getCaption()), cc.xy(1, 2));
            }
            pb.add(comp, cc.xy(3, 2));
            panel.add(pb.getPanel());

            maxWidth = Math.max(maxWidth, fi.getLeft() + fi.getWidth());
            maxHeight = Math.max(maxHeight, fi.getTop() + fi.getHeight());

            maxCellWidth = Math.max(maxWidth, fi.getCellX() + fi.getCellWidth());
            maxCellHeight = Math.max(maxHeight, fi.getCellY() + fi.getCellHeight());

            boolean newWay = false;
            if (newWay) {
                Rectangle r = fi.getBoundsFromCellDim();
                pb.getPanel().setLocation(r.x, r.y);
                pb.getPanel().setSize(r.width, r.height);

            } else {
                pb.getPanel().setLocation(fi.getLeft(), fi.getTop());
                pb.getPanel().setSize(fi.getWidth(), fi.getHeight());
            }

            System.out.println("MaxW: " + maxWidth + "  " + maxCellWidth);
            System.out.println("MaxH: " + maxHeight + "  " + maxCellHeight);
        }
    }

    boolean newWay = false;
    if (newWay) {
        int cw = FormFieldInfo.getSegWidth();
        panel.setPreferredSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw));
        panel.setSize(new Dimension(maxCellWidth * cw, maxCellHeight * cw));
    } else {
        panel.setPreferredSize(new Dimension(maxWidth, maxHeight));
        panel.setSize(new Dimension(maxWidth, maxHeight));
    }

    System.out.println("MaxW: " + maxWidth + "  " + maxCellWidth);
    System.out.println("MaxH: " + maxHeight + "  " + maxCellHeight);

    return new FormPanelInfo(formInfo.getTitle(), panel, maxWidth, maxHeight);
}

From source file:org.kuali.kfs.module.ar.batch.service.impl.CustomerInvoiceWriteoffBatchServiceImpl.java

protected void writeFileNameSectionTitle(com.lowagie.text.Document pdfDoc, String filenameLine) {
    Font font = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD);

    //  file name title, get title only, on windows & unix platforms
    String fileNameOnly = filenameLine.toUpperCase();
    int indexOfSlashes = fileNameOnly.lastIndexOf("\\");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }/*from  w  w w  . ja  v  a 2 s.c om*/
    indexOfSlashes = fileNameOnly.lastIndexOf("/");
    if (indexOfSlashes < fileNameOnly.length()) {
        fileNameOnly = fileNameOnly.substring(indexOfSlashes + 1);
    }

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(com.lowagie.text.Element.ALIGN_LEFT);
    Chunk chunk = new Chunk(fileNameOnly, font);
    chunk.setBackground(Color.LIGHT_GRAY, 5, 5, 5, 5);
    paragraph.add(chunk);

    //  blank line
    paragraph.add(new Chunk("", font));

    try {
        pdfDoc.add(paragraph);
    } catch (DocumentException e) {
        LOG.error("iText DocumentException thrown when trying to write content.", e);
        throw new RuntimeException("iText DocumentException thrown when trying to write content.", e);
    }
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.SparkLine.java

private void addPointSeries(TimeSeries series, XYPlot plot) {
    logger.debug("IN");
    TimeSeries pointSerie = new TimeSeries("Point", Month.class);
    for (int i = 0; i < series.getItemCount(); i++) {
        pointSerie.add(series.getTimePeriod(i), series.getValue(i));
    }// w w w . j a  va 2  s.  c  o  m
    final TimeSeriesCollection avgDs = new TimeSeriesCollection(pointSerie);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) {
        public boolean getItemShapeVisible(int _series, int item) {
            return (true);
        }
    };
    renderer.setSeriesPaint(2, Color.LIGHT_GRAY);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.BLACK);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setUseOutlinePaint(true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-2.0, -2.0, 4.0, 4.0));

    plot.setDataset(2, avgDs);
    plot.setRenderer(2, renderer);
    logger.debug("OUT");

}

From source file:com.ctsim.dmi.MainFrame.java

private void drawButtonYard(int x, int y, boolean isRequest) {
    FontMetrics metrics = g2.getFontMetrics();
    int strWidth = metrics.stringWidth("Yard");

    if (App.atpStatus == 1) {
        g2.setColor(Color.GREEN);
        g2.fillRect(x, y, bttnWidth, bttnHeight);
        g2.setColor(Color.BLACK);

    } else if (isRequest) {

        if (isFlashOn) {
            g2.setStroke(new BasicStroke(4));
            g2.setColor(Color.YELLOW);
        } else {/*from   w ww .j  a  va  2 s.c  o m*/
            g2.setStroke(new BasicStroke(2));
            g2.setColor(Color.LIGHT_GRAY);
        }

    } else {
        g2.setStroke(new BasicStroke(2));
        g2.setColor(Color.LIGHT_GRAY);
    }

    g2.drawRect(x, y, bttnWidth, bttnHeight);
    g2.drawString("Yard", x + (bttnWidth / 2) - strWidth / 2, y + bttnHeight - 5 - metrics.getHeight() / 2);
}

From source file:com.jd.survey.web.pdf.SurveyPdf.java

private void writeAnswersMatrix(Document document, Question question, String[][] answerValuesMatrix)
        throws Exception {
    Table matrixTable;/*from ww w  .  ja v a 2 s .com*/
    Cell cell;

    Paragraph questionParagraph = new Paragraph();
    questionParagraph.add(new Chunk(question.getQuestionText().trim() + ": ", boldedFont));
    document.add(questionParagraph);

    matrixTable = new Table(question.getColumnLabels().size() + 1);
    matrixTable.setPadding(2);
    matrixTable.setWidth(100);
    matrixTable.setDefaultCellBorder(0);
    matrixTable.setBorder(0);
    matrixTable.setOffset(4);
    matrixTable.setAutoFillEmptyCells(true);
    matrixTable.setCellsFitPage(true);

    matrixTable.setTableFitsPage(true);
    cell = new Cell("");
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    matrixTable.addCell(cell);

    for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
        cell = new Cell(new Paragraph(questionColumnLabel.getLabel(), boldedFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        matrixTable.addCell(cell);
    }
    int rowIndex = 0;
    for (QuestionRowLabel questionRowLabel : question.getRowLabels()) {
        int columnIndex = 0;
        questionParagraph = new Paragraph(questionRowLabel.getLabel(), boldedFont);
        questionParagraph.setLeading(12, 0);
        cell = new Cell(questionParagraph);
        if ((rowIndex % 2) == 1) {
            cell.setBackgroundColor(new Color(231, 238, 244));
        }
        matrixTable.addCell(cell);
        for (QuestionColumnLabel questionColumnLabel : question.getColumnLabels()) {
            questionParagraph = new Paragraph(answerValuesMatrix[rowIndex][columnIndex] == null ? ""
                    : answerValuesMatrix[rowIndex][columnIndex], normalFont);
            questionParagraph.setLeading(12, 0);
            cell = new Cell(questionParagraph);
            if ((rowIndex % 2) == 1) {
                cell.setBackgroundColor(new Color(231, 238, 244));
            }
            matrixTable.addCell(cell);
            columnIndex++;
        }
        rowIndex++;
    }
    document.add(matrixTable);
}