protected void applyStyle()

in src/syntaxhighlight/SyntaxHighlighterPane.java [346:366]


  protected void applyStyle() {
    if (theme == null || styleList == null) {
      return;
    }

    DefaultStyledDocument document = (DefaultStyledDocument) getDocument();
    // clear all the existing style
    document.setCharacterAttributes(0, document.getLength(), theme.getPlain().getAttributeSet(), true);

    // apply style according to the style list
    for (String key : styleList.keySet()) {
      List<ParseResult> posList = styleList.get(key);

      SimpleAttributeSet attributeSet = theme.getStyle(key).getAttributeSet();
      for (ParseResult pos : posList) {
        document.setCharacterAttributes(pos.getOffset(), pos.getLength(), attributeSet, true);
      }
    }

    repaint();
  }