java 字符串替换效率



  for (int i = 0; i < length; i++) {
                    List<String> strs = new ArrayList<>();
//                 Object[] objs=trials.get(i);
                    String dnadata = (String) xulieDatas.get(i)[7];
                    if (dnadata.length() > 0) {
                        JLabel jep = new JLabel();
                        jep.setFont(new Font("宋体",0,16));//加粗
                        maxlen = Math.max(dnadata.length() * 6 * 1.5f, maxlen);
                        jep.setPreferredSize(new Dimension((int) (dnadata.length() * 6 * 1.5), height));

                        dnadata=dnadata.replaceAll("A","<font size='5' color =green>A</font>");
                        dnadata=dnadata.replaceAll("G","<font size='5' color =black>G</font>");
                        dnadata=dnadata.replaceAll("T","<font size='5' color =red>T</font>");
                        dnadata=dnadata.replaceAll("C","<font size='5' color =blue style='border:1px solid;color =blue;'>C</font>");
                        dnadata=dnadata.replaceAll("N","<font size='5' style='font-weight:bold;'color =blue><u>N</u></font>");


                        jep.setText("<html>" + dnadata + "</html>");
                        jep.setName(xulieDatas.get(i)[2] + "");
                        //-----------------
//                         JTextPane jep = new JTextPane();
//                         jep.setPreferredSize(new Dimension(1250, height));
//                         jep.setContentType("text/html");
//
                StyledDocument doc = jep.getStyledDocument();
                SimpleAttributeSet center = new SimpleAttributeSet();
                StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
                doc.setParagraphAttributes(0, doc.getLength(), center, false);
//                         jep.setText(sb.toString());
                        jLabels.add(jep);

                    }
                }

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页
实付 19.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值