diff -ur JiGLE/org/mimezine/jigle/JiGLEBaseStation.java JiGLEnew/org/mimezine/jigle/JiGLEBaseStation.java --- JiGLE/org/mimezine/jigle/JiGLEBaseStation.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLEBaseStation.java 2004-05-25 03:17:28.000000000 -0400 @@ -37,6 +37,7 @@ import java.awt.*; import java.awt.font.*; import java.awt.geom.*; +import java.text.*; import java.util.*; import org.mimezine.geo.*; import org.mimezine.codec.ns1.*; @@ -53,14 +54,11 @@ */ public final class JiGLEBaseStation extends JiGLEStation { public static final String VERSION_ID = - "$Id: JiGLEBaseStation.java,v 1.41 2004/05/04 02:09:56 uhtu Exp $"; + "$Id: JiGLEBaseStation.java,v 1.42 2004/05/24 03:39:35 uhtu Exp $"; /** the logger for this class. */ private static final Logger log = Logger.getLogger( JiGLEBaseStation.class.getName() ); - /** val, unused. */ // XXX: find out what this is for, or clean it up. - private int val; - /** station BSSID */ private String BSSID; @@ -88,9 +86,9 @@ /** is wep on? */ private boolean wep; - /** when this station was found. */ // XXX: should be Date? - private String foundOn; - + /** when this station was found. */ + private Date foundOn; + /** the color of the station qos */ private Color qosColor = STATION_BORDER; @@ -150,6 +148,8 @@ private static int CURN_HEIGHT_MEMO = -1; + private SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); + /** default constructor */ public JiGLEBaseStation() { } @@ -161,14 +161,12 @@ * @param c the color of this station * @param n the name of this station * @param i the id of this station. - * @param v the value of this station */ - public JiGLEBaseStation( GPSPoint g, java.awt.Color c, String n, String i, - int v) { + public JiGLEBaseStation( GPSPoint g, java.awt.Color c, String n, String i) { super( g, c, n, i ); - val = v; } + /** * value constructor with latitude and longitude. * @@ -185,25 +183,22 @@ * @param commented the user comment * @param qos the QOS * @param isWep is WEP on for this station? - * @param v the value - * @param lastUpdate seconds since the epoch when this JiGLEStation was last updated + * @param lastUpdate when this JiGLEStation was last updated */ public JiGLEBaseStation( float lat, float lon, java.awt.Color c, String n, - String i, String bssid, String ifind, int chan, String mode, - String fndondate, String commented, int qos, boolean isWep, int v, - long lastUpdate ) { - + String i, String bssid, String ifind, int chan, String mode, + Date fndondate, String commented, int qos, boolean isWep, + Date lastUpdate ) { super( lat, lon, c, n, i ); channel = chan; finder = ifind; BSSID = bssid; - val = v; stnMode = mode; wep = isWep; this.qos = qos; comment = commented; - foundOn = fndondate; - this.lastUpdate = lastUpdate; + foundOn = new Date(fndondate.getTime()); + this.lastUpdate = new Date(lastUpdate.getTime()); initQOSColor(); } @@ -231,8 +226,8 @@ wep = isWep; this.qos = qos; comment = commented; - foundOn = ap.getFirstSeen().toString(); - lastUpdate = ap.getLastSeen().getTime(); + foundOn = ap.getFirstSeen(); + lastUpdate = ap.getLastSeen(); initQOSColor(); } @@ -252,7 +247,25 @@ wep = Boolean.valueOf( (String) atts.get("wep") ).booleanValue(); comment = (String) atts.get("comment"); qos = Integer.parseInt( (String)atts.get("qos") ); - lastUpdate = Long.parseLong( (String)atts.get("lastupdt") ); + synchronized(df) { + try { + lastUpdate = df.parse( (String)atts.get("lastupdt") ); + } catch(ParseException e){ + log.log(Level.FINE,"excepted parsing:"+atts.get("lastupdt"),e); + lastUpdate = new Date(0); + } + } + { + long ft = 0; + try { + ft = Long.parseLong((String) atts.get("firsttime")); + foundOn = new Date(ft); + } catch (Exception ex) { + log.log(Level.FINE,"excepted parsing"+atts.get("firsttime"),ex); + foundOn = new Date (0); + } + } + onlyMine = Boolean.valueOf( (String) atts.get("userfound") ).booleanValue(); initQOSColor(); @@ -278,20 +291,6 @@ return qosColor; } - /** - * set the station value. - * @param v the value. - */ - public void setStationValue( int v ) { - val = v; - } - - /** - * @return the station value - */ - public int getStationValue() { - return val; - } /** * set the BSSID. @@ -431,17 +430,17 @@ /** * sets the found date. - * @param date the found date string. + * @param date the found date */ - public void setStationFoundDate( String date ) { - foundOn = date; + public void setStationFoundDate( Date date ) { + foundOn = new Date(date.getTime()); } /** - * @return the found date string + * @return the found date */ - public String getStationFoundDate() { - return foundOn; + public Date getStationFoundDate() { + return new Date(foundOn.getTime()); } /** @@ -490,6 +489,13 @@ return EMPTY_RECTANGLE_ARRAY; } + if ( getOnlyMine() && + Preferences.getBoolean( Preferences.NOT_MINE_KEY ) ) { + // is a mine, which is all we want + lastRect = EMPTY_RECTANGLE_ARRAY; + return EMPTY_RECTANGLE_ARRAY; + } + if ( ! getStationFreenet() && Preferences.getBoolean( Preferences.FREENET_KEY ) ) { // not a freenet, which is all we want diff -ur JiGLE/org/mimezine/jigle/JiGLEDataSet.java JiGLEnew/org/mimezine/jigle/JiGLEDataSet.java --- JiGLE/org/mimezine/jigle/JiGLEDataSet.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLEDataSet.java 2004-05-29 00:06:17.000000000 -0400 @@ -2,7 +2,7 @@ // vim:ts=2:sw=2:tw=80:et /* - * Copyright (c) 2002-2003, Andrew Carra and Robert Hagemann + * Copyright (c) 2002-2004, Andrew Carra and Robert Hagemann * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ */ public class JiGLEDataSet { public static final String VERSION_ID = - "$Id: JiGLEDataSet.java,v 1.21 2004/05/10 03:53:12 bobzilla Exp $"; + "$Id: JiGLEDataSet.java,v 1.22 2004/05/24 03:39:35 uhtu Exp $"; /** the logger for this class. */ private static final Logger log = Logger.getLogger( JiGLEDataSet.class.getName() ); @@ -57,8 +57,20 @@ // as JiGLEStations are mutable, this is.. tricky. private TreeNode stations; - /** seconds since epoch that the most recently updated JiGLEStation in this Set was updated. */ - private long lastUpdate = 0; + /** when the most recently updated JiGLEStation in this Set was updated. */ + private Date firstLastUpdate = new Date(0); + private Date lastLastUpdate = new Date(0); + private Date firstNetworkDate = new Date(0); + private Date lastNetworkDate = new Date(0); + + private long numWep = 0; + private long numNotWep = 0; + private long numFree = 0; + private long numNotFree = 0; + private long numPay = 0; + private long numNotPay = 0; + private long numMine = 0; + private long numNotMine = 0; /** * default constructor @@ -76,7 +88,7 @@ /** * add a JiGLEStation. - * The station should have a lastUpdate of 0 unless it comes from the server + * The station should have a lastLastUpdate of 0 unless it comes from the server * JiGLEStations already in this JiGLEDataSet will be replaced by newer ones. * This relies on the caller implementing a sane hashcode for the station. * @param s the JiGLEStation to add or update @@ -86,17 +98,37 @@ return; } - if ( newStation.getStationLastUpdate() > lastUpdate ) { - lastUpdate = newStation.getStationLastUpdate(); + if ( (newStation.getStationLastUpdate().compareTo(firstLastUpdate) < 0) + || (firstLastUpdate.getTime() == 0) ) { + firstLastUpdate = newStation.getStationLastUpdate(); + } + + if ( newStation.getStationLastUpdate().compareTo(lastLastUpdate) > 0 ) { + lastLastUpdate = newStation.getStationLastUpdate(); + } + + if ( newStation instanceof JiGLEBaseStation ) + { + if ( +(((JiGLEBaseStation)newStation).getStationFoundDate().compareTo(firstNetworkDate) +< 0) || (firstNetworkDate.getTime() == 0)) { + firstNetworkDate = ((JiGLEBaseStation)newStation).getStationFoundDate(); + } + + if ( ((JiGLEBaseStation)newStation).getStationFoundDate().compareTo(lastNetworkDate) > 0 ) { + lastNetworkDate = ((JiGLEBaseStation)newStation).getStationFoundDate(); + } } // O(1) good. if ( stations.containsKey( newStation ) ) { JiGLEStation old = (JiGLEStation) stations.get( newStation ); - if ( newStation.getStationLastUpdate() > old.getStationLastUpdate() ) { + if ( newStation.getStationLastUpdate().compareTo( old.getStationLastUpdate() ) > 0 ) { stations.remove( newStation ); + removeStationFromStats( newStation ); stations.add( newStation, newStation.getLocation(), 0f ); + addStationToStats( newStation ); } else { if ( log.isLoggable ( Level.FINEST ) ) { @@ -106,6 +138,69 @@ } else { stations.add( newStation, newStation.getLocation(), 0f ); + addStationToStats( newStation ); + } + } + + public void addStationToStats( JiGLEStation newStation ) + { + if ( newStation instanceof JiGLEBaseStation ) + { + if (((JiGLEBaseStation)newStation).getStationWep()) + { + numWep++; + } else { + numNotWep++; + } + if (((JiGLEBaseStation)newStation).getStationFreenet()) + { + numFree++; + } else { + numNotFree++; + } + if (((JiGLEBaseStation)newStation).getStationPaynet()) + { + numPay++; + } else { + numNotPay++; + } + if (((JiGLEBaseStation)newStation).getOnlyMine()) + { + numMine++; + } else { + numNotMine++; + } + } + } + + public void removeStationFromStats( JiGLEStation newStation ) + { + if ( newStation instanceof JiGLEBaseStation ) + { + if (((JiGLEBaseStation)newStation).getStationWep()) + { + numWep--; + } else { + numNotWep--; + } + if (((JiGLEBaseStation)newStation).getStationFreenet()) + { + numFree--; + } else { + numNotFree--; + } + if (((JiGLEBaseStation)newStation).getStationPaynet()) + { + numPay--; + } else { + numNotPay--; + } + if (((JiGLEBaseStation)newStation).getOnlyMine()) + { + numMine--; + } else { + numNotMine--; + } } } @@ -139,10 +234,87 @@ } /** - * Return the largest lastUpdate we've seen. (seconds since epoch) + * Return the latest lastLastUpdate we've seen. + */ + public Date getFirstLastUpdate() { + return new Date(firstLastUpdate.getTime()); + } + + /** + * Return the latest lastLastUpdate we've seen. + */ + public Date getLastLastUpdate() { + return new Date(lastLastUpdate.getTime()); + } + + /** + * Return the latest found date we've seen. + */ + public Date getLastFoundDate() { + return new Date(lastNetworkDate.getTime()); + } + + /** + * Return the earlier found date we've seen. + */ + public Date getFirstFoundDate() { + return new Date(firstNetworkDate.getTime()); + } + + /** + * Return the number of wep stations in dataSet we've seen. + */ + public long getNumWep() { + return numWep; + } + + /** + * Return the number of wep stations in dataSet we've seen. + */ + public long getNumNotWep() { + return numNotWep; + } + + /** + * Return the number of wep stations in dataSet we've seen. + */ + public long getNumFree() { + return numFree; + } + + /** + * Return the number of wep stations in dataSet we've seen. + */ + public long getNumNotFree() { + return numNotFree; + } + + /** + * Return the number of wep stations in dataSet we've seen. + */ + public long getNumPay() { + return numPay; + } + + /** + * Return the number of wep stations in dataSet we've seen. + */ + public long getNumNotPay() { + return numNotPay; + } + + /** + * Return the number of wep stations in dataSet we've seen. + */ + public long getNumMine() { + return numMine; + } + + /** + * Return the number of wep stations in dataSet we've seen. */ - public long getLastUpdate() { - return lastUpdate; + public long getNumNotMine() { + return numNotMine; } /** diff -ur JiGLE/org/mimezine/jigle/JiGLE.java JiGLEnew/org/mimezine/jigle/JiGLE.java --- JiGLE/org/mimezine/jigle/JiGLE.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLE.java 2004-05-24 15:05:18.000000000 -0400 @@ -85,6 +85,7 @@ private static JiGLE jigleApp; public static final String VERNUM = "0.7.2.20040516213000"; + private static final String PROPERTIES_FILE_NAME = "JiGLE.properties"; private static final String MAPPACK_FILE_KEY = ".mappack"; private static final String MAPPACK_LOC_KEY = "JiGLEMap/maps/"; diff -ur JiGLE/org/mimezine/jigle/JiGLEMapper.java JiGLEnew/org/mimezine/jigle/JiGLEMapper.java --- JiGLE/org/mimezine/jigle/JiGLEMapper.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLEMapper.java 2004-05-29 00:16:01.000000000 -0400 @@ -67,7 +67,7 @@ PreferencesListener { public static final String VERSION_ID = - "$Id: JiGLEMapper.java,v 1.101 2004/05/10 03:53:12 bobzilla Exp $"; + "$Id: JiGLEMapper.java,v 1.102 2004/05/24 03:39:35 uhtu Exp $"; /** the logger for this class. */ private static final Logger log = Logger.getLogger( JiGLEMapper.class.getName() ); @@ -91,8 +91,6 @@ // coords: displayed map private JiGLEViewPort currentVP; private JiGLEViewPort lastVP; - // panel for adding new stations - private JiGLEAddDialog adder; // our kismet listener private JiGLEKismetListener kismetListener; @@ -115,7 +113,6 @@ public static final int ZOOMIN = 1; public static final int ZOOMOUT = 2; public static final int SELECTSTATION = 3; - public static final int SELECTPOINT = 4; public static final int SHOWGPSPOS = 5; //current zoom depth from top, top=0 @@ -173,6 +170,9 @@ // add ourselves to preferences events Preferences.addListener( this ); + //filterq.addFilter( new DateFilter() ); + filterq.addFilter( new DateFilter() ); + ImageFilter scaler; this.wigle = wigle; this.squigle = squigle; @@ -659,28 +659,6 @@ break; - case SELECTPOINT: - where = pix2Geo(new Point(e.getX(), e.getY())); - - // System.out.println("GPS Lat=" + where.getLat() + " Lon=, " - // + where.getLon()); - Frame f = getFrame(); - adder = new JiGLEAddDialog( f, where, eventProcessor ); - adder.setLocation( e.getX() + f.getLocation().x, - e.getY() + f.getLocation().y ); - adder.show(); - - // System.out.println(adder.getResult()); - // if result==ok, - // we could add the station to our dataset here - // avoiding req'ing and update from the server - - // throw a point event - eventProcessor.broadcastJiGLEMapEvent( new JiGLEMapEvent( this, - new GPSPoint( where.getLat(), where.getLon() ), - JiGLEMapEvent.POINT_SELECTED ) ); - break; - case SHOWGPSPOS: where = pix2Geo(new Point(e.getX(), e.getY())); @@ -748,9 +726,6 @@ mouseClickMeaning = DONOTHING; } - public void setMouseToSelectPoint() { - mouseClickMeaning = SELECTPOINT; - } public void setMouseToShowGpsPos() { mouseClickMeaning = SHOWGPSPOS; @@ -1721,5 +1696,34 @@ } } + /** + * inner class filters based on date + */ + class DateFilter implements Filter { + // docs inherit from Filter + public boolean matches(Object o) { + if ( !( o instanceof JiGLEBaseStation) ) { + return true; // if we can't test it for qos, let it draw itself. XXX: is this correct? + } + JiGLEBaseStation jbs = (JiGLEBaseStation) o; + + boolean retVal; + + if (Preferences.getBoolean( Preferences.DATE_FILTER_TYPE_KEY)) + { + retVal = jbs.getStationFoundDate().getTime() + <= ((Preferences.getLong( Preferences.DATE_KEY, 0 ) + + Preferences.getLong( Preferences.EARLIEST_DATE_KEY, 0)) * 1000); + } else + { + retVal = jbs.getStationLastUpdate().getTime() + <= ((Preferences.getLong( Preferences.DATE_KEY, 0 ) + + Preferences.getLong( Preferences.EARLIEST_DATE_KEY, 0)) * 1000); + } + + return retVal; + } + } + } diff -ur JiGLE/org/mimezine/jigle/JiGLEMenu.java JiGLEnew/org/mimezine/jigle/JiGLEMenu.java --- JiGLE/org/mimezine/jigle/JiGLEMenu.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLEMenu.java 2004-05-28 23:59:12.000000000 -0400 @@ -56,6 +56,7 @@ private JCheckBoxMenuItem followmeMenuItem; private JCheckBoxMenuItem wepOnMenuItem; private JCheckBoxMenuItem wepOffMenuItem; + private JCheckBoxMenuItem dateTypeMenuItem; private JRadioButtonMenuItem[] qosItems; private ImageIcon jigleIcon; @@ -196,6 +197,15 @@ filterMenuItem.addActionListener( this ); filterMenu.add( filterMenuItem ); + filterMenuItem = new JCheckBoxMenuItem( "Not Found By Me" ); + filterMenuItem.setMnemonic( KeyEvent.VK_O ); + filterMenuItem.setState( + Preferences.getBoolean( Preferences.NOT_MINE_KEY ) ); + filterMenuItem.getAccessibleContext().setAccessibleDescription( + "Only Found By Me"); + filterMenuItem.addActionListener( this ); + filterMenu.add( filterMenuItem ); + filterMenuItem = new JCheckBoxMenuItem( "Only Freenets" ); filterMenuItem.setMnemonic( KeyEvent.VK_R ); filterMenuItem.setState( @@ -232,6 +242,15 @@ wepOffMenuItem.addActionListener( this ); filterMenu.add( wepOffMenuItem ); + dateTypeMenuItem = new JCheckBoxMenuItem( "First Found Date / Last Update" ); + dateTypeMenuItem.setMnemonic( KeyEvent.VK_D ); + dateTypeMenuItem.setState( + Preferences.getBoolean( Preferences.DATE_FILTER_TYPE_KEY ) ); + dateTypeMenuItem.getAccessibleContext().setAccessibleDescription( + "First Found Date / Last Update" ); + dateTypeMenuItem.addActionListener( this ); + filterMenu.add( dateTypeMenuItem ); + JMenu qosMenu = new JMenu( "Quality of Service" ); qosMenu.setMnemonic( KeyEvent.VK_Q ); qosMenu.getAccessibleContext().setAccessibleDescription( @@ -258,6 +277,17 @@ this.add( filterMenu ); + // Stats menu + JMenu statsMenu = new JMenu( "Stats" ); + statsMenu.setMnemonic( KeyEvent.VK_S ); + statsMenu.getAccessibleContext().setAccessibleDescription( "Stats menu"); + this.add( statsMenu ); + + menuItem = new JMenuItem( "Statistics" ); + menuItem.getAccessibleContext().setAccessibleDescription( "Statistics" ); + menuItem.addActionListener( this ); + statsMenu.add( menuItem ); + // Help menu JMenu helpMenu = new JMenu( "Help" ); helpMenu.setMnemonic( KeyEvent.VK_H ); @@ -293,6 +323,10 @@ Preferences.setProperty( Preferences.ONLY_MINE_KEY, ((JCheckBoxMenuItem) source).getState() ); } + else if ( source.getText().equals( "Not Found By Me" ) ) { + Preferences.setProperty( Preferences.NOT_MINE_KEY, + ((JCheckBoxMenuItem) source).getState() ); + } else if ( source.getText().equals( "Only Commercial Nets" ) ) { Preferences.setProperty( Preferences.PAYNET_KEY, ((JCheckBoxMenuItem) source).getState() ); @@ -321,6 +355,11 @@ Preferences.setProperty( Preferences.DRAW_WEP_OFF_KEY, ((JCheckBoxMenuItem) source).getState() ); } + else if ( source.getText().equals( "First Found Date / Last Update" ) ) { + Preferences.setProperty( Preferences.DATE_FILTER_TYPE_KEY, + ((JCheckBoxMenuItem) source).getState() ); + jiglePane.updateDateSlider((jiglePane.getJiGLEMapper()).getDataSet()); + } else if ( source.getText().equals( "About" ) ) { JOptionPane.showMessageDialog(jigle.getFrame(), "JiGLE " + jigle.VERNUM + "\n" @@ -336,6 +375,41 @@ JOptionPane.showMessageDialog(jigle.getFrame(), "Preferences coming soon!" ); } + else if ( source.getText().equals( "Statistics" ) ) { + JiGLEDataSet data = (jiglePane.getJiGLEMapper()).getDataSet(); + + String statsLine; + + if (data.hasStations()) + { + statsLine = new String( + "WEP " + data.getNumWep() + " " + + data.getNumNotWep() + " " + (((float)data.getNumWep() / + ((float)data.getNumNotWep() + (float)data.getNumWep())) * 100) + "%\n" + + "Freenet " + data.getNumFree() + " " + + data.getNumNotFree() + " " + (((float)data.getNumFree() / + ((float)data.getNumNotFree() + (float)data.getNumFree())) * 100) + "%\n" + + "Paynet " + data.getNumPay() + " " + + data.getNumNotPay() + " " + (((float)data.getNumPay() / + ((float)data.getNumNotPay() + (float)data.getNumPay())) * 100) + "%\n" + + "Mine " + data.getNumMine() + " " + + data.getNumNotMine() + " " + (((float)data.getNumMine() / + ((float)data.getNumNotMine() + (float)data.getNumMine())) * 100) + + "%\n" + + "First Network: " + data.getFirstFoundDate().toString() + + "\n" + + "Latest Network: " + data.getLastFoundDate().toString() + + "\n" + + "First Update: " + data.getFirstLastUpdate().toString() + + "\n" + + "Last Update: " + data.getLastLastUpdate().toString()); + } else + { + statsLine = new String("Map not loaded"); + } + + JOptionPane.showMessageDialog(jigle.getFrame(), statsLine); + } else if ( source.getText().equals( "Authenticate to WiGLE" ) ) { jigle.doLogin(); } diff -ur JiGLE/org/mimezine/jigle/JiGLEPane.java JiGLEnew/org/mimezine/jigle/JiGLEPane.java --- JiGLE/org/mimezine/jigle/JiGLEPane.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLEPane.java 2004-05-29 11:08:44.000000000 -0400 @@ -72,8 +72,10 @@ private JPanel pan; private JPanel nPan; private JPanel ePan; + private JPanel sPan; private JComboBox mappacks; private JSlider qosSlider; + private JSlider dateSlider; private JButton nudgeW, nudgeE, nudgeN, nudgeS; private JButton zin, zout, selStn, selGps/*,drawLabel, drawArea, drawSightings*/; private int prevTab; @@ -165,6 +167,10 @@ + "Make sure your internet connection is live," + " and that WiGLE.net is accessible."); } + + + updateDateSlider(data); + setDataSet( data ); this.requestFocus(); @@ -335,7 +341,7 @@ qosSlider.setForeground( SystemColor.windowText ); qosSlider.setBackground( SystemColor.control ); - qosSlider.addChangeListener(new SliderListener()); + qosSlider.addChangeListener(new qosSliderListener()); qosSlider.setMajorTickSpacing(1); qosSlider.setPaintTicks(true); qosSlider.setSnapToTicks(true); @@ -359,12 +365,40 @@ ePan.add( nudgeE, BorderLayout.CENTER ); ePan.add( slidePan, BorderLayout.SOUTH ); + // south-sieed panel + dateSlider = new JSlider(JSlider.HORIZONTAL, 0, + 1, 1 ); //Will be updated when map loads + + dateSlider.setForeground( SystemColor.windowText ); + dateSlider.setBackground( SystemColor.control ); + dateSlider.addChangeListener(new dateSliderListener()); + dateSlider.setPaintTicks(false); + dateSlider.setSnapToTicks(false); + dateSlider.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); + dateSlider.setPreferredSize( + new Dimension( (int) dateSlider.getPreferredSize().getWidth(), +50 ) ); + dateSlider.setValue( 0 ); + + JPanel dateSlidePan = new JPanel( new BorderLayout() ); + dateSlidePan.setBorder( BorderFactory.createEmptyBorder() ); + JLabel dateLabel = new JLabel( "Date", SwingConstants.CENTER ); + dateSlidePan.add( dateLabel, BorderLayout.NORTH ); + dateSlidePan.add( dateSlider, BorderLayout.CENTER ); + + sPan = new JPanel( new BorderLayout() ); + sPan.setBorder( BorderFactory.createEmptyBorder() ); + sPan.setForeground( Color.black ); + sPan.setBackground( SystemColor.control ); + sPan.add( nudgeS, BorderLayout.CENTER ); + sPan.add( dateSlidePan, BorderLayout.SOUTH ); + // ...then add everything to the main panel pan.add( "North", nPan ); pan.add( "East", ePan ); pan.add( "West", nudgeW ); pan.add( "Center", jigleMapper ); - pan.add( "South", nudgeS ); + pan.add( "South", sPan ); // handle events from the buttons and palette mappacks.addItemListener( this ); @@ -822,7 +856,161 @@ } } - class SliderListener implements ChangeListener { + private static final long MINUTEINMS = 60000L; + private static final long HOURINMS = 3600000L; + private static final long DAYINMS = 86400000L; + private static final long WEEKINMS = 604800000L; + private static final long MONTHINMS = 2419200000L; + + public String msToString(long timeInMs) { + if (timeInMs == MINUTEINMS) + { + return(new String("Minute")); + } else if (timeInMs == HOURINMS) + { + return(new String("Hour")); + } else if (timeInMs == DAYINMS) + { + return(new String("Day")); + } else if (timeInMs == WEEKINMS) + { + return(new String("Week")); + } else if (timeInMs == WEEKINMS * 2) + { + return(new String("Fortnight")); + } else if (timeInMs == MONTHINMS) + { + return(new String("Month")); + } else if (timeInMs == MONTHINMS * 3) + { + return(new String("Quarter")); + } else if (timeInMs == MONTHINMS * 6) + { + return(new String("Half Year")); + } else if (timeInMs == MONTHINMS * 12) + { + return(new String("Year")); + } else + { + return(new String("Unknown")); + } + } + + public void updateDateSlider( JiGLEDataSet data ) { + long dateDif; + + if (Preferences.getBoolean( Preferences.DATE_FILTER_TYPE_KEY)) + { + dateDif = data.getLastFoundDate().getTime() - +data.getFirstFoundDate().getTime(); + dateSlider.setMinimum( 0 ); + dateSlider.setMaximum((int)( dateDif / 1000 )); + dateSlider.setValue( (int)( dateDif / 1000 )); + + Preferences.setProperty( Preferences.EARLIEST_DATE_KEY, +data.getFirstFoundDate().getTime() / 1000); + } else + { + dateDif = data.getLastLastUpdate().getTime() - +data.getFirstLastUpdate().getTime(); + dateSlider.setMinimum( 0 ); + dateSlider.setMaximum((int)( dateDif / 1000 )); + dateSlider.setValue( (int)( dateDif / 1000 )); + + Preferences.setProperty( Preferences.EARLIEST_DATE_KEY, +data.getFirstLastUpdate().getTime() / 1000 ); + } + + dateSlider.setPaintTicks(true); + + dateSlider.setPaintLabels(false); + + Hashtable sliderLabels = new Hashtable(); + + if (dateDif > 0) + { + if (dateDif < MINUTEINMS) // One minute + { + dateSlider.setMajorTickSpacing((int)MINUTEINMS / 1000 / 6); + + for (long i = 0; i < dateDif / 1000; i += MINUTEINMS / 1000 / 6) + { + sliderLabels.put(new Integer((int)i),new JLabel("One")); + } + + dateSlider.setLabelTable(sliderLabels); + + //dateSlider.createStandardLabels((int)MINUTEINMS / 1000 / 6); + } else if (dateDif < HOURINMS) // One Hour + { + dateSlider.setMajorTickSpacing((int)MINUTEINMS * 10 / 1000); + + dateSlider.createStandardLabels((int)MINUTEINMS * 10 / 1000); + } else if (dateDif < DAYINMS) // One Day + { + dateSlider.setMajorTickSpacing((int)HOURINMS / 1000); + + dateSlider.createStandardLabels((int)HOURINMS / 1000); + } else if (dateDif < WEEKINMS) // One Week + { + dateSlider.setMajorTickSpacing((int)DAYINMS / 1000); + + dateSlider.createStandardLabels((int)DAYINMS / 1000); + } else if (dateDif < MONTHINMS) // One Month (Four Weeks) + { + dateSlider.setMajorTickSpacing((int)MONTHINMS / 8 / 1000); + + dateSlider.createStandardLabels((int)MONTHINMS / 8 / 1000); + } else if (dateDif < MONTHINMS * 3) // One Quarter (Three Months) + { + dateSlider.setMajorTickSpacing((int)WEEKINMS / 1000); + + dateSlider.createStandardLabels((int)WEEKINMS / 1000); + } else if (dateDif < MONTHINMS * 6) // One Half Year (Six Months) + { + dateSlider.setMajorTickSpacing((int)(MONTHINMS / 1000)); + + for (long i = 0; i < dateDif / 1000; i += MONTHINMS / 1000 ) + { + sliderLabels.put(new Integer((int)i),new +JLabel(msToString(MONTHINMS))); + } + + dateSlider.setLabelTable(sliderLabels); + + //dateSlider.createStandardLabels((int)(MONTHINMS / 1000)); + } else if (dateDif < MONTHINMS * 12) // One Year (Twelve Months) + { + dateSlider.setMajorTickSpacing((int)(MONTHINMS / 1000)); + + for (long i = 0; i < (dateDif / 1000); i += (MONTHINMS / 1000) ) + { + sliderLabels.put(new Integer((int)i), new +JLabel(msToString(MONTHINMS))); + } + + dateSlider.setLabelTable(sliderLabels); + + //dateSlider.createStandardLabels((int)(MONTHINMS / 1000)); + } else if (dateDif < MONTHINMS * 24) // Two Years + { + dateSlider.setMajorTickSpacing((int)MONTHINMS * 2 / 1000); + + dateSlider.createStandardLabels((int)MONTHINMS * 2 / 1000); + } else if (dateDif < MONTHINMS * 36) // Three Years + { + dateSlider.setMajorTickSpacing((int)MONTHINMS * 3 / 1000); + + dateSlider.createStandardLabels((int)MONTHINMS * 3 / 1000); + } else + { + } + + dateSlider.setPaintLabels(true); + } + } + + class qosSliderListener implements ChangeListener { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider)e.getSource(); if ( ! source.getValueIsAdjusting() ) { @@ -832,5 +1020,15 @@ } } + class dateSliderListener implements ChangeListener { + public void stateChanged(ChangeEvent e) { + JSlider source = (JSlider)e.getSource(); + if ( ! source.getValueIsAdjusting() ) { + long date = (long)source.getValue(); + Preferences.setProperty( Preferences.DATE_KEY, date ); + } + } + } + } diff -ur JiGLE/org/mimezine/jigle/JiGLEStation.java JiGLEnew/org/mimezine/jigle/JiGLEStation.java --- JiGLE/org/mimezine/jigle/JiGLEStation.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLEStation.java 2004-05-24 15:04:50.000000000 -0400 @@ -2,7 +2,7 @@ // vim:ts=2:sw=2:tw=80:et /* - * Copyright (c) 2002, Andrew Carra and Robert Hagemann + * Copyright (c) 2002-2004, Andrew Carra and Robert Hagemann * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ public abstract class JiGLEStation { public static final String VERSION_ID = - "$Id: JiGLEStation.java,v 1.17 2003/06/17 03:33:48 uhtu Exp $"; + "$Id: JiGLEStation.java,v 1.18 2004/05/24 03:39:35 uhtu Exp $"; // these need to stay protected as long as this is a base class // *grr* composition is your friend. @@ -53,7 +53,8 @@ protected String name; protected String id; protected Color stationColor; - protected long lastUpdate; + + protected Date lastUpdate; /** * default constructor. @@ -203,19 +204,28 @@ /** * set the last updated time. - * @param lastUpdate seconds since the epoch when this JiGLEStation was + * @param lastUpdate seconds since the unix epoch when this JiGLEStation was * last updated + * @deprecated #setStationLastUpdate(Date) */ public void setStationLastUpdate( long lastUpdate ) { - this.lastUpdate = lastUpdate; + this.lastUpdate = new Date( 1000 * lastUpdate); } /** - * @return seconds since the epoch when this JiGLEStation was last - * updated + * set the last updated time. + * @param lastUpdate Date when this JiGLEStation was last updated + */ + public void setStationLastUpdate( Date lastUpdate ) { + this.lastUpdate = new Date( lastUpdate.getTime() ); + } + + + /** + * @return when this JiGLEStation was last updated */ - public long getStationLastUpdate() { - return lastUpdate; + public Date getStationLastUpdate() { + return new Date(lastUpdate.getTime()); } /** diff -ur JiGLE/org/mimezine/jigle/JiGLETrace.java JiGLEnew/org/mimezine/jigle/JiGLETrace.java --- JiGLE/org/mimezine/jigle/JiGLETrace.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/JiGLETrace.java 2004-05-24 15:04:50.000000000 -0400 @@ -2,7 +2,7 @@ // vim:ts=2:sw=2:tw=80:et /* - * Copyright (c) 2003-2004 Hugh Kennedy + * Copyright (c) 2004 Robert Hagemann and Hugh Kennedy * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ public final class JiGLETrace extends JiGLEStation { public static final String VERSION_ID = - "$Id: JiGLETrace.java,v 1.4 2004/02/22 07:16:10 uhtu Exp $"; + "$Id: JiGLETrace.java,v 1.5 2004/05/24 03:39:35 uhtu Exp $"; /** the logger for this class. */ private static final Logger log = Logger.getLogger( JiGLETrace.class.getName() ); diff -ur JiGLE/org/mimezine/jigle/Preferences.java JiGLEnew/org/mimezine/jigle/Preferences.java --- JiGLE/org/mimezine/jigle/Preferences.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/Preferences.java 2004-05-28 23:14:00.000000000 -0400 @@ -66,15 +66,19 @@ public static final String USERNAME_KEY = "authentication.username"; public static final String QOS_KEY = "filter.qos"; + public static final String DATE_KEY = "filter.date"; public static final String FREENET_KEY = "filter.freenet"; public static final String PAYNET_KEY = "filter.paynet"; public static final String ONLY_MINE_KEY = "filter.onlymine"; + public static final String NOT_MINE_KEY = "filter.notmine"; public static final String DRAW_WEP_ON_KEY = "filter.drawwepon"; public static final String DRAW_WEP_OFF_KEY = "filter.drawwepoff"; public static final String DRAW_AREA_KEY = "filter.drawarea"; public static final String DRAW_SIGHTINGS_KEY = "filter.drawsightings"; public static final String DRAW_LABELS_KEY = "filter.drawlabels"; public static final String KISMET_HOST_KEY = "kismet.host"; + public static final String EARLIEST_DATE_KEY = "earliest.date"; + public static final String DATE_FILTER_TYPE_KEY = "filter.date.type"; /** gpsd menu default values */ public static final String GPSD_HOST_KEY = "gpsd.host"; @@ -134,6 +138,13 @@ return retval; } + public static long getLong( String key, long defaultValue ) { + String value = preferences.getProperty( key, + Long.toString( defaultValue )); + long retval = Long.parseLong( value ); + return retval; + } + public static void setProperty( String key, boolean value ) { setProperty( key, Boolean.toString( value ) ); } @@ -143,6 +154,11 @@ setProperty( key, stringValue ); } + public static void setProperty( String key, long value ) { + String stringValue = Long.toString( value ); + setProperty( key, stringValue ); + } + public static void setProperty( String key, String value ) { String oldValue = null; synchronized ( preferences ) { diff -ur JiGLE/org/mimezine/jigle/WiGLE.java JiGLEnew/org/mimezine/jigle/WiGLE.java --- JiGLE/org/mimezine/jigle/WiGLE.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/jigle/WiGLE.java 2004-05-25 10:34:03.000000000 -0400 @@ -57,7 +57,7 @@ */ public class WiGLE implements WiGLEQueryListener { public static final String VERSION_ID = - "$Id: WiGLE.java,v 1.69 2004/05/13 05:56:43 uhtu Exp $"; + "$Id: WiGLE.java,v 1.70 2004/05/24 03:39:35 uhtu Exp $"; /** the logger for this class. */ private static final Logger log = Logger.getLogger( WiGLE.class.getName() ); @@ -273,6 +273,7 @@ dlWiGLEData = getDataFromAPI( points, bounding ); } + //Thrown for both stumble loads and WiGLE download / cache throwEvent( WiGLEEvent.DATA_LOADED, dlWiGLEData ); } @@ -599,8 +600,8 @@ new JiGLEBaseStation( currentStation.getCurrentLat(), currentStation.getCurrentLon(), Color.red, currentStation.getStnName(), currentStation.getStnID(), - currentStation.getStnID(), "unknown", 0, "n/d", "n/d", - "--stumble--", 0, false, 5, 0 ) ); + currentStation.getStnID(), "unknown", 0, "n/d", new Date(), + "--stumble--", 0, false, new Date() ) ); } } } diff -ur JiGLE/org/mimezine/wigle/WiGLEQueryImpl.java JiGLEnew/org/mimezine/wigle/WiGLEQueryImpl.java --- JiGLE/org/mimezine/wigle/WiGLEQueryImpl.java 2004-05-16 16:30:18.000000000 -0400 +++ JiGLEnew/org/mimezine/wigle/WiGLEQueryImpl.java 2004-05-25 03:22:24.000000000 -0400 @@ -123,6 +123,7 @@ new Attribute.WiGLEBooleanConverter()) ); supportedAttributes.put( "UserFound", new Attribute("userfound", new Attribute.WiGLEBooleanConverter()) ); + supportedAttributes.put( "FoundOn", new Attribute("firsttime") ); } private Properties config; @@ -628,7 +629,20 @@ inbound_column_operations.put( FREENETHEADER, new BooleanInsert(FREENETHEADER) ); inbound_column_operations.put( PAYNETHEADER, new BooleanInsert(PAYNETHEADER) ); inbound_column_operations.put( WEPHEADER, new BooleanInsert(WEPHEADER) ); - inbound_column_operations.put( DISCOVEREDHEADER, new PassthroughInsert(DISCOVEREDHEADER) ); + inbound_column_operations.put( DISCOVEREDHEADER, new +InsertColumnOperator() { + public void doit(String s, WiGLEPointImpl wp){ + Date ft = new Date(0); + + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); + + try { + ft = df.parse(s); + } catch ( Exception ex ) { + WiGLEQueryImpl.log.log(Level.FINEST,"bad firsttime from:"+s,ex); + } + + wp.put(DISCOVEREDHEADER, Long.toString(ft.getTime())); } } ); inbound_column_operations.put( COMMENTHEADER, new PassthroughInsert(COMMENTHEADER) ); inbound_column_operations.put( QOSHEADER, new InsertColumnOperator() { public void doit(String s, WiGLEPointImpl wp){