📄 placelabstumblergui.java
字号:
fixZoomSlider(); } else { mapView2.zoomOut(); } } protected void displayPlacelabReticle() { } protected void buildMapViews() { GridData gridData; /* create a group to hold all the tracked map view stuff */ Label seperatorLabel = new Label(wifiTableController.body, SWT.SEPARATOR | SWT.HORIZONTAL); gridData = new GridData(GridData.FILL_HORIZONTAL); seperatorLabel.setLayoutData(gridData); tmvGroup = new Group(sash, SWT.SHADOW_ETCHED_IN); tmvGroup.setText("Mini Map"); //tmvGroup.setBounds(gap,wifiHistoryTable.getBounds().y + wifiHistoryTable.getBounds().height + gap,500,300); //tmvGroup.setBounds(gap,historyLabel.getBounds().y + historyLabel.getBounds().height + gap,500,300); //tmvGroup.setBounds(gap,wifiActiveTable.getBounds().y + wifiActiveTable.getBounds().height + gap,500,300); tmvGroup.setVisible(true); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; //gridData.grabExcessHorizontalSpace = true; //gridData.grabExcessVerticalSpace = true; gridData.heightHint = 250; //gridData.widthHint = 500; tmvGroup.setLayoutData(gridData); GridLayout tmvLayout = new GridLayout(); tmvLayout.numColumns = 2; tmvGroup.setLayout(tmvLayout); /*mapHolderGroup = new Group(tmvGroup, SWT.BORDER); //mapHolderGroup.setLocation(gap, gap*3); //mapHolderGroup.setBounds(gap, gap * 3, 300, 270); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 1; gridData.widthHint = 300; gridData.heightHint = 250; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; mapHolderGroup.setLayoutData(gridData); GridLayout mapLayout = new GridLayout(); mapLayout.numColumns = 1; mapLayout.marginHeight = 0; mapLayout.marginWidth = 0; mapHolderGroup.setLayout(mapLayout);*/ /*tmvLabel = new Label(mapHolderGroup,SWT.NONE); tmvLabel.setLocation(0,0); //tmvLabel.setBounds(gap,gap*3,300,270); //tmvLabel.setLocation(gap,gap); tmvLabel.setBackground(new Color(display,242,255,179)); tmvLabel.setText(loadMessage); gridData = new GridData(GridData.FILL_BOTH); gridData.heightHint = 250; gridData.widthHint = 300; tmvLabel.setLayoutData(gridData); tmvLabel.setVisible(true);*/ // stumbler tab's map view mapView1 = new TrackedMapView(tmvGroup, SWT.NONE, tracker, mapper); mapView1.setVisible(true); mapView1.setShowBeacons(false); mapView1.setAutoScroll(true); gridData = new GridData(GridData.FILL_BOTH); gridData.horizontalSpan = 1; mapView1.setLayoutData(gridData); Composite mapControls = new Composite(tmvGroup, SWT.NONE); gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gridData.horizontalSpan = 1; //gridData.heightHint = 270; mapControls.setLayoutData(gridData); GridLayout mapControlLayout = new GridLayout(); mapControlLayout.numColumns = 1; mapControls.setLayout(mapControlLayout); // zoom label and scale Label tmvZoomLabel = new Label(mapControls,SWT.NONE); //tmvZoomLabel.setBounds(300+gap*3,gap*3,150,20); //tmvZoomLabel.setLocation(300+gap*3, gap*3); tmvZoomLabel.setText("Zoom Level"); tmvZoomLabel.setVisible(true); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 1; gridData.verticalSpan = 1; tmvZoomLabel.setLayoutData(gridData); tmvZoomScale = new Scale(mapControls,SWT.HORIZONTAL); tmvZoomScale.setMinimum(0); tmvZoomScale.setMaximum(120); tmvZoomScale.setPageIncrement(20); tmvZoomScale.setSelection(60); tmvZoomScale.setVisible(true); tmvZoomScale.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { checkZoomLevel(); } public void widgetDefaultSelected(SelectionEvent e) { } }); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 1; gridData.verticalSpan = 1; gridData.widthHint = 150; gridData.heightHint = 20; tmvZoomScale.setLayoutData(gridData); // check boxes Composite positionComp = new Composite(mapControls, SWT.NONE); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 1; gridData.verticalSpan = 1; positionComp.setLayoutData(gridData); tmvBtnPosition = new Button(positionComp,SWT.CHECK); tmvBtnPosition.setBounds(0,0,20,20); tmvBtnPosition.setVisible(true); Label tmvLblPosition = new Label(positionComp,SWT.NONE); tmvLblPosition.setText("Show My Position"); tmvLblPosition.setBounds(25, 0, 140, 15); tmvLblPosition.setVisible(true); Composite trackComp = new Composite(mapControls, SWT.NONE); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 1; gridData.verticalSpan = 1; trackComp.setLayoutData(gridData); tmvBtnTrack = new Button(trackComp,SWT.CHECK); tmvBtnTrack.setBounds(0,0,20,20); tmvBtnTrack.setVisible(true); tmvBtnTrack.setEnabled(false); Label tmvLblTrack = new Label(trackComp,SWT.NONE); tmvLblTrack.setText("Track My Movement"); tmvLblTrack.setBounds(25,0,140,15); tmvLblTrack.setVisible(true); Composite scrollComp = new Composite(mapControls, SWT.NONE); gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gridData.horizontalSpan = 1; gridData.verticalSpan = 1; scrollComp.setLayoutData(gridData); scrollComp.setVisible(true); tmvBtnScroll = new Button(scrollComp, SWT.CHECK); tmvBtnScroll.setBounds(0,0,20,20); tmvBtnScroll.setVisible(true); Label tmvLblScroll = new Label(scrollComp, SWT.NONE); tmvLblScroll.setText("Auto-Scroll Map"); tmvLblScroll.setBounds(25,0,140,15); tmvLblScroll.setVisible(true); boolAutoScroll = true; tmvBtnScroll.setSelection(true); tmvBtnScroll.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { toggleAutoScroll(); } public void widgetDefaultSelected(SelectionEvent e) { } }); /* * MAP TAB GUI SETUP */ // map tab's big map view /*mapView2 = new TrackedMapView(item2Comp, SWT.NONE, daemon); mapView2.setLayoutData(new GridData(GridData.FILL_BOTH)); mapView2.setBounds(gap,gap,shell.getClientArea().width-gap*5,shell.getClientArea().height-gap*8); mapView2.setVisible(true); mapView2.setShowBeacons(false); mapView2.setAutoScroll(true);*/ if(tmvBigLabel != null && !tmvBigLabel.isDisposed()) { tmvBigLabel.dispose(); tmvBigLabel = null; } //phantomHolder = new Composite(item2Comp, SWT.NONE); //phantomHolder.setLayoutData(new GridData(GridData.FILL_BOTH)); phantom = new PhantomView(mapView1.getHolder(), item2Comp, SWT.NONE); phantom.setLayoutData(new GridData(GridData.FILL_BOTH)); item2Comp.layout(); int[] weights = new int[tableCount + 1]; int i; for(i = 0; i < tableCount; i++) { weights[i] = 60 / tableCount; } weights[tableCount] = 40; sash.setWeights(weights); // Object[] children = sash.getChildren();// System.out.println("length " + children.length);// for (int z = 0; z < children.length; z++){// System.out.println("child " + z + ": " + children[z].getClass().toString());// }//// System.out.println("look at my children: " + children); item1Comp.layout(); } public void widgetDefaultSelected(SelectionEvent ee){ System.out.println("widgetDefaultSelected fired"); } private static long getDefaultTimeout() { long timeout = 2000; try { timeout = Long.parseLong( PlacelabProperties.get("placelab.StumblerFunnel.timeout")); } catch (NumberFormatException nfe) { } return timeout; } protected void beginStumbling() throws IOException { eventQueue = new Vector(); wifi = new WiFiSpotter(); boolean stumbleBT = PlacelabProperties.get("placelab.stumble_bluetooth"). equalsIgnoreCase("true"); String btgsm = PlacelabProperties.get("placelab.cellphone"); boolean stumbleGSM = (btgsm != null) && (btgsm.length() > 0); if (stumbleBT) { bluetooth = new BluetoothSpotter(); } if(stumbleGSM) { System.out.println("Making RemoteGSM..."); gsm = new RemoteGSMSpotter(btgsm,false); } try { wifi.open(); } catch (SpotterException e) { wifi = null; e.printStackTrace(); } //wifi = null; if(bluetooth != null) { try { bluetooth.open(); } catch (SpotterException e) { bluetooth = null; e.printStackTrace(); } } if(gsm != null) { try { gsm.open(); } catch (SpotterException e) { gsm = null; e.printStackTrace(); } } logWriter = new LogWriter(); funnel = new StumblerFunnel(getDefaultTimeout()); setupGPS(); // the 500 argument to a SpotterExtension when the second argument is true // means that we know wifi returns with a quickness, but nonetheless we don't // want it to be polled more frequently than once every 500ms ( // (this is because there is a 300ms minimum for wifi scans on windows // and in practice this is a bit longer. // -- lowest common denominator and all that) if(wifi != null) { long scanMinimum = 500; long timeout = getDefaultTimeout(); if(scanMinimum < timeout) scanMinimum = timeout; wifiExtension = new SpotterExtension(wifi, true, -1); try { wifiExtension.open(); } catch (SpotterException se) { se.printStackTrace(); } funnel.addDependentSpotter(wifiExtension); } if(gsm != null) { gsmExtension = new SpotterExtension(gsm, false, 20000); try { gsmExtension.open(); } catch (SpotterException se) { se.printStackTrace(); } funnel.addIndependentSpotter(gsmExtension); } if(bluetooth != null) { // we say that bluetooth spotters aren't stale until 11 seconds bluetoothExtension = new SpotterExtension(bluetooth, false, 11000); funnel.addIndependentSpotter(bluetoothExtension); } funnel.addUpdateListener(logWriter); funnel.addShutdownListener(logWriter); funnel.addUpdateListener(this); if(Cmdline.getArg("audio") != null) { funnel.addUpdateListener(new AudioNotifier()); } funnel.start(); } protected void resetGPS() { PlacelabProperties.set("placelab.gps_device", ""); setupGPS(); } protected void setupGPS() { if(gps != null) { try { gpsExtension.close(); } catch (SpotterException e) { errorDialog("GPS Error", e); } if(funnel != null) { funnel.suspendListen(); funnel.removeSpotter(gpsExtension); funnel.resumeListen(); } gps = null; gpsExtension = null; } if(PlacelabProperties.get("placelab.gps_device").length() == 0) { doGPSPref(); } if(bluetooth != null && // if i couldn't open the bluetooth spotter, i can't open bt gps PlacelabProperties.get("placelab.gps_device").equalsIgnoreCase("bluetooth")) { // specifying false here means that the InquiryBluetoothGPSSpotter doesn't // do inquiries for bluetooth gps devices. Instead, BluetoothSpotter // feeds it readings through the SpotterListener interface. In this way, // the two don't fight for who gets to do inquiries. // the 30000 means that if it can't establish connections with any newly // found gps devices, it will wait 30 seconds before trying the same ones // again, so long as those same ones are still being seen. gps = new ListenerBluetoothGPSSpotter(bluetooth); } else if(PlacelabProperties.get("placelab.gps_device").length() >= 0) { gps = new SerialGPSSpotter(); } if(gps != null) { try { gps.open(); } catch (SpotterException e) { gps = null; e.printStackTrace(); } } if(gps != null) { gpsExtension = new SpotterExtension(gps, false, SpotterExtension.GPS_STALE_TIME); funnel.suspendListen(); funnel.addTriggerSpotter(gpsExtension); funnel.resumeListen(); } // XXX: hack to get timeout lines Vector criticalSpotters = new Vector(); if(gps != null) criticalSpotters.addElement(gps); logWriter.criticalSpotters = criticalSpotters; } protected boolean doGPSPref() { // get the serial ports for the system Vector ports = new Vector(); Enumeration e = CommPortIdentifier.getPortIdentifiers(); while(e.hasMoreElements()) { CommPortIdentifier cpi = (CommPortIdentifier)e.nextElement(); if(cpi.getPortType() == CommPortIdentifier.PORT_SERIAL) { ports.addElement(cpi.getName()); } } String[] portsS = new String[ports.size()]; ports.copyInto(portsS); String q1 = "Scan for nearby bluetooth gps devices"; String q2 = "Or, use a serial gps device (choose port)"; String q3 = "Choose the serial port your gps is connected to"; // run a dialog to get the user's preference about gps Vector questions = new Vector(); if(bluetooth != null) { // this computer can support using InquiryBluetoothGPSSpotter QuestionBox.QuestionPackage qp = new QuestionBox.QuestionPackage( q1, true); questions.addElement(qp); qp = new QuestionBox.QuestionPackage( q2, portsS, false); questions.addElement(qp); } else { QuestionBox.QuestionPackage qp = new QuestionBox.QuestionPackage( q3, portsS, false); questions.addElement(qp); } QuestionBox qb = new QuestionBox(shell, questions, "Setup GPS Preferences");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -