Skip to content

Commit

Permalink
a6.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mararsh committed May 12, 2024
1 parent 642f388 commit aab36db
Show file tree
Hide file tree
Showing 15 changed files with 315 additions and 582 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* @License Apache License Version 2.0
*/
public class BaseDataConvertController extends BaseTaskController {

@FXML
protected TextArea cssArea;
@FXML
Expand All @@ -58,7 +58,7 @@ public class BaseDataConvertController extends BaseTaskController {
protected ControlTextOptions textWriteOptionsController;
@FXML
protected ControlPdfWriteOptions pdfOptionsController;

public void initControls(String name) {
baseName = name + "_" + baseName;
initCSV();
Expand All @@ -67,13 +67,13 @@ public void initControls(String name) {
initPDF();
initHtml();
}

private void initCSV() {
if (csvWriteController != null) {
csvWriteController.setControls(baseName + "CSVWrite", false, false);
}
}

private void initExcel() {
if (excelWithNamesCheck != null) {
excelWithNamesCheck.setSelected(UserConfig.getBoolean(baseName + "ExcelTargetWithNames", true));
Expand All @@ -82,27 +82,27 @@ private void initExcel() {
currentSheetOnlyCheck.setSelected(UserConfig.getBoolean(baseName + "ExcelCurrentSheetOnly", false));
}
}

private void initTexts() {
if (textWriteOptionsController != null) {
textWriteOptionsController.setControls(baseName + "TextWrite", false, true);
}
}

private void initHtml() {
if (cssArea != null) {
cssArea.setText(UserConfig.getString(baseName + "Css", HtmlStyles.TableStyle));
}
}

private void initPDF() {
if (pdfOptionsController != null) {
pdfOptionsController.set(baseName, false);
pdfOptionsController.pixSizeRadio.setDisable(true);
pdfOptionsController.standardSizeRadio.setSelected(true);
}
}

public DataFileCSVWriter pickCSVWriter() {
try {
DataFileCSVWriter writer = new DataFileCSVWriter();
Expand All @@ -115,14 +115,14 @@ public DataFileCSVWriter pickCSVWriter() {
.setDelimiter(csvWriteController.getDelimiterName())
.setWriteHeader(csvWriteController.withName());
}

return writer;
} catch (Exception e) {
MyBoxLog.error(e);
return null;
}
}

public DataFileExcelWriter pickExcelWriter() {
try {
DataFileExcelWriter writer = new DataFileExcelWriter();
Expand All @@ -134,14 +134,14 @@ public DataFileExcelWriter pickExcelWriter() {
UserConfig.setBoolean(baseName + "ExcelCurrentSheetOnly", currentSheetOnlyCheck.isSelected());
writer.setCurrentSheetOnly(currentSheetOnlyCheck.isSelected());
}

return writer;
} catch (Exception e) {
MyBoxLog.error(e);
return null;
}
}

public DataFileTextWriter pickTextWriter() {
try {
DataFileTextWriter writer = new DataFileTextWriter();
Expand All @@ -154,18 +154,21 @@ public DataFileTextWriter pickTextWriter() {
.setDelimiter(textWriteOptionsController.getDelimiterName())
.setWriteHeader(textWriteOptionsController.withName());
}

return writer;
} catch (Exception e) {
MyBoxLog.error(e);
return null;
}
}

public PdfWriter pickPDFWriter() {
try {
PdfWriter writer = new PdfWriter();
if (pdfOptionsController != null) {
if (!pdfOptionsController.pickValues()) {
return null;
}
List<Integer> columnWidths = new ArrayList<>();
String w = widthList.getText();
if (w != null && !w.isBlank()) {
Expand All @@ -180,6 +183,7 @@ public PdfWriter pickPDFWriter() {
}
}
}

writer.setPdfTable(PaginatedPdfTable.create()
.setPageSize(new PDRectangle(pdfOptionsController.pageWidth, pdfOptionsController.pageHeight))
.setTtf(pdfOptionsController.getTtfFile())
Expand All @@ -191,14 +195,14 @@ public PdfWriter pickPDFWriter() {
.setFooter(pdfOptionsController.getFooter())
.setShowPageNumber(pdfOptionsController.showPageNumber));
}

return writer;
} catch (Exception e) {
MyBoxLog.error(e);
return null;
}
}

public HtmlWriter pickHtmlWriter() {
try {
HtmlWriter writer = new HtmlWriter();
Expand All @@ -207,14 +211,14 @@ public HtmlWriter pickHtmlWriter() {
UserConfig.setString(baseName + "Css", css);
writer.setCss(css);
}

return writer;
} catch (Exception e) {
MyBoxLog.error(e);
return null;
}
}

public Data2DWriter pickWriter(TargetType format) {
try {
if (format == null) {
Expand Down Expand Up @@ -262,13 +266,13 @@ public Data2DWriter pickWriter(TargetType format) {
break;
}
if (writer != null) {

}
return writer;
} catch (Exception e) {
MyBoxLog.error(e);
return null;
}
}

}
16 changes: 10 additions & 6 deletions alpha/MyBox/src/main/java/mara/mybox/controller/BaseLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,19 @@ public void updateLogs(String line, boolean showTime, boolean immediate) {
if (line == null) {
return;
}
if (logsTextArea == null) {
popInformation(line);
return;
}
if (Platform.isFxApplicationThread()) {
writeLogs(line, showTime, immediate);
if (logsTextArea == null) {
popInformation(line);
} else {
writeLogs(line, showTime, immediate);
}
} else {
Platform.runLater(() -> {
writeLogs(line, showTime, immediate);
if (logsTextArea == null) {
popInformation(line);
} else {
writeLogs(line, showTime, immediate);
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.VBox;
import mara.mybox.data.SetValue;
import mara.mybox.data.SetValue.ValueType;
Expand Down Expand Up @@ -41,18 +41,17 @@ public class ControlData2DSetValue extends BaseController {
numberSuffixStringRadio, numberPrefixStringRadio,
gaussianDistributionRadio, identifyRadio, upperTriangleRadio, lowerTriangleRadio;
@FXML
protected TextField valueInput, prefixInput, suffixInput, startInput, digitInput,
numberSuffixInput, numberPrefixInput;
protected TextField startInput, digitInput;
@FXML
protected ComboBox<String> scaleSelector;
protected TextArea valueInput, prefixInput, suffixInput, numberSuffixInput, numberPrefixInput;
@FXML
protected FlowPane scalePane, numberPane, matrixPane;
protected ComboBox<String> scaleSelector;
@FXML
protected ControlData2DRowExpression expressionController;
@FXML
protected CheckBox fillZeroCheck;
@FXML
protected VBox expBox;
protected VBox expBox, matrixBox;

public void setParameter(Data2DSetValuesController handleController) {
try {
Expand Down Expand Up @@ -182,10 +181,10 @@ public void setData2D(Data2D data2D) {

public void setMatrixPane(boolean isAvailable) {
if (isAvailable) {
matrixPane.setDisable(false);
matrixBox.setVisible(true);

} else {
matrixPane.setDisable(true);
matrixBox.setVisible(false);
if (gaussianDistributionRadio.isSelected() || identifyRadio.isSelected()
|| upperTriangleRadio.isSelected() || lowerTriangleRadio.isSelected()) {
valueRadio.setSelected(true);
Expand Down Expand Up @@ -308,12 +307,36 @@ public boolean pickValues() {
UserConfig.setBoolean(conn, baseName + "FillZero", setValue.isFillZero());
UserConfig.setBoolean(conn, baseName + "AutoDigit", setValue.isAotoDigit());
} else if (gaussianDistributionRadio.isSelected()) {
if (handleController.sourceController.filteredRowsIndices.size()
!= handleController.checkedColsIndices.size()) {
outError(message("MatricesCannotCalculateShouldSqure"));
return false;
}
if (handleController.sourceController.filteredRowsIndices.size() % 2 == 0) {
outError(message("MatricesCannotCalculateShouldOdd"));
return false;
}
setValue.setType(ValueType.GaussianDistribution);
} else if (identifyRadio.isSelected()) {
if (handleController.sourceController.filteredRowsIndices.size()
!= handleController.checkedColsIndices.size()) {
outError(message("MatricesCannotCalculateShouldSqure"));
return false;
}
setValue.setType(ValueType.GaussianDistribution);
} else if (upperTriangleRadio.isSelected()) {
if (handleController.sourceController.filteredRowsIndices.size()
!= handleController.checkedColsIndices.size()) {
outError(message("MatricesCannotCalculateShouldSqure"));
return false;
}
setValue.setType(ValueType.UpperTriangle);
} else if (lowerTriangleRadio.isSelected()) {
if (handleController.sourceController.filteredRowsIndices.size()
!= handleController.checkedColsIndices.size()) {
outError(message("MatricesCannotCalculateShouldSqure"));
return false;
}
setValue.setType(ValueType.LowerTriangle);
} else if (expressionRadio.isSelected()) {
if (!expressionController.checkExpression(handleController.isAllPages())) {
Expand Down
Loading

0 comments on commit aab36db

Please sign in to comment.