Commit c20146ae authored by Matti Pulkkinen's avatar Matti Pulkkinen
Browse files

extracted coordinate update to a separate method

parent 232504db
......@@ -70,10 +70,7 @@ public class MapDialog extends JFrame {
|| Math.abs(MapDialog.this.southernLatitude - MapDialog.this.northernLatitude) <= 20) {
;
} else {
MapDialog.this.westernLongitude += 20;
MapDialog.this.easternLongitude += -20;
MapDialog.this.southernLatitude += 10;
MapDialog.this.northernLatitude += -10;
MapDialog.this.updateCoordinates(20, -20, 10, -10);
MapDialog.this.updateImage();
}
}
......@@ -85,10 +82,7 @@ public class MapDialog extends JFrame {
|| MapDialog.this.southernLatitude == -90 || MapDialog.this.northernLatitude == 90) {
;
} else {
MapDialog.this.westernLongitude += -20;
MapDialog.this.easternLongitude += 20;
MapDialog.this.southernLatitude += -10;
MapDialog.this.northernLatitude += 10;
MapDialog.this.updateCoordinates(-20, 20, -10, 10);
MapDialog.this.updateImage();
}
......@@ -97,8 +91,6 @@ public class MapDialog extends JFrame {
} // actionPerformed(ActionEvent)
} // class ButtonListener
// Käyttöliittymän komponentit
// Valintalaatikko, joka muistaa karttakerroksen nimen
private class LayerCheckBox extends JCheckBox {
private static final long serialVersionUID = 1L;
......@@ -122,12 +114,12 @@ public class MapDialog extends JFrame {
} // main(String[])
private final JLabel imageLabel = new JLabel();
private JPanel leftPanel = new JPanel();
private JButton refreshB = new JButton("Päivitä");
private JButton leftB = new JButton("<");
private JButton rightB = new JButton(">");
private JButton upB = new JButton("^");
private JButton downB = new JButton("v");
private JButton zoomInB = new JButton("+");
......@@ -137,6 +129,7 @@ public class MapDialog extends JFrame {
private Timer resizeTimer;
private int westernLongitude = -180;
private int easternLongitude = 180;
private int southernLatitude = -90;
private int northernLatitude = 90;
......@@ -263,4 +256,13 @@ public class MapDialog extends JFrame {
this.leftPanel.add(new LayerCheckBox(name, title, (i == 0) ? true : false));
}
}
private synchronized void updateCoordinates(int westDelta, int eastDelta, int southDelta,
int northDelta) {
this.westernLongitude += westDelta;
this.easternLongitude += eastDelta;
this.southernLatitude += southDelta;
this.northernLatitude += northDelta;
}
// Käyttöliittymän komponentit
} // MapDialog
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment