Added ETX factor to convert the ETX value
This commit is contained in:
parent
6e28b1d3fb
commit
39d1e09232
1 changed files with 23 additions and 6 deletions
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: MapPanel.java,v 1.5 2010/10/12 22:26:56 nifi Exp $
|
||||
* $Id: MapPanel.java,v 1.6 2010/10/22 11:04:04 nifi Exp $
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
|
@ -34,8 +34,8 @@
|
|||
*
|
||||
* Authors : Joakim Eriksson, Niclas Finne
|
||||
* Created : 3 jul 2008
|
||||
* Updated : $Date: 2010/10/12 22:26:56 $
|
||||
* $Revision: 1.5 $
|
||||
* Updated : $Date: 2010/10/22 11:04:04 $
|
||||
* $Revision: 1.6 $
|
||||
*/
|
||||
|
||||
package se.sics.contiki.collect.gui;
|
||||
|
@ -55,13 +55,17 @@ import java.awt.event.ComponentEvent;
|
|||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
@ -132,6 +136,8 @@ public class MapPanel extends JPanel implements Configurable, Visualizer, Action
|
|||
private int layoutAttract = 50;
|
||||
private int layoutGravity = 1;
|
||||
|
||||
private double etxFactor = 1.0;
|
||||
|
||||
private boolean isLayoutActive = true;
|
||||
private boolean hideNetwork = false;
|
||||
|
||||
|
@ -212,8 +218,19 @@ public class MapPanel extends JPanel implements Configurable, Visualizer, Action
|
|||
});
|
||||
configPanel.add(slider);
|
||||
|
||||
add(configPanel);
|
||||
final JFormattedTextField etxField = new JFormattedTextField(new Double(etxFactor));
|
||||
etxField.setBorder(BorderFactory.createTitledBorder("ETX factor"));
|
||||
etxField.setColumns(5);
|
||||
etxField.addPropertyChangeListener("value", new PropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
etxFactor = ((Number)etxField.getValue()).doubleValue();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
configPanel.add(etxField);
|
||||
|
||||
configPanel.setVisible(false);
|
||||
add(configPanel);
|
||||
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
public void componentResized(ComponentEvent ev) {
|
||||
|
@ -477,7 +494,7 @@ public class MapPanel extends JPanel implements Configurable, Visualizer, Action
|
|||
dy += fnHeight - fnDescent;
|
||||
}
|
||||
g.drawString(
|
||||
Double.toString(((int) (link.getETX() * 100 + 0.5)) / 100.0),
|
||||
Double.toString(((int) (link.getETX() * etxFactor * 100 + 0.5)) / 100.0),
|
||||
dx, dy);
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +580,7 @@ public class MapPanel extends JPanel implements Configurable, Visualizer, Action
|
|||
double vy = n2.y - n.y;
|
||||
double dist = Math.sqrt(vx * vx + vy * vy);
|
||||
dist = dist == 0 ? 0.00001 : dist;
|
||||
double etx = link.getETX();
|
||||
double etx = link.getETX() * etxFactor;
|
||||
if (etx > 5) etx = 5;
|
||||
double factor = (etx * layoutAttract - dist) / (dist * 3);
|
||||
double dx = factor * vx;
|
||||
|
|
Loading…
Reference in a new issue