Browse Source

Move ColorModel classes to util

pull/235/head
weisj 4 years ago
parent
commit
3c28c4cd15
  1. 2
      core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java
  2. 1
      core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java
  3. 2
      core/src/main/java/com/github/weisj/darklaf/task/ForegroundColorGenerationTask.java
  4. 2
      core/src/main/java/com/github/weisj/darklaf/task/StyleSheetInitTask.java
  5. 1
      core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java
  6. 2
      core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java
  7. 6
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java
  8. 2
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  9. 2
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java
  10. 4
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java
  11. 2
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkColorTableCellRendererEditor.java
  12. 2
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRenderer.java
  13. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java
  14. 6
      core/src/test/java/documentation/CreateUITable.java
  15. 4
      core/src/test/java/test/CustomTitleBarTest.java
  16. 3
      property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java
  17. 12
      property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java
  18. 6
      utils/src/main/java/com/github/weisj/darklaf/color/ColorUtil.java
  19. 0
      utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java
  20. 0
      utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java
  21. 0
      utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java
  22. 0
      utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java
  23. 0
      utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java
  24. 2
      utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java

2
core/src/main/java/com/github/weisj/darklaf/components/color/SmallColorChooser.java

@ -32,6 +32,7 @@ import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.text.*;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.color.DarkColorModel;
import com.github.weisj.darklaf.color.DarkColorModelHSB;
import com.github.weisj.darklaf.color.DarkColorModelHSL;
@ -50,7 +51,6 @@ import com.github.weisj.darklaf.ui.colorchooser.ColorTriangle;
import com.github.weisj.darklaf.ui.colorchooser.ColorValueFormatter;
import com.github.weisj.darklaf.ui.slider.DarkSliderUI;
import com.github.weisj.darklaf.ui.tabbedpane.DarkTabbedPaneUI;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
public class SmallColorChooser extends JPanel implements ChooserComponent<Color> {

1
core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java

@ -34,6 +34,7 @@ import javax.swing.text.View;
import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.ui.OpacityBufferedUI;
import com.github.weisj.darklaf.util.*;

2
core/src/main/java/com/github/weisj/darklaf/task/ForegroundColorGenerationTask.java

@ -27,12 +27,12 @@ import java.util.Properties;
import javax.swing.plaf.ColorUIResource;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.color.DarkColorModelHSB;
import com.github.weisj.darklaf.color.DarkColorModelHSL;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.theme.info.AccentColorRule;
import com.github.weisj.darklaf.uiresource.DarkColorUIResource;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.Pair;
public class ForegroundColorGenerationTask extends ColorAdjustmentTask {

2
core/src/main/java/com/github/weisj/darklaf/task/StyleSheetInitTask.java

@ -27,8 +27,8 @@ import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.util.ColorUtil;
public class StyleSheetInitTask implements DefaultsInitTask {

1
core/src/main/java/com/github/weisj/darklaf/ui/DarkPopupFactory.java

@ -28,6 +28,7 @@ import java.util.Objects;
import javax.swing.*;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.graphics.GraphicsUtil;
import com.github.weisj.darklaf.platform.DecorationsHandler;
import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI;

2
core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java

@ -26,11 +26,11 @@ import java.awt.*;
import javax.swing.*;
import javax.swing.tree.DefaultTreeCellRenderer;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.ui.list.DarkListUI;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.table.renderer.IconWrapper;
import com.github.weisj.darklaf.ui.tree.DarkTreeUI;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyKey;
import com.github.weisj.darklaf.util.PropertyUtil;

6
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/ColorTriangle.java

@ -32,13 +32,13 @@ import java.util.List;
import javax.swing.*;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.color.DarkColorModel;
import com.github.weisj.darklaf.color.DarkColorModelHSB;
import com.github.weisj.darklaf.color.DarkColorModelHSL;
import com.github.weisj.darklaf.color.DarkColorModelRGB;
import com.github.weisj.darklaf.graphics.GraphicsContext;
import com.github.weisj.darklaf.graphics.GraphicsUtil;
import com.github.weisj.darklaf.util.ColorUtil;
public class ColorTriangle extends JComponent {
@ -449,7 +449,7 @@ public class ColorTriangle extends JComponent {
try {
// For calculating pick location. MouseEvents already respect the ui scaling.
triangleInverse = rotationTransform.createInverse();
} catch (NoninvertibleTransformException e) {
} catch (final NoninvertibleTransformException e) {
e.printStackTrace();
}
}
@ -644,7 +644,7 @@ public class ColorTriangle extends JComponent {
triangleInverse.transform(dummy, dummy);
Point2D sv = getSaturationAndValue(dummy.getX(), dummy.getY());
setPixel(raster, i, j, getColorRGB(getHue(), sv.getX(), sv.getY()));
} catch (NoninvertibleTransformException ignored) {
} catch (final NoninvertibleTransformException ignored) {
}
}
}

2
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/DarkColorChooserPanel.java

@ -28,12 +28,12 @@ import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.AncestorEvent;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.color.DarkColorModel;
import com.github.weisj.darklaf.components.DefaultColorPipette;
import com.github.weisj.darklaf.listener.AncestorAdapter;
import com.github.weisj.darklaf.listener.UpdateDocumentListener;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.PropertyUtil;
/**

2
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java

@ -32,10 +32,10 @@ import java.util.function.Consumer;
import javax.swing.*;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.ColorUtil;
/**
* @author Alexey Pegov

4
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarUI.java

@ -28,8 +28,8 @@ import javax.swing.event.ChangeEvent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.PropertyUtil;
/** @author Jannis Weis */
@ -217,7 +217,7 @@ public class DarkScrollBarUI extends BasicScrollBarUI implements ScrollBarConsta
public void layoutContainer(final Container scrollbarContainer) {
try {
super.layoutContainer(scrollbarContainer);
} catch (NullPointerException ignore) {
} catch (final NullPointerException ignore) {
// installUI is not performed yet or uninstallUI has set almost every field to null.
}
}

2
core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkColorTableCellRendererEditor.java

@ -29,8 +29,8 @@ import javax.swing.*;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.components.color.PopupColorChooser;
import com.github.weisj.darklaf.util.ColorUtil;
/** @author Jannis Weis */
public class DarkColorTableCellRendererEditor extends AbstractCellEditor implements TableCellRenderer, TableCellEditor {

2
core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRenderer.java

@ -26,7 +26,7 @@ import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.color.ColorUtil;
/** @author Jannis Weis */
public class DarkTableCellRenderer extends DefaultTableCellRenderer {

2
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java

@ -33,12 +33,12 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToolTipUI;
import javax.swing.text.View;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.graphics.*;
import com.github.weisj.darklaf.ui.DarkPopupFactory;
import com.github.weisj.darklaf.uiresource.DarkColorUIResource;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyKey;

6
core/src/test/java/documentation/CreateUITable.java

@ -40,12 +40,12 @@ import javax.swing.border.EmptyBorder;
import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.components.border.DropShadowBorder;
import com.github.weisj.darklaf.icons.DarkSVGIcon;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.icons.IconColorMapper;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.ImageUtil;
import com.github.weisj.darklaf.util.StringUtil;
import com.github.weisj.darklaf.util.SystemInfo;
@ -241,7 +241,7 @@ public class CreateUITable {
} else {
path = createImage(value, keyName, size);
}
} catch (IOException ignored) {
} catch (final IOException ignored) {
return StringUtil.repeat(IDENT, ident) + "<td></td>\n";
}
return StringUtil.repeat(IDENT, ident) + String
@ -278,7 +278,7 @@ public class CreateUITable {
StringBuilder sb = new StringBuilder(StringUtil.repeat(IDENT, ident)).append("<td align=\"center\">\n");
try {
readFile(icon.getSvgURI().toURL(), sb, ident + 1);
} catch (IOException e) {
} catch (final IOException e) {
e.printStackTrace();
}
sb.append(StringUtil.repeat(IDENT, ident)).append("</td>\n");

4
core/src/test/java/test/CustomTitleBarTest.java

@ -35,10 +35,10 @@ import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.theme.DarculaTheme;
import com.github.weisj.darklaf.theme.IntelliJTheme;
import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.SystemInfo;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ -99,7 +99,7 @@ class CustomTitleBarTest extends AbstractImageTest {
lock.wait(100000);
// Wait some time because the window may still be transparent.
Thread.sleep(500);
} catch (InterruptedException e) {
} catch (final InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}

3
property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java

@ -37,6 +37,7 @@ import javax.swing.*;
import javax.swing.plaf.DimensionUIResource;
import javax.swing.plaf.InsetsUIResource;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.icons.DarkUIAwareIcon;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.icons.IconLoader;
@ -326,7 +327,7 @@ public final class PropertyLoader {
} else {
try {
values[i] = Integer.parseInt(subKeys[i]);
} catch (NumberFormatException ignored) {
} catch (final NumberFormatException ignored) {
// In this case the value will be 0.
}
}

12
property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java

@ -30,7 +30,7 @@ import java.util.logging.Logger;
import javax.swing.*;
import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.color.ColorUtil;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.Pair;
import com.github.weisj.darklaf.util.Types;
@ -60,7 +60,7 @@ public final class IconColorMapper {
LOGGER.finer(() -> "Patching colors of icon " + svgIcon.getSvgURI());
try {
loadColors(diagram, defaults, contextDefaults);
} catch (SVGElementException e) {
} catch (final SVGElementException e) {
LOGGER.log(Level.SEVERE, "Failed patching colors. " + e.getMessage(), e.getStackTrace());
}
}
@ -158,7 +158,7 @@ public final class IconColorMapper {
attribute.setName(key);
try {
child.getStyle(attribute);
} catch (SVGException e) {
} catch (final SVGException e) {
return null;
}
return attribute;
@ -169,7 +169,7 @@ public final class IconColorMapper {
attribute.setName("stop-opacity");
try {
stop.getStyle(attribute);
} catch (SVGException e) {
} catch (final SVGException e) {
return -1;
}
return !attribute.getStringValue().isEmpty() ? attribute.getFloatValue() : -1;
@ -204,7 +204,7 @@ public final class IconColorMapper {
attribute.setName("opacity");
try {
child.getStyle(attribute);
} catch (SVGException e) {
} catch (final SVGException e) {
e.printStackTrace();
return null;
}
@ -238,7 +238,7 @@ public final class IconColorMapper {
}
grad.loaderAddChild(null, stop1);
grad.loaderAddChild(null, stop2);
} catch (SVGException e) {
} catch (final SVGException e) {
e.printStackTrace();
}
});

6
utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java → utils/src/main/java/com/github/weisj/darklaf/color/ColorUtil.java

@ -19,12 +19,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.github.weisj.darklaf.util;
package com.github.weisj.darklaf.color;
import java.awt.*;
import javax.swing.plaf.UIResource;
import com.github.weisj.darklaf.util.ColorWrapper;
/** @author Jannis Weis */
public final class ColorUtil {
@ -59,7 +61,7 @@ public final class ColorUtil {
public static Color fromHex(final String str, final Color defaultValue) {
try {
return fromHex(str);
} catch (Exception var3) {
} catch (final Exception var3) {
return defaultValue;
}
}

0
core/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java → utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModel.java

0
core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java → utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelCMYK.java

0
core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java → utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSB.java

0
core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java → utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelHSL.java

0
core/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java → utils/src/main/java/com/github/weisj/darklaf/color/DarkColorModelRGB.java

2
utils/src/main/java/com/github/weisj/darklaf/util/PropertyUtil.java

@ -32,6 +32,8 @@ import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.UIResource;
import com.github.weisj.darklaf.color.ColorUtil;
public final class PropertyUtil {
public static void installSystemProperty(final String key, final String value) {

Loading…
Cancel
Save