Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1031203 // showLineCompedSingleLevelsAsColoredText_v2

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (6436L/41K).

static JTextPane showLineCompedSingleLevelsAsColoredText_v2(LineCompedSingle<Char> lc) {
  // each matrix element is the symbol starting position for the character+1 (or 0 for empty)
  int[][] rows = renderLineCompedSingleLevels_raw_v2(lc);
  S text = uncompressLineCompedSingle(lc);
  printVars(+rows);
  int n = l(first(rows));
  new L out;
  forEach(rows, row -> {
    var color = Color.white;
    out.add(color);
    var lastSymbol = 0;
    for i to n: {
      if (row[i] == 0) {
        if (color != Color.white) out.add(color = Color.white);
        lastSymbol = 0;
        out.add(' ');
      } else {
        if (row[i] != lastSymbol) {
          color = color == Color.yellow ? Color.blue : Color.yellow;
          out.add(color);
          lastSymbol = row[i];
        }
        out.add(text.charAt(i));
      }
    }
    out.add("\n");
  });
  ret withTypeWriterFont(showColoredText(out));
}

Author comment

Began life as a copy of #1031201

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031203
Snippet name: showLineCompedSingleLevelsAsColoredText_v2
Eternal ID of this version: #1031203/5
Text MD5: fc67ab84d5690f0a42235be2ccfc50cc
Transpilation MD5: e5d0ec269062b97166f91c11f01d8cc5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-20 15:15:17
Source code size: 932 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 75 / 112
Version history: 4 change(s)
Referenced in: [show references]