summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/GUI.java69
-rw-r--r--gui/ListTest.java47
-rw-r--r--gui/Localization.java291
-rw-r--r--gui/LocalizationNew.java773
-rw-r--r--gui/MapShow.java38
-rw-r--r--gui/MapTest.java119
-rw-r--r--gui/MapViewer.java54
-rw-r--r--gui/ShowMapStrength.java309
-rw-r--r--gui/Start.java64
-rw-r--r--gui/test.java72
10 files changed, 1836 insertions, 0 deletions
diff --git a/gui/GUI.java b/gui/GUI.java
new file mode 100644
index 0000000..03e8b3a
--- /dev/null
+++ b/gui/GUI.java
@@ -0,0 +1,69 @@
+package gui;
+
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+import javax.swing.JFrame;
+
+public class GUI {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame map = new JFrame("Map");
+ map.setSize(600, 450);
+ // JFrame control = new JFrame("Control");
+ map.setVisible(true);
+ map.addWindowListener(new WindowsCloser());
+
+ }
+
+}
+
+class WindowsCloser implements WindowListener {
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ // TODO Auto-generated method stub
+ System.exit(0);
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowOpened(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/gui/ListTest.java b/gui/ListTest.java
new file mode 100644
index 0000000..951fb71
--- /dev/null
+++ b/gui/ListTest.java
@@ -0,0 +1,47 @@
+package gui;
+
+import java.util.Date;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class ListTest {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ JFrame test = new JFrame();
+ test.setSize(300, 50);
+
+ DefaultListModel listModel = new DefaultListModel();
+ listModel.addElement("bla");
+ listModel.addElement(new Date());
+ JList list = new JList(listModel);
+ test.add(list);
+ test.setVisible(true);
+ listModel.addElement("neues Element");
+ listModel.addElement("neues Element");
+ JScrollPane listScroller = new JScrollPane(list);
+ list.setSelectionMode(0);
+ test.add(listScroller);
+
+ list.addListSelectionListener(new ListSelectionListener() {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ // TODO Auto-generated method stub
+ if (!e.getValueIsAdjusting()) {
+ System.out.println(((JList) e.getSource())
+ .getSelectedIndex());
+ }
+
+ }
+ });
+
+ }
+}
diff --git a/gui/Localization.java b/gui/Localization.java
new file mode 100644
index 0000000..8024c9e
--- /dev/null
+++ b/gui/Localization.java
@@ -0,0 +1,291 @@
+package gui;
+
+import helper.ListBTS;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Graphics2D;
+import java.awt.TextField;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+
+import org.jdesktop.swingx.JXMapKit;
+import org.jdesktop.swingx.JXMapKit.DefaultProviders;
+import org.jdesktop.swingx.JXMapViewer;
+import org.jdesktop.swingx.mapviewer.DefaultTileFactory;
+import org.jdesktop.swingx.mapviewer.GeoPosition;
+import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
+import org.jdesktop.swingx.painter.CompoundPainter;
+import org.jdesktop.swingx.painter.Painter;
+
+import DataStructure.BayesAll;
+import DataStructure.Interpolator;
+import DataStructure.MobilePhone;
+import DataStructure.PhoneContainer;
+import DataStructure.SingleBTS;
+import Parse.SqlPollerDate;
+import Parse.SqlPollerUnThreaded;
+
+public class Localization {
+ static Interpolator map;
+
+ private static ArrayList<SingleBTS> filterMR(ArrayList<SingleBTS> MR,
+ JCheckBox[] btsFilter) {
+ SingleBTS[] content = map.content();
+ ArrayList<SingleBTS> result = new ArrayList<SingleBTS>();
+ for (int i = 0; i < content.length; i++) {
+ if (btsFilter[i].isSelected()) {
+ // add this BTS
+ ArrayList<SingleBTS> elementsToAdd = ListBTS.getAllARFCN(MR,
+ content[i].ARFCN);
+ if (elementsToAdd != null)
+ result.addAll(elementsToAdd);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @param args
+ */
+ @SuppressWarnings("unused")
+ public static void main(String[] args) {
+ JFrame frame = new JFrame();
+ JFrame control = new JFrame();
+ control.setSize(400, 300);
+ JFrame filter = new JFrame("filter BTS");
+ filter.setSize(200, 600);
+
+ frame.setSize(400, 400);
+ JXMapKit mapViewer = new JXMapKit();
+ // JXMapViewer
+ // Painter
+ // mapViewer.setDefaultProvider(DefaultProviders.OpenStreetMaps);
+ mapViewer.setDefaultProvider(DefaultProviders.Custom);
+
+ TileFactoryInfo ownTileFactory = new TileFactoryInfo(0, 18, 18, 256,
+ false, false, "http://c.tile.openstreetmap.org", "/", "/", "/") {
+ public String getTileUrl(int x, int y, int zoom) {
+ return this.baseURL + "/" + (18 - zoom) + "/" + x + "/" + y
+ + ".png";
+ }
+ };
+ mapViewer.setTileFactory(new DefaultTileFactory(ownTileFactory));
+
+ mapViewer.setDataProviderCreditShown(true);
+ frame.add(mapViewer);
+ System.out.println("da");
+
+ SqlPollerUnThreaded sql = new SqlPollerUnThreaded();
+ SqlPollerDate sqlDate;
+ sqlDate = new SqlPollerDate(sql);
+ TextField actionRefID = new TextField();
+ TextField confidenceField = new TextField();
+ control.add(actionRefID, BorderLayout.CENTER);
+ JCheckBox useActionRef = new JCheckBox("use RefID");
+ control.add(useActionRef, BorderLayout.SOUTH);
+ confidenceField.setText("0.75");
+ actionRefID.setText("146373");
+ control.add(confidenceField, BorderLayout.NORTH);
+ control.setVisible(true);
+ Button next = new Button("next");
+ control.add(next, BorderLayout.EAST);
+ frame.setVisible(true);
+ mapViewer.setZoom(18);
+ try {
+
+ map = readGSM("D:/parallel-strictdB-BER.obj");
+ // map = readGSM("parallel-strictdB.obj");
+ // map = readGSM("RichyUndKerstinInterpoliert.obj");
+ // map = readGSM("parallel.obj");
+ mapViewer.setAddressLocation(new GeoPosition(
+ (map.minY + map.maxY) / 2, (map.minX + map.maxX) / 2));
+ mapViewer.setAddressLocationShown(true);
+ mapViewer.setZoom(1);
+ mapViewer.setCenterPosition(new GeoPosition(
+ (map.minY + map.maxY) / 2, (map.minX + map.maxX) / 2));
+
+ // mapViewer.setTileFactory(new DefaultTileFactory(new
+ // ownTileFactory(minimumZoomLevel, maximumZoomLevel, totalMapZoom,
+ // tileSize, xr2l, yt2b, baseURL, xparam, yparam, zparam)))
+ // mapViewer.getMainMap().
+
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ SingleBTS[] content = map.content();
+ JCheckBox[] btsFilter = new JCheckBox[content.length];
+ int y = 30;
+ filter.setLayout(null);
+ for (int i = 0; i < content.length; i++) {
+ btsFilter[i] = new JCheckBox(Integer.toString(content[i].ARFCN),
+ true);
+ btsFilter[i].setLocation(30, y);
+ btsFilter[i].setSize(70, 25);
+ y += 30;
+ filter.add(btsFilter[i]);
+ }
+ filter.validate();
+ filter.setVisible(true);
+
+ PhoneContainer container = new PhoneContainer();
+ CompoundPainter cp = new CompoundPainter();
+ BayesAll bayes = new BayesAll(map);
+
+ // hack: make while (true) again!
+ // long lastRefID = 0;
+
+ while (true) {
+
+ if (useActionRef.isSelected()) {
+
+ try {
+ double confidence = Double.parseDouble(confidenceField
+ .getText());
+ long refID = Long.parseLong(actionRefID.getText());
+
+ ArrayList<SingleBTS> report = sqlDate.getActionRefID(refID).MR;
+
+ // MobilePhone phone = sqlDate.getActionRefID(refID);
+ MobilePhone phone = new MobilePhone();
+ phone.bayes = bayes;
+ phone.MR = filterMR(report, btsFilter);
+ phone.correctCoordinate = sqlDate.getCoord(refID);
+ long time = phone.getMinTime();
+ // long timeMax = phone.getMaxTime();
+ confidence = Double.parseDouble(confidenceField.getText());
+ phone.locate(confidence);
+ // phone.locateTimeSensitiv(confidence, (time + timeMax) /
+ // 2);
+ // phone.locateTimeSensitiv(confidence, timeMax - 3000);
+ // Zeitschleife
+ System.out.println(phone.localizationAccuracy());
+
+ while (time <= phone.getMaxTime()) {
+ // go out of while loop
+ if (true)
+ break;
+ phone.MR = filterMR(report, btsFilter);
+ // phone.MR = ListBTS.generateAveragedList(phone.MR);
+
+ System.out.println("Zeit: " + new Date(time) + "("
+ + time + ")");
+ confidence = Double.parseDouble(confidenceField
+ .getText());
+ // phone.locateTimeSensitiv(map, confidence, time);
+ phone.locateTimeSensitiv(confidence, time);
+ System.out.println(phone.localizationAccuracy());
+ mapViewer.getMainMap().setOverlayPainter(phone);
+ time += 3000;
+ }
+ System.out.println("Ende Zeitschleife... Neuanfang");
+
+ // phone.locate(map, confidence, false);
+ System.out.println("confidence: " + confidence);
+ mapViewer.getMainMap().setOverlayPainter(phone);
+ } catch (NumberFormatException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ System.out.println("irgednwas anderes hat nicht geklappt");
+ e.printStackTrace();
+ }
+ } else {
+ container.removeAll();
+ ArrayList<MobilePhone> phones = sql.getMRs();
+ // MobilePhone hackPhone = new MobilePhone();
+
+ // insert MR reports from phone!
+
+ for (MobilePhone phone : phones) {
+ phone.locate(map, 0.75, false);
+ container.add(phone);
+ }
+
+ // make mappainter overlay
+
+ cp.setCacheable(false);
+
+ mapViewer.getMainMap().setOverlayPainter(container);
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ static private Interpolator readGSM(String filename)
+ throws FileNotFoundException, IOException, ClassNotFoundException {
+
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
+ filename));
+ Interpolator map = (Interpolator) ois.readObject();
+ System.out.println("GSMMap eingelesen");
+ return map;
+ }
+
+}
+
+class locationPainter implements Painter<JXMapViewer> {
+ private ArrayList<MobilePhone> phones = new ArrayList<MobilePhone>();
+
+ // private Interpolator map;
+
+ public locationPainter(ArrayList<MobilePhone> phones, Interpolator map) {
+ this.phones = phones;
+ // this.map = map;
+ for (int i = 0; i < phones.size(); i++) {
+ phones.get(i).locate(map, false);
+ }
+
+ }
+
+ @Override
+ public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
+
+ for (int i = 0; i < phones.size(); i++) {
+
+ }
+
+ }
+
+}
+
+class ownTileFactory extends TileFactoryInfo {
+
+ public ownTileFactory(int minimumZoomLevel, int maximumZoomLevel,
+ int totalMapZoom, int tileSize, boolean xr2l, boolean yt2b,
+ String baseURL, String xparam, String yparam, String zparam) {
+ super(0, 18, 18, 256, true, true, "http://b.tile.openstreetmap.org",
+ xparam, yparam, zparam);
+ maximumZoomLevel = 18;
+ minimumZoomLevel = 0;
+ totalMapZoom = 18;
+
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/gui/LocalizationNew.java b/gui/LocalizationNew.java
new file mode 100644
index 0000000..911dc9e
--- /dev/null
+++ b/gui/LocalizationNew.java
@@ -0,0 +1,773 @@
+package gui;
+
+import helper.ListBTS;
+
+import java.awt.BorderLayout;
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import org.jdesktop.swingx.JXMapKit;
+import org.jdesktop.swingx.JXMapKit.DefaultProviders;
+import org.jdesktop.swingx.JXMapViewer;
+import org.jdesktop.swingx.mapviewer.DefaultTileFactory;
+import org.jdesktop.swingx.mapviewer.GeoPosition;
+import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
+import org.jdesktop.swingx.painter.Painter;
+
+import DataStructure.BayesAll;
+import DataStructure.GSMMap;
+import DataStructure.Interpolator;
+import DataStructure.MobilePhone;
+import DataStructure.SingleBTS;
+import Parse.SqlPollerDate;
+
+public class LocalizationNew {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ UserInterface.showFrames();
+ UserInterface.setLive(false);
+ UserInterface.setIMSIorRef(153227);
+ try {
+ SqlPollerDate sql = new SqlPollerDate();
+ BayesAll bayes = new BayesAll(UserInterface.getGsmMap());
+ MobilePhone phone = new MobilePhone(bayes);
+
+ while (true) {
+ try {
+ if (!UserInterface.getLive()
+ && UserInterface.getIMSI() != 0) {
+ phone = getPhoneRefID(UserInterface.getIMSI(), bayes,
+ sql);
+
+ if (!UserInterface.getStep()) {
+ // Locate based on average of all MRs
+ phone.locate(UserInterface.getConfidence());
+ UserInterface.setMapPainter(phone);
+ } else {
+ long time = phone.getMinTime();
+ long maxtime = phone.getMaxTime();
+ while (time < maxtime && UserInterface.getStep()) {
+ phone.locateTimeSensitiv(
+ UserInterface.getConfidence(), time);
+ time += 2000;
+ UserInterface.setMapPainter(phone);
+ }
+ }
+
+ } else if (UserInterface.getLive()
+ && UserInterface.getIMSI() != 0) {
+ phone = getPhoneLastSeen(UserInterface.getIMSI(),
+ bayes, sql);
+ phone.locate(UserInterface.getConfidence());
+ UserInterface.setMapPainter(phone);
+ }
+ System.gc();
+ Thread.sleep(500);
+ } catch (Exception e) {
+ System.out.println("Error. Cannot Localize.");
+ // e.printStackTrace();
+ }
+ }
+
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ System.out.println("No Internet Connection?");
+ }
+
+ }
+
+ private static MobilePhone getPhoneLastSeen(long imsi, BayesAll bayes,
+ SqlPollerDate sql) throws SQLException {
+ // TODO Auto-generated method stub
+ MobilePhone phone = new MobilePhone();
+ phone = sql.getLastMRs(imsi);
+ phone.bayes = bayes;
+ if (UserInterface.getFilter())
+ BTSFilter.filterMR(phone);
+ return phone;
+ }
+
+ private static MobilePhone getPhoneRefID(long IMSI, BayesAll bayes,
+ SqlPollerDate sql) throws SQLException {
+ MobilePhone phone = sql.getActionRefID(UserInterface.getIMSI());
+ phone.bayes = bayes;
+ if (UserInterface.getFilter())
+ BTSFilter.filterMR(phone);
+ return phone;
+ }
+}
+
+/**
+ * Creates user Interface for Localization
+ *
+ * @author richy
+ *
+ */
+class UserInterface {
+ private static TextField input;
+ private static JCheckBox live;
+ private static JCheckBox history;
+ private static TextField confidence;
+ private static JXMapKit mapViewer;
+ private static GSMMap map;
+ private static JCheckBox filter;
+
+ /**
+ * Show UserInterface
+ */
+ public static void showFrames() {
+ JFrame map = new JFrame();
+ map.addWindowListener(new quit());
+ map.setSize(600, 450);
+ mapViewer = getMapViewer();
+ map.add(mapViewer);
+ map.setVisible(true);
+ JFrame control = new JFrame();
+ control.addWindowListener(new quit());
+ control.setSize(400, 300);
+ control.setLayout(null);
+ // JCheckBox imsiOrActionRef = new JCheckBox("IMSI");
+ input = new TextField("187970");
+ input.setLocation(20, 20);
+ input.setSize(200, 20);
+ final JLabel imsiLabel = new JLabel("IMSI");
+ imsiLabel.setSize(200, 20);
+ imsiLabel.setLocation(20, 0);
+
+ live = new JCheckBox("Last known position");
+ live.setSelected(true);
+ live.setLocation(20, 40);
+ live.setSize(200, 20);
+ live.addChangeListener(new ChangeListener() {
+ @Override
+ public void stateChanged(ChangeEvent e) {
+
+ if (live.isSelected()) {
+ imsiLabel.setText("IMSI");
+ // System.out.println("Enabled");
+ } else {
+ imsiLabel.setText("ActionRefID");
+ // System.out.println("Disabled");
+ }
+ }
+ });
+ JLabel confidenceLabel = new JLabel("Confidence");
+ confidenceLabel.setLocation(230, 0);
+ confidenceLabel.setSize(100, 20);
+
+ confidence = new TextField("0.75");
+ confidence.setLocation(230, 20);
+ confidence.setSize(60, 20);
+
+ history = new JCheckBox("Step by Step");
+ history.setLocation(20, 60);
+ history.setSize(200, 20);
+
+ filter = new JCheckBox("filter BTS");
+ filter.setLocation(20, 80);
+ filter.setSize(200, 20);
+ filter.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (filter.isSelected()) {
+ BTSFilter.showFilter(getGsmMap());
+ } else {
+ BTSFilter.hideFilter();
+ }
+
+ }
+ });
+
+ JButton getFromName = new JButton("Get IMSI");
+ getFromName.setLocation(20, 120);
+ getFromName.setSize(80, 20);
+ getFromName.addActionListener(new ImsiFromName());
+
+ JButton getActions = new JButton("Get Actions");
+ getActions.setLocation(120, 120);
+ getActions.setSize(120, 20);
+ getActions.addActionListener(new ActionFromIMSI());
+
+ control.add(input);
+ control.add(imsiLabel);
+ control.add(live);
+ control.add(confidenceLabel);
+ control.add(confidence);
+ control.add(history);
+ control.add(getFromName);
+ control.add(getActions);
+ control.add(filter);
+ control.setVisible(true);
+ }
+
+ private static JXMapKit getMapViewer() {
+ JXMapKit mapViewer = new JXMapKit();
+ // JXMapViewer
+ // Painter
+ // mapViewer.setDefaultProvider(DefaultProviders.OpenStreetMaps);
+ mapViewer.setDefaultProvider(DefaultProviders.Custom);
+
+ TileFactoryInfo ownTileFactory = new TileFactoryInfo(0, 18, 18, 256,
+ false, false, "http://c.tile.openstreetmap.org", "/", "/", "/") {
+ public String getTileUrl(int x, int y, int zoom) {
+ return this.baseURL + "/" + (18 - zoom) + "/" + x + "/" + y
+ + ".png";
+ }
+ };
+ mapViewer.setTileFactory(new DefaultTileFactory(ownTileFactory));
+
+ mapViewer.setDataProviderCreditShown(true);
+
+ try {
+ map = readGSM("parallel-strictdB-BER.obj");
+ mapViewer.setAddressLocation(new GeoPosition(
+ (map.minY + map.maxY) / 2, (map.minX + map.maxX) / 2));
+ mapViewer.setAddressLocationShown(true);
+ mapViewer.setZoom(1);
+ mapViewer.setCenterPosition(new GeoPosition(
+ (map.minY + map.maxY) / 2, (map.minX + map.maxX) / 2));
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ System.out.println("GSM-map not readable");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ System.out.println("GSM-map not readable");
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return mapViewer;
+ }
+
+ public static void setMapPainter(Painter<JXMapViewer> painter) {
+ mapViewer.getMainMap().setOverlayPainter(painter);
+ }
+
+ public static GSMMap getGsmMap() {
+ return map;
+ }
+
+ static private Interpolator readGSM(String filename)
+ throws FileNotFoundException, IOException, ClassNotFoundException {
+ System.out.println("trying to read GSM-map...");
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
+ filename));
+ Interpolator map = (Interpolator) ois.readObject();
+ System.out.println("GSMMap read successful");
+ return map;
+ }
+
+ public static long getIMSI() {
+ try {
+ return Long.parseLong(input.getText().trim());
+ } catch (Exception e) {
+ return 0;
+ }
+ }
+
+ public static void setIMSIorRef(long IMSI) {
+ try {
+ input.setText(Long.toString(IMSI));
+ } catch (NullPointerException e) {
+ setIMSIorRef(0);
+ }
+ }
+
+ public static void setLive(boolean value) {
+ live.setSelected(value);
+ }
+
+ public static boolean getLive() {
+ return live.isSelected();
+ }
+
+ public static boolean getStep() {
+ return history.isSelected();
+ }
+
+ public static boolean getFilter() {
+ return filter.isSelected();
+ }
+
+ public static void setFilter(boolean value) {
+ filter.setSelected(value);
+ }
+
+ public static double getConfidence() {
+ try {
+ return Double.parseDouble(confidence.getText().trim());
+ } catch (NumberFormatException e) {
+ return 0.75;
+ }
+ }
+}
+
+class ImsiFromName implements ActionListener {
+ // private name;
+ // JFrame result;
+ DefaultListModel listModel;
+ long[] IMSIs;
+
+ private void createFrame() {
+ final JFrame result = new JFrame("Search for IMSIs from Name");
+ result.setSize(400, 400);
+ JButton search = new JButton("search");
+
+ JButton ok = new JButton("OK");
+
+ final TextField name = new TextField();
+ listModel = new DefaultListModel();
+ final JList list = new JList(listModel);
+ list.setSelectionMode(0);
+ JScrollPane listScroller = new JScrollPane(list);
+ result.add(listScroller, BorderLayout.CENTER);
+ result.add(name, BorderLayout.NORTH);
+ result.add(ok, BorderLayout.SOUTH);
+ result.add(search, BorderLayout.EAST);
+ result.addWindowListener(new close());
+ result.setVisible(true);
+
+ search.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ IMSIs = searchForIMSI(name.getText().trim());
+ } catch (ClassNotFoundException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ }
+ });
+
+ ok.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // get choosen index within list
+ int i = list.getSelectedIndex();
+ try {
+ UserInterface.setIMSIorRef(IMSIs[i]);
+ UserInterface.setLive(true);
+ } catch (ArrayIndexOutOfBoundsException e1) {
+
+ } finally {
+ // result.dispose();
+ }
+
+ }
+ });
+
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ createFrame();
+
+ // result.dispose();
+
+ }
+
+ private long[] searchForIMSI(String name) throws ClassNotFoundException,
+ SQLException {
+ // clear the list-window
+ listModel.clear();
+
+ // get IMSIs for given name
+ name = name.trim();
+ Connection cn = getConnection();
+ // Connection is ready
+ // get IMSIs now...
+ Statement st = cn.createStatement();
+ st.setQueryTimeout(3);
+ ResultSet rs = st.executeQuery(query(name));
+ // IMSIs are now stored in rs.
+ ArrayList<Long> IMSIs = new ArrayList<Long>();
+ while (rs.next()) {
+ // add to result
+ IMSIs.add(rs.getLong("imsi"));
+ // add to list
+ listModel.addElement(rs.getLong("imsi") + " ("
+ + rs.getString("extension") + ")");
+ }
+ long[] result = new long[IMSIs.size()];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = IMSIs.get(i);
+ }
+ rs.close();
+ st.close();
+ cn.close();
+ return result;
+ }
+
+ private Connection getConnection() throws ClassNotFoundException,
+ SQLException {
+ Class.forName("com.mysql.jdbc.Driver");
+ Connection cn = DriverManager
+ .getConnection("jdbc:mysql://132.230.4.13:3306/hlr", "richard",
+ "uh237Aug.ad7");
+ cn.setReadOnly(true);
+ return cn;
+ }
+
+ private String query(String name) {
+
+ String query = "select imsi, extension from User JOIN UserWatch ON"
+ + " surname = '" + name + "' AND user_id = User.id "
+ + "JOIN Subscriber ON Subscriber.id = subscriber_id";
+
+ return query;
+ }
+
+}
+
+class ActionFromIMSI implements ActionListener {
+ DefaultListModel listModel;
+ long[] Actions;
+
+ private void createFrame() {
+ final JFrame result = new JFrame("Search for Actions from IMSI");
+ result.setSize(400, 400);
+ JButton search = new JButton("search");
+
+ JButton ok = new JButton("OK");
+
+ final TextField imsi = new TextField(Long.toString(UserInterface
+ .getIMSI()));
+ listModel = new DefaultListModel();
+ final JList list = new JList(listModel);
+ list.setSelectionMode(0);
+ JScrollPane listScroller = new JScrollPane(list);
+ result.add(listScroller, BorderLayout.CENTER);
+ result.add(imsi, BorderLayout.NORTH);
+ result.add(ok, BorderLayout.SOUTH);
+ result.add(search, BorderLayout.EAST);
+ result.addWindowListener(new close());
+ result.setVisible(true);
+
+ search.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ Actions = searchForAction(imsi.getText().trim());
+
+ } catch (ClassNotFoundException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ }
+
+ private long[] searchForAction(String imsi)
+ throws ClassNotFoundException, SQLException {
+ imsi = imsi.trim();
+ Connection cn = getConnection();
+ Statement st = cn.createStatement();
+ st.setQueryTimeout(3);
+ ResultSet rs = st.executeQuery(query(imsi));
+ ArrayList<Long> IDs = new ArrayList<Long>(500);
+ listModel.clear();
+ while (rs.next()) {
+ Date time = rs.getTimestamp("cur_timestamp");
+ String reason = rs.getString("name");
+ String actionID = rs.getString("id");
+ actionID current = new actionID(time, reason, actionID);
+ listModel.addElement(current);
+ IDs.add(Long.parseLong(actionID));
+ }
+
+ long[] result = new long[IDs.size()];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = IDs.get(i);
+ }
+ rs.close();
+ st.close();
+ cn.close();
+ return result;
+ }
+ });
+
+ ok.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // get choosen index within list
+ int i = list.getSelectedIndex();
+ try {
+ UserInterface.setIMSIorRef(Actions[i]);
+ UserInterface.setLive(false);
+ } catch (ArrayIndexOutOfBoundsException e1) {
+
+ } finally {
+ // result.dispose();
+ }
+
+ }
+ });
+
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ createFrame();
+ }
+
+ private Connection getConnection() throws ClassNotFoundException,
+ SQLException {
+ Class.forName("com.mysql.jdbc.Driver");
+ Connection cn = DriverManager.getConnection(
+ "jdbc:mysql://132.230.4.13:3306/logging", "richard",
+ "uh237Aug.ad7");
+ cn.setReadOnly(true);
+ return cn;
+ }
+
+ private String query(String imsi) {
+
+ String query = "Select action.cur_timestamp, action.id, "
+ + "Name from action JOIN actionIdentifier ON "
+ + "actionID = actionIdentifier.id WHERE " + "IMSI = '" + imsi
+ + "' ORDER BY action.id desc LIMIT 0,500";
+
+ return query;
+ }
+}
+
+class close implements WindowListener {
+
+ @Override
+ public void windowOpened(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ // ((JFrame) e.getSource()).dispose();
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ ((JFrame) e.getSource()).dispose();
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ // TODO Auto-generated method stub
+ // result.dispose();
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
+
+class quit implements WindowListener {
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ System.exit(0);
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowOpened(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
+
+class actionID {
+ Date time;
+ String reason;
+ String actionID;
+
+ public actionID(Date time, String reason, String actionID) {
+ this.time = time;
+ this.reason = reason;
+ this.actionID = actionID;
+ }
+
+ public String toString() {
+ return actionID + ": " + time + " (" + reason + ")";
+ }
+}
+
+class BTSFilter {
+ private static JCheckBox[] btsFilter;
+ private static JFrame filter;
+ private static GSMMap map;
+
+ static void showFilter(GSMMap GSMmap) {
+ map = GSMmap;
+ filter = new JFrame("filter BTS");
+ filter.addWindowListener(new WindowListener() {
+
+ @Override
+ public void windowOpened(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ UserInterface.setFilter(false);
+
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ UserInterface.setFilter(false);
+
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ filter.setSize(70, 250);
+ SingleBTS[] content = map.content();
+ btsFilter = new JCheckBox[content.length];
+ int y = 5;
+ filter.setLayout(null);
+ for (int i = 0; i < content.length; i++) {
+ btsFilter[i] = new JCheckBox(Integer.toString(content[i].ARFCN),
+ true);
+ btsFilter[i].setLocation(10, y);
+ btsFilter[i].setSize(70, 25);
+ y += 20;
+ filter.add(btsFilter[i]);
+ }
+ filter.validate();
+ filter.setVisible(true);
+ }
+
+ static void hideFilter() {
+ filter.setVisible(false);
+ }
+
+ static void filterMR(MobilePhone phone) {
+ SingleBTS[] content = map.content();
+ ArrayList<SingleBTS> result = new ArrayList<SingleBTS>();
+ for (int i = 0; i < content.length; i++) {
+ if (btsFilter[i].isSelected()) {
+ // add this BTS
+ ArrayList<SingleBTS> elementsToAdd = ListBTS.getAllARFCN(
+ phone.MR, content[i].ARFCN);
+ if (elementsToAdd != null)
+ result.addAll(elementsToAdd);
+ }
+ }
+ phone.MR = result;
+ }
+} \ No newline at end of file
diff --git a/gui/MapShow.java b/gui/MapShow.java
new file mode 100644
index 0000000..8e47897
--- /dev/null
+++ b/gui/MapShow.java
@@ -0,0 +1,38 @@
+package gui;
+
+@SuppressWarnings("serial")
+public class MapShow extends javax.swing.JFrame {
+
+ private org.jdesktop.swingx.JXMapKit jXMapKit1;
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ new MapShow().setVisible(true);
+
+ }
+ });
+
+ }
+
+ public MapShow() {
+ initComponents();
+ }
+
+ private void initComponents() {
+ jXMapKit1 = new org.jdesktop.swingx.JXMapKit();
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ jXMapKit1
+ .setDefaultProvider(org.jdesktop.swingx.JXMapKit.DefaultProviders.OpenStreetMaps);
+ getContentPane().add(jXMapKit1);
+ pack();
+
+ }
+
+}
diff --git a/gui/MapTest.java b/gui/MapTest.java
new file mode 100644
index 0000000..97d457d
--- /dev/null
+++ b/gui/MapTest.java
@@ -0,0 +1,119 @@
+package gui;
+
+import helper.ListBTS;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.geom.Point2D;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JFrame;
+
+import org.jdesktop.swingx.JXMapKit;
+import org.jdesktop.swingx.JXMapKit.DefaultProviders;
+import org.jdesktop.swingx.JXMapViewer;
+import org.jdesktop.swingx.mapviewer.GeoPosition;
+import org.jdesktop.swingx.painter.Painter;
+
+import DataStructure.GSMMap;
+import DataStructure.SingleBTS;
+
+public class MapTest {
+ public static void createGui() throws FileNotFoundException, IOException,
+ ClassNotFoundException {
+ JFrame frame = new JFrame();
+ frame.setVisible(true);
+ frame.setSize(400, 400);
+ JXMapKit mapViewer = new JXMapKit();
+ // JXMapViewer
+ // Painter
+ mapViewer.setDefaultProvider(DefaultProviders.OpenStreetMaps);
+ mapViewer.setDataProviderCreditShown(true);
+ frame.add(mapViewer);
+ System.out.println("da");
+
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
+ "interpolatedGSMMap.obj"));
+ GSMMap map = (GSMMap) ois.readObject();
+ SingleBTS[] content = map.content();
+ final ArrayList<GeoPosition> btss = new ArrayList<GeoPosition>();
+ for (int x = 0; x < map.Xcoords.length; x++) {
+ for (int y = 0; y < map.Ycoords.length; y++) {
+ SingleBTS current = ListBTS.getARFCN(map.map[x][y], content[0]);
+ if (current != null) {
+ btss.add(new GeoPosition(map.Ycoords[y], map.Xcoords[x]));
+ }
+ }
+ }
+
+ Painter<JXMapViewer> polygonOverlay = new Painter<JXMapViewer>() {
+
+ public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
+ g = (Graphics2D) g.create();
+ // convert from viewport to world bitmap
+ Rectangle rect = map.getViewportBounds();
+ g.translate(-rect.x, -rect.y);
+
+ // create a polygon
+ Polygon poly = new Polygon();
+ for (GeoPosition gp : btss) {
+ // convert geo to world bitmap pixel
+ Point2D pt = map.getTileFactory().geoToPixel(gp,
+ map.getZoom());
+ poly.addPoint((int) pt.getX(), (int) pt.getY());
+ }
+
+ // do the drawing
+ g.setColor(new Color(255, 0, 0, 100));
+ g.fill(poly);
+ g.setColor(Color.RED);
+ g.draw(poly);
+
+ g.dispose();
+ }
+
+ };
+ mapViewer.getMainMap().setOverlayPainter(polygonOverlay);
+
+ }
+
+ public static void main(String[] args) throws FileNotFoundException,
+ IOException, ClassNotFoundException {
+ createGui();
+
+ final List<GeoPosition> region = new ArrayList<GeoPosition>();
+ region.add(new GeoPosition(38.266, 12.4));
+ region.add(new GeoPosition(38.283, 15.65));
+ region.add(new GeoPosition(36.583, 15.166));
+ region.add(new GeoPosition(37.616, 12.25));
+ /*
+ * Painter<JXMapViewer> polygonOverlay = new Painter<JXMapViewer>() {
+ *
+ * public void paint(Graphics2D g, JXMapViewer map, int w, int h) { g =
+ * (Graphics2D) g.create(); // convert from viewport to world bitmap
+ * Rectangle rect = map.getViewportBounds(); g.translate(-rect.x,
+ * -rect.y);
+ *
+ * // create a polygon Polygon poly = new Polygon(); for (GeoPosition gp
+ * : region) { // convert geo to world bitmap pixel Point2D pt =
+ * map.getTileFactory().geoToPixel(gp, map.getZoom());
+ * poly.addPoint((int) pt.getX(), (int) pt.getY()); }
+ *
+ * // do the drawing g.setColor(new Color(255, 0, 0, 100));
+ * g.fill(poly); g.setColor(Color.RED); g.draw(poly);
+ *
+ * g.dispose(); }
+ *
+ * };
+ */
+
+ }
+
+} \ No newline at end of file
diff --git a/gui/MapViewer.java b/gui/MapViewer.java
new file mode 100644
index 0000000..3292fdf
--- /dev/null
+++ b/gui/MapViewer.java
@@ -0,0 +1,54 @@
+package gui;
+
+@SuppressWarnings("serial")
+public class MapViewer extends javax.swing.JFrame {
+
+ private org.jdesktop.swingx.JXMapKit jXMapKit1;
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ new MapViewer().setVisible(true);
+
+ }
+ });
+
+ }
+
+ public MapViewer() {
+ initComponents();
+ }
+
+ private void initComponents() {
+ // TileFactoryInfo test = new TileFactoryInfo(1, 14, 3, 50, true, true,
+ // "http://tile.openstreetmap.org/", "x", "y", "zoom");
+ /*
+ * TileFactoryInfo info = new TileFactoryInfo(0, // min level 8, // max
+ * allowed level 9, // max level 256, // tile size true, true, // x/y
+ * orientation is normal "http://wesmilepretty.com/gmap2/", // base url
+ * "x", "y", "z" // url args for x, y and z ) { public String
+ * getTileUrl(int x, int y, int zoom) { // int wow_zoom = 9 - zoom;
+ * String url = this.baseURL; // if (y >= Math.pow(2, wow_zoom - 1)) {
+ * // url = "http://int2e.com/gmapoutland2/"; // } return url + "zoom" +
+ * zoom + "maps/" + x + "_" + y + "_" + zoom + ".jpg"; } };
+ */
+
+ jXMapKit1 = new org.jdesktop.swingx.JXMapKit();
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ jXMapKit1
+ .setDefaultProvider(org.jdesktop.swingx.JXMapKit.DefaultProviders.OpenStreetMaps);
+ // jXMapKit1.setDefaultProvider(test);
+ // jXMapKit1.setTileFactory(new TileFactory(info));
+
+ getContentPane().add(jXMapKit1);
+ pack();
+
+ }
+
+}
diff --git a/gui/ShowMapStrength.java b/gui/ShowMapStrength.java
new file mode 100644
index 0000000..a74e064
--- /dev/null
+++ b/gui/ShowMapStrength.java
@@ -0,0 +1,309 @@
+package gui;
+
+import helper.ListBTS;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Label;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.awt.geom.Point2D;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+import javax.swing.JFrame;
+
+import org.jdesktop.swingx.JXMapKit;
+import org.jdesktop.swingx.JXMapKit.DefaultProviders;
+import org.jdesktop.swingx.JXMapViewer;
+import org.jdesktop.swingx.mapviewer.DefaultTileFactory;
+import org.jdesktop.swingx.mapviewer.GeoPosition;
+import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
+import org.jdesktop.swingx.painter.Painter;
+
+import DataStructure.GSMMap;
+import DataStructure.GSMMap.PaintEnum;
+import DataStructure.Interpolator;
+import DataStructure.SingleBTS;
+
+public class ShowMapStrength {
+ // private static blub overlay;
+ private static int index = 0;
+ private GSMMap.PaintEnum whatToPaint = GSMMap.PaintEnum.DL;
+ static int paintindex = 0;
+
+ /**
+ * @param args
+ * @throws IOException
+ * @throws FileNotFoundException
+ * @throws ClassNotFoundException
+ */
+ public static void main(String[] args) throws FileNotFoundException,
+ IOException, ClassNotFoundException {
+ JFrame frame = new JFrame();
+ // JFrame control = new JFrame();
+ frame.addWindowListener(new closeWindow());
+
+ frame.setSize(400, 400);
+ final JXMapKit mapViewer = new JXMapKit();
+ // JXMapViewer
+ // Painter
+ mapViewer.setDefaultProvider(DefaultProviders.OpenStreetMaps);
+ mapViewer.setDataProviderCreditShown(true);
+ frame.add(mapViewer, BorderLayout.CENTER);
+ Button knopf1 = new Button("change ARFCN");
+ Button knopf2 = new Button("Map -");
+ Button knopf3 = new Button("Map +");
+ frame.add(knopf1, BorderLayout.SOUTH);
+ frame.add(knopf2, BorderLayout.WEST);
+ frame.add(knopf3, BorderLayout.EAST);
+ final Label label1 = new Label();
+ frame.add(label1, BorderLayout.NORTH);
+
+ frame.setVisible(true);
+ System.out.println("da");
+ // ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
+ // "parallel.obj"));
+ ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
+ "parallel-strictdB-BER.obj"));
+ // ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
+ // "D:/parallel-strictdB-BER.obj"));
+ final Interpolator map = (Interpolator) ois.readObject();
+
+ System.out.println("GSMMap eingelesen");
+
+ mapViewer.setAddressLocation(new GeoPosition((map.minY + map.maxY) / 2,
+ (map.minX + map.maxX) / 2));
+ mapViewer.setZoom(1);
+ mapViewer.setAddressLocationShown(true);
+
+ mapViewer.setDefaultProvider(DefaultProviders.Custom);
+
+ TileFactoryInfo ownTileFactory = new TileFactoryInfo(0, 18, 18, 256,
+ false, false, "http://b.tile.openstreetmap.org", "/", "/", "/") {
+ public String getTileUrl(int x, int y, int zoom) {
+ return this.baseURL + "/" + (18 - zoom) + "/" + x + "/" + y
+ + ".png";
+ }
+ };
+ mapViewer.setTileFactory(new DefaultTileFactory(ownTileFactory));
+
+ mapViewer.setAddressLocation(new GeoPosition((map.minY + map.maxY) / 3,
+ (map.minX + map.maxX) / 3));
+ mapViewer.setAddressLocationShown(true);
+ mapViewer.setZoom(1);
+ mapViewer.setCenterPosition(new GeoPosition((map.minY + map.maxY) / 2,
+ (map.minX + map.maxX) / 2));
+
+ // overlay = new blub(map, map.content()[index]);
+ map.whatToPaint = GSMMap.PaintEnum.DL;
+ map.indexToPaint = 0;
+
+ mapViewer.getMainMap().setOverlayPainter(map);
+
+ knopf1.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ index++;
+ if (index > map.content().length - 1) {
+ index = 0;
+ }
+ map.indexToPaint = index;
+ mapViewer.getMainMap().setOverlayPainter(map);
+ // overlay = new blub(map, map.content()[index]);
+ // mapViewer.getMainMap().setOverlayPainter(
+ // (org.jdesktop.swingx.painter.Painter) overlay);
+ label1.setText("ARFCN:" + map.content()[index].ARFCN);
+ // label1.setAlignment(2);
+
+ }
+ });
+
+ knopf2.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // map.whatToPaint = GSMMap.PaintEnum.DL;
+ paintindex++;
+ if (paintindex > PaintEnum.values().length - 1) {
+ paintindex = 0;
+ }
+ map.whatToPaint = PaintEnum.values()[paintindex];
+ mapViewer.getMainMap().setOverlayPainter(map);
+ }
+ });
+ knopf3.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // map.whatToPaint = GSMMap.PaintEnum.variance;
+ // mapViewer.getMainMap().setOverlayPainter(map);
+ paintindex--;
+ if (paintindex < 0) {
+ paintindex = PaintEnum.values().length - 1;
+ }
+ map.whatToPaint = PaintEnum.values()[paintindex];
+ mapViewer.getMainMap().setOverlayPainter(map);
+
+ }
+ });
+
+ }
+}
+
+class blub implements Painter<JXMapViewer> {
+ private GSMMap gsmmap;
+ private SingleBTS what;
+
+ public blub(GSMMap map, SingleBTS what) {
+ this.gsmmap = map;
+ this.what = what;
+ }
+
+ public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
+ g = (Graphics2D) g.create();
+ // convert from viewport to world bitmap
+ Rectangle rect = ((org.jdesktop.swingx.JXMapViewer) map)
+ .getViewportBounds();
+ g.translate(-rect.x, -rect.y);
+
+ // draw each rectangle
+ for (int x = 0; x < gsmmap.Xcoords.length; x++) {
+ for (int y = 0; y < gsmmap.Ycoords.length; y++) {
+ SingleBTS current = ListBTS.getARFCN(gsmmap.map[x][y], what);
+ if (current != null) {
+ // draw it
+ double coordX = gsmmap.Xcoords[x];
+ double coordY = gsmmap.Ycoords[y];
+ double accuracy = gsmmap.accuracy;
+ Polygon tile = new Polygon();
+
+ GeoPosition pos1 = new GeoPosition(coordY - accuracy / 2,
+ coordX + accuracy / 2);
+ GeoPosition pos2 = new GeoPosition(coordY + accuracy / 2,
+ coordX + accuracy / 2);
+ GeoPosition pos3 = new GeoPosition(coordY + accuracy / 2,
+ coordX - accuracy / 2);
+ GeoPosition pos4 = new GeoPosition(coordY - accuracy,
+ coordX - accuracy);
+ Point2D pt1 = map.getTileFactory().geoToPixel(pos1,
+ map.getZoom());
+ Point2D pt2 = map.getTileFactory().geoToPixel(pos2,
+ map.getZoom());
+ Point2D pt3 = map.getTileFactory().geoToPixel(pos3,
+ map.getZoom());
+ Point2D pt4 = map.getTileFactory().geoToPixel(pos4,
+ map.getZoom());
+
+ // finally, draw it!
+ Color color = getColor((int) current.getDldB());
+ g.setColor(color);
+ tile.addPoint((int) pt1.getX(), (int) pt1.getY());
+ tile.addPoint((int) pt2.getX(), (int) pt2.getY());
+ tile.addPoint((int) pt3.getX(), (int) pt3.getY());
+ tile.addPoint((int) pt4.getX(), (int) pt4.getY());
+ g.fill(tile);
+ g.draw(tile);
+
+ }
+ }
+ }
+ g.dispose();
+ }
+
+ private Color getColor(int strength) {
+ int green = 0;
+ int red = 0;
+ // yellow at -75
+ if (strength > -75) {
+ green = 255;
+ red = 256 - Math.abs((256 / 45) * (-75 - strength));
+
+ } else {
+ // transient green from now on
+ red = 255;
+ green = Math.abs((256 / 45) * (-120 - strength));
+ }
+ // int green = 256 - Math.abs((256 / 90) * (-120 - strength));
+ // int red = Math.abs((256 / 90) * (-120 - strength));
+ // int result = red << 24 | green
+ if ((green > 255) || (red > 255))
+ System.out.println("Zu groß bei strength= " + strength + ",Rot: "
+ + red + "Grün: " + green);
+ if (green > 255)
+ green = 255;
+ if (red > 255)
+ red = 255;
+ // return ("7f00" + Integer.toHexString(red) +
+ // Integer.toHexString(green));
+ // return ("ff00" + Integer.toHexString(red) +
+ // Integer.toHexString(green));
+ // return ("ff00" + Integer.toHexString(red) +
+ // Integer.toHexString(green));
+
+ Color result = new Color(red, green, 0, 100);
+
+ // return ("ff00" + Integer.toHexString(green) +
+ // Integer.toHexString(red));
+ return result;
+
+ }
+
+}
+
+class closeWindow implements WindowListener {
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ // TODO Auto-generated method stub
+ ((JFrame) e.getSource()).dispose();
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ // TODO Auto-generated method stub
+ ((JFrame) e.getSource()).dispose();
+ System.exit(0);
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowOpened(WindowEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/gui/Start.java b/gui/Start.java
new file mode 100644
index 0000000..aaf05ba
--- /dev/null
+++ b/gui/Start.java
@@ -0,0 +1,64 @@
+package gui;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+public class Start extends JFrame {
+
+ private static final long serialVersionUID = 1L;
+ private JPanel jContentPane = null;
+ private JButton jButton = null;
+
+ /**
+ * This is the default constructor
+ */
+ public Start() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(664, 283);
+ this.setContentPane(getJContentPane());
+ this.setTitle("GSM");
+ }
+
+ /**
+ * This method initializes jContentPane
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ BorderLayout borderLayout = new BorderLayout();
+ borderLayout.setHgap(12);
+ borderLayout.setVgap(5);
+ jContentPane = new JPanel();
+ jContentPane.setLayout(borderLayout);
+ jContentPane.add(getJButton(), BorderLayout.SOUTH);
+ }
+ return jContentPane;
+ }
+
+ /**
+ * This method initializes jButton
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButton() {
+ if (jButton == null) {
+ jButton = new JButton();
+ jButton.setText("test");
+ }
+ return jButton;
+ }
+
+} // @jve:decl-index=0:visual-constraint="10,10"
diff --git a/gui/test.java b/gui/test.java
new file mode 100644
index 0000000..a2ce839
--- /dev/null
+++ b/gui/test.java
@@ -0,0 +1,72 @@
+package gui;
+
+import java.awt.Button;
+import java.awt.Frame;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+
+public class test {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Frame f = new Frame();
+ f.setSize(600, 400);
+ Button test = new Button("ein Test");
+ // f.setLayout(new FlowLayout());
+ f.setLayout(null);
+ test.setLocation(10, 10);
+ test.setSize(25, 25);
+ f.add(test);
+ Button test2 = new Button("ein zweiter Test");
+ test2.setLocation(50, 100);
+ test2.setSize(25, 30);
+ f.add(test2);
+ f.validate();
+ f.setVisible(true);
+ f.addWindowListener(new WindowListener() {
+
+ @Override
+ public void windowOpened(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowIconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void windowClosing(WindowEvent arg0) {
+ System.exit(0);
+ }
+
+ @Override
+ public void windowClosed(WindowEvent arg0) {
+ System.exit(0);
+
+ }
+
+ @Override
+ public void windowActivated(WindowEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+}