Clean up code a bit
This commit is contained in:
parent
d1656c2954
commit
d482c62f2e
@ -36,7 +36,7 @@ public class ScaleSelector extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final ScaleScrollPane scrollPane;
|
private final ScaleScrollPane scrollPane;
|
||||||
private JComboBox<String> scaleSelector;
|
private final JComboBox<String> scaleSelector;
|
||||||
|
|
||||||
public ScaleSelector(ScaleScrollPane scroll) {
|
public ScaleSelector(ScaleScrollPane scroll) {
|
||||||
super(new MigLayout());
|
super(new MigLayout());
|
||||||
@ -57,9 +57,7 @@ public class ScaleSelector extends JPanel {
|
|||||||
add(button);
|
add(button);
|
||||||
|
|
||||||
// Zoom level selector
|
// Zoom level selector
|
||||||
String[] settings = SCALE_LABELS;
|
scaleSelector = new JComboBox<>(SCALE_LABELS);
|
||||||
|
|
||||||
scaleSelector = new JComboBox<>(settings);
|
|
||||||
scaleSelector.setEditable(true);
|
scaleSelector.setEditable(true);
|
||||||
setZoomText();
|
setZoomText();
|
||||||
scaleSelector.addActionListener(new ActionListener() {
|
scaleSelector.addActionListener(new ActionListener() {
|
||||||
@ -67,6 +65,7 @@ public class ScaleSelector extends JPanel {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
try {
|
try {
|
||||||
String text = (String) scaleSelector.getSelectedItem();
|
String text = (String) scaleSelector.getSelectedItem();
|
||||||
|
if (text == null) return;
|
||||||
text = text.replaceAll("%", "").trim();
|
text = text.replaceAll("%", "").trim();
|
||||||
|
|
||||||
if (text.toLowerCase(Locale.getDefault()).startsWith(SCALE_FIT.toLowerCase(Locale.getDefault()))){
|
if (text.toLowerCase(Locale.getDefault()).startsWith(SCALE_FIT.toLowerCase(Locale.getDefault()))){
|
||||||
@ -144,8 +143,7 @@ public class ScaleSelector extends JPanel {
|
|||||||
}
|
}
|
||||||
if (currentScale > SCALE_LEVELS[SCALE_LEVELS.length / 2]) {
|
if (currentScale > SCALE_LEVELS[SCALE_LEVELS.length / 2]) {
|
||||||
// scale is large, give next full 100%
|
// scale is large, give next full 100%
|
||||||
double nextScale = Math.floor(currentScale + 1.05);
|
return Math.floor(currentScale + 1.05);
|
||||||
return nextScale;
|
|
||||||
}
|
}
|
||||||
return currentScale * 1.5;
|
return currentScale * 1.5;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user