Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Testing save bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bonosoft committed Jul 17, 2018
1 parent be56d5b commit 0ec06bd
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 27 deletions.
2 changes: 1 addition & 1 deletion install/makeapp.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
jar2app ../out/artifacts/PhotonFileValidator.jar -i img/icons/photonsters.icns -n "Photon File Validator" -v 1.3.0 -s 1.3.0 -c "(C) Copyright by Bonosoft" -j "-Xmx5g -Xms1g"
jar2app ../out/artifacts/PhotonFileValidator.jar -i img/icons/photonsters.icns -n "Photon File Validator" -v 1.4.0 -s 1.4.0 -c "(C) Copyright by Bonosoft" -j "-Xmx5g -Xms1g"

2 changes: 1 addition & 1 deletion install/makeappjre.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
jar2app ../out/artifacts/PhotonFileValidator.jar -i img/icons/photonsters.icns -n "Photon File Validator jre" -v 1.3.0 -s 1.3.0 -c "(C) Copyright by Bonosoft" -j "-Xmx5g -Xms1g" -r /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk
jar2app ../out/artifacts/PhotonFileValidator.jar -i img/icons/photonsters.icns -n "Photon File Validator jre" -v 1.4.0 -s 1.4.0 -c "(C) Copyright by Bonosoft" -j "-Xmx5g -Xms1g" -r /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk

