ATranscriptionWidget.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:TranskribusSwtGui 作者:
protected void setLineBulletAndStuff() {
        text.setLineBullet(0, text.getLineCount(), null); // delete line bullet first to guarantee update! (bug in SWT?)
        if (settings.isShowLineBullets() && currentRegionObject!=null && getNTextLines()>0) {
            Storage store = Storage.getInstance();
            for (int i=0; i<text.getLineCount(); ++i) {             
                final int docId = store.getDoc().getId();
                final int pNr = store.getPage().getPageNr();

                int bulletFgColor = SWT.COLOR_BLACK;

                int fontStyle = SWT.NORMAL;
                if (i>= 0 && i <currentRegionObject.getTextLine().size()) {
                    final String lineId = currentRegionObject.getTextLine().get(i).getId();
                    boolean hasWg = store.hasWordGraph(docId, pNr, lineId);

                    fontStyle = (i == getCurrentLineIndex()) ? SWT.BOLD : SWT.NORMAL;   
                    bulletFgColor = hasWg ? SWT.COLOR_DARK_GREEN : SWT.COLOR_BLACK;
                }

                StyleRange style = new StyleRange(0, text.getCharCount(), Colors.getSystemColor(bulletFgColor), Colors.getSystemColor(SWT.COLOR_GRAY), fontStyle);
                style.metrics = new GlyphMetrics(0, 0, Integer.toString(text.getLineCount() + 1).length() * 12);
//              style.background = Colors.getSystemColor(SWT.COLOR_GRAY);
                Bullet bullet = new Bullet(/*ST.BULLET_NUMBER |*/ ST.BULLET_TEXT, style);
                bullet.text = ""+(i+1);

                text.setLineBullet(i, 1, bullet);
                text.setLineIndent(i, 1, 25);
                text.setLineAlignment(i, 1, settings.getTextAlignment());
                text.setLineWrapIndent(i, 1, 25+style.metrics.width);
            }

//          text.setLineBullet(0, text.getLineCount(), bullet);
//          text.setLineIndent(0, text.getLineCount(), 25);
//          text.setLineAlignment(0, text.getLineCount(), textAlignment);
//          text.setLineWrapIndent(0, text.getLineCount(), 25+style.metrics.width);         


        }
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号