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:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Salvar") {
        // salvaAlteracoes.salvar();

    } else if (cmd.equals("SelecionarTudo")) {
        boxCode.getTextPane().selectAll();
        boxCode.getTextPane().requestFocus();
    } else if (cmd == "Abrir") {
        abrirArquivoLocal();/*  w ww.ja  v  a  2 s  .  c o m*/
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        // boxCode.undo();
        // boxCode.coloreSource();
        // reavalia(boxCode.getText());
    } else if (cmd == "AumentaFonte") {
        boxCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        boxCode.diminuiFontSize();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Contraste") {
        boxCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 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 = boxCode.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

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

        ColorModel cm = tArParticipRotulo.getColorModel();

        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)) {
                corretordePosicoesdoControle = 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));
            boxCode.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            boxCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

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

        TabelaAnaliseGeral 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 = boxCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // gambiarra provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

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

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

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:org.scify.talkandplay.gui.users.UserFormPanel.java

private void setUI() {

    ButtonGroup scanButtons = new ButtonGroup();
    scanButtons.add(autoScanRadioButton);
    scanButtons.add(manualScanRadioButton);

    //set the titles of the form
    nameLabel.setFont(new Font(UIConstants.mainFont, Font.BOLD, 14));
    imageLabel.setFont(new Font(UIConstants.mainFont, Font.BOLD, 14));
    sensorLabel.setFont(new Font(UIConstants.mainFont, Font.BOLD, 14));
    rotationSpeedLabel.setFont(new Font(UIConstants.mainFont, Font.BOLD, 14));
    defaultGridSizeLabel.setFont(new Font(UIConstants.mainFont, Font.BOLD, 14));
    tilesLabel.setFont(new Font(UIConstants.mainFont, Font.BOLD, 14));

    nameTextField.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.GRAY));
    nameTextField.setFont(new Font(UIConstants.mainFont, Font.ITALIC, 14));
    nameTextField.setHorizontalAlignment(JTextField.CENTER);
    uploadImageLabel.setFont(new Font(UIConstants.mainFont, Font.BOLD, 14));

    rowsTextField.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.GRAY));
    rowsTextField.setHorizontalAlignment(JTextField.CENTER);
    columnsTextField.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.GRAY));
    columnsTextField.setHorizontalAlignment(JTextField.CENTER);

    disableTextField(selectionSensorTextField2);
    disableTextField(navigationSensorTextField);
    enableTextField(selectionSensorTextField1);

    //set the text color
    selectionSensorTextField1.setForeground(Color.decode(UIConstants.green));
    selectionSensorTextField2.setForeground(Color.decode(UIConstants.green));
    navigationSensorTextField.setForeground(Color.decode(UIConstants.green));

    selectionSensorTextField1.setHorizontalAlignment(JTextField.CENTER);
    selectionSensorTextField2.setHorizontalAlignment(JTextField.CENTER);
    navigationSensorTextField.setHorizontalAlignment(JTextField.CENTER);

    step6ExplTextArea.setEditable(false);
    step6ExplTextArea.setLineWrap(true);
    step6ExplTextArea.setWrapStyleWord(true);
    step6ExplTextArea.setBorder(javax.swing.BorderFactory.createEmptyBorder());
    jScrollPane1.setBorder(null);//  www. j  a  v  a 2s.c o m

    imageCheckBox.setSelected(true);
    imageCheckBox.setVisible(false);
}

From source file:org.scify.talkandplay.gui.users.UserFormPanel.java

