Example usage for java.awt Color decode

List of usage examples for java.awt Color decode

Introduction

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

Prototype

public static Color decode(String nm) throws NumberFormatException 

Source Link

Document

Converts a String to an integer and returns the specified opaque Color .

Usage

From source file:org.n52.io.img.BarRenderer.java

@Override
public void setColorForSeriesAt(int index) {
    this.renderer.setSeriesPaint(index, Color.decode(style.getColor()));
}

From source file:org.n52.io.measurement.img.BarRenderer.java

@Override
public void setColorForSeries() {
    // each renderer renders just one series
    this.renderer.setSeriesPaint(0, Color.decode(style.getColor()));
}

From source file:org.kuali.coeus.common.framework.print.watermark.Font.java

/**
 * //from w w  w.  j a  va2s. c  o m
 * This method for setting the color to font.
 * Default font color is Color.LIGHT_GRAY.
 * @param strColor
 */
public void setColor(String strColor) {
    if (strColor == null) {
        color = WatermarkConstants.DEFAULT_COLOR;
        return;
    }
    try {
        color = Color.decode(strColor);
    } catch (NumberFormatException nfe) {
        try {
            final Field f = Color.class.getField(strColor);
            color = (Color) f.get(null);
        } catch (Exception exception) {
            color = WatermarkConstants.DEFAULT_WATERMARK_COLOR;
            LOG.error("Exception occured in WatermarkFont.. NumberFormatException: " + exception);
        }
    }

}

From source file:org.global.canvas.services.impl.DrawServiceImpl.java

public void draw(DrawEvent event) {
    currentUser = event.getUser();/* w  ww .  j  av a2s .co m*/
    if (event.getType().equals("dragstart")) {
        domImpl = GenericDOMImplementation.getDOMImplementation();
        document = domImpl.createDocument(svgNS, "svg", null);
        svgGenerator = new SVGGraphics2D(document);
        System.out.println("Color here: " + event.getColor());
        svgGenerator.setColor(Color.decode(event.getColor()));
        svgGenerator.setStroke(
                new BasicStroke(5, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 0, new float[] { 3, 1 }, 0));
    }

    currentX.add(event.getX());
    currentY.add(event.getY());

    if (event.getType().equals("dragend")) {
        svgGenerator.drawPolyline(ArrayUtils.toPrimitive(currentX.toArray(new Integer[0])),
                ArrayUtils.toPrimitive(currentY.toArray(new Integer[0])), currentX.size());
        export();
        domImpl = null;
        document = null;
        svgGenerator = null;
        currentX.clear();
        currentY.clear();

    }

}

From source file:org.sonar.api.charts.AbstractChart.java

private void improveChart(JFreeChart jfrechart, ChartParameters params) {
    Color background = Color
            .decode("#" + params.getValue(ChartParameters.PARAM_BACKGROUND_COLOR, "FFFFFF", false));
    jfrechart.setBackgroundPaint(background);

    jfrechart.setBorderVisible(false);//from w  w  w .  j  a  va2s  .  c  om
    jfrechart.setAntiAlias(true);
    jfrechart.setTextAntiAlias(true);
    jfrechart.removeLegend();
}

From source file:umich.ms.batmass.filesupport.files.types.mzrt.data.MzrtTableModel.java

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    List<CSVRecord> records = f.getFile().getRecords();
    //MzrtFeature feat = f.getMs1().getList().get(rowIndex);
    if (rowIndex < 0 || rowIndex >= records.size())
        return null;

    MzrtFile file = f.getFile();//from   www  .jav  a 2  s .co m
    int[] idxs = file.getIndexesMzRtColorOpacity();
    String str = f.getFile().getRecords().get(rowIndex).get(columnIndex);

    for (int i = 0; i < 4; i++) {
        if (columnIndex == idxs[i])
            return Double.parseDouble(str);
    }
    if (columnIndex == idxs[4])
        return Color.decode(str);

    if (columnIndex == idxs[5])
        return Float.parseFloat(str);

    return str;
}

From source file:com.uimirror.image.form.UimImageFormParam.java

