Checkstyle fix

This commit is contained in:
Jindra Petřík
2026-02-01 05:47:25 +01:00
parent cf9c777b43
commit 177bd72ee7

View File

@@ -99,7 +99,7 @@ public class ExportDialog extends AppDialog {
TagTreeModel.FOLDER_MORPHSHAPES,
"symbolclass"
};
String[] optionIcons = {
"shape",
"text",
@@ -116,7 +116,7 @@ public class ExportDialog extends AppDialog {
"morphshape",
"symbolclass"
};
//Display options only when these classes found
Class[][] objClasses = {
{ShapeTag.class},
@@ -171,24 +171,23 @@ public class ExportDialog extends AppDialog {
private JTextField zoomTextField = new JTextField(4);
private JCheckBox embedCheckBox;
private JCheckBox transparentFrameBackgroundCheckBox;
private JTextField durationTextField = new JTextField(4);
private JTextField numberOfFramesTextField = new JTextField(4);
private JLabel durationLabel = new JLabel(translateTitle("morph.duration"));
private JLabel secondsLabel = new JLabel(translate("morph.duration.seconds"));
private JLabel numberOfFramesLabel = new JLabel(translateTitle("morph.numberOfFrames"));
private JLabel zoomLabel = new JLabel(translateTitle("zoom"));
private JLabel percentLabel = new JLabel(translate("zoom.percent"));
@SuppressWarnings("unchecked")
public <E> E getValue(Class<E> option) {
for (int i = 0; i < optionClasses.length; i++) {
@@ -215,12 +214,12 @@ public class ExportDialog extends AppDialog {
public boolean isEmbedEnabled() {
return embedCheckBox.isSelected();
}
}
public boolean isTransparentFrameBackgroundEnabled() {
return transparentFrameBackgroundCheckBox.isSelected();
}
public Double getMorphDuration() {
try {
Double val = Double.valueOf(durationTextField.getText());
@@ -232,7 +231,7 @@ public class ExportDialog extends AppDialog {
return null;
}
}
public Integer getMorphNumberOfFrames() {
try {
int val = Integer.valueOf(numberOfFramesTextField.getText());
@@ -254,7 +253,7 @@ public class ExportDialog extends AppDialog {
}
private boolean saveConfig() {
if (isOptionEnabled(MorphShapeExportMode.class)) {
MorphShapeExportMode morphMode = getValue(MorphShapeExportMode.class);
if (morphMode.hasDuration() && getMorphDuration() == null) {
@@ -267,7 +266,7 @@ public class ExportDialog extends AppDialog {
numberOfFramesTextField.requestFocusInWindow();
return false;
}
try {
Double.parseDouble(zoomTextField.getText());
} catch (NumberFormatException nfe) {
@@ -276,8 +275,7 @@ public class ExportDialog extends AppDialog {
return false;
}
}
StringBuilder cfg = new StringBuilder();
for (int i = 0; i < optionNames.length; i++) {
Object val = ((ComboValue) combos[i].getSelectedItem()).value;
@@ -289,17 +287,16 @@ public class ExportDialog extends AppDialog {
cfg.append(key);
}
Double morphDuration = getMorphDuration();
if (morphDuration != null) {
Configuration.lastExportMorphDuration.set(morphDuration);
}
Integer morphNumberOfFrames = getMorphNumberOfFrames();
}
Integer morphNumberOfFrames = getMorphNumberOfFrames();
if (morphNumberOfFrames != null) {
Configuration.lastExportMorphNumberOfFrames.set(morphNumberOfFrames);
}
Configuration.lastSelectedExportZoom.set(Double.parseDouble(zoomTextField.getText()) / 100);
Configuration.lastSelectedExportFormats.set(cfg.toString());
if (embedCheckBox.isVisible()) {
@@ -333,25 +330,25 @@ public class ExportDialog extends AppDialog {
private String translateTitle(String title) {
return translate("titleFormat").replace("%title%", translate(title));
}
private void onChange() {
if (!isOptionEnabled(MorphShapeExportMode.class)) {
durationLabel.setVisible(false);
durationTextField.setVisible(false);
secondsLabel.setVisible(false);
numberOfFramesLabel.setVisible(false);
numberOfFramesTextField.setVisible(false);
numberOfFramesTextField.setVisible(false);
} else {
MorphShapeExportMode mode = getValue(MorphShapeExportMode.class);
durationLabel.setVisible(mode.hasDuration());
durationTextField.setVisible(mode.hasDuration());
secondsLabel.setVisible(mode.hasDuration());
numberOfFramesLabel.setVisible(mode.hasFrames());
numberOfFramesTextField.setVisible(mode.hasFrames());
numberOfFramesTextField.setVisible(mode.hasFrames());
}
transparentFrameBackgroundCheckBox.setVisible(isOptionEnabled(FrameExportMode.class));
boolean hasZoom = false;
for (Class c : zoomClasses) {
if (isOptionEnabled(c)) {
@@ -364,7 +361,7 @@ public class ExportDialog extends AppDialog {
percentLabel.setVisible(hasZoom);
}
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
public ExportDialog(Window owner, List<TreeItem> exportables) {
super(owner);
setTitle(translate("dialog.title"));
@@ -471,7 +468,7 @@ public class ExportDialog extends AppDialog {
checkBoxes[i] = new JCheckBox();
checkBoxes[i].setSelected(true);
checkBoxes[i].addActionListener((ActionEvent e) -> {
onChange();
});
@@ -484,30 +481,30 @@ public class ExportDialog extends AppDialog {
if (Arrays.asList(zoomClasses).contains(c)) {
zoomable = true;
}
combos[i].addItemListener((ItemEvent e) -> {
onChange();
});
visibleOptionClasses.add(c);
JLabel label = new JLabel(translate(optionNames[i]));
label.setIcon(View.getIcon(optionIcons[i].toLowerCase() + "16"));
label.setIcon(View.getIcon(optionIcons[i].toLowerCase() + "16"));
label.setLabelFor(combos[i]);
label.setHorizontalTextPosition(SwingConstants.LEFT);
gbc.gridy++;
gbc.gridx = 0;
gbc.anchor = GridBagConstraints.LINE_END;
comboPanel.add(label, gbc);
gbc.gridx++;
gbc.anchor = GridBagConstraints.LINE_START;
JLabel arrowLabel = new JLabel(translate("arrow"));
gbc.insets = new Insets(1, 5, 1, 5);
comboPanel.add(arrowLabel, gbc);
comboPanel.add(arrowLabel, gbc);
gbc.insets = new Insets(1, 2, 1, 2);
gbc.gridx++;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = GridBagConstraints.HORIZONTAL;
@@ -522,8 +519,7 @@ public class ExportDialog extends AppDialog {
}
gbc.insets = new Insets(2, 2, 2, 2);
embedCheckBox = new JCheckBox(translate("embed"));
embedCheckBox.setVisible(false);
@@ -551,7 +547,7 @@ public class ExportDialog extends AppDialog {
if (Configuration.lastExportEnableEmbed.get()) {
embedCheckBox.setSelected(true);
}
}
}
transparentFrameBackgroundCheckBox = new JCheckBox(translate("transparentFrameBackground"));
transparentFrameBackgroundCheckBox.setVisible(false);
@@ -563,7 +559,7 @@ public class ExportDialog extends AppDialog {
transparentFrameBackgroundCheckBox.setSelected(true);
}
}
durationTextField.setVisible(false);
numberOfFramesTextField.setVisible(false);
if (visibleOptionClasses.contains(MorphShapeExportMode.class)) {
@@ -576,31 +572,30 @@ public class ExportDialog extends AppDialog {
durationTextField.setText(durationString);
numberOfFramesTextField.setVisible(true);
numberOfFramesTextField.setText("" + Configuration.lastExportMorphNumberOfFrames.get());
durationLabel.setLabelFor(durationTextField);
numberOfFramesLabel.setLabelFor(numberOfFramesTextField);
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_END;
comboPanel.add(durationLabel, gbc);
gbc.gridx+=2;
gbc.gridx += 2;
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.LINE_START;
comboPanel.add(durationTextField, gbc);
comboPanel.add(durationTextField, gbc);
gbc.gridx++;
gbc.anchor = GridBagConstraints.LINE_START;
comboPanel.add(secondsLabel, gbc);
comboPanel.add(secondsLabel, gbc);
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_END;
comboPanel.add(numberOfFramesLabel, gbc);
gbc.gridx+=2;
gbc.gridx += 2;
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.anchor = GridBagConstraints.LINE_START;
comboPanel.add(numberOfFramesTextField, gbc);
}
@@ -610,8 +605,8 @@ public class ExportDialog extends AppDialog {
gbc.gridx = 0;
gbc.gridwidth = 2;
gbc.anchor = GridBagConstraints.LINE_END;
comboPanel.add(zoomLabel, gbc);
gbc.gridx+=2;
comboPanel.add(zoomLabel, gbc);
gbc.gridx += 2;
gbc.gridwidth = 1;
gbc.anchor = GridBagConstraints.LINE_START;
comboPanel.add(zoomTextField, gbc);
@@ -624,9 +619,9 @@ public class ExportDialog extends AppDialog {
gbc.gridx = 0;
gbc.gridwidth = 5;
gbc.fill = GridBagConstraints.BOTH;
gbc.weighty = 1;
gbc.weighty = 1;
comboPanel.add(new JPanel(), gbc);
cnt.add(comboPanel, BorderLayout.CENTER);
JPanel buttonsPanel = new JPanel(new FlowLayout());
@@ -666,7 +661,7 @@ public class ExportDialog extends AppDialog {
if (!saveConfig()) {
return;
}
result = OK_OPTION;
setVisible(false);
}