Binary file modified out/artifacts/PhotonFileValidator.jar
Binary file not shown.
24 changes: 12 additions & 12 deletions src/photon/application/MainForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@
<component id="31d5" class="javax.swing.JButton" binding="marginNextBtn">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="40" height="18"/>
<preferred-size width="40" height="18"/>
<maximum-size width="40" height="18"/>
<minimum-size width="35" height="18"/>
<preferred-size width="35" height="18"/>
<maximum-size width="45" height="18"/>
</grid>
</constraints>
<properties>
Expand All @@ -209,9 +209,9 @@
<component id="7bc55" class="javax.swing.JButton" binding="marginPrevBtn">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="40" height="18"/>
<preferred-size width="40" height="18"/>
<maximum-size width="40" height="18"/>
<minimum-size width="35" height="18"/>
<preferred-size width="35" height="18"/>
<maximum-size width="45" height="18"/>
</grid>
</constraints>
<properties>
Expand Down Expand Up @@ -249,9 +249,9 @@
<component id="6828f" class="javax.swing.JButton" binding="islandNextBtn">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="40" height="18"/>
<preferred-size width="40" height="18"/>
<maximum-size width="40" height="18"/>
<minimum-size width="35" height="18"/>
<preferred-size width="35" height="18"/>
<maximum-size width="45" height="18"/>
</grid>
</constraints>
<properties>
Expand All @@ -262,9 +262,9 @@
<component id="e8cad" class="javax.swing.JButton" binding="islandPrevBtn">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="40" height="18"/>
<preferred-size width="40" height="18"/>
<maximum-size width="40" height="18"/>
<minimum-size width="35" height="18"/>
<preferred-size width="35" height="18"/>
<maximum-size width="45" height="18"/>
</grid>
</constraints>
<properties>
Expand Down
8 changes: 4 additions & 4 deletions src/photon/application/MainForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ private void createUIComponents() {
marginNextBtn = new JButton();
marginNextBtn.setEnabled(false);
marginNextBtn.setText(">");
panel4.add(marginNextBtn, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(40, 18), new Dimension(40, 18), new Dimension(40, 18), 0, false));
panel4.add(marginNextBtn, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(35, 18), new Dimension(35, 18), new Dimension(45, 18), 0, false));
marginPrevBtn = new JButton();
marginPrevBtn.setEnabled(false);
marginPrevBtn.setText("<");
panel4.add(marginPrevBtn, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(40, 18), new Dimension(40, 18), new Dimension(40, 18), 0, false));
panel4.add(marginPrevBtn, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(35, 18), new Dimension(35, 18), new Dimension(45, 18), 0, false));
marginInfo = new JLabel();
marginInfo.setText("");
panel4.add(marginInfo, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
Expand All @@ -362,11 +362,11 @@ private void createUIComponents() {
islandNextBtn = new JButton();
islandNextBtn.setEnabled(false);
islandNextBtn.setText(">");
panel5.add(islandNextBtn, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(40, 18), new Dimension(40, 18), new Dimension(40, 18), 0, false));
panel5.add(islandNextBtn, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(35, 18), new Dimension(35, 18), new Dimension(45, 18), 0, false));
islandPrevBtn = new JButton();
islandPrevBtn.setEnabled(false);
islandPrevBtn.setText("<");
panel5.add(islandPrevBtn, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(40, 18), new Dimension(40, 18), new Dimension(40, 18), 0, false));
panel5.add(islandPrevBtn, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(35, 18), new Dimension(35, 18), new Dimension(45, 18), 0, false));
layerInfo = new JLabel();
layerInfo.setText("");
panel5.add(layerInfo, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
Expand Down
39 changes: 33 additions & 6 deletions src/photon/application/dialogs/EditDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.security.PublicKey;
import java.util.HashSet;

public class EditDialog extends JDialog {
Expand All @@ -56,13 +57,16 @@ public class EditDialog extends JDialog {
private int layerY;
private HashSet<PhotonDot> dots;

public PhotonDot pressedDot;


public EditDialog(MainForm mainForm) {
super(mainForm.frame);
this.me = this;
this.mainForm = mainForm;

$$$setupUI$$$();

setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
Expand Down Expand Up @@ -91,12 +95,23 @@ public void actionPerformed(ActionEvent e) {

editArea.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getX() > 15 && e.getY() > 15) {
int x = (e.getX() - 15) / 10;
int y = (e.getY() - 15) / 10;
if (x < 75 && y < 45) {
me.handleClick(x, y);
public void mousePressed(MouseEvent e) {
pressedDot = getPosition(e);
}

@Override
public void mouseReleased(MouseEvent e) {
PhotonDot releasedDot = getPosition(e);
if (pressedDot != null && releasedDot != null) {
int x1 = Integer.min(pressedDot.x, releasedDot.x);
int x2 = Integer.max(pressedDot.x, releasedDot.x);
int y1 = Integer.min(pressedDot.y, releasedDot.y);
int y2 = Integer.max(pressedDot.y, releasedDot.y);

for (int x = x1; x <= x2; x++) {
for (int y = y1; y <= y2; y++) {
me.handleClick(x, y);
}
}
}
}
Expand Down Expand Up @@ -194,6 +209,18 @@ private void createUIComponents() {
editArea = new PhotonEditPanel(780, 480);
}

public static PhotonDot getPosition(MouseEvent e) {
if (e.getX() > 15 && e.getY() > 15) {
int x = (e.getX() - 15) / 10;
int y = (e.getY() - 15) / 10;
if (x < 75 && y < 45) {
return new PhotonDot(x, y);
}
}
return null;
}


/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
Expand Down
18 changes: 15 additions & 3 deletions src/photon/application/dialogs/SaveDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SaveDialog extends JDialog {
private JPanel contentPane;
Expand Down Expand Up @@ -86,9 +88,9 @@ private void onOK() {
File file = new File(path + File.separatorChar + textName.getText());
try {
PhotonFileHeader header = photonFile.getPhotonFileHeader();
header.setExposureTimeSeconds(Float.parseFloat(textExposure.getText()));
header.setOffTimeSeconds(Float.parseFloat(textOffTime.getText()));
header.setExposureBottomTimeSeconds(Float.parseFloat(textBottomExposure.getText()));
header.setExposureTimeSeconds(getFloat(textExposure.getText()));
header.setOffTimeSeconds(getFloat(textOffTime.getText()));
header.setExposureBottomTimeSeconds(getFloat(textBottomExposure.getText()));
header.setBottomLayers(Integer.parseInt(textBottomLayers.getText()));
photonFile.adjustLayerSettings();
photonFile.saveFile(file);
Expand Down Expand Up @@ -126,11 +128,21 @@ public void setInformation(PhotonFile photonFile, String path, String name) {
}

private String makeFileName(String path, String name, String ext) {
Pattern pattern = Pattern.compile("(.+)-[0-9]+");
Matcher matcher = pattern.matcher(name);
if (matcher.matches()) {
name = matcher.group(1);
}
int i = 1;
while ((new File(path + File.separatorChar + name + "-" + i + ext)).exists()) i++;
return name + "-" + i + ext;
}

private float getFloat(String str) {
return Float.parseFloat(str.replace(',', '.'));
}


{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
Expand Down

0 comments on commit 0ec06bd

Please sign in to comment.