Example usage for java.awt Color getHSBColor

List of usage examples for java.awt Color getHSBColor

Introduction

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

Prototype

public static Color getHSBColor(float h, float s, float b) 

Source Link

Document

Creates a Color object based on the specified values for the HSB color model.

Usage

From source file:Presentacion.SimpleGraphView.java

public void printarLouvainIteracion0(Grafo<Cancion, Float> G, ArrayList<Comunidad> Com) {
    ComL = Com;/*  w  ww.  j  av a  2 s.  c om*/
    soluL = new Solucion("", ComL);
    crearGrafo(G);
    Gr = G;
    Transformer<Cancion, Paint> vertexPaint = new Transformer<Cancion, Paint>() {
        Integer n = Gr.ObtenerNodos().size();
        Color[] cols = new Color[n];

        public Paint transform(Cancion can) {
            for (Integer i = 0; i < n; i++)
                cols[i] = Color.getHSBColor((float) i / (float) n, 0.85f, 1.0f);
            Integer color = Gr.consultarIndice(can);
            Color c = cols[color];
            return c;
        }
    };
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    add(vv);
    revalidate();
}

From source file:Presentacion.SimpleGraphView.java

public void printarLouvainFinal(Grafo<Cancion, Float> G, Solucion s) {
    solu = s;/*from w  w  w  . j  a  v  a  2  s . c  o  m*/
    init(G);
    crearGrafo(G);
    Transformer<Cancion, Paint> vertexPaint = new Transformer<Cancion, Paint>() {
        Integer n = solu.obtenerComunidades().size();
        Color[] cols = new Color[n];

        public Paint transform(Cancion can) {
            for (Integer i = 0; i < n; i++)
                cols[i] = Color.getHSBColor((float) i / (float) n, 0.85f, 1.0f);
            Integer color = solu.consultarComunidad(can);
            Color c = cols[color];
            return c;
        }
    };
    ;
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    add(vv);
    revalidate();
}

From source file:Presentacion.SimpleGraphView.java

public void printarCliqueParcial(Grafo<Cancion, Float> G, ArrayList<ArrayList<Cancion>> sol) {
    init(G);/*from  w w  w .j  a  v  a 2  s .  c  o m*/
    crearGrafo(G);
    CliqueParcial = sol;
    Transformer<Cancion, Paint> vertexPaint = new Transformer<Cancion, Paint>() {
        Integer n = CliqueParcial.size();
        Color[] cols = new Color[n];

        public Paint transform(Cancion can) {
            for (Integer i = 0; i < n; i++)
                cols[i] = Color.getHSBColor((float) i / (float) n, 0.85f, 1.0f);
            Integer color = consultarComunidadCliqueParcial(can);
            Color c = cols[color];
            return c;
        }
    };
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    add(vv);
    revalidate();
}

From source file:Presentacion.SimpleGraphView.java

public void printarCliqueFinal(Grafo<Cancion, Float> G, Solucion s) {
    solu = s;/*from www.j  a  v a 2 s. co  m*/
    init(G);
    crearGrafo(G);
    Transformer<Cancion, Paint> vertexPaint = new Transformer<Cancion, Paint>() {
        Integer n = solu.obtenerComunidades().size();
        Color[] cols = new Color[n];

        public Paint transform(Cancion can) {
            for (Integer i = 0; i < n; i++)
                cols[i] = Color.getHSBColor((float) i / (float) n, 0.85f, 1.0f);
            Integer color = solu.consultarComunidad(can);
            Color c = cols[color];
            return c;
        }
    };
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    add(vv);
    revalidate();
    deboHacerfinalClique = false;
}

From source file:smlm.util.SRutil.java

public static Color getGradientColor(Color ini, Color fin, int numberOfSteps, int step) {
    if (numberOfSteps == 0)
        return ini;
    if (step % numberOfSteps == 0)
        return ini;
    if (step % numberOfSteps == numberOfSteps - 1)
        return fin;
    else {/*from w  w w.j a v  a 2 s .c  o  m*/
        float[] hsbini = Color.RGBtoHSB(ini.getRed(), ini.getGreen(), ini.getBlue(), null);
        float[] hsbfin = Color.RGBtoHSB(fin.getRed(), fin.getGreen(), fin.getBlue(), null);
        float h = ((numberOfSteps - step % numberOfSteps) * hsbini[0] + (step % numberOfSteps) * hsbfin[0])
                / numberOfSteps;
        float s = ((numberOfSteps - step % numberOfSteps) * hsbini[1] + (step % numberOfSteps) * hsbfin[1])
                / numberOfSteps;
        float b = ((numberOfSteps - step % numberOfSteps) * hsbini[2] + (step % numberOfSteps) * hsbfin[2])
                / numberOfSteps;
        return Color.getHSBColor(h, s, b);
    }
}

From source file:tauargus.gui.PanelTable.java

private Color getBackgroundColor(Cell cell, Code code) {
    if (tableSet.hasBeenAudited) { //adapt background color if audit is not OK
        if (cell.status.isPrimaryUnsafe()) {
            if ((cell.response == cell.realizedLower) && (cell.response == cell.realizedUpper)) {
                return Color.orange;
            } //exact
            if ((cell.response + cell.upper) > cell.realizedUpper) {
                return Color.getHSBColor(255, 100, 100);
            }//  w ww . j a  v  a  2 s .  co  m
            if ((cell.response + cell.lower) < cell.realizedLower) {
                return Color.getHSBColor(255, 100, 100);
            }
            return getBackgroundColor(code);
        } else {
            return getBackgroundColor(code);
        }
        //        if (cell.status.isUnsafe() && cell.auditOk) {
        //            if (cell.status.isPrimaryUnsafe()) {
        //                return Color.red;
        //            } else {
        //                return Color.orange;
        //            }
    } else {
        return getBackgroundColor(code);
    }
}

From source file:uk.ac.kcl.texthunter.core.AnnotationEditor.java

private void disableCancelButton() {
    cancelButton.setEnabled(false);
    cancelButton.setBackground(Color.getHSBColor(240, 240, 240));
}

From source file:url.Domain.java

public String getColor() {

    Random random = new Random();
    final float hue = random.nextFloat() + 0.5f;
    final float saturation = 0.9f;//1.0 for brilliant, 0.0 for dull
    final float luminance = 1.0f; //1.0 for brighter, 0.0 for black*/
    Color color = Color.getHSBColor(hue, saturation, luminance);

    Formatter f = new Formatter(new StringBuffer("#"));
    f.format("%06x", color.getRGB());
    f.toString();// w  w w.  j av a2  s  .  co  m
    return f.toString();
}