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:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private void addCapa(final Layer layer) {
    SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {
        @Override/*from  www.ja  v  a2  s. c om*/
        protected Object doInBackground() throws Exception {
            layer.visible = true;
            if (!Main.pref.putColor("layer " + layer.name, Color.decode(LogicConstants.getNextColor()))) {
                log.error("Error al asignar el color");
            }
            return null;
        }

        @Override
        protected void done() {
            super.done();
            mapView.addLayer(layer, false);
            capas.add(layer);
            limpiar.setEnabled(true);

            HistoryMapViewer.enableSaveGpx(true);
        }
    };
    sw.execute();
}

From source file:com.centurylink.mdw.designer.pages.ExportHelper.java

private void printElementHtml(Element element, Object parent, int depth, Font font, int parentLevel) {
    String tag = element.getName();
    Object av;//from  www .  j  a  v  a2 s  . c  o m
    if (element instanceof HTMLDocument.RunElement) {
        HTMLDocument.RunElement re = (HTMLDocument.RunElement) element;
        int start = re.getStartOffset();
        int end = re.getEndOffset();
        try {
            String content = re.getDocument().getText(start, end - start);
            printAttributesHtml(re);
            av = re.getAttribute(CSS.Attribute.FONT_SIZE);
            String fontsize = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.FONT_FAMILY);
            String fontfamily = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.COLOR);
            String fontcolor = av == null ? null : av.toString();
            if (fontcolor != null || fontsize != null || fontfamily != null) {
                if (fontfamily == null)
                    fontfamily = font.getFamilyname();
                float size = fontsize == null ? font.getSize() : (Float.parseFloat(fontsize) + 9);
                int style = font.getStyle();
                Color color;
                if (fontcolor != null) {
                    color = Color.decode(fontcolor);
                } else
                    color = font.getColor();
                font = FontFactory.getFont(fontfamily, size, style, color);
            }
            if (parent instanceof Paragraph) {
                ((Paragraph) parent).add(new Chunk(content, font));
            } else {
                System.err.println("chunk with parent "
                        + (parent == null ? "null" : parent.getClass().getName()) + ": " + content);
            }
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
    } else if (element instanceof HTMLDocument.BlockElement) {
        HTMLDocument.BlockElement be = (HTMLDocument.BlockElement) element;
        printAttributesHtml(be);
        av = be.getAttribute(javax.swing.text.html.HTML.Attribute.ALIGN);
        String align = av == null ? null : av.toString();
        if (tag.equalsIgnoreCase("html")) {
            printElementChildrenHtml(element, parent, depth + 1, font, parentLevel);
        } else if (tag.equalsIgnoreCase("head")) {
            // do nothing
        } else if (tag.equalsIgnoreCase("body")) {
            printElementChildrenHtml(element, parent, depth + 1, font, parentLevel);
        } else if (tag.equalsIgnoreCase("p")) {
            if (parent instanceof Section) {
                Paragraph paragraph = new Paragraph();
                if (align != null) {
                    paragraph.setAlignment(align);
                }
                printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel);
                ((Section) parent).add(paragraph);
            } else {
                System.err.println("p with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("h1") || tag.equalsIgnoreCase("h2") || tag.equalsIgnoreCase("h3")) {
            if (parent instanceof Section) {
                Paragraph title = new Paragraph();
                printElementChildrenHtml(element, title, depth + 1, subSectionFont, parentLevel);
                ((Section) parent).addSection(title, parentLevel == 0 ? 0 : (parentLevel + 1));
            } else {
                System.err
                        .println("list with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("ul")) {
            if (parent instanceof Section) {
                com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f);
                printElementChildrenHtml(element, list, depth + 1, normalFont, parentLevel);
                ((Section) parent).add(list);
            } else {
                System.err
                        .println("list with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("ol")) {
            if (parent instanceof Section) {
                com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0f);
                printElementChildrenHtml(element, list, depth + 1, normalFont, parentLevel);
                ((Section) parent).add(list);
            } else {
                System.err
                        .println("list with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("li")) {
            ListItem li = new ListItem();
            li.setSpacingAfter(0.0f);
            printElementChildrenHtml(element, li, depth + 1, normalFont, parentLevel);
            ((com.lowagie.text.List) parent).add(li);
        } else if (tag.equalsIgnoreCase("p-implied")) {
            if (parent instanceof ListItem) {
                Paragraph paragraph = new Paragraph();
                printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel);
                ((ListItem) parent).add(paragraph);
            } else if (parent instanceof Cell) {
                Paragraph paragraph = new Paragraph();
                printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel);
                ((Cell) parent).add(paragraph);
            }
        } else if (tag.equalsIgnoreCase("table")) {
            try {
                Table table = new Table(3);
                table.setBorderWidth(1);
                table.setBorderColor(new Color(0, 128, 128));
                table.setPadding(1.0f);
                table.setSpacing(0.5f);
                Cell c = new Cell("header");
                c.setHeader(true);
                c.setColspan(3);
                table.addCell(c);
                table.endHeaders();
                printElementChildrenHtml(element, table, depth + 1, normalFont, parentLevel); // TODO
                ((Section) parent).add(table);
            } catch (BadElementException e) {
                e.printStackTrace();
            }
        } else if (tag.equalsIgnoreCase("tr")) {
            printElementChildrenHtml(element, parent, depth + 1, normalFont, parentLevel); // TODO
        } else if (tag.equalsIgnoreCase("td")) {
            Cell cell = new Cell();
            printElementChildrenHtml(element, cell, depth + 1, normalFont, parentLevel); // TODO
            ((Table) parent).addCell(cell);
        } else {
            System.err.println("Unknown element " + element.getName());
            printElementChildrenHtml(element, parent, depth + 1, normalFont, parentLevel);
        }
    } else {
        return; // could be BidiElement - not sure what it is
    }
}

From source file:org.languagetool.gui.Configuration.java

private void parseErrorColors(String colorsString) {
    if (StringUtils.isNotEmpty(colorsString)) {
        String[] typeToColorList = colorsString.split(COLOR_SPLITTER_REGEXP);
        for (String typeToColor : typeToColorList) {
            String[] typeAndColor = typeToColor.split(COLOR_SPLITTER_REGEXP_COLON);
            if (typeAndColor.length != 2) {
                throw new RuntimeException(
                        "Could not parse type and color, colon expected: '" + typeToColor + "'");
            }/*  w w  w .j a v a2  s  .c  o  m*/
            ITSIssueType type = ITSIssueType.getIssueType(typeAndColor[0]);
            String hexColor = typeAndColor[1];
            errorColors.put(type, Color.decode(hexColor));
        }
    }
}

From source file:com.netsteadfast.greenstep.util.SimpleUtils.java

public static int[] getColorRGB2(String color) throws Exception {
    if (StringUtils.isEmpty(color) || color.length() != 7) {
        return new int[] { 0, 0, 0 };
    }//from  w w w  .j  a v  a  2s  . c om
    Color c = Color.decode(color);
    return new int[] { c.getRed(), c.getGreen(), c.getBlue() };
}

From source file:org.languagetool.gui.Configuration.java

private void parseUnderlineColors(String colorsString) {
    if (StringUtils.isNotEmpty(colorsString)) {
        String[] typeToColorList = colorsString.split(COLOR_SPLITTER_REGEXP);
        for (String typeToColor : typeToColorList) {
            String[] typeAndColor = typeToColor.split(COLOR_SPLITTER_REGEXP_COLON);
            if (typeAndColor.length != 2) {
                throw new RuntimeException(
                        "Could not parse type and color, colon expected: '" + typeToColor + "'");
            }//from w w w.  ja  v  a 2s .  c o m
            underlineColors.put(typeAndColor[0], Color.decode(typeAndColor[1]));
        }
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.PanelDescricaoImagens.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Salvar") {
        salvaAlteracoes.salvar();/*from  w  w w  .j av  a2s  .  co  m*/

    } else if (cmd == "Abrir") {
        abrirArquivoLocal();
    } else if (cmd.equals("SelecionarTudo")) {
        textAreaSourceCode.getTextPane().selectAll();
        textAreaSourceCode.getTextPane().requestFocus();
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        textAreaSourceCode.undo();
    } else if (cmd == "AumentaFonte") {
        textAreaSourceCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        textAreaSourceCode.diminuiFontSize();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Contraste") {
        textAreaSourceCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        ArrayList<Integer> ordenador = new ArrayList<Integer>();
        ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
        conteudoParticRotulo = null;
        conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
        String[] conteudo = new String[3];
        String codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

        while (codHTML.indexOf("SIL" + inicial) != -1) {
            inicial++;
        }

        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");
            ordenador.add(Integer.parseInt(conteudo[1]));
        }

        int[] ordem = new int[ordenador.size()];
        for (int i = 0; i < ordem.length; i++) {
            ordem[i] = ordenador.get(i);
        }

        Arrays.sort(ordem);

        for (int i = 0; i < ordem.length; i++) {
            for (String conteudoPR : conteudoParticRotulo) {
                conteudo = conteudoPR.split("@");

                if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                    conteudoParticRotuloOrdenado.add(conteudoPR);
                }

            }
        }
        for (String conteudoPR : conteudoParticRotuloOrdenado) {
            conteudo = conteudoPR.split("@");

            // System.out.println("posico: " +
            // Integer.parseInt(conteudo[1]));

        }

        for (String conteudoPR : conteudoParticRotuloOrdenado) {

            conteudo = conteudoPR.split("@");
            conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>";
            selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
            selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
            // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial +
            // "\"></label>").length();

            if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {

            }
            /*
             * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
             * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
             * selectedEnd+("id=x").length());
             * 
             * }else{ }
             */
            // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart,
            // selectedEnd);
            // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);
            arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY,
                    SimpleAttributeSet.EMPTY));
            textAreaSourceCode.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            textAreaSourceCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

        // arTextPainelCorrecao.formataHTML();
        // tArParticipRotulo.apagaTexto();

        TabelaDescricao tcl = tableLinCod;
        int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0);
        int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1);
        // int endTag = 0;
        int posAtual = 0;
        int posFinal = 0;
        codHTML = textAreaSourceCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // Adaptao provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

        setPosTagRepInit(posFinal);
        setPosTagRepEnd(posFinal + i + 1);

        textAreaSourceCode.goToLine(linha);
        textAreaSourceCode.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd());

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java

