mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 16:58:51 -05:00
Refactor TextColorizer
This commit is contained in:
parent
4d87f4c456
commit
af3c60eeef
@ -305,18 +305,14 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||||||
if (header != null) {
|
if (header != null) {
|
||||||
html.append(escapeHTML(header)).append("<br>");
|
html.append(escapeHTML(header)).append("<br>");
|
||||||
}
|
}
|
||||||
for (File file : sortByUniquePath(selection)) {
|
|
||||||
html.append("<nobr>");
|
|
||||||
html.append("• ");
|
|
||||||
|
|
||||||
|
TextColorizer colorizer = new TextColorizer("<nobr>• ", "</nobr><br>");
|
||||||
|
for (File file : sortByUniquePath(selection)) {
|
||||||
File path = getStructurePathTail(file);
|
File path = getStructurePathTail(file);
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
path = getRelativePathTail(file, 3);
|
path = getRelativePathTail(file, 3);
|
||||||
}
|
}
|
||||||
|
colorizer.colorizePath(html, path, true);
|
||||||
new TextColorizer().colorizePath(html, path, true);
|
|
||||||
html.append("</nobr>");
|
|
||||||
html.append("<br>");
|
|
||||||
}
|
}
|
||||||
if (selection.size() < files.size()) {
|
if (selection.size() < files.size()) {
|
||||||
html.append("• ").append("…").append("<br>");
|
html.append("• ").append("…").append("<br>");
|
||||||
|
@ -256,17 +256,12 @@ class MovieMatcher implements AutoCompleteMatcher {
|
|||||||
html.append(escapeHTML(header)).append("<br>");
|
html.append(escapeHTML(header)).append("<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
html.append("<nobr>");
|
|
||||||
html.append("• ");
|
|
||||||
|
|
||||||
File path = getStructurePathTail(file);
|
File path = getStructurePathTail(file);
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
path = getRelativePathTail(file, 3);
|
path = getRelativePathTail(file, 3);
|
||||||
}
|
}
|
||||||
|
TextColorizer colorizer = new TextColorizer("<nobr>• ", "</nobr><br>");
|
||||||
new TextColorizer().colorizePath(html, path, file.isFile());
|
colorizer.colorizePath(html, path, file.isFile());
|
||||||
html.append("</nobr>");
|
|
||||||
html.append("<br>");
|
|
||||||
|
|
||||||
html.append("<br>");
|
html.append("<br>");
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
@ -14,19 +14,29 @@ public class TextColorizer {
|
|||||||
private Color pathRainbowBeginColor;
|
private Color pathRainbowBeginColor;
|
||||||
private Color pathRainbowEndColor;
|
private Color pathRainbowEndColor;
|
||||||
|
|
||||||
|
private String before;
|
||||||
|
private String after;
|
||||||
|
|
||||||
public TextColorizer() {
|
public TextColorizer() {
|
||||||
this(new Color(0xCC3300), new Color(0x008080));
|
this("<html><nobr>", "</nobr></html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextColorizer(Color pathRainbowBeginColor, Color pathRainbowEndColor) {
|
public TextColorizer(String before, String after) {
|
||||||
|
this(before, after, new Color(0xCC3300), new Color(0x008080));
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextColorizer(String before, String after, Color pathRainbowBeginColor, Color pathRainbowEndColor) {
|
||||||
|
this.before = before;
|
||||||
|
this.after = after;
|
||||||
this.pathRainbowBeginColor = pathRainbowBeginColor;
|
this.pathRainbowBeginColor = pathRainbowBeginColor;
|
||||||
this.pathRainbowEndColor = pathRainbowEndColor;
|
this.pathRainbowEndColor = pathRainbowEndColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringBuilder colorizePath(StringBuilder html, File file, boolean hasExtension) {
|
public StringBuilder colorizePath(StringBuilder html, File file, boolean hasExtension) {
|
||||||
List<File> path = listPath(file);
|
html.append(before);
|
||||||
|
|
||||||
// colorize parent path
|
// colorize parent path
|
||||||
|
List<File> path = listPath(file);
|
||||||
for (int i = 0; i < path.size() - 1; i++) {
|
for (int i = 0; i < path.size() - 1; i++) {
|
||||||
float f = (path.size() <= 2) ? 1 : (float) i / (path.size() - 2);
|
float f = (path.size() <= 2) ? 1 : (float) i / (path.size() - 2);
|
||||||
Color c = interpolateHSB(pathRainbowBeginColor, pathRainbowEndColor, f);
|
Color c = interpolateHSB(pathRainbowBeginColor, pathRainbowEndColor, f);
|
||||||
@ -44,7 +54,7 @@ public class TextColorizer {
|
|||||||
html.append(file.getName());
|
html.append(file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return html;
|
return html.append(after);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user