Skip to content

Commit

Permalink
BugFix saving to prop file;now using only curr dir prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutralizer committed Feb 5, 2019
1 parent 8854b38 commit 4b7807b
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 20 deletions.
9 changes: 5 additions & 4 deletions REMOVEME.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Oct 31 10:42:44 EET 2018
ESCAPE=0.0,0.0,27,1
#Tue Feb 05 05:03:23 EET 2019
F2=0.35,0.62,70,1
F1=0.74,0.8,70,1
4=0.41,0.38,52,1
R=0.14,0.0,82,1
F=0.92,0.0,70,1
E=0.8,0.0,69,1
F=0.74,0.25,70,1
17 changes: 10 additions & 7 deletions src/main/java/bgSubtraction/properties/PropertiesOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ public PropertiesOperations(ROIManipulator roiManipulator) {

public void saveRoiToPropFile(String folderPath, String currentPropFile) {
try {

File file = new File(folderPath + "\\" + currentPropFile);
if (!file.delete()) {
throw new IllegalStateException("File cound not be cleaned before saving");
prop = new Properties();
File file = new File(currentPropFile);
boolean isFiledeleted = file.delete();
if (!isFiledeleted) {
throw new IllegalStateException("File cound not be cleaned before saving or does not exist");
}
output = new FileOutputStream(folderPath + "\\" + currentPropFile);

output = new FileOutputStream(currentPropFile);

Map<String, Integer> duplicates = new HashMap<String, Integer>();

// TODO make unique intermediary check with map
for (ROI roi : roiManipulator.getListRoi()) {
String keyName = KeyEvent.getKeyText(roi.getKey().getKeyCode());
String modifiedKeyName = modifyKeyNameToAvoidDuplicates(duplicates,keyName);
Expand Down Expand Up @@ -103,6 +104,7 @@ private String modifyKeyNameToAvoidDuplicates(Map<String, Integer> duplicates, S
return keyName;
}

//TODO debug
public void createPropFile(String folderPath, String filename) {
try {

Expand Down Expand Up @@ -153,7 +155,8 @@ private void addRoiToProperty(String key, int width, int height, int sizeWidth,
*/
public void loadPropertiesFileIntoInternalRoiManipulator(String folderPath, String filename) {
try {
input = new FileInputStream(folderPath + "\\" + filename);
// input = new FileInputStream(folderPath + "\\" + filename);//TODO not curr dir
input = new FileInputStream(filename);
// input = new FileInputStream("REMOVEME.properties");//TODO for prop inside jar
if (input == null) {
System.err.println("Error - unable to find " + filename);// TODO throw for future displaying of err
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/interfacePanel/panel/KeyTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void actionPerformed(ActionEvent e) {
@Override
public void actionPerformed(ActionEvent e) {

prop.saveRoiToPropFile(folderPath,currentPropFile);
prop.saveRoiToPropFile(null,currentPropFile);//TODO changed to current dir

}
});
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/interfacePanel/panel/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,15 @@ private void startExecution() {
Display display = new Display();
roi = new ROIManipulator(camera);
prop = new PropertiesOperations(roi);//cpp way - give obj and populate it
prop.loadPropertiesFileIntoInternalRoiManipulator(UtilitiesPanel.FILE_DIR, selectedPropFile);// "config.properties"
prop.loadPropertiesFileIntoInternalRoiManipulator(null, selectedPropFile);// "config.properties"

if(useWS) {
if(useWS) {//TODO dropped to deprecated status
SpecialKey wsKey = new SpecialKey(KeyEvent.VK_DOLLAR, KeyPressType.SPECIAL);
roi.addRoiToList(0, 0.52, wsKey);
roi.addRoiToList(0.16, 0.96, 0.70, 0.04, KeyEvent.VK_W, KeyPressType.CONSTANT);// must be last
}
kt = new KeyTable(display,roi,prop,UtilitiesPanel.FILE_DIR, selectedPropFile);
kt = new KeyTable(display,roi,prop,null, selectedPropFile);

// kt.fill(c, panelForm);
kt.createTable(c,panelForm);
this.pack();

Expand All @@ -277,7 +276,7 @@ public void initializePropertiesAfterCameraIsLoaded() {
Camera camera = new Camera(cameraNum);
roi = new ROIManipulator(camera);
prop = new PropertiesOperations(roi);
prop.loadPropertiesFileIntoInternalRoiManipulator(UtilitiesPanel.FILE_DIR, comboBoxPresets.getSelectedItem().toString());
// prop.loadPropertiesFileIntoInternalRoiManipulator(UtilitiesPanel.FILE_DIR, comboBoxPresets.getSelectedItem().toString());
}

}
3 changes: 1 addition & 2 deletions src/main/java/interfacePanel/panel/UtilitiesPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
*/
public class UtilitiesPanel {

public static final String FILE_DIR = System.getProperty("user.dir");//--"c:\\MovementController\\";
//TODO filedir may not be used - remove when folder loading is finalized
public static final String FILE_DIR = System.getProperty("user.dir");
public static final String FILE_TEXT_EXT = ".properties";

public String[] listFile(String folder) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Sat Jan 26 21:35:32 EET 2019
#Mon Feb 04 13:44:40 EET 2019
version=0.0.1-SNAPSHOT
groupId=cv
m2e.projectName=MovementControllerByNeutralizer
Expand Down
Binary file not shown.
Binary file modified target/classes/interfacePanel/panel/KeyTable$7.class
Binary file not shown.
Binary file modified target/classes/interfacePanel/panel/MainPanel.class
Binary file not shown.
Binary file not shown.
Binary file modified target/classes/interfacePanel/panel/UtilitiesPanel.class
Binary file not shown.

0 comments on commit 4b7807b

Please sign in to comment.