private void disableTextField(JTextField textField) {
    textField.setEnabled(false);/*  w  ww . j ava  2 s  .  c  om*/
    textField.setForeground(Color.decode(UIConstants.disabledColor));
    textField.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.decode(UIConstants.disabledColor)));
    textField.setBorder(BorderFactory.createCompoundBorder(textField.getBorder(),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
}

From source file:org.scify.talkandplay.gui.users.UserFormPanel.java

private void enableTextField(JTextField textField) {
    textField.setEnabled(true);// www .  ja  v a  2 s . c  om
    textField.setForeground(Color.decode(UIConstants.green));
    textField.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.decode(UIConstants.green)));
    textField.setBorder(BorderFactory.createCompoundBorder(textField.getBorder(),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

/**
 * Utility function to update a scatterplot line's data series.
 * @param data the datagraph data.//from ww w .j av a 2  s. co  m
 * @param sheet the Excel sheet which contains corresponding data from the scatterplot data series.
 * @param seriesIdx the index of the data in the dategraph data.
 * @param series the XML object representing the series in the chart.
 */
private static void updateCTScatterSer(final DategraphData data, final XSSFSheet sheet, final int seriesIdx,
        final CTScatterSer series) {
    final String sheetName = sheet.getSheetName();

    // the series idx starts from 0
    final DategraphData.Row row = data.getRows().get(seriesIdx);
    final String title = row.getLabel();
    final Color color = Color.decode(row.getColor());

    series.getOrder().setVal(seriesIdx);
    series.getIdx().setVal(seriesIdx);

    final CTSolidColorFillProperties fill = series.getSpPr().getLn().getSolidFill();

    // We have to set any possible colour type, PowerPoint throws an error if there's multiple fills, and we don't
    //   know what colour type the user may have used in their template slide.
    if (fill.getSchemeClr() != null) {
        fill.unsetSchemeClr();
    }
    if (fill.getSrgbClr() != null) {
        fill.unsetSrgbClr();
    }
    if (fill.getHslClr() != null) {
        fill.unsetHslClr();
    }
    if (fill.getPrstClr() != null) {
        fill.unsetPrstClr();
    }
    if (fill.getScrgbClr() != null) {
        fill.unsetScrgbClr();
    }
    if (fill.getSysClr() != null) {
        fill.unsetSysClr();
    }

    final CTSRgbColor fillClr = fill.addNewSrgbClr();
    final byte[] colorBytes = { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() };
    fillClr.setVal(colorBytes);

    final CTMarker marker = series.getMarker();

    if (marker != null) {
        final CTShapeProperties markerSpPr = marker.getSpPr();
        unsetSpPrFills(markerSpPr);
        markerSpPr.addNewSolidFill().addNewSrgbClr().setVal(colorBytes);

        final CTLineProperties markerLn = markerSpPr.getLn();
        if (markerLn != null) {
            unsetLineFills(markerLn);
            markerLn.addNewSolidFill().addNewSrgbClr().setVal(colorBytes);
        }
    }

    final CTStrRef strRef = series.getTx().getStrRef();
    strRef.getStrCache().getPtArray()[0].setV(title);

    strRef.setF(new CellReference(sheetName, 0, seriesIdx + 1, true, true).formatAsString());

    final long[] timestamps = data.getTimestamps();
    {
        final CTNumRef timestampCatNumRef = series.getXVal().getNumRef();
        timestampCatNumRef.setF(new AreaReference(new CellReference(sheetName, 1, 0, true, true),
                new CellReference(sheetName, 1 + timestamps.length, 0, true, true)).formatAsString());

        final CTNumData timeStampCatNumCache = timestampCatNumRef.getNumCache();
        timeStampCatNumCache.getPtCount().setVal(timestamps.length);
        timeStampCatNumCache.setPtArray(null);

        for (int ii = 0; ii < timestamps.length; ++ii) {
            final CTNumVal pt = timeStampCatNumCache.addNewPt();
            pt.setIdx(ii);
            pt.setV(sheet.getRow(1 + ii).getCell(0).getRawValue());
        }
    }

    {
        final double[] seriesData = row.getValues();

        final CTNumRef valuesNumRef = series.getYVal().getNumRef();
        valuesNumRef.setF(new AreaReference(new CellReference(sheetName, 1, seriesIdx + 1, true, true),
                new CellReference(sheetName, 1 + timestamps.length, seriesIdx + 1, true, true))
                        .formatAsString());

        final CTNumData valuesNumCache = valuesNumRef.getNumCache();
        valuesNumCache.getPtCount().setVal(timestamps.length);
        valuesNumCache.setPtArray(null);

        for (int ii = 0; ii < timestamps.length; ++ii) {
            final CTNumVal pt = valuesNumCache.addNewPt();
            pt.setIdx(ii);
            pt.setV(Double.toString(seriesData[ii]));
        }
    }
}

From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java

protected final static void setBackground(Component c, NuclosScript ns, final Collectable clct,
        EntityMetaDataVO meta, boolean isEnabled) {
    try {//from  www  .  ja  v  a2 s .  co m
        String rgb = Integer.toHexString(c.getBackground().getRGB());
        rgb = rgb.substring(2, rgb.length());
        Object o = ScriptEvaluator.getInstance().eval(ns, new CollectableScriptContext(clct), "#" + rgb);

        if (o instanceof String) {
            Color color = Color.decode((String) o);
            if (isEnabled) {
                c.setBackground(color);
            } else {
                c.setBackground(new Color(Math.max(0, color.getRed() - (color.getRed() * 15 / 100)),
                        Math.max(0, color.getGreen() - (color.getGreen() * 15 / 100)),
                        Math.max(0, color.getBlue() - (color.getBlue() * 15 / 100))));
            }
        }
    } catch (Exception ex) {
        LOG.warn(ex);
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.script.PainelScript.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();//w w w .  j a v  a2  s  .c o  m
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    }

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

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 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++;
        }

        ColorModel cm = tArParticipRotulo.getColorModel();

        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)) {
                corretordePosicoesdoControle = 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;
        // gambiarra 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();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.objeto.PainelObjeto.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Procurar") {
        scrollPaneDescricao.buscar();// ww w. j a v  a2s  .c  o  m
    } else

    if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    }

    else

    if (cmd == "Salvar") {
        salvaAlteracoes.salvar();

    } else if (cmd == "Abrir") {
        // abrirArquivo();
        Abrir();

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

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 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 = scrollPaneDescricao.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

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

        ColorModel cm = tArParticipRotulo.getColorModel();

        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)) {
                corretordePosicoesdoControle = 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));
            scrollPaneDescricao.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            scrollPaneDescricao.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 = scrollPaneDescricao.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // gambiarra provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

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

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

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.label.PainelLabel.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd == "Salvar") {
        System.out.println("action Salvar");
        salvaAlteracoes.salvar();/* www  . j a  va2s  .  co m*/

    } else if (cmd == "Abrir") {
        // abrirArquivo();

        abrir();
    } else if (cmd.equals("SelecionarTudo")) {
        textAreaSourceCode.getTextPane().selectAll();
        textAreaSourceCode.getTextPane().requestFocus();
    } else if (cmd == "AbrirURL") {
        abreUrl();

    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        // boxCode.undo();
        // boxCode.coloreSource();
        // reavalia(boxCode.getText());
    } else if (cmd == "AumentaFonte") {
        textAreaSourceCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        textAreaSourceCode.diminuiFontSize();
    } else if (cmd == "Contraste") {
        textAreaSourceCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 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++;
        }

        ColorModel cm = tArParticipRotulo.getColorModel();

        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)) {
                corretordePosicoesdoControle = 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();

        TabelaCorrecaoLabel 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;
        // gambiarra 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();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}

From source file:com.hp.autonomy.frontend.reports.powerpoint.PowerPointServiceImpl.java

/**
 * Utility function to render a TextData object as multiple text runs on the screen in a single text paragraph.
 * Note that newlines are not added automatically; this is so we can support adjacent text with different formatting.
 * @param slide the slide to add to./*from ww  w  . j  a va 2s . com*/
 * @param anchor bounding rectangle to draw onto, in PowerPoint coordinates.
 * @param data the text data to render.
 */
private void addTextData(final XSLFSlide slide, final Rectangle2D.Double anchor, final TextData data) {
    final XSLFTextBox textBox = slide.createTextBox();
    textBox.setAnchor(anchor);
    textBox.clearText();

    final XSLFTextParagraph para = textBox.addNewTextParagraph();

    for (final TextData.Paragraph runData : data.getText()) {
        final XSLFTextRun run = para.addNewTextRun();
        run.setText(runData.getText());
        run.setFontSize(runData.getFontSize());
        run.setBold(runData.isBold());
        run.setItalic(runData.isItalic());
        run.setFontColor(Color.decode(runData.getColor()));

        if (textBox.getTextHeight() > anchor.getHeight()) {
            // Try removing words from the last box until we find something that fits, or we run out of words
            final String trimmedText = runData.getText().trim();
            run.setText(trimmedText);

            for (final StringBuilder text = new StringBuilder(trimmedText); textBox.getTextHeight() > anchor
                    .getHeight() && text.length() > 0;) {
                final int lastSpaceIdx = Math.max(text.lastIndexOf(" "), text.lastIndexOf("\n"));

                if (lastSpaceIdx < 0) {
                    break;
                }

                text.delete(lastSpaceIdx, text.length());
                // Add a trailing ellipsis unless it's empty or already contained a trailing ellipsis or "..." at the final truncated position.
                run.setText(
                        text.length() > 0 ? text.toString().replaceFirst("(\\s*(\\.{3}|\u2026))?$", "\u2026")
                                : "");
            }

            // The font metrics aren't going to be perfect (due to unavailability of fonts etc.) so we force the truncated text to fit.
            textBox.setTextAutofit(TextShape.TextAutofit.NORMAL);

            break;
        }
    }
}