parent
a949420f6a
commit
7ebfa7ac0e
@ -8,8 +8,8 @@ AtlantaFX is based on GitHub Primer color system. You can check [GitHub Primer i
|
||||
|
||||
### Foreground Colors
|
||||
|
||||
| Color |Usage |
|
||||
|----------------------|--------------------------------|
|
||||
| Color | Usage |
|
||||
|----------------------|----------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `-color-fg-default` | Primary color for text and icons. It should be used for body content, titles and labels. |
|
||||
| `-color-fg-muted` | For content that is secondary or that provides additional context but is not critical to understanding the flow of an interface. |
|
||||
| `-color-fg-subtle` | For placeholders or decorative foregrounds. |
|
||||
|
@ -14,6 +14,8 @@ import atlantafx.sampler.page.SampleBlock;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.Label;
|
||||
@ -127,9 +129,10 @@ public class CustomTextFieldPage extends AbstractPage {
|
||||
timeField.textProperty().addListener((obs, old, val) -> {
|
||||
if (val != null) {
|
||||
try {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
LocalTime.parse(val, timeFormatter);
|
||||
timeField.pseudoClassStateChanged(STATE_DANGER, false);
|
||||
} catch (Exception e) {
|
||||
} catch (DateTimeParseException e) {
|
||||
timeField.pseudoClassStateChanged(STATE_DANGER, true);
|
||||
}
|
||||
}
|
||||
|
@ -24,22 +24,28 @@ import java.util.List;
|
||||
@SuppressWarnings({"unused", "NarrowingCompoundAssignment"})
|
||||
final class ColorThief {
|
||||
|
||||
private ColorThief() {
|
||||
// Default constructor
|
||||
}
|
||||
|
||||
private static final int DEFAULT_QUALITY = 10;
|
||||
private static final boolean DEFAULT_IGNORE_WHITE = true;
|
||||
|
||||
public static int[] getColor(BufferedImage source) {
|
||||
int[][] palette = getPalette(source, 5);
|
||||
if (palette == null) {
|
||||
|
||||
if (palette == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
return palette[0];
|
||||
}
|
||||
|
||||
public static int[][] getPalette(BufferedImage source, int colorCount) {
|
||||
MMCQ.ColorMap colorMap = getColorMap(source, colorCount);
|
||||
if (colorMap == null) {
|
||||
|
||||
if (colorMap == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
return colorMap.palette();
|
||||
}
|
||||
|
||||
@ -49,12 +55,10 @@ final class ColorThief {
|
||||
|
||||
public static MMCQ.ColorMap getColorMap(BufferedImage sourceImage, int colorCount, int quality,
|
||||
boolean ignoreWhite) {
|
||||
if (colorCount < 2 || colorCount > 256) {
|
||||
if (colorCount < 2 || colorCount > 256)
|
||||
throw new IllegalArgumentException("Specified colorCount must be between 2 and 256.");
|
||||
}
|
||||
if (quality < 1) {
|
||||
if (quality < 1)
|
||||
throw new IllegalArgumentException("Specified quality should be greater then 0.");
|
||||
}
|
||||
|
||||
int[][] pixelArray = switch (sourceImage.getType()) {
|
||||
case TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR -> getPixelsFast(sourceImage, quality, ignoreWhite);
|
||||
@ -94,7 +98,7 @@ final class ColorThief {
|
||||
int offset, r, g, b, a;
|
||||
|
||||
switch (type) {
|
||||
case TYPE_3BYTE_BGR:
|
||||
case TYPE_3BYTE_BGR -> {
|
||||
for (int i = 0; i < pixelCount; i += quality) {
|
||||
offset = i * 3;
|
||||
b = pixels[offset] & 0xFF;
|
||||
@ -102,13 +106,12 @@ final class ColorThief {
|
||||
r = pixels[offset + 2] & 0xFF;
|
||||
|
||||
if (!(ignoreWhite && r > 250 && g > 250 && b > 250)) {
|
||||
pixelArray[numUsedPixels] = new int[] {r, g, b};
|
||||
pixelArray[numUsedPixels] = new int[]{r, g, b};
|
||||
numUsedPixels++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_4BYTE_ABGR:
|
||||
}
|
||||
case TYPE_4BYTE_ABGR -> {
|
||||
for (int i = 0; i < pixelCount; i += quality) {
|
||||
offset = i * 4;
|
||||
a = pixels[offset] & 0xFF;
|
||||
@ -117,14 +120,12 @@ final class ColorThief {
|
||||
r = pixels[offset + 3] & 0xFF;
|
||||
|
||||
if (a >= 125 && !(ignoreWhite && r > 250 && g > 250 && b > 250)) {
|
||||
pixelArray[numUsedPixels] = new int[] {r, g, b};
|
||||
pixelArray[numUsedPixels] = new int[]{r, g, b};
|
||||
numUsedPixels++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Unhandled type: " + type);
|
||||
}
|
||||
default -> throw new IllegalArgumentException("Unhandled type: " + type);
|
||||
}
|
||||
|
||||
return Arrays.copyOfRange(pixelArray, 0, numUsedPixels);
|
||||
@ -153,7 +154,7 @@ final class ColorThief {
|
||||
g = (rgb >> 8) & 0xFF;
|
||||
b = rgb & 0xFF;
|
||||
if (!(ignoreWhite && r > 250 && g > 250 && b > 250)) {
|
||||
res[numUsedPixels] = new int[] {r, g, b};
|
||||
res[numUsedPixels] = new int[]{r, g, b};
|
||||
numUsedPixels++;
|
||||
}
|
||||
}
|
||||
@ -259,9 +260,9 @@ final class ColorThief {
|
||||
}
|
||||
|
||||
if (ntot > 0) {
|
||||
gAvg = new int[] {(rsum / ntot), (gsum / ntot), (bsum / ntot)};
|
||||
gAvg = new int[]{(rsum / ntot), (gsum / ntot), (bsum / ntot)};
|
||||
} else {
|
||||
gAvg = new int[] {(MULT * (r1 + r2 + 1) / 2), (MULT * (g1 + g2 + 1) / 2),
|
||||
gAvg = new int[]{(MULT * (r1 + r2 + 1) / 2), (MULT * (g1 + g2 + 1) / 2),
|
||||
(MULT * (b1 + b2 + 1) / 2)};
|
||||
}
|
||||
}
|
||||
@ -279,7 +280,7 @@ final class ColorThief {
|
||||
|
||||
public static class ColorMap {
|
||||
|
||||
public final ArrayList<VBox> vboxes = new ArrayList<>();
|
||||
public final List<VBox> vboxes = new ArrayList<>();
|
||||
|
||||
public void push(VBox box) {
|
||||
vboxes.add(box);
|
||||
@ -386,7 +387,7 @@ final class ColorThief {
|
||||
}
|
||||
|
||||
if (vbox.count(false) == 1) {
|
||||
return new VBox[] {vbox.clone(), null};
|
||||
return new VBox[]{vbox.clone(), null};
|
||||
}
|
||||
|
||||
int rw = vbox.r2 - vbox.r1 + 1;
|
||||
@ -508,7 +509,7 @@ final class ColorThief {
|
||||
vbox2.b1 = d2 + 1;
|
||||
}
|
||||
|
||||
return new VBox[] {vbox1, vbox2};
|
||||
return new VBox[]{vbox1, vbox2};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user