diff --git a/src/main/java/pixelitor/filters/BorderMask.java b/src/main/java/pixelitor/filters/BorderMask.java index 3a7ce680..03456e24 100644 --- a/src/main/java/pixelitor/filters/BorderMask.java +++ b/src/main/java/pixelitor/filters/BorderMask.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -51,8 +51,8 @@ public class BorderMask extends ParametrizedFilter { new String[]{"North", "East", "South", "West"}, 0, 10, 500, true); private final RangeParam roundnessParam = new RangeParam("Roundness", 0, 20, 500); private final AngleParam angleParam = new AngleParam("Rotate", 0); - private final BooleanParam invertParam = new BooleanParam("Invert", false); - private final BooleanParam transparencyParam = new BooleanParam("Render Transparency", false); + private final BooleanParam invertParam = new BooleanParam("Invert"); + private final BooleanParam transparencyParam = new BooleanParam("Render Transparency"); public BorderMask() { super(false); diff --git a/src/main/java/pixelitor/filters/BumpMap.java b/src/main/java/pixelitor/filters/BumpMap.java index a7e5c53d..10ae3ba7 100644 --- a/src/main/java/pixelitor/filters/BumpMap.java +++ b/src/main/java/pixelitor/filters/BumpMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -32,7 +32,7 @@ public class BumpMap extends ParametrizedFilter { public static final String NAME = "Bump Map"; private final SelectImageParam imageParam = new SelectImageParam("Bump Map"); - private final BooleanParam tileParam = new BooleanParam("Tile", false); + private final BooleanParam tileParam = new BooleanParam("Tile"); private final AngleParam lightDirection = new AngleParam( "Light Direction", 0); private final RangeParam depth = new RangeParam( diff --git a/src/main/java/pixelitor/filters/Canny.java b/src/main/java/pixelitor/filters/Canny.java index 96eeeed2..07ff2502 100644 --- a/src/main/java/pixelitor/filters/Canny.java +++ b/src/main/java/pixelitor/filters/Canny.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -48,10 +48,8 @@ public class Canny extends ParametrizedFilter { "Gaussian Kernel Width", 2, 16, 50); private final RangeParam gaussianKernelRadius = new RangeParam( "Gaussian Kernel Radius", 0, 2, 10); - private final BooleanParam contrastNormalized = new BooleanParam( - "Contrast Normalized", false); - private final BooleanParam invert = new BooleanParam( - "Invert", false); + private final BooleanParam contrastNormalized = new BooleanParam("Contrast Normalized"); + private final BooleanParam invert = new BooleanParam("Invert"); public Canny() { super(true); diff --git a/src/main/java/pixelitor/filters/ChannelToTransparency.java b/src/main/java/pixelitor/filters/ChannelToTransparency.java index ae2ba5b4..929c4923 100644 --- a/src/main/java/pixelitor/filters/ChannelToTransparency.java +++ b/src/main/java/pixelitor/filters/ChannelToTransparency.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -51,7 +51,7 @@ public class ChannelToTransparency extends ParametrizedFilter { new Item("Green", GREEN), new Item("Blue", BLUE) }); - private final BooleanParam invertParam = new BooleanParam("Invert", false); + private final BooleanParam invertParam = new BooleanParam("Invert"); private final BooleanParam keepParam = new BooleanParam("Keep Existing Transparency", true); public ChannelToTransparency() { diff --git a/src/main/java/pixelitor/filters/ChaosGame.java b/src/main/java/pixelitor/filters/ChaosGame.java index 3c2161a7..7a2d2b31 100644 --- a/src/main/java/pixelitor/filters/ChaosGame.java +++ b/src/main/java/pixelitor/filters/ChaosGame.java @@ -71,9 +71,9 @@ public class ChaosGame extends ParametrizedFilter { new Item("Last but One", COLORS_LAST_BUT_ONE), new Item("Last but Two", COLORS_LAST_BUT_TWO), }, IGNORE_RANDOMIZE); - private final BooleanParam centerJump = new BooleanParam("Jump to Center", false); - private final BooleanParam midpointJump = new BooleanParam("Jump to Midpoints", false); - private final BooleanParam restrict = new BooleanParam("No Vertex Repetition", false); + private final BooleanParam centerJump = new BooleanParam("Jump to Center"); + private final BooleanParam midpointJump = new BooleanParam("Jump to Midpoints"); + private final BooleanParam restrict = new BooleanParam("No Vertex Repetition"); private final BooleanParam showPoly = new BooleanParam("Show Polygon", false, IGNORE_RANDOMIZE); public ChaosGame() { diff --git a/src/main/java/pixelitor/filters/CurveFilter.java b/src/main/java/pixelitor/filters/CurveFilter.java index 3ab40a47..38efbe4e 100644 --- a/src/main/java/pixelitor/filters/CurveFilter.java +++ b/src/main/java/pixelitor/filters/CurveFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -90,25 +90,25 @@ public abstract class CurveFilter extends ParametrizedFilter { new Item("Transparent", FG_TRANSPARENT), }, IGNORE_RANDOMIZE); - private final BooleanParam waterMark = new BooleanParam("Watermarking", false); + private final BooleanParam waterMark = new BooleanParam("Watermarking"); protected final ImagePositionParam center = new ImagePositionParam("Center"); private final GroupedRangeParam scale = new GroupedRangeParam("Scale (%)", 1, 100, 500); private final AngleParam rotate = new AngleParam("Rotate", 0); - private final EnumParam nonlinType = NonlinTransform.asParam(); - private final RangeParam nonlinTuning = new RangeParam("Distortion Tuning", -100, 0, 100); + private final EnumParam distortType = NonlinTransform.asParam(); + private final RangeParam distortAmount = NonlinTransform.createAmountParam(); private transient Shape exportedShape; protected CurveFilter() { super(false); - nonlinType.setupEnableOtherIf(nonlinTuning, NonlinTransform::hasTuning); + distortType.setupEnableOtherIf(distortAmount, NonlinTransform::hasAmount); setParams( background, foreground, waterMark, - new DialogParam("Transform", nonlinType, nonlinTuning, center, rotate, scale), + new DialogParam("Transform", distortType, distortAmount, center, rotate, scale), strokeParam.withStrokeWidth(2), effectsParam ).withAction(new FilterButtonModel("Export SVG...", this::exportSVG, @@ -151,9 +151,9 @@ public BufferedImage transform(BufferedImage src, BufferedImage dest) { return dest; } - NonlinTransform nonlin = nonlinType.getSelected(); + NonlinTransform nonlin = distortType.getSelected(); if (nonlin != NONE) { - double amount = nonlinTuning.getValueAsDouble(); + double amount = distortAmount.getValueAsDouble(); Point2D pivotPoint = center.getAbsolutePoint(src); shape = nonlin.transform(shape, pivotPoint, amount, srcWidth, srcHeight); } @@ -357,6 +357,6 @@ public Path2D getPath() { } protected boolean hasNonlinDistort() { - return nonlinType.getSelected() != NONE; + return distortType.getSelected() != NONE; } } \ No newline at end of file diff --git a/src/main/java/pixelitor/filters/DisplacementMap.java b/src/main/java/pixelitor/filters/DisplacementMap.java index 72ece54c..bb0d07fc 100644 --- a/src/main/java/pixelitor/filters/DisplacementMap.java +++ b/src/main/java/pixelitor/filters/DisplacementMap.java @@ -27,7 +27,7 @@ public class DisplacementMap extends ParametrizedFilter { public static final String NAME = "Displacement Map"; private final SelectImageParam imageParam = new SelectImageParam("Displacement Map"); - private final BooleanParam tileParam = new BooleanParam("Tile", false); + private final BooleanParam tileParam = new BooleanParam("Tile"); private final RangeParam amount = new RangeParam( "Amount", 0, 10, 100); private final AngleParam angle = new AngleParam("Angle", 0); diff --git a/src/main/java/pixelitor/filters/ExtractChannel.java b/src/main/java/pixelitor/filters/ExtractChannel.java index 1fbe7751..82ec4e98 100644 --- a/src/main/java/pixelitor/filters/ExtractChannel.java +++ b/src/main/java/pixelitor/filters/ExtractChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -54,7 +54,7 @@ public class ExtractChannel extends ParametrizedFilter { new Item("Blue", BLUE_CHANNEL), new Item("Remove Blue", REMOVE_BLUE_CHANNEL), }); - private final BooleanParam bwParam = new BooleanParam("Black and White", false); + private final BooleanParam bwParam = new BooleanParam("Black and White"); public ExtractChannel() { super(true); diff --git a/src/main/java/pixelitor/filters/Flashlight.java b/src/main/java/pixelitor/filters/Flashlight.java index b7b0a38f..c2435a90 100644 --- a/src/main/java/pixelitor/filters/Flashlight.java +++ b/src/main/java/pixelitor/filters/Flashlight.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -51,7 +51,7 @@ public class Flashlight extends ParametrizedFilter { new Item("Background Color", Impl.BG_TOOL_BG), new Item("Transparent", Impl.BG_TRANSPARENT), }, IGNORE_RANDOMIZE); - private final BooleanParam invert = new BooleanParam("Invert", false); + private final BooleanParam invert = new BooleanParam("Invert"); private Impl filter; diff --git a/src/main/java/pixelitor/filters/FlowField.java b/src/main/java/pixelitor/filters/FlowField.java index b20e828b..b69f202d 100644 --- a/src/main/java/pixelitor/filters/FlowField.java +++ b/src/main/java/pixelitor/filters/FlowField.java @@ -235,7 +235,7 @@ public boolean requiresColorField() { private final RangeParam numParticlesParam = new RangeParam("Particle Count", 1, 1000, 20000, true, BORDER, IGNORE_RANDOMIZE); private final StrokeParam strokeParam = new StrokeParam("Stroke"); - private final BooleanParam antiAliasParam = new BooleanParam("Use Antialiasing", false); + private final BooleanParam antiAliasParam = new BooleanParam("Use Antialiasing"); private final ColorParam backgroundColorParam = new ColorParam("Background Color", new Color(0, 0, 0, 1.0f), FREE_TRANSPARENCY); private final ColorParam particleColorParam = new ColorParam("Particle Color", new Color(1, 1, 1, 0.12f), FREE_TRANSPARENCY); private final EnumParam initialColorsParam = new EnumParam<>("Initialize Colors", ColorSource.class); diff --git a/src/main/java/pixelitor/filters/LittlePlanet.java b/src/main/java/pixelitor/filters/LittlePlanet.java index 7c94fed3..ab43f30f 100644 --- a/src/main/java/pixelitor/filters/LittlePlanet.java +++ b/src/main/java/pixelitor/filters/LittlePlanet.java @@ -40,7 +40,7 @@ public class LittlePlanet extends ParametrizedFilter { private final AngleParam rotateResult = new AngleParam("Rotate Result", 90, INTUITIVE_DEGREES); private final RangeParam zoom = new RangeParam(ZOOM + " (%)", 1, 100, 501); private final RangeParam innerZoom = new RangeParam("Inner Zoom (%)", 30, 100, 170); - private final BooleanParam invert = new BooleanParam("Invert", false); + private final BooleanParam invert = new BooleanParam("Invert"); private final IntChoiceParam edgeAction = IntChoiceParam.forEdgeAction(true); private final IntChoiceParam interpolation = IntChoiceParam.forInterpolation(); diff --git a/src/main/java/pixelitor/filters/Magnify.java b/src/main/java/pixelitor/filters/Magnify.java index 7ab7bdba..90123561 100644 --- a/src/main/java/pixelitor/filters/Magnify.java +++ b/src/main/java/pixelitor/filters/Magnify.java @@ -38,7 +38,7 @@ public class Magnify extends ParametrizedFilter { private final RangeParam softness = new RangeParam("Softness", 0, 100, 1000); private final ImagePositionParam center = new ImagePositionParam("Center"); private final IntChoiceParam shape = BlurredShape.getChoices(); - private final BooleanParam invert = new BooleanParam("Invert", false); + private final BooleanParam invert = new BooleanParam("Invert"); private final IntChoiceParam edgeAction = IntChoiceParam.forEdgeAction(); private final IntChoiceParam interpolation = IntChoiceParam.forInterpolation(); diff --git a/src/main/java/pixelitor/filters/Marble.java b/src/main/java/pixelitor/filters/Marble.java index 3307f0dc..1c3a7987 100644 --- a/src/main/java/pixelitor/filters/Marble.java +++ b/src/main/java/pixelitor/filters/Marble.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -64,7 +64,7 @@ public class Marble extends ParametrizedFilter { }); private final IntChoiceParam waveType = IntChoiceParam.forWaveType(); - private final BooleanParam smoothDetails = new BooleanParam("Smoother Details", false); + private final BooleanParam smoothDetails = new BooleanParam("Smoother Details"); private final GradientParam gradient = new GradientParam("Colors", new float[]{0.0f, 0.5f, 1.0f}, diff --git a/src/main/java/pixelitor/filters/ParamTest.java b/src/main/java/pixelitor/filters/ParamTest.java index 2b1f3c95..709fc510 100644 --- a/src/main/java/pixelitor/filters/ParamTest.java +++ b/src/main/java/pixelitor/filters/ParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -82,7 +82,7 @@ public static FilterParam[] getTestParams() { new AngleParam("AngleParam", 0), new ElevationAngleParam("ElevationAngleParam", 0), new BlendingModeParam(BlendingMode.values()), - new BooleanParam("BooleanParam", false), + new BooleanParam("BooleanParam"), new TextParam("TextParam", "default value", true), new LogZoomParam("Zoom", 200, 200, 1000), }; diff --git a/src/main/java/pixelitor/filters/PoissonDiskTester.java b/src/main/java/pixelitor/filters/PoissonDiskTester.java index 526e1e74..4c21ce0b 100644 --- a/src/main/java/pixelitor/filters/PoissonDiskTester.java +++ b/src/main/java/pixelitor/filters/PoissonDiskTester.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -44,7 +44,7 @@ public class PoissonDiskTester extends ParametrizedFilter { private final RangeParam distance = new RangeParam("Distance", 10, 20, 300); private final RangeParam k = new RangeParam("k", 1, 30, 100); - private final BooleanParam improved = new BooleanParam("Improved", false); + private final BooleanParam improved = new BooleanParam("Improved"); private final BooleanParam debugGrid = new BooleanParam("Debug Grid", false, IGNORE_RANDOMIZE); private final ColorListParam colors = new ColorListParam("Colors", diff --git a/src/main/java/pixelitor/filters/Rose.java b/src/main/java/pixelitor/filters/Rose.java index cde7f8af..4cd85081 100644 --- a/src/main/java/pixelitor/filters/Rose.java +++ b/src/main/java/pixelitor/filters/Rose.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -53,13 +53,13 @@ public class Rose extends ParametrizedFilter { private final ColorParam fgColor = new ColorParam("Foreground Color", WHITE, USER_ONLY_TRANSPARENCY); private final GroupedRangeParam scale = new GroupedRangeParam("Scale (%)", 1, 100, 500); private final AngleParam rotate = new AngleParam("Rotate", 0); - private final EnumParam nonlinType = NonlinTransform.asParam(); - private final RangeParam nonlinTuning = new RangeParam("Distortion Tuning", -100, 0, 100); + private final EnumParam distortType = NonlinTransform.asParam(); + private final RangeParam distortAmount = NonlinTransform.createAmountParam(); public Rose() { super(false); - nonlinType.setupEnableOtherIf(nonlinTuning, NonlinTransform::hasTuning); + distortType.setupEnableOtherIf(distortAmount, NonlinTransform::hasAmount); setParams( nParam, @@ -67,7 +67,7 @@ public Rose() { bgColor, fgColor, new DialogParam("Transform", - nonlinType, nonlinTuning, center, rotate, scale) + distortType, distortAmount, center, rotate, scale) ); helpURL = "https://en.wikipedia.org/wiki/Rose_(mathematics)"; @@ -110,9 +110,9 @@ public BufferedImage transform(BufferedImage src, BufferedImage dest) { } path.closePath(); - NonlinTransform nonlin = nonlinType.getSelected(); + NonlinTransform nonlin = distortType.getSelected(); if (nonlin != NONE) { - double amount = nonlinTuning.getValueAsDouble(); + double amount = distortAmount.getValueAsDouble(); Point2D pivotPoint = new Point2D.Double(cx, cy); path = nonlin.transform(path, pivotPoint, amount, width, height); } diff --git a/src/main/java/pixelitor/filters/SlippingTiles.java b/src/main/java/pixelitor/filters/SlippingTiles.java index b8effa52..fd0bcfd6 100644 --- a/src/main/java/pixelitor/filters/SlippingTiles.java +++ b/src/main/java/pixelitor/filters/SlippingTiles.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -107,7 +107,7 @@ boolean isSecondSideFalling() { } private final RangeParam centerTileSizeParam = new RangeParam("Center Tile Width", 1, 50, 99); - private final BooleanParam isCenterTileSizeAutomaticallyCalculatedParam = new BooleanParam("Auto-Adjust Width", false); + private final BooleanParam isCenterTileSizeAutomaticallyCalculatedParam = new BooleanParam("Auto-Adjust Width"); private final RangeParam numberOfTilesParam = new RangeParam("Number of Tiles", 1, 4, 20); private final EnumParam distributionParam = new EnumParam<>("Distribution", Distributor.class); private final RangeParam slipDisplacementParam = new RangeParam("Slip Length", 1, 50, 99); diff --git a/src/main/java/pixelitor/filters/Spiral.java b/src/main/java/pixelitor/filters/Spiral.java index d9e0bf9f..f53bdbc1 100644 --- a/src/main/java/pixelitor/filters/Spiral.java +++ b/src/main/java/pixelitor/filters/Spiral.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -51,8 +51,8 @@ public class Spiral extends CurveFilter { new Item("Polygon", TYPE_POLYGON) }); private final RangeParam sidesParam = new RangeParam("Polygon Sides", 3, 4, 10); - private final BooleanParam symmetry = new BooleanParam("Symmetric", false); - private final BooleanParam log = new BooleanParam("Logarithmic", false); + private final BooleanParam symmetry = new BooleanParam("Symmetric"); + private final BooleanParam log = new BooleanParam("Logarithmic"); private final BooleanParam scale = new BooleanParam("Scale", true); public Spiral() { diff --git a/src/main/java/pixelitor/filters/XYZTest.java b/src/main/java/pixelitor/filters/XYZTest.java index b15a35df..e6ce6e4a 100644 --- a/src/main/java/pixelitor/filters/XYZTest.java +++ b/src/main/java/pixelitor/filters/XYZTest.java @@ -40,7 +40,7 @@ public class XYZTest extends ParametrizedFilter { private final RangeParam x = new RangeParam("X", -20, 0, 20); private final RangeParam y = new RangeParam("Y", -20, 0, 20); private final RangeParam z = new RangeParam("Z", -20, 0, 20); - private final BooleanParam linRGB = new BooleanParam("Linearize", false); + private final BooleanParam linRGB = new BooleanParam("Linearize"); // private static final ColorSpace XYZ_CS = ColorSpace.getInstance(ColorSpace.CS_CIEXYZ); diff --git a/src/main/java/pixelitor/filters/gmic/BoxFitting.java b/src/main/java/pixelitor/filters/gmic/BoxFitting.java index bc3718b3..120c1c5c 100644 --- a/src/main/java/pixelitor/filters/gmic/BoxFitting.java +++ b/src/main/java/pixelitor/filters/gmic/BoxFitting.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -33,7 +33,7 @@ public class BoxFitting extends GMICFilter { private final RangeParam maxSize = new RangeParam("Maximal Size", 1, 50, 100); private final RangeParam density = new RangeParam("Initial Density", 0, 25, 100); private final RangeParam minSpacing = new RangeParam("Minimal Spacing", 1, 1, 100); - private final BooleanParam transparency = new BooleanParam("Transparency", false); + private final BooleanParam transparency = new BooleanParam("Transparency"); public BoxFitting() { maxSize.ensureHigherValueThan(minSize); diff --git a/src/main/java/pixelitor/filters/gui/BooleanParam.java b/src/main/java/pixelitor/filters/gui/BooleanParam.java index f00ed307..a407339d 100644 --- a/src/main/java/pixelitor/filters/gui/BooleanParam.java +++ b/src/main/java/pixelitor/filters/gui/BooleanParam.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -41,6 +41,10 @@ public class BooleanParam extends AbstractFilterParam { private final boolean addResetButton; private List pendingItemListeners; + public BooleanParam(String name) { + this(name, false, ALLOW_RANDOMIZE); + } + public BooleanParam(String name, boolean defaultValue) { this(name, defaultValue, ALLOW_RANDOMIZE); } diff --git a/src/main/java/pixelitor/filters/gui/StrokeParam.java b/src/main/java/pixelitor/filters/gui/StrokeParam.java index f7b8336b..7850674a 100644 --- a/src/main/java/pixelitor/filters/gui/StrokeParam.java +++ b/src/main/java/pixelitor/filters/gui/StrokeParam.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -47,7 +47,7 @@ public class StrokeParam extends AbstractFilterParam { private final EnumParam strokeJoinParam = StrokeJoin.asParam(); private final EnumParam strokeTypeParam = StrokeType.asParam(); private final EnumParam shapeTypeParam = ShapeType.asParam(); - private final BooleanParam dashedParam = new BooleanParam("Dashed", false); + private final BooleanParam dashedParam = new BooleanParam("Dashed"); private ResetButton resetButton; private JComponent previewer; diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHCrystallize.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHCrystallize.java index 74058a6c..3cfce3da 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHCrystallize.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHCrystallize.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -43,7 +43,7 @@ public class JHCrystallize extends ParametrizedFilter { private final RangeParam edgeThickness = new RangeParam("Edge Thickness", 0, 40, 100); private final RangeParam size = new RangeParam("Size", 1, 20, 200); private final ColorParam edgeColor = new ColorParam("Edge Color", BLACK, FREE_TRANSPARENCY); - private final BooleanParam fadeEdges = new BooleanParam("Fade Edges", false); + private final BooleanParam fadeEdges = new BooleanParam("Fade Edges"); private final RangeParam randomness = new RangeParam("Shape Randomness (%)", 0, 0, 100); private final IntChoiceParam gridType = IntChoiceParam.forGridType("Shape", randomness); diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHDifferenceOfGaussians.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHDifferenceOfGaussians.java index 34523cac..b70de804 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHDifferenceOfGaussians.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHDifferenceOfGaussians.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -39,7 +39,7 @@ public class JHDifferenceOfGaussians extends ParametrizedFilter { private final RangeParam radius1 = new RangeParam(GUIText.RADIUS + " 1", 0, 0, 10); private final RangeParam radius2 = new RangeParam(GUIText.RADIUS + " 2", 0, 4, 10); private final BooleanParam normalize = new BooleanParam("Maximize Contrast", true); - private final BooleanParam invert = new BooleanParam("Invert", false); + private final BooleanParam invert = new BooleanParam("Invert"); private DoGFilter filter; diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHDotsHalftone.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHDotsHalftone.java index 547d8532..77c6e63a 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHDotsHalftone.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHDotsHalftone.java @@ -72,7 +72,7 @@ public class JHDotsHalftone extends ParametrizedFilter { }); private final BooleanParam monochrome = new BooleanParam("Monochrome", true); - private final BooleanParam invert = new BooleanParam("Invert Pattern", false); + private final BooleanParam invert = new BooleanParam("Invert Pattern"); private final RangeParam softness = new RangeParam("Softness", 0, 10, 100); public JHDotsHalftone() { diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHDropShadow.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHDropShadow.java index 1919329c..4c856f47 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHDropShadow.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHDropShadow.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -51,7 +51,7 @@ public class JHDropShadow extends ParametrizedFilter { private final RangeParam distance = new RangeParam("Distance", 0, 10, 100); private final RangeParam opacity = new RangeParam(GUIText.OPACITY, 0, 90, 100); private final RangeParam softness = new RangeParam("Softness", 0, 10, 25); - private final BooleanParam shadowOnly = new BooleanParam("Shadow Only", false); + private final BooleanParam shadowOnly = new BooleanParam("Shadow Only"); private final ColorParam color = new ColorParam("Color", BLACK, NO_TRANSPARENCY); private ShadowFilter filter; diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHEmboss.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHEmboss.java index bac8c86b..0b990bbd 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHEmboss.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHEmboss.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -47,7 +47,7 @@ public class JHEmboss extends ParametrizedFilter { "Depth", 1, 7, 15); private final BooleanParam texture = new BooleanParam( - "Texture (Multiply with the Source Image)", false); + "Texture (Multiply with the Source Image)"); private EmbossFilter filter; diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHFocus.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHFocus.java index 0e222688..71cf27fb 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHFocus.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHFocus.java @@ -42,7 +42,7 @@ public class JHFocus extends ParametrizedFilter { private final RangeParam softness = new RangeParam("Transition Softness", 0, 20, 100); private final GroupedRangeParam blurRadius = new GroupedRangeParam("Blur Radius", 0, 10, 48); private final RangeParam numIterations = new RangeParam("Blur Iterations (Quality)", 1, 3, 10); - private final BooleanParam invert = new BooleanParam("Invert", false); + private final BooleanParam invert = new BooleanParam("Invert"); private final BooleanParam hpSharpening = BooleanParam.forHPSharpening(); private final IntChoiceParam shape = BlurredShape.getChoices(); diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHMaskedHalftone.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHMaskedHalftone.java index 179df27c..26158495 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHMaskedHalftone.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHMaskedHalftone.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -39,7 +39,7 @@ public abstract class JHMaskedHalftone extends ParametrizedFilter { private static final int REPETITION_REPEAT = 2; protected final BooleanParam monochrome = new BooleanParam("Monochrome", true); - protected final BooleanParam invert = new BooleanParam("Invert Pattern", false); + protected final BooleanParam invert = new BooleanParam("Invert Pattern"); protected final RangeParam stripesDistance = new RangeParam("Stripes Distance (px)", 1, 20, 101); protected final IntChoiceParam repetitionType = new IntChoiceParam("Stripes Type", new Item[]{ new Item("Symmetric", REPETITION_REFLECT), diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHQuantize.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHQuantize.java index 8f5f008a..1546289f 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHQuantize.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHQuantize.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -35,8 +35,8 @@ public class JHQuantize extends ParametrizedFilter { private static final long serialVersionUID = 8187472652067667061L; private final RangeParam numColors = new RangeParam("Number of Colors", 2, 2, 256); - private final BooleanParam dither = new BooleanParam("Dither", false); - private final BooleanParam serpentine = new BooleanParam("Dither with Serpentine", false); + private final BooleanParam dither = new BooleanParam("Dither"); + private final BooleanParam serpentine = new BooleanParam("Dither with Serpentine"); private QuantizeFilter filter; diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHSparkle.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHSparkle.java index 31559a93..ca9d2546 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHSparkle.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHSparkle.java @@ -40,7 +40,7 @@ public class JHSparkle extends ParametrizedFilter { private static final long serialVersionUID = -2547285385455761188L; private final ImagePositionParam center = new ImagePositionParam("Center"); - private final BooleanParam lightOnly = new BooleanParam("Light Only", false); + private final BooleanParam lightOnly = new BooleanParam("Light Only"); private final ColorParam color = new ColorParam("Color", WHITE, USER_ONLY_TRANSPARENCY); private final RangeParam numRays = new RangeParam("Number of Rays", 1, 200, 501); private final RangeParam radius = new RangeParam("High Intensity Radius", 1, 50, 500); diff --git a/src/main/java/pixelitor/filters/jhlabsproxies/JHWeave.java b/src/main/java/pixelitor/filters/jhlabsproxies/JHWeave.java index 8a0ba85c..e869593d 100644 --- a/src/main/java/pixelitor/filters/jhlabsproxies/JHWeave.java +++ b/src/main/java/pixelitor/filters/jhlabsproxies/JHWeave.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -51,7 +51,7 @@ public class JHWeave extends ParametrizedFilter { }); private final GroupedRangeParam size = new GroupedRangeParam("Size", "Width", "Height", 0, 16, 100, true); private final GroupedRangeParam gap = new GroupedRangeParam("Gap", 0, 6, 100); - private final BooleanParam roundThreads = new BooleanParam("Round Threads", false); + private final BooleanParam roundThreads = new BooleanParam("Round Threads"); private final BooleanParam shadeCrossings = new BooleanParam("Shade Crossings", true); private final BooleanParam useImageColors = new BooleanParam("Use Image Colors", true, IGNORE_RANDOMIZE); diff --git a/src/main/java/pixelitor/filters/transitions/AbstractTransition.java b/src/main/java/pixelitor/filters/transitions/AbstractTransition.java index 6c2a0281..8fa7c582 100644 --- a/src/main/java/pixelitor/filters/transitions/AbstractTransition.java +++ b/src/main/java/pixelitor/filters/transitions/AbstractTransition.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -31,7 +31,7 @@ public abstract class AbstractTransition extends ParametrizedFilter { private final RangeParam progress = new RangeParam("Progress (%)", 0, 50, 100); - protected final BooleanParam invert = new BooleanParam("Invert Transparency", false); + protected final BooleanParam invert = new BooleanParam("Invert Transparency"); protected AbstractTransition() { super(true); diff --git a/src/main/java/pixelitor/io/magick/WebPExportSettings.java b/src/main/java/pixelitor/io/magick/WebPExportSettings.java index 2ed82056..5d211f6b 100644 --- a/src/main/java/pixelitor/io/magick/WebPExportSettings.java +++ b/src/main/java/pixelitor/io/magick/WebPExportSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -40,7 +40,7 @@ class WebPExportSettings extends JPanel implements ExportSettings { private final RangeParam quality = new RangeParam("Quality (Size)", 1, 50, 100, false, LabelPosition.NONE); - private final BooleanParam lossless = new BooleanParam("Lossless", false); + private final BooleanParam lossless = new BooleanParam("Lossless"); private final IntChoiceParam imageHint = new IntChoiceParam( "Image Hint", new IntChoiceParam.Item[]{ new IntChoiceParam.Item("Default", HINT_DEFAULT), diff --git a/src/main/java/pixelitor/layers/Layer.java b/src/main/java/pixelitor/layers/Layer.java index 91d4424e..e1f0a599 100644 --- a/src/main/java/pixelitor/layers/Layer.java +++ b/src/main/java/pixelitor/layers/Layer.java @@ -448,7 +448,7 @@ public void addMask(LayerMaskAddType addType) { } if (addType.needsSelection() && !comp.hasSelection()) { String msg = format("The composition \"%s\" has no selection.", comp.getName()); - Messages.showInfo("No selection", msg, comp.getDialogParent()); + Messages.showInfo("No Selection", msg, comp.getDialogParent()); return; } @@ -1036,7 +1036,7 @@ public void unGroup() { if (holder instanceof LayerGroup group) { group.replaceWithUnGrouped(null, true); } else { - Messages.showError("Can't ungroup", + Messages.showError("Can't Ungroup", "The layer \"%s\" isn't inside a layer group.".formatted(getName())); } } diff --git a/src/main/java/pixelitor/layers/LayerNameEditor.java b/src/main/java/pixelitor/layers/LayerNameEditor.java index 3ab7ef7c..d765c292 100644 --- a/src/main/java/pixelitor/layers/LayerNameEditor.java +++ b/src/main/java/pixelitor/layers/LayerNameEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -22,25 +22,16 @@ import java.awt.event.FocusEvent; /** - * A JTextField for layer names that becomes editable only if double-clicked + * A JTextField for editing layer names that becomes editable only if double-clicked. */ public class LayerNameEditor extends JTextField { private final LayerGUI layerGUI; public LayerNameEditor(LayerGUI layerGUI) { super(layerGUI.getLayer().getName()); - - // TODO setting up a tool tip would show an - // annoying GRAY "disabled tooltip" - // One solution would be to put - // UIManager.put("ToolTip[Disabled].backgroundPainter", UIManager.get("ToolTip[Enabled].backgroundPainter")); - // at the beginning (not ideal), another would be - // to create a custom tooltip specifically - // for this component - - // setToolTipText("Double-click to rename this layer."); - this.layerGUI = layerGUI; + + setToolTipText("Double-click to rename this layer."); disableEditing(); addFocusListener(new FocusAdapter() { @@ -50,7 +41,7 @@ public void focusLost(FocusEvent e) { } }); - // disable if enter pressed + // finish editing if enter pressed addActionListener(e -> finishEditing()); } diff --git a/src/main/java/pixelitor/layers/SmartObject.java b/src/main/java/pixelitor/layers/SmartObject.java index 10e60b38..795bd6fe 100644 --- a/src/main/java/pixelitor/layers/SmartObject.java +++ b/src/main/java/pixelitor/layers/SmartObject.java @@ -792,23 +792,31 @@ public SmartObject shallowDuplicate() { return d; } - public void moveUp(SmartFilter smartFilter) { - int index = filters.indexOf(smartFilter); - if (index == filters.size() - 1) { - // already the last filter - throw new IllegalStateException(); + @Override + public void moveActiveLayer(boolean up) { + SmartFilter smartFilter = getSelectedSmartFilter(); + if (smartFilter != null) { + move(smartFilter, up); } - swapSmartFilters(index, index + 1, "Move " + smartFilter.getName() + " Up"); - comp.setActiveLayer(smartFilter); + } + + public void moveUp(SmartFilter smartFilter) { + move(smartFilter, true); } public void moveDown(SmartFilter smartFilter) { + move(smartFilter, false); + } + + public void move(SmartFilter smartFilter, boolean up) { int index = filters.indexOf(smartFilter); - if (index == 0) { - // already the first filter - throw new IllegalStateException(); + if ((up && index == filters.size() - 1) || (!up && index == 0)) { + return; // already at the boundary } - swapSmartFilters(index - 1, index, "Move " + smartFilter.getName() + " Down"); + String editName = "Move " + smartFilter.getName() + (up ? " Up" : " Down"); + int indexA = up ? index : index - 1; + int indexB = indexA + 1; + swapSmartFilters(indexA, indexB, editName); comp.setActiveLayer(smartFilter); } @@ -874,7 +882,7 @@ public void editSelectedSmartFilter() { SmartFilter selected = getSelectedSmartFilter(); if (selected != null) { selected.edit(); - } else { // the smart object as a whole is selected + } else { // edit the last smart filter filters.getLast().edit(); } @@ -886,7 +894,7 @@ private SmartFilter getSelectedSmartFilter() { return filter; } } - return null; + return null; // the smart object as a whole is selected } @Override @@ -1000,7 +1008,7 @@ public int getActiveLayerIndex() { if (sf != null) { return filters.indexOf(sf); } - return -1; // TODO + return -1; } @Override @@ -1042,18 +1050,6 @@ public void addLayerToList(Layer newLayer, int index) { iconImageNeedsRefresh = true; } - @Override - public void moveActiveLayer(boolean up) { - SmartFilter sf = getSelectedSmartFilter(); - if (sf != null) { - if (up) { - moveUp(sf); - } else { - moveDown(sf); - } - } - } - @Override public void deleteLayer(Layer layer, boolean addToHistory) { deleteSmartFilter((SmartFilter) layer, addToHistory, true); @@ -1124,8 +1120,8 @@ public void removeLayerFromList(Layer layer) { @Override public BufferedImage createIconThumbnail() { -// BufferedImage bigImg = getCanvasSizedSubImage(); - // TODO is the image always canvas-sized? + // TODO the thumbnail currently isn't created from the + // canvas-visible region of the image return createThumbnail(getVisibleImage(), thumbSize, thumbCheckerBoardPainter); } diff --git a/src/main/java/pixelitor/tools/AbstractBrushTool.java b/src/main/java/pixelitor/tools/AbstractBrushTool.java index e4ff4e4b..646c6e8a 100644 --- a/src/main/java/pixelitor/tools/AbstractBrushTool.java +++ b/src/main/java/pixelitor/tools/AbstractBrushTool.java @@ -88,8 +88,7 @@ public abstract class AbstractBrushTool extends Tool { protected boolean lazyMouse; // the name of the param is used only as the preset key - protected final BooleanParam lazyMouseEnabled = new BooleanParam( - "Lazy.Enabled", false); + protected final BooleanParam lazyMouseEnabled = new BooleanParam("Lazy.Enabled"); private final RangeParam lazyMouseDist = LazyMouseBrush.createDistParam(); private JDialog lazyMouseDialog; private JButton showLazyMouseDialogButton; diff --git a/src/main/java/pixelitor/tools/brushes/ConnectBrushSettings.java b/src/main/java/pixelitor/tools/brushes/ConnectBrushSettings.java index e018bf66..39fc4c87 100644 --- a/src/main/java/pixelitor/tools/brushes/ConnectBrushSettings.java +++ b/src/main/java/pixelitor/tools/brushes/ConnectBrushSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -30,7 +30,7 @@ public class ConnectBrushSettings extends BrushSettings { private final RangeParam densityModel = new RangeParam("Line Density (%)", 1, 50, 100); private final RangeParam widthModel = new RangeParam("Line Width (px)", 1, 1, 10); private final BooleanParam resetForEachStroke = new BooleanParam( - "Reset History for Each Stroke", false); + "Reset History for Each Stroke"); @Override protected void forEachParam(Consumer consumer) { diff --git a/src/main/java/pixelitor/tools/brushes/OnePixelBrushSettings.java b/src/main/java/pixelitor/tools/brushes/OnePixelBrushSettings.java index 3ebf55a9..85a61a7e 100644 --- a/src/main/java/pixelitor/tools/brushes/OnePixelBrushSettings.java +++ b/src/main/java/pixelitor/tools/brushes/OnePixelBrushSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -29,8 +29,7 @@ */ public class OnePixelBrushSettings extends BrushSettings { private static final String AA_TEXT = "Anti-aliasing"; - private final BooleanParam aaParam = - new BooleanParam(AA_TEXT, false); + private final BooleanParam aaParam = new BooleanParam(AA_TEXT); private JComponent aaGUI; @Override diff --git a/src/main/java/pixelitor/tools/gui/ToolsPanel.java b/src/main/java/pixelitor/tools/gui/ToolsPanel.java index 97d1cb3d..e4c34a49 100644 --- a/src/main/java/pixelitor/tools/gui/ToolsPanel.java +++ b/src/main/java/pixelitor/tools/gui/ToolsPanel.java @@ -38,9 +38,9 @@ public class ToolsPanel extends JPanel { public ToolsPanel(PixelitorWindow pw, Dimension screenSize) { Dimension buttonSize = calcToolButtonSize(screenSize, pw); - // we need to give a hint to the layout manager, but at - // this point neither the panel nor the window size is known - int heightHint = screenSize.height - 168; + // We need to give a hint to the layout manager, but at + // this point neither the panel nor the window size is known. + int heightHint = Math.max(screenSize.height - 168, 0); JPanel buttonsPanel = new JPanel(new ToolButtonsLayout(buttonSize.width, buttonSize.height, 0, heightHint)); addToolButtons(buttonsPanel); diff --git a/src/main/java/pixelitor/tools/pen/AnchorPoint.java b/src/main/java/pixelitor/tools/pen/AnchorPoint.java index 5500a39c..69947271 100644 --- a/src/main/java/pixelitor/tools/pen/AnchorPoint.java +++ b/src/main/java/pixelitor/tools/pen/AnchorPoint.java @@ -44,7 +44,6 @@ * An anchor point on a {@link SubPath}. */ public class AnchorPoint extends DraggablePoint { - // compatible with Pixelitor 4.2.3 @Serial private static final long serialVersionUID = -7001569188242665053L; @@ -169,29 +168,36 @@ public void imTranslate(double dx, double dy) { */ public DraggablePoint findHandleAt(double x, double y, boolean altDown) { - if (altDown) { - // check the control handles first, so that - // retracted handles can be dragged out with Alt-drag - if (ctrlOut.handleContains(x, y)) { - return ctrlOut; - } - if (ctrlIn.handleContains(x, y)) { - return ctrlIn; - } - if (handleContains(x, y)) { - return this; - } - } else { - // check the anchor handle first - if (handleContains(x, y)) { - return this; - } - if (ctrlOut.handleContains(x, y)) { - return ctrlOut; - } - if (ctrlIn.handleContains(x, y)) { - return ctrlIn; - } + return altDown + ? findControlHandleFirst(x, y) + : findAnchorHandleFirst(x, y); + } + + // checks the control handles first, so that + // retracted handles can be dragged out with Alt-drag + private DraggablePoint findControlHandleFirst(double x, double y) { + if (ctrlOut.handleContains(x, y)) { + return ctrlOut; + } + if (ctrlIn.handleContains(x, y)) { + return ctrlIn; + } + if (handleContains(x, y)) { + return this; + } + return null; + } + + // checks the anchor handle first + private DraggablePoint findAnchorHandleFirst(double x, double y) { + if (handleContains(x, y)) { + return this; + } + if (ctrlOut.handleContains(x, y)) { + return ctrlOut; + } + if (ctrlIn.handleContains(x, y)) { + return ctrlIn; } return null; } diff --git a/src/main/java/pixelitor/tools/pen/ControlPoint.java b/src/main/java/pixelitor/tools/pen/ControlPoint.java index 33d035de..7a154963 100644 --- a/src/main/java/pixelitor/tools/pen/ControlPoint.java +++ b/src/main/java/pixelitor/tools/pen/ControlPoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -32,7 +32,6 @@ * A control point of an {@link AnchorPoint}. */ public class ControlPoint extends DraggablePoint { - // compatible with Pixelitor 4.2.3 @Serial private static final long serialVersionUID = 8776344572399099909L; @@ -142,17 +141,15 @@ public String getMoveEditName() { @Override public String toColoredString() { - if (isRetracted()) { - return super.toColoredString() + Ansi.red(" retracted!"); - } - return super.toColoredString(); + return isRetracted() + ? super.toColoredString() + Ansi.red(" retracted!") + : super.toColoredString(); } @Override public String toString() { - if (isRetracted()) { - return super.toString() + " retracted!"; - } - return super.toString(); + return isRetracted() + ? super.toString() + " retracted!" + : super.toString(); } } diff --git a/src/main/java/pixelitor/tools/pen/MovingPoint.java b/src/main/java/pixelitor/tools/pen/MovingPoint.java index cbc60f74..0ded2564 100644 --- a/src/main/java/pixelitor/tools/pen/MovingPoint.java +++ b/src/main/java/pixelitor/tools/pen/MovingPoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -26,12 +26,12 @@ import java.awt.geom.Point2D; /** - * A point that is at the mouse cursor when the mouse - * is moving (as opposed to dragging) as the path is built. - * It has an inverse mouse cycle: it is dragged when the mouse is - * actually up; its mousePressed is called when the mouse is released, etc. - * If Shift is pressed, it is constrained relative to the previous - * anchor point. + * A point that follows the mouse cursor when the mouse + * is moving (not dragging) as the path is being built. + * It has an inverse mouse cycle: it is dragged when the mouse is actually + * moved; its mousePressed is called when the mouse is released, etc. + * If the Shift key is pressed, the point is constrained + * relative to the previous anchor point. */ public class MovingPoint extends DraggablePoint { private final AnchorPoint prevAnchor; @@ -48,13 +48,14 @@ public void paintHandle(Graphics2D g) { @Override public void setConstrainedLocation(double mouseX, double mouseY) { - // constrain it relative to the previous anchor - Point2D p = Utils.constrainToNearestAngle(prevAnchor.x, prevAnchor.y, mouseX, mouseY); + // constrain it relative to the previous anchor point + Point2D p = Utils.constrainToNearestAngle( + prevAnchor.x, prevAnchor.y, mouseX, mouseY); setLocation(p.getX(), p.getY()); } /** - * Transform it into a regular anchor point when the mouse is pressed. + * Converts this moving point into a regular anchor point when the mouse is pressed. */ public AnchorPoint toAnchor() { return new AnchorPoint(x, y, view, prevAnchor.getSubPath()); diff --git a/src/main/java/pixelitor/tools/pen/TraceAction.java b/src/main/java/pixelitor/tools/pen/TraceAction.java index f88729cd..f95c892a 100644 --- a/src/main/java/pixelitor/tools/pen/TraceAction.java +++ b/src/main/java/pixelitor/tools/pen/TraceAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -51,7 +51,7 @@ private void trace(Composition comp) { Path path = comp.getActivePath(); if (path == null) { String msg = "There is no path in the composition."; - Messages.showInfo("No path", msg, comp.getDialogParent()); + Messages.showInfo("No Path", msg, comp.getDialogParent()); return; } diff --git a/src/main/java/pixelitor/tools/shapes/StrokeSettingsPanel.java b/src/main/java/pixelitor/tools/shapes/StrokeSettingsPanel.java index cea098e1..370e55fa 100644 --- a/src/main/java/pixelitor/tools/shapes/StrokeSettingsPanel.java +++ b/src/main/java/pixelitor/tools/shapes/StrokeSettingsPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -38,10 +38,10 @@ public class StrokeSettingsPanel extends JPanel { private static final int PREVIEW_SIZE = 120; - public StrokeSettingsPanel(StrokeParam sp) { + public StrokeSettingsPanel(StrokeParam strokeParam) { super(new GridBagLayout()); - RangeParam strokeWidthParam = sp.getStrokeWidthParam(); + RangeParam strokeWidthParam = strokeParam.getStrokeWidthParam(); JComponent strokeWidthGUI = strokeWidthParam.createGUI("width"); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, @@ -52,24 +52,24 @@ public StrokeSettingsPanel(StrokeParam sp) { 3, 3); add(strokeWidthGUI, gbc); - JPanel capJoinPanel = createCapJoinPanel(sp); + JPanel capJoinPanel = createCapJoinPanel(strokeParam); gbc.gridy = 1; add(capJoinPanel, gbc); - JPanel strokeTypePanel = createStrokeTypePanel(sp); + JPanel strokeTypePanel = createStrokeTypePanel(strokeParam); gbc.gridy = 2; add(strokeTypePanel, gbc); - JPanel strokePreviewPanel = createStrokePreviewPanel(sp); + JPanel strokePreviewPanel = createStrokePreviewPanel(strokeParam); gbc.gridy = 3; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; add(strokePreviewPanel, gbc); } - private static JPanel createCapJoinPanel(StrokeParam sp) { - EnumParam capParam = sp.getStrokeCapParam(); - EnumParam joinParam = sp.getStrokeJoinParam(); + private static JPanel createCapJoinPanel(StrokeParam strokeParam) { + EnumParam capParam = strokeParam.getStrokeCapParam(); + EnumParam joinParam = strokeParam.getStrokeJoinParam(); JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(createTitledBorder("Line Endpoints")); @@ -78,9 +78,8 @@ private static JPanel createCapJoinPanel(StrokeParam sp) { JComponent capSelector = capParam.createGUI("cap"); - // Dirty trick: manually set the preferred width so that - // the layout aligns with the layout in the other panel. - // Doubling the width is about OK. + // Manually set the preferred width so that the layout aligns with + // the layout in the other panel. Doubling the width is about OK. Dimension dim = capSelector.getPreferredSize(); dim.setSize(dim.getWidth() * 2, dim.getHeight()); capSelector.setPreferredSize(dim); @@ -93,21 +92,21 @@ private static JPanel createCapJoinPanel(StrokeParam sp) { return panel; } - private static JPanel createStrokeTypePanel(StrokeParam sp) { + private static JPanel createStrokeTypePanel(StrokeParam strokeParam) { JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(createTitledBorder("Stroke Type")); var gbh = new GridBagHelper(panel); - gbh.addLabelAndControl(sp.getStrokeTypeParam(), "strokeType"); - gbh.addLabelAndControl(sp.getShapeTypeParam(), "shapeType"); - gbh.addLabelAndControl(sp.getDashedParam(), "dashed"); + gbh.addLabelAndControl(strokeParam.getStrokeTypeParam(), "strokeType"); + gbh.addLabelAndControl(strokeParam.getShapeTypeParam(), "shapeType"); + gbh.addLabelAndControl(strokeParam.getDashedParam(), "dashed"); return panel; } - private static JPanel createStrokePreviewPanel(StrokeParam sp) { - JComponent preview = createPreviewComponent(sp); - sp.setPreviewer(preview); + private static JPanel createStrokePreviewPanel(StrokeParam strokeParam) { + JComponent preview = createPreviewComponent(strokeParam); + strokeParam.setPreviewer(preview); JPanel panel = new JPanel(new BorderLayout()); panel.add(preview, CENTER); @@ -116,7 +115,7 @@ private static JPanel createStrokePreviewPanel(StrokeParam sp) { return panel; } - private static JComponent createPreviewComponent(StrokeParam sp) { + private static JComponent createPreviewComponent(StrokeParam strokeParam) { JComponent preview = new JComponent() { // only the height matters, because the width will be stretched final Dimension size = new Dimension(PREVIEW_SIZE, PREVIEW_SIZE); @@ -141,7 +140,7 @@ protected void paintComponent(Graphics g) { width * 0.9, height * 0.4 ); g2.setColor(darkTheme ? Color.WHITE : Color.BLACK); - g2.setStroke(sp.createStroke()); + g2.setStroke(strokeParam.createStroke()); g2.draw(shape); } diff --git a/src/main/java/pixelitor/utils/NonlinTransform.java b/src/main/java/pixelitor/utils/NonlinTransform.java index adc32ecb..7afef333 100644 --- a/src/main/java/pixelitor/utils/NonlinTransform.java +++ b/src/main/java/pixelitor/utils/NonlinTransform.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -18,6 +18,7 @@ package pixelitor.utils; import pixelitor.filters.gui.EnumParam; +import pixelitor.filters.gui.RangeParam; import java.awt.Shape; import java.awt.geom.Path2D; @@ -113,33 +114,33 @@ public PointMapper createMapper(Point2D center, double tuning, int width, int he return new Point2D.Double(newX, newY); }; } - }, POLAR_TO_RECT("Polar to Rectangular", true) { - @Override - public PointMapper createMapper(Point2D center, double tuning, int width, int height) { - double cx = center.getX(); - double cy = center.getY(); - double maxR = Math.sqrt(width * width + height * height) / 2.0; - return (x, y) -> { - double r = center.distance(x, y) / maxR; - - // atan2 is in the range -pi..pi, angle will be 0..2*pi - double angle = atan2(y - cy, x - cx) + PI; - - // in the range 0..1 - double normalizedAngle = angle / (2 * PI); - normalizedAngle += tuning / 100.0; - if (normalizedAngle > 1) { - normalizedAngle -= 1; - } else if (normalizedAngle < 0) { - normalizedAngle += 1; - } - - double newX = normalizedAngle * width; - double newY = r * height; - - return new Point2D.Double(newX, newY); - }; - } +// }, POLAR_TO_RECT("Polar to Rectangular", true) { +// @Override +// public PointMapper createMapper(Point2D center, double tuning, int width, int height) { +// double cx = center.getX(); +// double cy = center.getY(); +// double maxR = Math.sqrt(width * width + height * height) / 2.0; +// return (x, y) -> { +// double r = center.distance(x, y) / maxR; +// +// // atan2 is in the range -pi..pi, angle will be 0..2*pi +// double angle = atan2(y - cy, x - cx) + PI; +// +// // in the range 0..1 +// double normalizedAngle = angle / (2 * PI); +// normalizedAngle += tuning / 100.0; +// if (normalizedAngle > 1) { +// normalizedAngle -= 1; +// } else if (normalizedAngle < 0) { +// normalizedAngle += 1; +// } +// +// double newX = normalizedAngle * width; +// double newY = r * height; +// +// return new Point2D.Double(newX, newY); +// }; +// } }, WAVE("Wave", true) { @Override public PointMapper createMapper(Point2D center, double tuning, int width, int height) { @@ -257,7 +258,11 @@ public static EnumParam asParam() { return new EnumParam<>("Distortion", NonlinTransform.class); } - public boolean hasTuning() { + public static RangeParam createAmountParam() { + return new RangeParam("Distortion Amount", -100, 0, 100); + } + + public boolean hasAmount() { return hasTuning; } diff --git a/src/main/java/pixelitor/utils/Shapes.java b/src/main/java/pixelitor/utils/Shapes.java index a0c32f6f..566898e3 100644 --- a/src/main/java/pixelitor/utils/Shapes.java +++ b/src/main/java/pixelitor/utils/Shapes.java @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.List; import java.util.Random; +import java.util.stream.Collectors; import static java.awt.Color.BLACK; import static java.awt.Color.WHITE; @@ -42,7 +43,6 @@ import static java.awt.geom.PathIterator.SEG_MOVETO; import static java.awt.geom.PathIterator.SEG_QUADTO; import static java.lang.Math.PI; -import static java.lang.String.format; import static net.jafama.FastMath.atan2; import static net.jafama.FastMath.cos; import static net.jafama.FastMath.sin; @@ -433,7 +433,7 @@ private static void appendSvgPathSegment(StringBuilder pathBuilder, int type, do pathBuilder.append(command); for (int i = 0; i < numCoords; i++) { - pathBuilder.append(format("%.3f ", coords[i])); + pathBuilder.append(String.format("%.3f ", coords[i])); } pathBuilder.append("\n"); } @@ -450,7 +450,10 @@ public static String getSvgFillRule(Shape shape) { } public static void debugPathIterator(Shape shape) { - PathIterator pathIterator = shape.getPathIterator(null); + debugPathIterator(shape.getPathIterator(null)); + } + + public static void debugPathIterator(PathIterator pathIterator) { double[] coords = new double[6]; while (!pathIterator.isDone()) { @@ -470,10 +473,13 @@ public static void debugPathIterator(Shape shape) { } /** - * Converts the first n elements of the given array to a String representation. + * Converts the first n elements of the given array to a string + * representation, with numbers rounded to 2 decimal places. */ private static String arrayToString(double[] array, int n) { - return Arrays.toString(Arrays.copyOf(array, n)); + return Arrays.stream(Arrays.copyOf(array, n)) + .mapToObj(d -> String.format("%.2f", d)) + .collect(Collectors.joining(", ", "(", ")")); } /** diff --git a/src/main/java/pixelitor/utils/TaperingStroke.java b/src/main/java/pixelitor/utils/TaperingStroke.java index 51187a45..07c73905 100644 --- a/src/main/java/pixelitor/utils/TaperingStroke.java +++ b/src/main/java/pixelitor/utils/TaperingStroke.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -39,12 +39,10 @@ /** * A {@link Stroke} implementation that creates a stroke that gradually tapers along its path. - * The stroke width decreases linearly from the starting point to the endpoint of the path. - * The tapering direction can be reversed to make the stroke taper from thin to thick instead. */ public class TaperingStroke implements Stroke { private final double maxStrokeWidth; - private final boolean reverse; // switches the tapering direction + private final boolean reverse; public TaperingStroke(double maxStrokeWidth) { this(maxStrokeWidth, false); @@ -60,19 +58,16 @@ public TaperingStroke(double maxStrokeWidth, boolean reverse) { @Override public Shape createStrokedShape(Shape shape) { - double[] coords = new double[6]; - - // Will hold the final shape of the tapered stroke GeneralPath taperedOutline = new GeneralPath(); - // Collects points along the path before processing + // collect points along the path before processing List points = new ArrayList<>(); - + double[] coords = new double[6]; var it = new FlatteningPathIterator(shape.getPathIterator(null), 1); while (!it.isDone()) { switch (it.currentSegment(coords)) { - case SEG_MOVETO: // Start of a new subpath - // Process any existing points for the last subpath + case SEG_MOVETO: // start of a new subpath + // process any existing points for the last subpath if (!points.isEmpty()) { if (reverse) { Collections.reverse(points); @@ -83,7 +78,6 @@ public Shape createStrokedShape(Shape shape) { // fallthrough: add the MOVETO point just like LINETO // noinspection fallthrough case SEG_LINETO: - // Store the point points.add(new Point2D.Double(coords[0], coords[1])); break; case PathIterator.SEG_CLOSE: @@ -97,7 +91,7 @@ public Shape createStrokedShape(Shape shape) { it.next(); } - // Process any remaining points for the last subpath + // process any remaining points for the last subpath if (!points.isEmpty()) { if (reverse) { Collections.reverse(points); @@ -111,7 +105,10 @@ public Shape createStrokedShape(Shape shape) { // creates the tapered outline for a subpath, // always starting from the full width and going to zero private void createSubpathOutline(List points, GeneralPath result) { - // Calculate segment lengths and total subpath length + if (points.size() < 2) { + return; + } + double[] segmentLengths = new double[points.size() - 1]; double totalPathLength = 0; for (int i = 0; i < segmentLengths.length; i++) { @@ -120,7 +117,7 @@ private void createSubpathOutline(List points, GeneralPath result) { totalPathLength += segmentLengths[i] = FastMath.hypot(a.getX() - b.getX(), a.getY() - b.getY()); } - // Handle the first segment of the subpath + // handle the first segment of the subpath Point2D first = points.get(0); Point2D second = points.get(1); Point2D firstLeft = new Point2D.Double(); @@ -128,54 +125,55 @@ private void createSubpathOutline(List points, GeneralPath result) { double initialDist = maxStrokeWidth / 2; calcPerpendicularPoints(first, second, initialDist, firstLeft, firstRight); - // Start the outline path + // start the outline path result.moveTo(firstLeft.getX(), firstLeft.getY()); double distanceCovered = segmentLengths[0]; - // Store points for the return path + // store points for the return path Point2D[] returnPath = new Point2D[points.size() - 1]; returnPath[0] = firstRight; - // Process intermediate points + // process intermediate points for (int i = 1, s = points.size() - 1; i < s; i++) { Point2D prev = points.get(i - 1); Point2D current = points.get(i); Point2D next = points.get(i + 1); - // Temporary points for storing perpendicular vectors + // temporary points for storing perpendicular vectors var prevPerp1 = new Point2D.Double(); var prevPerp2 = new Point2D.Double(); var nextPerp1 = new Point2D.Double(); var nextPerp2 = new Point2D.Double(); - // stroke width at this point based on distance covered + // the stroke width decreases linearly from the + // starting point to the endpoint of the path double currentWidth = (maxStrokeWidth - maxStrokeWidth * distanceCovered / totalPathLength) / 2; distanceCovered += segmentLengths[i - 1]; - // Calculate perpendicular points for both segments meeting at current point + // calculate perpendicular points for both segments meeting at current point calcPerpendicularPoints(current, prev, prevPerp1, prevPerp2); calcPerpendicularPoints(current, next, nextPerp1, nextPerp2); - // Average the perpendicular vectors to create smooth transitions + // average the perpendicular vectors to create smooth transitions Point2D avgLeft = Geometry.midPoint(prevPerp1, nextPerp2); Point2D avgRight = Geometry.midPoint(prevPerp2, nextPerp1); - // Normalize and scale the vectors to current stroke width + // normalize and scale the vectors to current stroke width normalizeAndScale(avgLeft, current, currentWidth); normalizeAndScale(avgRight, current, currentWidth); - // Store for return path + // store for later returnPath[i] = avgLeft; - // Add to forward path + // add to forward path result.lineTo(avgRight.getX(), avgRight.getY()); } - // Complete the outline by going to the endpoint + // complete the outline by going to the endpoint Point2D last = points.getLast(); result.lineTo(last.getX(), last.getY()); - // Draw the return path back to start + // draw the return path back to start for (int i = returnPath.length - 1; i >= 0; i--) { Point2D P = returnPath[i]; result.lineTo(P.getX(), P.getY()); @@ -185,13 +183,13 @@ private void createSubpathOutline(List points, GeneralPath result) { } private static void normalizeAndScale(Point2D avgLeft, Point2D currentPoint, double currentWidth) { - // Convert to vector from current point + // convert to vector from current point subtract(avgLeft, currentPoint, avgLeft); normalize(avgLeft); scale(avgLeft, currentWidth); - // Move back to absolute position + // move back to absolute position add(avgLeft, currentPoint, avgLeft); } } diff --git a/src/main/java/pixelitor/utils/Texts.java b/src/main/java/pixelitor/utils/Texts.java index b102cbc2..9bd43876 100644 --- a/src/main/java/pixelitor/utils/Texts.java +++ b/src/main/java/pixelitor/utils/Texts.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -25,8 +25,6 @@ * The internationalized texts of the UI */ public class Texts { - // this locale is used in the tests, the GUI replaces it -// private static ResourceBundle resources = ResourceBundle.getBundle("texts", Locale.US); private static ResourceBundle resources; private Texts() { diff --git a/src/main/java/pixelitor/utils/ToolSettingsLayout.java b/src/main/java/pixelitor/utils/ToolSettingsLayout.java index e95875ac..24a04ec0 100644 --- a/src/main/java/pixelitor/utils/ToolSettingsLayout.java +++ b/src/main/java/pixelitor/utils/ToolSettingsLayout.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Laszlo Balazs-Csiki and Contributors + * Copyright 2025 Laszlo Balazs-Csiki and Contributors * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU @@ -25,14 +25,14 @@ import java.awt.LayoutManager; /** - * The layout manager used in {@link ToolSettingsPanel} + * Custom layout manager for {@link ToolSettingsPanel}. * * It is similar to a left-aligned FlowLayout, but - * the components are centered vertically + * the components are centered vertically. */ public class ToolSettingsLayout implements LayoutManager { private static final int HEIGHT = 38; - private static final Dimension size = new Dimension(100, HEIGHT); + private static final Dimension PREFERRED_SIZE = new Dimension(100, HEIGHT); private static final int HORIZONTAL_GAP = 5; @Override @@ -47,25 +47,25 @@ public void removeLayoutComponent(Component comp) { @Override public Dimension preferredLayoutSize(Container parent) { - return size; + return PREFERRED_SIZE; } @Override public Dimension minimumLayoutSize(Container parent) { - return size; + return PREFERRED_SIZE; } @Override public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { int numChildren = parent.getComponentCount(); - int x = HORIZONTAL_GAP; + int currentX = HORIZONTAL_GAP; for (int i = 0; i < numChildren; i++) { - Component m = parent.getComponent(i); - Dimension childSize = m.getPreferredSize(); - m.setSize(childSize); - m.setLocation(x, (HEIGHT - childSize.height) / 2); - x += (childSize.width + HORIZONTAL_GAP); + Component child = parent.getComponent(i); + Dimension childSize = child.getPreferredSize(); + child.setSize(childSize); + child.setLocation(currentX, (HEIGHT - childSize.height) / 2); + currentX += (childSize.width + HORIZONTAL_GAP); } } } diff --git a/src/test/java/pixelitor/layers/SmartFilterTest.java b/src/test/java/pixelitor/layers/SmartFilterTest.java index fd055364..82f9e512 100644 --- a/src/test/java/pixelitor/layers/SmartFilterTest.java +++ b/src/test/java/pixelitor/layers/SmartFilterTest.java @@ -26,7 +26,6 @@ import java.awt.Dimension; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static pixelitor.assertions.PixelitorAssertions.assertThat; @DisplayName("Smart filter tests") @@ -425,10 +424,8 @@ void moveUp() { .invariantsAreOK(); History.assertNumEditsIs(2); - // can't be moved further - assertThatThrownBy(() -> smartObject.moveUp(filter1)) - .isInstanceOf(IllegalStateException.class); - + smartObject.moveUp(filter1); + // can't be moved further, nothing happens assertThat(smartObject) .smartFilterNamesAre("Filter 2", "Filter 3", "Filter 1") .invariantsAreOK(); @@ -494,10 +491,8 @@ void moveDown() { .invariantsAreOK(); History.assertNumEditsIs(2); - // can't be moved further - assertThatThrownBy(() -> smartObject.moveDown(filter3)) - .isInstanceOf(IllegalStateException.class); - + smartObject.moveDown(filter3); + // can't be moved further, nothing happens assertThat(smartObject) .smartFilterNamesAre("Filter 3", "Filter 1", "Filter 2") .invariantsAreOK();