Skip to content

Commit

Permalink
v4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mararsh committed Nov 4, 2018
1 parent a1f2bc9 commit 253a99d
Show file tree
Hide file tree
Showing 314 changed files with 3,942 additions and 5,176 deletions.
2 changes: 1 addition & 1 deletion MyBox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>mara</groupId>
<artifactId>MyBox</artifactId>
<version>3.9</version>
<version>4.0</version>
<packaging>jar</packaging>

<name>MyBox</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected void initializeNext() {
date.setText(CommonValues.AppVersionDate);
userGuideLink.setText("https://github.com/Mararsh/MyBox/releases/download/v"
+ CommonValues.AppVersion + "/MyBox-UserGuide-" + CommonValues.AppVersion
+ "-" + AppVaribles.getLanguage() + ".pdf");
+ "-Overview-" + AppVaribles.getLanguage() + ".pdf");

FxmlTools.miao8();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import mara.mybox.objects.CommonValues;
import mara.mybox.tools.FileTools;
import static mara.mybox.tools.FxmlTools.badStyle;
import mara.mybox.tools.FxmlImageTools;
import mara.mybox.image.FxmlImageTools;
import mara.mybox.tools.FxmlTools;
import mara.mybox.tools.NetworkTools;
import static mara.mybox.tools.NetworkTools.checkWeiboPassport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import javafx.stage.Modality;
import static mara.mybox.controller.BaseController.logger;
import mara.mybox.objects.CommonValues;
import mara.mybox.tools.FxmlImageTools;
import mara.mybox.image.FxmlImageTools;
import static mara.mybox.tools.FxmlTools.badStyle;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static mara.mybox.controller.BaseController.logger;
import mara.mybox.objects.AppVaribles;
import mara.mybox.objects.CommonValues;
import mara.mybox.tools.FxmlImageTools;
import mara.mybox.image.FxmlImageTools;
import static mara.mybox.tools.FxmlTools.badStyle;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static mara.mybox.controller.BaseController.logger;
import mara.mybox.image.ImageConvertTools;
import mara.mybox.objects.AppVaribles;
import mara.mybox.tools.FxmlImageTools;
import mara.mybox.image.FxmlImageTools;
import static mara.mybox.tools.FxmlTools.badStyle;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static mara.mybox.controller.BaseController.logger;
import mara.mybox.image.ImageConvertTools;
import static mara.mybox.objects.AppVaribles.getMessage;
import mara.mybox.tools.FxmlImageTools;
import mara.mybox.image.FxmlImageTools;
import mara.mybox.tools.FxmlTools;
import static mara.mybox.tools.FxmlTools.badStyle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ private void checkColorOperationType() {
if (colorInput.getText().trim().isEmpty()) {
colorInput.setText("10");
}
increaseRadio.setDisable(false);

} else if (getMessage("Saturation").equals(selected.getText())) {
colorOperationType = ColorOperationType.Sauration;
Expand Down Expand Up @@ -180,6 +179,46 @@ private void checkColorOperationType() {
colorInput.setText("10");
}

} else if (getMessage("Yellow").equals(selected.getText())) {
colorOperationType = ColorOperationType.Yellow;
colorSlider.setMax(255);
colorSlider.setMin(1);
colorSlider.setBlockIncrement(1);
colorUnit.setText("");
if (colorInput.getText().trim().isEmpty()) {
colorInput.setText("10");
}

} else if (getMessage("Cyan").equals(selected.getText())) {
colorOperationType = ColorOperationType.Cyan;
colorSlider.setMax(255);
colorSlider.setMin(1);
colorSlider.setBlockIncrement(1);
colorUnit.setText("");
if (colorInput.getText().trim().isEmpty()) {
colorInput.setText("10");
}

} else if (getMessage("Magenta").equals(selected.getText())) {
colorOperationType = ColorOperationType.Magenta;
colorSlider.setMax(255);
colorSlider.setMin(1);
colorSlider.setBlockIncrement(1);
colorUnit.setText("");
if (colorInput.getText().trim().isEmpty()) {
colorInput.setText("10");
}

} else if (getMessage("RGB").equals(selected.getText())) {
colorOperationType = ColorOperationType.RGB;
colorSlider.setMax(255);
colorSlider.setMin(1);
colorSlider.setBlockIncrement(1);
colorUnit.setText("");
if (colorInput.getText().trim().isEmpty()) {
colorInput.setText("10");
}

}
}

