Search in sources :

Example 46 with Color

use of java.awt.Color in project Contrast-Finder by Asqatasun.

the class ColorFinderHsvTest method testFindColorsBornBlack2.

public void testFindColorsBornBlack2() {
    System.out.println("FindColorsBornBlack2");
    Color foregroundColor = new Color(1, 1, 1);
    Color backgroundColor = new Color(3, 3, 3);
    Float coefficientLevel = 4.5f;
    ColorFinderHsv instance = new ColorFinderHsv();
    List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
    instance.findColors(foregroundColor, backgroundColor, false, coefficientLevel);
    for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
        LOGGER.debug("HashCode :" + colorCombinaison.hashCode() + "    COLOR : " + combinaisons.getContrast());
        colorCombinaison.add(combinaisons);
    }
    Color firstColor = new Color(131, 131, 131);
    assertEquals(firstColor, colorCombinaison.get(0).getColor());
}
Also used : ColorCombinaison(org.asqatasun.contrastFinder.result.ColorCombinaison) Color(java.awt.Color) ArrayList(java.util.ArrayList)

Example 47 with Color

use of java.awt.Color in project Contrast-Finder by Asqatasun.

the class ColorFinderHsvTest method testFindColorsBornBlack.

public void testFindColorsBornBlack() {
    System.out.println("FindColorsBornBlack");
    Color foregroundColor = new Color(1, 1, 1);
    Color backgroundColor = new Color(3, 3, 3);
    Float coefficientLevel = 4.5f;
    ColorFinderHsv instance = new ColorFinderHsv();
    List<ColorCombinaison> colorCombinaison = new ArrayList<ColorCombinaison>();
    instance.findColors(foregroundColor, backgroundColor, true, coefficientLevel);
    for (ColorCombinaison combinaisons : instance.getColorResult().getSuggestedColors()) {
        LOGGER.debug("HashCode :" + colorCombinaison.hashCode() + "    COLOR : " + combinaisons.getContrast());
        colorCombinaison.add(combinaisons);
    }
    Color firstColor = new Color(133, 133, 133);
    assertEquals(firstColor, colorCombinaison.get(0).getColor());
}
Also used : ColorCombinaison(org.asqatasun.contrastFinder.result.ColorCombinaison) Color(java.awt.Color) ArrayList(java.util.ArrayList)

Example 48 with Color

use of java.awt.Color in project ACS by ACS-Community.

the class ColoredEditorSupport method paintValue.

/**
   * a static version of the paintValue method that can be called from other places
   * @param graphics the graphics on which to drow
   * @param rectangle the rectangle to fill
   * @param text the text to display
   */
public static void paintValue(Graphics g, Rectangle rectangle, String text, Color backGround, Color foreGround) {
    Color origColor = g.getColor();
    // change background color only if the parameter backGround is non-null
    if (backGround != null) {
        g.setColor(backGround);
    }
    g.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
    // draw the text
    int xOffset = 6;
    if (foreGround != null) {
        g.setColor(foreGround);
    } else {
        g.setColor(Color.black);
    }
    FontMetrics fm = g.getFontMetrics();
    g.drawString(text, rectangle.x + xOffset, rectangle.y + (rectangle.height - fm.getHeight()) / 2 + fm.getAscent());
    // restore color
    g.setColor(origColor);
}
Also used : FontMetrics(java.awt.FontMetrics) Color(java.awt.Color)

Example 49 with Color

use of java.awt.Color in project ACS by ACS-Community.

the class LogManagerGui method colorFromLevel.

////////////////////////////////////////////////////////
/// ----------------- Internal --------------------- ///
////////////////////////////////////////////////////////
Color colorFromLevel(Level x) {
    Color ret = (Color) level2color.get(x);
    if (ret == null) {
        ret = Color.magenta;
        message("no color defined for log-level " + x);
    }
    return ret;
}
Also used : Color(java.awt.Color)

Example 50 with Color

use of java.awt.Color in project tomcat by apache.

the class Clock2 method init.

@Override
public void init() {
    lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0;
    formatter = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault());
    currentDate = new Date();
    lastdate = formatter.format(currentDate);
    clockFaceFont = new Font("Serif", Font.PLAIN, 14);
    handColor = Color.blue;
    numberColor = Color.darkGray;
    try {
        setBackground(new Color(Integer.parseInt(getParameter("bgcolor"), 16)));
    } catch (Exception e) {
    // Ignored
    }
    try {
        handColor = new Color(Integer.parseInt(getParameter("fgcolor1"), 16));
    } catch (Exception e) {
    // Ignored
    }
    try {
        numberColor = new Color(Integer.parseInt(getParameter("fgcolor2"), 16));
    } catch (Exception e) {
    // Ignored
    }
    // Set clock window size
    resize(300, 300);
}
Also used : Color(java.awt.Color) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Font(java.awt.Font)

Aggregations

Color (java.awt.Color)2973 Graphics2D (java.awt.Graphics2D)396 Font (java.awt.Font)250 BufferedImage (java.awt.image.BufferedImage)236 Dimension (java.awt.Dimension)193 JPanel (javax.swing.JPanel)193 Point (java.awt.Point)188 BasicStroke (java.awt.BasicStroke)177 ArrayList (java.util.ArrayList)173 Test (org.junit.Test)156 JLabel (javax.swing.JLabel)148 Paint (java.awt.Paint)140 Rectangle (java.awt.Rectangle)109 GradientPaint (java.awt.GradientPaint)108 Insets (java.awt.Insets)103 GridBagConstraints (java.awt.GridBagConstraints)96 IOException (java.io.IOException)96 Stroke (java.awt.Stroke)94 JScrollPane (javax.swing.JScrollPane)93 File (java.io.File)89