public Color getBg() {
    try {//from  w  w w .java2  s  . com
        Color cl = StringUtils.hasText(bg) ? Color.decode(bg) : Color.BLUE;
        return cl;
    } catch (Exception e) {
        return Color.BLUE;
    }
}

From source file:org.jets3t.gui.skins.html.SkinnedLookAndFeel.java

public SkinnedLookAndFeel(Properties skinProperties, String itemName) {
    super();/*from ww w. j  a  va 2  s .  c  o  m*/

    // Determine system defaults.
    JLabel defaultLabel = new JLabel();
    Color backgroundColor = defaultLabel.getBackground();
    Color textColor = defaultLabel.getForeground();
    Font font = defaultLabel.getFont();

    // Find skinning configurations.
    String backgroundColorValue = skinProperties.getProperty("backgroundColor", null);
    String textColorValue = skinProperties.getProperty("textColor", null);
    String fontValue = skinProperties.getProperty("font", null);

    // Apply skinning configurations.
    if (backgroundColorValue != null) {
        Color color = Color.decode(backgroundColorValue);
        if (color == null) {
            log.error("Unable to set background color with value: " + backgroundColorValue);
        } else {
            backgroundColor = color;
        }
    }
    if (textColorValue != null) {
        Color color = Color.decode(textColorValue);
        if (color == null) {
            log.error("Unable to set text color with value: " + textColorValue);
        } else {
            textColor = color;
        }
    }
    if (fontValue != null) {
        Font myFont = Font.decode(fontValue);
        if (myFont == null) {
            log.error("Unable to set font with value: " + fontValue);
        } else {
            font = myFont;
        }
    }

    // Update metal theme with configured display properties.
    SkinnedMetalTheme skinnedTheme = new SkinnedMetalTheme(new ColorUIResource(backgroundColor),
            new ColorUIResource(textColor), new FontUIResource(font));
    MetalLookAndFeel.setCurrentTheme(skinnedTheme);
}

From source file:SystemAnomalies.bouncedLogInRate.java

public ChartPanel getChartPanel() {
    XYSeries series = new XYSeries("Annual Composite Production Vs Farmers Experience");
    series.add(0, 0);/*from   w ww  . ja  va  2s .  c  o m*/
    series.add(1, 100);
    series.add(2, 100);
    series.add(3, 100);
    series.add(4, 120);
    series.add(5, 120);
    series.add(6, 1040);
    series.add(7, 1040);
    series.add(8, 1040);
    series.add(9, 2000);
    series.add(10, 2000);
    series.add(11, 100);
    series.add(12, 100);
    series.add(13, 100);
    series.add(14, 120);
    series.add(15, 120);
    series.add(16, 1040);
    series.add(17, 1040);
    series.add(18, 1040);
    series.add(19, 2000);
    series.add(20, 2000);
    series.add(21, 1845);
    series.add(22, 1040);
    series.add(23, 2000);

    // Add the series to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("Sign-in Bounce off Rate", // Title
            "Time of Day", // x-axis Label
            "Number of Attempts", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBackground(Color.WHITE);
    chartPanel.setBounds(2, 5, 750, 500);
    chartPanel.setBorder(new LineBorder(Color.decode("#f5f5f5"), 2));

    return chartPanel;
}

From source file:iqq.app.core.service.impl.SkinServiceImpl.java

/**
 * ?/*from  w ww .j av a2s. c  om*/
 *
 * @param key
 * @return
 */
@Override
public Color getColorByKey(String key) {
    if (StringUtils.isNotEmpty(key)) {
        try {
            // ???
            String color = XmlUtils.getNodeText(getSkinConfig(), key);
            return Color.decode(color);
        } catch (NullPointerException e) {
            // ????
            String color = null;
            try {
                // getDefaultConfig()??
                color = XmlUtils.getNodeText(getDefaultConfig(), key);
            } catch (NullPointerException e1) {
                LOG.error("?, key=" + key, e1);
            } catch (DocumentException e2) {
                LOG.error("?, key=" + key, e2);
            }
            return Color.decode(color);
        } catch (DocumentException e) {
            LOG.error("?, key=" + key, e);
        }
    }
    return null;
}