/**
 * Colocar na classe de controle/*from   ww  w  . j a  v a 2 s.  c  o m*/
 * 
 */
public void getProxPagina() {
    // this.panelDescricaoImagens.parentFrame.setCursor(new
    // Cursor(Cursor.WAIT_CURSOR));
    // this.panelDescricaoImagens.scrollPaneDescricao.getTextPane().selectAll();
    // this.panelDescricaoImagens.arTextPainelCorrecao.setColorForSelectedText(new
    // Color(255, 255, 255), new Color(0, 0, 0));
    // this.panelDescricaoImagens.scrollPaneDescricao.coloreSource();

    int linha = (Integer) this.dtm.getValueAt(0, 1);
    int coluna = (Integer) this.dtm.getValueAt(0, 2);
    String endereco = (String) this.dtm.getValueAt(0, 0);
    try {

        Statement stConsultaTabPag = null;

        Connection con = (DriverManager.getConnection(ConexaoBanco.bancoEmUso));
        ResultSet rs2 = null;
        if (!paginaAtual.equals(endereco)) {
            stConsultaTabPag = con.createStatement();

            System.out.println("4");

            rs2 = stConsultaTabPag.executeQuery("SELECT * from Pagina WHERE nomePagina='" + endereco + "'"); //
            StringBuilder buffer = new StringBuilder();
            System.out.println("5");
            if (rs2.next()) {

                String hashCodeAtual = rs2.getString("hashCode");
                // this.hashCodeAtual = hashCodeAtual;
                // if
                // (endereco.equals(panelDescricaoImagens.enderecoPagina)) {
                // this.hashCodeInicial = this.hashCodeAtual;
                // }
                // System.out.println("tabela hashcodeAtualBanco:" +
                // this.hashCodeAtual);
                buffer = trabComTemp(hashCodeAtual);

                //System.out.println("9");
                this.boxCode.setText(buffer.toString());
            }
        }
        //System.out.println("10");
        int posAtual = 0;
        int posFinal = 0;
        String codHTML = this.boxCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;

        //System.out.println("11");
        Statement stConsultaTabImg = con.createStatement();
        //System.out.println("linha: " + linha + " coluna: " + coluna + " endereco: " + endereco);

        rs2 = stConsultaTabImg.executeQuery("SELECT * from imagem WHERE endPagina='" + endereco + "' AND linha="
                + linha + " AND coluna=" + coluna); //
        if (rs2.next()) {
            //System.out.println("12");
            posFinal = codHTML.indexOf(rs2.getString("tag"), posAtual + coluna);
            //System.out.println("13");
        }
        // Adaptao provisria
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }
        //System.out.println("14");
        this.setPosTagRepInit(posFinal);
        this.setPosTagRepEnd(posFinal + i + 1);
        //System.out.println("15");
        this.boxCode.goToLine(linha);
        this.boxCode.getTextPane().select(this.getPosTagRepInit(), this.getPosTagRepEnd());
        this.arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        this.arTextPainelCorrecao.setUnderline();
        //System.out.println("16");
        paginaAtual = endereco;
        /*
         * /
         * this.panelDescricaoImagens.scrollPaneDescricao.getTextPane().select(200,250); //
         */
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

}

