Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalazscs committed Apr 9, 2022
1 parent 1c84f6e commit cebf139
Show file tree
Hide file tree
Showing 38 changed files with 186 additions and 85 deletions.
3 changes: 3 additions & 0 deletions src/main/java/pixelitor/Composition.java
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,9 @@ public LayerAdder atIndex(int newLayerIndex) {
return this;
}

/**
* The final operation which actually adds the layer.
*/
public void add(Layer newLayer) {
Layer activeLayerBefore = null;
MaskViewMode oldViewMode = null;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/pixelitor/colors/Colors.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.util.Locale;
import java.util.function.Consumer;
import java.util.function.Supplier;

Expand Down Expand Up @@ -249,11 +250,11 @@ public static int HSBAtoARGB(float[] hsb_col, int alpha) {

public static String toHTMLHex(Color c, boolean includeAlpha) {
if (includeAlpha) {
String argb = format("%08X", c.getRGB());
String argb = format(Locale.ENGLISH, "%08X", c.getRGB());
String rgba = argb.substring(2) + argb.substring(0, 2);
return rgba;
} else {
return format("%06X", 0xFFFFFF & c.getRGB());
return format(Locale.ENGLISH, "%06X", 0xFFFFFF & c.getRGB());
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/pixelitor/filters/BrightnessContrast.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -39,6 +39,9 @@ public class BrightnessContrast extends ParametrizedFilter {
public BrightnessContrast() {
super(true);

brightnessParam.setPresetKey("Brightness");
contrastParam.setPresetKey("Contrast");

setParams(
brightnessParam,
contrastParam
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/pixelitor/filters/BumpMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -62,4 +62,9 @@ public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
public boolean supportsGray() {
return false;
}

@Override
public boolean canBeSmart() {
return false;
}
}
4 changes: 2 additions & 2 deletions src/main/java/pixelitor/filters/ChannelToTransparency.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -95,7 +95,7 @@ int getChannelValue(int rgb) {
}

@Override
public void randomizeSettings() {
public void randomize() {
// no settings
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/pixelitor/filters/ColorThreshold.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -45,6 +45,7 @@ public ColorThreshold() {
blueThreshold
}, false);

threshold.setPresetKey("Threshold");
setParams(threshold);
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/pixelitor/filters/Colorize.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -36,7 +36,7 @@
public class Colorize extends ParametrizedFilter {
public static final String NAME = i18n("colorize");

private final RangeParam adjustBrightness = new RangeParam(
private final RangeParam brightnessParam = new RangeParam(
BRIGHTNESS, -100, 0, 100);
private final ColorParam colorParam = new ColorParam(
COLOR, new Color(255, 207, 119), NO_TRANSPARENCY);
Expand All @@ -46,16 +46,19 @@ public class Colorize extends ParametrizedFilter {
public Colorize() {
super(true);

brightnessParam.setPresetKey("Brightness");
colorParam.setPresetKey("Color");

setParams(
colorParam,
adjustBrightness,
brightnessParam,
opacityParam
);
}

@Override
public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
float briShift = adjustBrightness.getPercentageValF();
float briShift = brightnessParam.getPercentageValF();
float opacity = opacityParam.getPercentageValF();

Color color = colorParam.getColor();
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/pixelitor/filters/DisplacementMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -65,6 +65,11 @@ public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
return filter.filter(src, dest);
}

@Override
public boolean canBeSmart() {
return false;
}

private static class Impl extends TransformFilter {
private int[] mapPixels;
private int mapWidth;
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/pixelitor/filters/ExtractChannelFilter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -30,6 +30,8 @@
* Extracts a channel from the image
*/
public class ExtractChannelFilter extends Filter {
public static final String DESATURATE_NAME = i18n("desaturate");
public static final String SATURATION_NAME = i18n("saturation");
private final RGBPixelOp rgbOp;

public ExtractChannelFilter(RGBPixelOp rgbOp) {
Expand Down Expand Up @@ -93,7 +95,7 @@ public static FilterAction getDesaturateChannelFA() {

return a << 24 | r << 16 | g << 8 | b;
};
return rgbOp.toFilterAction(i18n("desaturate"));
return rgbOp.toFilterAction(DESATURATE_NAME);
}

public static FilterAction getSaturationChannelFA() {
Expand All @@ -118,7 +120,7 @@ public static FilterAction getSaturationChannelFA() {

return a << 24 | r << 16 | g << 8 | b;
};
return rgbOp.toFilterAction(i18n("saturation"));
return rgbOp.toFilterAction(SATURATION_NAME);
}

public static FilterAction getHueChannelFA() {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/pixelitor/filters/HueSat.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -50,6 +50,10 @@ public class HueSat extends ParametrizedFilter {
public HueSat() {
super(true);

hue.setPresetKey("Hue");
saturation.setPresetKey("Saturation");
brightness.setPresetKey("Brightness");

setParams(
hue,
saturation,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pixelitor/filters/ParametrizedFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void showAffectedArea() {
}

@Override
public void randomizeSettings() {
public void randomize() {
paramSet.randomize();
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pixelitor/filters/PhotoCollage.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -62,6 +62,8 @@ public class PhotoCollage extends ParametrizedFilter {
public PhotoCollage() {
super(true);

bgColor.setPresetKey("Background Color");

DialogParam shadowDialog = new DialogParam("Shadow Settings",
shadowOpacityParam,
shadowAngleParam,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pixelitor/filters/RandomFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected BufferedImage transform(BufferedImage src, BufferedImage dest) {
}

@Override
public void randomizeSettings() {
public void randomize() {
throw new UnsupportedOperationException("this should not be called");
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pixelitor/filters/Solarize.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -46,6 +46,8 @@ public class Solarize extends ParametrizedFilter {
public Solarize() {
super(true);

type.setPresetKey("Type");

setParams(
type,
redThreshold,
Expand Down
1 change: 1 addition & 0 deletions src/main/java/pixelitor/filters/Spirograph.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class Spirograph extends ShapeFilter {

public Spirograph() {
zoom.setPresetKey("Zoom (%)");
type.setPresetKey("Type");

addParamsToFront(
time,
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pixelitor/filters/Threshold.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -41,6 +41,8 @@ public class Threshold extends ParametrizedFilter {
public Threshold() {
super(true);

thresholdParam.setPresetKey("Threshold");

setParams(channelParam, thresholdParam, dithering);
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/pixelitor/filters/TransformLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class TransformLayer extends ParametrizedFilter {
public TransformLayer() {
super(true);

bgColorParam.setPresetKey("Background Color");

setParams(
centerParam,
angleParam,
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pixelitor/filters/Transition2D.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Laszlo Balazs-Csiki and Contributors
* Copyright 2022 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
Expand Down Expand Up @@ -78,6 +78,8 @@ public class Transition2D extends ParametrizedFilter {
public Transition2D() {
super(true);

type.setPresetKey("Type");

setParams(type, progress);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pixelitor/filters/convolve/Convolve.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public FilterGUI createGUI(Drawable dr, boolean reset) {
}

@Override
public void randomizeSettings() {
public void randomize() {
kernelMatrix = createRandomKernelMatrix(matrixOrder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public BufferedImage transform(BufferedImage src, BufferedImage dest) {
}

@Override
public void randomizeSettings() {
public void randomize() {
// not supported yet
}

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/pixelitor/filters/gui/EffectsParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package pixelitor.filters.gui;

import pixelitor.AppContext;
import pixelitor.filters.painters.AreaEffects;
import pixelitor.filters.painters.EffectsPanel;
import pixelitor.gui.utils.DialogBuilder;
import pixelitor.utils.Messages;
import pixelitor.utils.Threads;

import javax.swing.*;
import java.awt.EventQueue;
Expand Down Expand Up @@ -86,7 +84,6 @@ public AreaEffects getEffects() {

private void ensureEffectsPanelIsCreated() {
if (effectsPanel == null) {
assert AppContext.isUnitTesting() || Threads.calledOnEDT();
effectsPanel = new EffectsPanel(null);
if (adjustmentListener != null) { // the listener was set before this
effectsPanel.setAdjustmentListener(adjustmentListener);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pixelitor/filters/gui/FilterWithGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected FilterWithGUI() {
*/
public abstract FilterGUI createGUI(Drawable dr, boolean reset);

public abstract void randomizeSettings();
public abstract void randomize();

private JMenuBar getMenuBar() {
boolean addPresets = canHaveUserPresets() || hasBuiltinPresets();
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/pixelitor/filters/gui/SelectImageParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ static class NamedImage {
NamedImage(Composition comp) {
// it's important to store this image before the filter starts,
// because the current composite image is affected by the filter
this.image = comp.getCompositeImage();
this.comp = comp;
if (comp != null) {
this.image = comp.getCompositeImage();
this.comp = comp;
} else {
// Can happen when deserializing a filter in the first
// opened pxc, and there is no open view yet.
// For this reason filters using this param can't be smart at the moment.
throw new IllegalStateException();
}
}

public BufferedImage getImage() {
Expand Down
Loading

0 comments on commit cebf139

Please sign in to comment.