-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'#1866: Set an initial color based on name for new bookmarks.
- Loading branch information
1 parent
0d240a1
commit 22f15d4
Showing
7 changed files
with
55 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
iped-app/src/main/java/iped/app/ui/bookmarks/BookmarkColorsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package iped.app.ui.bookmarks; | ||
|
||
import java.awt.Color; | ||
import java.util.Set; | ||
|
||
public class BookmarkColorsManager { | ||
public static Color getInitialColor(Set<Color> usedColors, String name) { | ||
int off = name.toLowerCase().hashCode() % BookmarkStandardColors.numStandardColors; | ||
Color ret = BookmarkStandardColors.colors[off]; | ||
for (int i = 0; i < BookmarkStandardColors.numStandardColors; i++) { | ||
int idx = (off + i) % BookmarkStandardColors.numStandardColors; | ||
Color c = BookmarkStandardColors.colors[idx]; | ||
if (!usedColors.contains(c)) { | ||
ret = c; | ||
break; | ||
} | ||
} | ||
return ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters