diff --git a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java index 4d9634b1..7b1bdc53 100644 --- a/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java +++ b/core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java @@ -98,9 +98,9 @@ public class DarkColorModelCMYK extends DarkColorModel { private static int[] CMYKtoRGB(final double c, final double m, final double y, final double k) { - rgb[0] = (int) Math.round(255 * (1.0f + c * k - k - c)); - rgb[1] = (int) Math.round(255 * (1.0f + m * k - k - m)); - rgb[2] = (int) Math.round(255 * (1.0f + y * k - k - y)); + rgb[0] = (int) Math.round(255 * (1 - c) * (1 - k)); + rgb[1] = (int) Math.round(255 * (1 - m) * (1 - k)); + rgb[2] = (int) Math.round(255 * (1 - y) * (1 - k)); return rgb; } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java b/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java index e802854a..2a91652f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java @@ -288,7 +288,7 @@ public class SmallColorChooser extends JPanel { } protected ColorPreviewComponent createPreviewComponent() { - ColorPreviewComponent comp = new ColorPreviewComponent() { + return new ColorPreviewComponent() { @Override public Dimension getMaximumSize() { return getPreferredSize(); @@ -303,8 +303,6 @@ public class SmallColorChooser extends JPanel { return size; } }; - comp.setBorder(null); - return comp; } protected static class Descriptor extends JLabel { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java index bb0bcad8..e7ec807f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorPreviewComponent.java @@ -34,7 +34,6 @@ public class ColorPreviewComponent extends JComponent { private Color color; public ColorPreviewComponent() { - setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2)); borderColor = UIManager.getColor("ColorChooser.previewBorderColor"); } @@ -63,10 +62,4 @@ public class ColorPreviewComponent extends JComponent { g.fillRect(i.left + width - 1, i.top, 1, height); g.fillRect(i.left, i.top + height - 1, width, 1); } - - - @Override - public Dimension getPreferredSize() { - return new Dimension(100, 32); - } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java index 158721a6..535cc889 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java @@ -26,7 +26,6 @@ package com.github.weisj.darklaf.ui.colorchooser; import com.github.weisj.darklaf.color.DarkColorModel; import com.github.weisj.darklaf.components.DefaultColorPipette; -import com.github.weisj.darklaf.components.uiresource.JButtonUIResource; import com.github.weisj.darklaf.decorators.AncestorAdapter; import com.github.weisj.darklaf.decorators.UpdateDocumentListener; import com.github.weisj.darklaf.ui.button.DarkButtonUI; @@ -84,7 +83,7 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements initInputFields(colorModels); setLayout(new BorderLayout()); - setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); + setBorder(BorderFactory.createEmptyBorder(20, 20, 0, 21)); add(buildTopPanel(UIManager.getBoolean("ColorChooser.pipetteEnabled")), BorderLayout.NORTH); add(colorWheelPanel, BorderLayout.CENTER); add(Box.createVerticalStrut(10), BorderLayout.SOUTH); @@ -114,7 +113,11 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements colorChanged(getColorFromHex(), textHex); }); for (JFormattedTextField inputField : valueFields) { - inputField.addPropertyChangeListener(e -> colorChanged(getColorFromFields(), inputField)); + inputField.addPropertyChangeListener(e -> { + if ("value".equals(e.getPropertyName())) { + colorChanged(getColorFromFields(), inputField); + } + }); } colorWheelPanel.addListener(this); } @@ -268,7 +271,6 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements return c == null ? currentColor : c; } - protected DarkColorModel getDarkColorModel() { return (DarkColorModel) formatBox.getSelectedItem(); } @@ -281,9 +283,13 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements if (enablePipette && pipette != null) { previewPanel.add(createPipetteButton(), BorderLayout.WEST); } + previewComponent.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + previewComponent.setPreferredSize(new Dimension(100, 25)); + previewPanel.add(previewComponent, BorderLayout.CENTER); result.add(previewPanel, BorderLayout.NORTH); + final JPanel valuePanel = new JPanel(); valuePanel.setLayout(new BoxLayout(valuePanel, BoxLayout.X_AXIS)); valuePanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); @@ -314,15 +320,17 @@ public class DarkColorChooserPanel extends AbstractColorChooserPanel implements } private JButton createPipetteButton() { - JButton pipetteButton = new JButtonUIResource(); - pipetteButton.putClientProperty(DarkButtonUI.KEY_VARIANT, DarkButtonUI.VARIANT_ONLY_LABEL); + JButton pipetteButton = new JButton(); pipetteButton.putClientProperty(DarkButtonUI.KEY_THIN, Boolean.TRUE); + pipetteButton.putClientProperty(DarkButtonUI.KEY_SQUARE, Boolean.TRUE); + pipetteButton.putClientProperty(DarkButtonUI.KEY_ALT_ARC, Boolean.TRUE); pipetteButton.setRolloverEnabled(true); + pipetteButton.setFocusable(false); + pipetteButton.setIcon(getPipetteIcon()); pipetteButton.setRolloverIcon(getPipetteRolloverIcon()); pipetteButton.setDisabledIcon(getPipetteRolloverIcon()); pipetteButton.setPressedIcon(getPipetteRolloverIcon()); - pipetteButton.setFocusable(false); pipetteButton.addActionListener(e -> { pipetteButton.setEnabled(false); pipette.setInitialColor(getColorFromModel()); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java index 9bb84ed6..fc30bf2d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkSwatchesChooserPanel.java @@ -26,7 +26,6 @@ package com.github.weisj.darklaf.ui.colorchooser; import javax.accessibility.AccessibleContext; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.colorchooser.ColorSelectionModel; @@ -59,11 +58,9 @@ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel { @Override protected void buildChooser() { + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); String recentStr = UIManager.getString("ColorChooser.swatchesRecentText", getLocale()); - JPanel superHolder = new JPanel(); - superHolder.setLayout(new BorderLayout()); - previewPanel = new ColorPreviewComponent(); previewPanel.setColor(getColorFromModel()); @@ -83,13 +80,13 @@ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel { recentSwatchPanel.addMouseListener(recentSwatchListener); recentSwatchPanel.addKeyListener(recentSwatchKeyListener); - JPanel mainHolder = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel mainHolder = new JPanel(new GridBagLayout()); Border border = new LineBorder(UIManager.getColor("ColorChooser.swatchBorderColor")); swatchPanel.setBorder(border); mainHolder.add(swatchPanel); recentSwatchPanel.setInheritsPopupMenu(true); - JPanel recentHolder = new JPanel(new FlowLayout(FlowLayout.CENTER)); + JPanel recentHolder = new JPanel(new GridBagLayout()); recentSwatchPanel.setBorder(border); recentHolder.setInheritsPopupMenu(true); recentHolder.add(recentSwatchPanel); @@ -100,8 +97,9 @@ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel { labelHolder.add(l); JPanel previewHolder = new JPanel(new BorderLayout()); - previewHolder.setBorder(new EmptyBorder(0, 5, 10, 5)); + previewHolder.add(Box.createVerticalStrut(25), BorderLayout.WEST); previewHolder.add(previewPanel, BorderLayout.CENTER); + previewHolder.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); JPanel swatches = new JPanel(); swatches.setInheritsPopupMenu(true); @@ -110,11 +108,8 @@ public class DarkSwatchesChooserPanel extends AbstractColorChooserPanel { swatches.add(labelHolder); swatches.add(recentHolder); - superHolder.add(previewHolder, BorderLayout.NORTH); - superHolder.add(swatches, BorderLayout.CENTER); - superHolder.setInheritsPopupMenu(true); - - add(superHolder); + add(previewHolder); + add(swatches); } public String getDisplayName() {