Expand Down Expand Up @@ -241,6 +280,18 @@ protected BufferedImage handleImage(BufferedImage source) {
} else if (colorOperationType == ColorOperationType.Blue) {
target = ImageConvertTools.changeBlue(source, value);

} else if (colorOperationType == ColorOperationType.Yellow) {
target = ImageConvertTools.changeYellow(source, value);

} else if (colorOperationType == ColorOperationType.Cyan) {
target = ImageConvertTools.changeCyan(source, value);

} else if (colorOperationType == ColorOperationType.Magenta) {
target = ImageConvertTools.changeMagenta(source, value);

} else if (colorOperationType == ColorOperationType.RGB) {
target = ImageConvertTools.changeRGB(source, value);

}

return target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import mara.mybox.image.ImageConvertTools;
import mara.mybox.objects.AppVaribles;
import static mara.mybox.objects.AppVaribles.getMessage;
import mara.mybox.tools.FxmlImageTools;
import mara.mybox.image.FxmlImageTools;
import mara.mybox.tools.FxmlTools;
import static mara.mybox.tools.FxmlTools.badStyle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.Toggle;
Expand All @@ -28,18 +30,22 @@
*/
public class ImageManufactureBatchEffectsController extends ImageManufactureBatchController {

protected int threadholding, threadholdingMin, threadholdingMax, effectType, blurRadius, posterizingSize;
protected int threadholding, threadholdingMin, threadholdingMax, effectType, intValue, direction;

@FXML
protected ToggleGroup effectsGroup;
@FXML
protected HBox blurBox, thresholdingBox;
protected HBox thresholdingBox;
@FXML
protected ComboBox blurRadiusBox, posterizingBox;
protected ComboBox intBox, stringBox;
@FXML
protected TextField thresholdingInput, thresholdingMinInput, thresholdingMaxInput;
@FXML
protected RadioButton thresholdingRadio;
@FXML
protected Label intLabel, stringLabel;
@FXML
protected CheckBox grayCheck;

public ImageManufactureBatchEffectsController() {

Expand Down Expand Up @@ -70,51 +76,69 @@ protected void initOptionsSection() {
@Override
public void changed(ObservableValue<? extends Toggle> ov,
Toggle old_toggle, Toggle new_toggle) {
checkEffetcssOperationType();
checkEffetcsOperationType();
}
});
checkEffetcssOperationType();
checkEffetcsOperationType();

blurRadiusBox.getItems().addAll(Arrays.asList("10", "5", "3", "8", "15", "20", "30"));
blurRadiusBox.valueProperty().addListener(new ChangeListener<String>() {
intBox.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String oldValue, String newValue) {
int defaultValue = 0;
if (effectType == EffectsOperationType.Blur) {
defaultValue = 1;
} else if (effectType == EffectsOperationType.Posterizing) {
defaultValue = 32;
} else if (effectType == EffectsOperationType.Emboss) {
defaultValue = 3;
}
try {
blurRadius = Integer.valueOf(newValue);
if (blurRadius > 0) {
blurRadiusBox.getEditor().setStyle(null);

String v = newValue;
int pos = v.indexOf(" ");
if (pos > 0) {
v = v.substring(0, pos);
}
intValue = Integer.valueOf(v);
if (intValue > 0) {
intBox.getEditor().setStyle(null);
} else {
blurRadius = 1;
blurRadiusBox.getEditor().setStyle(badStyle);
intValue = defaultValue;
intBox.getEditor().setStyle(badStyle);
}
} catch (Exception e) {
blurRadius = 1;
blurRadiusBox.getEditor().setStyle(badStyle);
intValue = defaultValue;
intBox.getEditor().setStyle(badStyle);
}
}
});
blurRadiusBox.getSelectionModel().select(0);

posterizingBox.getItems().addAll(Arrays.asList("64", "32", "128", "16"));
posterizingBox.valueProperty().addListener(new ChangeListener<String>() {
stringBox.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String oldValue, String newValue) {
try {
posterizingSize = Integer.valueOf(newValue);
if (posterizingSize > 0) {
posterizingBox.getEditor().setStyle(null);
} else {
posterizingSize = 32;
posterizingBox.getEditor().setStyle(badStyle);
}
} catch (Exception e) {
posterizingSize = 32;
posterizingBox.getEditor().setStyle(badStyle);
if (newValue == null || newValue.trim().isEmpty()) {
return;
}
if (getMessage("Top").equals(newValue)) {
direction = ImageConvertTools.Direction.Top;
} else if (getMessage("Bottom").equals(newValue)) {
direction = ImageConvertTools.Direction.Bottom;
} else if (getMessage("Left").equals(newValue)) {
direction = ImageConvertTools.Direction.Top;
} else if (getMessage("Right").equals(newValue)) {
direction = ImageConvertTools.Direction.Right;
} else if (getMessage("LeftTop").equals(newValue)) {
direction = ImageConvertTools.Direction.LeftTop;
} else if (getMessage("RightBottom").equals(newValue)) {
direction = ImageConvertTools.Direction.RightBottom;
} else if (getMessage("LeftBottom").equals(newValue)) {
direction = ImageConvertTools.Direction.LeftBottom;
} else if (getMessage("RightTop").equals(newValue)) {
direction = ImageConvertTools.Direction.RightTop;
} else {
direction = ImageConvertTools.Direction.Top;
}
}
});
posterizingBox.getSelectionModel().select(0);

Tooltip tips = new Tooltip("0~255");
// tips.setFont(new Font(16));
Expand Down Expand Up @@ -192,24 +216,57 @@ private void checkThresholding() {
}
}

private void checkEffetcssOperationType() {
blurBox.setDisable(true);
private void checkEffetcsOperationType() {
intLabel.setText("");
intBox.setDisable(true);
stringLabel.setText("");
stringBox.setDisable(true);
thresholdingBox.setDisable(true);
posterizingBox.setDisable(true);
thresholdingInput.setStyle(null);
thresholdingMinInput.setStyle(null);
thresholdingMaxInput.setStyle(null);
grayCheck.setDisable(true);
RadioButton selected = (RadioButton) effectsGroup.getSelectedToggle();
if (getMessage("Blur").equals(selected.getText())) {
effectType = EffectsOperationType.Blur;
blurBox.setDisable(false);
intLabel.setText(getMessage("Radius"));
intBox.setDisable(false);
intBox.getItems().clear();
intBox.getItems().addAll(Arrays.asList("10", "5", "3", "8", "15", "20", "30"));
intBox.setEditable(true);
intValue = 10;
intBox.getSelectionModel().select("10");
} else if (getMessage("Sharpen").equals(selected.getText())) {
effectType = EffectsOperationType.Sharpen;
} else if (getMessage("EdgeDetection").equals(selected.getText())) {
effectType = EffectsOperationType.EdgeDetect;
} else if (getMessage("Emboss").equals(selected.getText())) {
effectType = EffectsOperationType.Emboss;
intLabel.setText(getMessage("Radius"));
intBox.setDisable(false);
intBox.getItems().clear();
intBox.getItems().addAll(Arrays.asList("3", "5"));
intBox.setEditable(false);
intValue = 3;
intBox.getSelectionModel().select("3");
stringLabel.setText(getMessage("Direction"));
stringBox.setDisable(false);
stringBox.getItems().clear();
stringBox.getItems().addAll(Arrays.asList(getMessage("Top"), getMessage("Bottom"),
getMessage("Left"), getMessage("Right"),
getMessage("LeftTop"), getMessage("RightBottom"),
getMessage("LeftBottom"), getMessage("RightTop")));
direction = ImageConvertTools.Direction.Top;
stringBox.getSelectionModel().select(getMessage("Top"));
grayCheck.setDisable(false);
} else if (getMessage("Posterizing").equals(selected.getText())) {
effectType = EffectsOperationType.Posterizing;
posterizingBox.setDisable(false);
intLabel.setText(getMessage("Size"));
intBox.setDisable(false);
intBox.getItems().clear();
intBox.getItems().addAll(Arrays.asList("64", "32", "128", "16"));
intBox.setEditable(false);
intBox.getSelectionModel().select("64");
} else if (getMessage("Thresholding").equals(selected.getText())) {
effectType = EffectsOperationType.Thresholding;
thresholdingBox.setDisable(false);
Expand All @@ -222,7 +279,7 @@ protected BufferedImage handleImage(BufferedImage source) {
try {
BufferedImage target = null;
if (effectType == EffectsOperationType.Blur) {
target = ImageConvertTools.blurImage(source, blurRadius);
target = ImageConvertTools.blurImage(source, intValue);

} else if (effectType == EffectsOperationType.Sharpen) {
target = ImageConvertTools.sharpenImage(source);
Expand All @@ -234,7 +291,11 @@ protected BufferedImage handleImage(BufferedImage source) {
target = ImageConvertTools.thresholding(ImageConvertTools.removeAlpha(source), threadholding, threadholdingMin, threadholdingMax);

} else if (effectType == EffectsOperationType.Posterizing) {
target = ImageConvertTools.posterizing(ImageConvertTools.removeAlpha(source), posterizingSize);
target = ImageConvertTools.posterizing(ImageConvertTools.removeAlpha(source), intValue);

} else if (effectType == EffectsOperationType.Emboss) {
target = ImageConvertTools.embossImage(ImageConvertTools.removeAlpha(source), direction, intValue, grayCheck.isSelected());

}
return target;
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 253a99d

Please sign in to comment.