From source file:com.diversityarrays.kdxplore.KDXploreFrame.java

private BrandingImageComponent createBrandingImageComponent() {
    BrandingImageComponent bic = null;// w w  w .  jav a 2s .  com

    if (iconImage != null) {
        bic = new BrandingImageComponent(iconImage);
        bic.setBorder(new EmptyBorder(4, 4, 4, 4));
        bic.setBackground(Color.decode("#ffe74a")); //$NON-NLS-1$
    }

    return bic;
}

From source file:com.eryansky.common.utils.SysUtils.java

/**
  * ?Color//from w  ww .j  a  v  a  2 s.c om
  * 
  * @param color
  * @return
  */
 public static Color toColor(String color) {
     int red, green, blue = 0;
     char[] rgb;
     color = "#" + color.trim();
     color = color.toLowerCase().replaceAll("[g-zG-Z]", "");
     switch (color.length()) {
     case 3:
         rgb = color.toCharArray();
         red = SysUtils.null2Int(rgb[0] + "" + rgb[0], 16);
         green = SysUtils.null2Int(rgb[1] + "" + rgb[1], 16);
         blue = SysUtils.null2Int(rgb[2] + "" + rgb[2], 16);
         return new Color(red, green, blue);
     case 6:
         rgb = color.toCharArray();
         red = SysUtils.null2Int(rgb[0] + "" + rgb[1], 16);
         green = SysUtils.null2Int(rgb[2] + "" + rgb[3], 16);
         blue = SysUtils.null2Int(rgb[4] + "" + rgb[5], 16);
         return new Color(red, green, blue);
     default:
         return Color.decode(color);
     }
 }

From source file:org.tellervo.desktop.prefs.Prefs.java

/**
 * Get a color for the specified preference key
 * //from www . java2s.c  o  m
 * @param key
 * @param deflt
 * @return
 */
public Color getColorPref(PrefKey key, Color deflt) {
    String value = prefs.getProperty(key.getValue());
    if (value == null)
        return deflt;
    try {
        return Color.decode(value);
    } catch (NumberFormatException nfe) {
        log.warn("Invalid color for preference '" + key.getValue() + "': " + value);
        return deflt;
    }
}