// EPS: Elgaard Positioning System: GPS navigation software. // Copyright (C) 1997, 1998, 1999, 2000 Niels Elgaard Larsen // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Niels Elgaard Larsen, // import java.awt.*; import java.lang.Math; import java.io.*; import java.net.*; //import java.util.*; import java.util.Properties; import java.util.Locale; import java.awt.event.*; import java.text.*; import java.applet.*; class ChartFrame1 extends ICF { static FileShield fShield; static ImageGMap IGMCanvas; // FIXME should not be static PoneInput posPanelLat; PoneInput posPanelLong; static Dimension mS = new Dimension(500,400); static DecimalFormat distFormat = new DecimalFormat("###0.00"); EPSFrame theWindow; private Label NMEALabel = new Label("No NMEA input"); GPSIF gps1 = null; static Properties applicationProps = new Properties(); // Tricky. If system.getProperties fail isWin stays false even on windows platforms. GMenv epsEnv; boolean inAnApplet = false; static Applet theApplet = null; float zzoom = 1; float azoom = 1; int activeRoute; Toolkit toolK; ChartFrame1 myself=this; WayPoint markedWP; boolean sjump=false; String loadFile="w2.swp"; TextField loadFileArea = new EPSTextField(""); String jvver; String jver; String jcver; boolean NMEAactive = false; boolean dgpsipActive = false; static Thread hThread; Label zoomLabel = new Label(" 100% zoom", Label.RIGHT); // List routeWPList = new List(8, false); List routeWPList = new EPSList(new Dimension(200,120)); Scrollbar zoomSlider; Button loadWPBut, loadTRBut, loadRTBut; Button addWPBut,addPWPBut, gotoWPBut, gotoPosBut, addRTBut, addWPRTBut, markWPBut; MenuItem exitMI =new MenuItem("Exit"); MenuItem saveOptionsMI =new MenuItem("Options"); MenuItem FileNMEAMI = new MenuItem("Read NMEA file"); MenuItem trDelMI =new MenuItem("Track"); MenuItem allDelMI =new MenuItem("All (wp,track, and route)"); MenuItem wpDelMI =new MenuItem("WayPoint"); MenuItem rtDelMI =new MenuItem("Route"); MenuItem rtwpDelMI =new MenuItem("WayPoint from Route"); //Unit Menu SetUnits; MenuItem SetMetricUnits; MenuItem SetKmMetricUnits; MenuItem SetStatuteUnits; MenuItem SetNauticalUnits; //MenuItem SetUTCMI; MenuItem MCDistance, MCPCDistance; MenuItem MCCourse; MenuItem SetPSizeMI =new MenuItem("Remember Window Size"); MenuItem SetInitZoomMI; // MenuItem SetCDWMI; MenuItem SetIPWMI; MenuItem SetGTWMI; MenuItem printMI =new MenuItem("Print"); MenuItem printChartMI =new MenuItem("Print Chart"); MenuItem wpMI =new MenuItem("WayPoints"); MenuItem pfDDDMI =new MenuItem("Positions as d.dddd"); MenuItem pfDMMMI =new MenuItem("Positions as d\u00b0mm.mm\'"); MenuItem pfDMSMI =new MenuItem("Positions as dd°mm\'ss\""); MenuItem ffGPSTRANSMI =new MenuItem("GPStrans file format"); MenuItem ffGLMI =new MenuItem("GARLINK file format"); MenuItem ffGRMMI =new MenuItem("GARMIN file format"); MenuItem routeColorMI =new MenuItem("routes"); MenuItem trackColorMI =new MenuItem("tracks"); MenuItem waypointColorMI =new MenuItem("waypoints"); MenuItem annoFontSizeMI =new MenuItem("annotation font size"); MenuItem nFontSizeMI =new MenuItem("normal font size"); MenuItem trMI = new MenuItem("Track"); MenuItem trcMI = new MenuItem("Track"); MenuItem rMI = new MenuItem("Routes"); MenuItem rcMI = new MenuItem("Routes"); Label WPLLabel = new Label("WayPoints"); Panel WPLPanel = new Panel(); Panel WActionPanel = new Panel(); Label RouteLLabel = new Label("Routes"); Label RouteWPLLabel = new Label("WP's in Route"); Panel addPanel = new Panel(); Panel bottomPanel = new Panel(); Panel IGMPanel = new Panel(); Panel centerPanel = new Panel(); Panel loadPanel = new Panel(); Panel northPanel = new Panel(new VFlowLayout()); Panel wpPanel = new Panel(); // Menu routeMenu = new Menu("Route"); // Menu wayPointMenu= new Menu("Route"); CMenuBar mb; CMenu mf; CMenu gpsMenu; CMenu msave; Menu mclr = new Menu("Clear"); Menu mPosFormat = new Menu("Position Formats"); Menu mFileFormat = new Menu("File Formats"); Menu mSetColors = new Menu("Colors (\"rrggbb\" hex)"); Menu mSetFontSize = new Menu("Font sizes"); Menu mAdd = new Menu("Add"); CMenu mDelete; CMenu mSet; CMenu mCompute; CMenu mHelp; CMenu mTest; Menu mHelpKeys = new Menu("Keys and buttons pressed on Map"); URL propURL=null; static Container mainContainer; public ChartFrame1(URL epsbase, String pfile, FileShield fs, boolean jcomm, Applet ap) { String osName = "?"; GMenv.GPSconnect = jcomm; // Clean up int case EPS is reloaded in Applet. theApplet = ap; if (GMenv.GPSconnect) { // comment out next line to not compile GPS support, att: Giancarlo CAux.perr("Now create GPS nmlbl="+this.NMEALabel.getText(),2); gps1 = new GPS (loadFileArea, this); } RouteC.deleteAll(); aWP.theWP.deleteAll(); TrackC.deleteAll(); CAux.perr("prp base="+epsbase+ " file="+ pfile,2); fShield = fs; try { propURL = new URL(epsbase,pfile); CAux.perr("propURL=" + propURL,2); } catch (SecurityException ioe) { System.out.println("s ex prp " + ioe); } catch (MalformedURLException ioe) { System.out.println("m ex prp " + ioe); } String cD="default", pD = "default"; URL tbase = null; if (ap == null) { RealMenuBar rmb = new RealMenuBar(); theWindow = new EPSFrame("Elgaard GPS Chart v. "+ CAux.epsversion); mainContainer = theWindow; //theWindow.setLayout(new VFlowLayout()); theWindow.setResizable(true); theWindow.setVisible(true); theWindow.setMenuBar(rmb); mf = new RealMenu("File"); msave = new RealMenu("Save"); mDelete = new RealMenu("Delete"); mSet = new RealMenu("Set"); mCompute = new RealMenu("Compute"); mHelp = new RealMenu("Help"); mTest = new RealMenu("Test"); if (GMenv.GPSconnect) { Menu gm = new RealMenu("GPS"); gm.setShortcut(new MenuShortcut(KeyEvent.VK_G,true)); gpsMenu = (CMenu) gm; } mb = rmb; //theWindow.pack(); theWindow.setVisible(true); theWindow.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { /* Now dispose of ones self, = or call system.exit(0) */ System.out.println("Close, Exit EPS application "); System.exit(0); } } ); } else { FakeMenuBar fmb; mainContainer = ap; CAux.perr("Using Fake menu",2); fmb = new FakeMenuBar(); mb = fmb; northPanel.add(fmb); CAux.perr("addet fake fmbar",2); mf = new FakeMenu("File"); msave = new FakeMenu("Save"); mDelete = new FakeMenu("Delete"); mSet = new FakeMenu("Set"); mCompute = new FakeMenu("Compute"); mHelp = new FakeMenu("Help"); mTest = new FakeMenu("Test"); if (GMenv.GPSconnect) { gpsMenu = new FakeMenu("GPS"); } mainContainer = ap; CAux.perr("Fake menu ready",2); } toolK = mainContainer.getToolkit(); setMenuNames_english(); try { CAux.perr("EPS locale "+ Locale.getDefault().getCountry()+"-"+ Locale.getDefault().getLanguage(),2); if (Locale.getDefault().getCountry()==null || Locale.getDefault().getLanguage()==null|| Locale.getDefault().getCountry().length()==0 || Locale.getDefault().getLanguage().length()==0) { Locale.setDefault(Locale.US); CAux.perr("now locale "+ Locale.getDefault().getCountry()+"-"+ Locale.getDefault().getLanguage(),2); } } catch (SecurityException ioe) { System.out.println("locale ex " + ioe); } try{ URL tURL; System.out.println("BASE is: " + epsbase); System.out.println("property file is: " + propURL); // tURL =new URL(base,PropertyFileName); if (propURL.getProtocol().equals("file")) { fShield.getPrp(applicationProps, new File(propURL.getFile())); } else { DataInputStream appStream; CAux.perr("load app datastream",2); appStream = new DataInputStream(propURL.openStream()); applicationProps.load(appStream); appStream.close(); } System.out.println("property file end"); } catch (FileNotFoundException fe) { System.out.println("Proporties file not found: " + fe); //System.exit(0); } catch (SecurityException ioe) { System.out.println("prp ld " + ioe); } catch (IOException ioe) { System.out.println("Proporties Not found " + ioe); //System.exit(0); } System.out.println("now t base: " + epsbase); try { String baseS = applicationProps.getProperty("eps.base"); if (baseS != null){ tbase = new URL(baseS); } if (tbase == null) { tbase = epsbase; } cD = applicationProps.getProperty("eps.ChartDatum","WGS84"); pD = applicationProps.getProperty("eps.PositionDatum","WGS84"); if (applicationProps==null) { epsEnv = new GMenv(); } else { GMenv.wpfile.update(applicationProps.getProperty("eps.wpts",null)); GMenv.rtfile.update(applicationProps.getProperty("eps.routes",null)); GMenv.trfile.update(applicationProps.getProperty("eps.track",null)); epsEnv = new GMenv( applicationProps.getProperty("eps.chartdir", "charts"), tbase, Integer.parseInt(applicationProps.getProperty("eps.initZoom","200")), Integer.parseInt(applicationProps.getProperty("eps.ChartWidth","10")), Integer.parseInt(applicationProps.getProperty("eps.ChartHeight","10")), applicationProps.getProperty("eps.fileFormat",null), applicationProps.getProperty("eps.gpstranspgm",null), //Integer.parseInt(applicationProps.getProperty("eps.UTCoff","0")), mMapDatum, mPositionDatum, Double.valueOf(applicationProps.getProperty("eps.initLatitude","55")).doubleValue(), Double.valueOf(applicationProps.getProperty("eps.initLongitude","12")).doubleValue() ); epsEnv.setNautical(); epsEnv.units = applicationProps.getProperty("eps.units","nautical").toLowerCase(); epsEnv.commAPI = applicationProps.getProperty("eps.commapi","comm api").toLowerCase(); GMenv.setColor(GMenv.TRACKCOLOR, new Color((int)Long.parseLong(applicationProps.getProperty("eps.trackColor","00ff00"),16))); GMenv.setColor(GMenv.ROUTECOLOR, new Color((int)Long.parseLong(applicationProps.getProperty("eps.routeColor","0000ff"),16))); GMenv.setColor(GMenv.WAYPOINTCOLOR, new Color((int)Long.parseLong(applicationProps.getProperty("eps.waypointColor","ff0000"),16))); GMenv.nFontSize = Integer.parseInt(applicationProps.getProperty("eps.nFontSize","12")); GMenv.posFormat = Integer.parseInt(applicationProps.getProperty("eps.posFormat",""+Pone.DMM)); GMenv.annoFontSize = Integer.parseInt(applicationProps.getProperty("eps.annoFontSize","12")); GMenv.prefSize = new Dimension (Integer.parseInt(applicationProps.getProperty("eps.winWidth","800")), Integer.parseInt(applicationProps.getProperty("eps.winHeight","700")) ); nFont = new Font("Helvetica", Font.PLAIN, GMenv.nFontSize); GMenv.dgpsServer = applicationProps.getProperty("eps.dgpsServer","dgps.wsrcc.com"); GMenv.dgpsPort = Integer.parseInt(applicationProps.getProperty("eps.dgpsPort","2101")); mainContainer.setFont(nFont); if (epsEnv.units.equals("nautical")) { epsEnv.setNautical(); } else if (epsEnv.units.equals("metric")) { epsEnv.setMetric(); } else if (epsEnv.units.equals("kmmetric")) { epsEnv.setKmMetric(); } else if (epsEnv.units.equals("statute")) { epsEnv.setStatute(); } GMenv.portName.update(applicationProps.getProperty("eps.portName",null)); CAux.perr("setting up comm/stty api PortN="+GMenv.portName.wval,2); } epsEnv.propURL = propURL; epsEnv.epsfBase = urlDecode(epsEnv.epsBase.getFile()); GMenv.useFShield = epsEnv.epsBase.getProtocol().equals("file"); //FIXME and this is a browser. CAux.perr("epsfBase="+epsEnv.epsfBase,1); CAux.perr("vendor="+System.getProperty("java.vendor"),1); CAux.perr("vm.vendor="+System.getProperty("java.vm.vendor"),1); osName = System.getProperty("os.name"); GMenv.isWin = osName.toUpperCase().indexOf("WINDOWS") >=0; //CAux.perr("PN="+System.getProperties().propertyNames(),3); CAux.perr(System.getProperties().getProperty("java.version"),2); } catch (MalformedURLException fe) { System.out.println(" URL: " + fe); } catch (SecurityException ioe) { CAux.perr("Cannot read system properties. Don't really need them",3); } CAux.perr("osName="+ osName+" isWin="+ GMenv.isWin,1); setupPos(); mMapDatum = new DatumMenu("Chart Datum"); mPositionDatum = new DatumMenu("Position Datum"); mMapDatum.setDatum(Pos.getNamedDatum(cD)); mPositionDatum.setDatum(Pos.getNamedDatum(pD)); epsEnv.chartDatum =mMapDatum; epsEnv.positionDatum =mPositionDatum; horz = new Scrollbar(Scrollbar.HORIZONTAL,500,25,0,1025); vert = new Scrollbar(Scrollbar.VERTICAL ,500,25,0,1025); horz.addAdjustmentListener(new PanAdapter(false)); vert.addAdjustmentListener(new PanAdapter(true)); pLabel = new Label("Position ", Label.LEFT); //SetUTCMI =new MenuItem("Offset to UTC: "+epsEnv.UTC_off); MCDistance =new MenuItem("distance"); MCPCDistance =new MenuItem("distance from cursor to pos input"); MCCourse =new MenuItem("initial course"); SetInitZoomMI =new MenuItem("default zoom to current zoom"); SetUnits =new Menu("Units"); SetMetricUnits =new MenuItem("Metric"); SetKmMetricUnits =new MenuItem("Metric (Km)"); SetNauticalUnits =new MenuItem("Nautical"); SetStatuteUnits =new MenuItem("Statute"); SetUnits.add(SetMetricUnits); SetUnits.add(SetKmMetricUnits); SetUnits.add(SetNauticalUnits); SetUnits.add(SetStatuteUnits); //SetCDWMI =new MenuItem("Chart Datum: "+epsEnv.Chart_Datum); SetIPWMI =new MenuItem("Initial Position: "+ (new Pos(epsEnv.initLong, epsEnv.initLat, mMapDatum.theDatum)).toString(GMenv.posFormat)); //SetGTWMI =new MenuItem("gpstrans pgm: "+ epsEnv.gtpgm); trackColorMI.addActionListener(new setColorAC(GMenv.TRACKCOLOR)); routeColorMI.addActionListener(new setColorAC(GMenv.ROUTECOLOR)); waypointColorMI.addActionListener(new setColorAC(GMenv.WAYPOINTCOLOR)); SetInitZoomMI.addActionListener(new setInitZoomAC()); MCDistance.addActionListener(new distanceAC()); MCPCDistance.addActionListener(new PCdistanceAC()); MCCourse.addActionListener(new courseAC()); nFontSizeMI.addActionListener(new fontSizeAC()); annoFontSizeMI.addActionListener(new annoFontSizeAC()); FileNMEAMI.addActionListener(new FileNMEAMIAC()); trDelMI.addActionListener(new TrDelMIAC()); wpDelMI.addActionListener(new WpDelMIAC()); rtwpDelMI.addActionListener(new RtwpDelMIAC()); allDelMI.addActionListener(new AllDelMIAC()); rtDelMI.addActionListener(new RtDelMIAC()); SetMetricUnits.addActionListener(new UnitMetricAC()); SetKmMetricUnits.addActionListener(new UnitKmMetricAC()); SetNauticalUnits.addActionListener(new UnitNauticalAC()); SetStatuteUnits.addActionListener(new UnitStatuteAC()); //SetUTCMI.addActionListener(new SetUTCMIAC()); exitMI.addActionListener(new ExitMIAC()); exitMI.setShortcut(new MenuShortcut(KeyEvent.VK_Q,false)); saveOptionsMI.addActionListener(new SaveOptionsMIAC()); routeMenu = new Menu("Route"); WActionPanel.setLayout(new BorderLayout()); IGMPanel.setLayout(new BorderLayout()); loadPanel.setLayout(new GridLayout(0,5)); addPanel.setLayout(new FlowLayout()); wpPanel.setLayout(new VFlowLayout()); bottomPanel.setLayout(new BorderLayout()); // waypointList = new List(8, false); waypointList = new EPSList(new Dimension(200,250)); waypointList.setForeground(GMenv.getColor(GMenv.WAYPOINTCOLOR)); //routeList = new List(4, false); routeList = new EPSList(new Dimension(200,90)); routeList.setForeground(GMenv.getColor(GMenv.ROUTECOLOR)); SetIPWMI.addActionListener(new SetIPWMIAC()); printMI.addActionListener(new PrintMIAC()); printChartMI.addActionListener(new PrintChartMIAC()); wpMI.addActionListener(new WpMIAC()); wpMI.setShortcut(new MenuShortcut(KeyEvent.VK_W,false)); rMI.addActionListener(new RMIAC()); rMI.setShortcut(new MenuShortcut(KeyEvent.VK_R,false)); trMI.setShortcut(new MenuShortcut(KeyEvent.VK_T,false)); trMI.addActionListener(new TrMIAC()); ffGPSTRANSMI.addActionListener(new FfGPSTRANSMIAC()); ffGRMMI.addActionListener(new FfGRMMIAC()); ffGLMI.addActionListener(new FfGLMIAC()); pfDDDMI.addActionListener(new pfDDDMIAC()); pfDMMMI.addActionListener(new pfDMMMIAC()); pfDMSMI.addActionListener(new pfDMSMIAC()); waypointList.addActionListener(new gotoWPButAC()); waypointList.addItemListener(new WPListAdapter(this)); waypointList.addActionListener(new WPAListAdapter()); routeList.addItemListener(new RTListAdapter()); routeList.setBackground(Color.white); routeWPList.setForeground(GMenv.getColor(GMenv.ROUTECOLOR)); routeWPList.setBackground(Color.white); waypointList.setBackground(Color.white); nFont = new Font("Helvetica", Font.PLAIN, GMenv.nFontSize); annoFontB = new Font("Helvetica", Font.BOLD, GMenv.annoFontSize); annoFont = new Font("Helvetica", Font.PLAIN, GMenv.annoFontSize); try { int joff; jvver = System.getProperty("java.vendor"); System.out.println(" vendor " + jvver); // jver = System.getProperties().getProperty("java.version"); // System.out.println(" version " + jver); //jcver = System.getProperties().getProperty("java.class.version"); //jcver = System.getProperties().getProperty("java.class.version"); //System.out.println(" We are running java " + jver + " c "+jcver ); //System.out.println(" class " + jcver); System.out.println(" os= " + System.getProperty("os.name") + ", " + System.getProperty("os.arch") +", " + System.getProperty("os.version") ); //System.out.println(" prp " + System.getProperties()); } catch (SecurityException ioe) { System.out.println("Could not read system properties " + ioe); } if (epsEnv.fileFormat!= null){ if (epsEnv.fileFormat.equals("gpstrans")){ fileFormat=Pone.ffGPSTRANS; } else if (epsEnv.fileFormat.equals("garlink")){ fileFormat=Pone.ffGARLINK; } else if (epsEnv.fileFormat.equals("garmin")){ fileFormat=Pone.ffGRM; } } mainContainer.setBackground(new Color(173, 223, 255)); mainContainer.setForeground(Color.black); mainContainer.setLayout(new BorderLayout()); //Set up the menu bar. msave.add(wpMI); msave.add(rMI); msave.add(trMI); mCompute.add(MCDistance); mCompute.add(MCPCDistance); mHelpKeys.add(new MenuItem("left mousebutton: place cursor")); mHelpKeys.add(new MenuItem("right mousebutton: set new trackpoint")); mHelpKeys.add(new MenuItem("p: insert mouse position into pos field")); mHelpKeys.add(new MenuItem("n: Start a new track log")); mHelpKeys.add(new MenuItem("cursor keys: scroll")); mHelp.add(mHelpKeys); mCompute.add(MCCourse); //mSet.add(SetUTCMI); mSet.add(SetInitZoomMI); mSet.add(SetPSizeMI); mSet.add(SetIPWMI); mSet.add(SetUnits); //mSet.add(SetGTWMI); // mSet.add(Garmincomm.portName); // Assumption: only used in one ChartFrame GMenv.wpfile.loadFileArea=loadFileArea; GMenv.rtfile.loadFileArea=loadFileArea; GMenv.trfile.loadFileArea=loadFileArea; mSet.add(GMenv.wpfile); mSet.add(GMenv.rtfile); mSet.add(GMenv.trfile); mDelete.add(allDelMI); mDelete.add(wpDelMI); mDelete.add(rtDelMI); mDelete.add(rtwpDelMI); mDelete.add(trDelMI); //mFileFormat.add(ffGPSTRANSMI); mFileFormat.add(ffGRMMI); mFileFormat.add(ffGLMI); mPosFormat.add(pfDDDMI); mPosFormat.add(pfDMMMI); mPosFormat.add(pfDMSMI); mSetFontSize.add(nFontSizeMI); mSetFontSize.add(annoFontSizeMI); mSetColors.add(trackColorMI); mSetColors.add(routeColorMI); mSetColors.add(waypointColorMI); mf.add(exitMI); mf.add(printChartMI); mf.add(printMI); msave.add(saveOptionsMI); //mf.add(grmInMI); //Carefull here mf.add(FileNMEAMI); mSet.add(mPosFormat); mSet.add(mFileFormat); mSet.add(mMapDatum); mSet.add(mPositionDatum); mSet.add(mSetColors); mSet.add(mSetFontSize); outArea = new EPSTextArea( "Elgaard Positioning System (EPS)\n"+ "version "+CAux.epsversion+", Copyright (C) 1997,1998, 1999 \n"+ "Niels Elgaard Larsen\n"+ "EPS comes with ABSOLUTELY NO WARRANTY.\n"+ "This is free software, and you are \nwelcome to redistribute it"+ "under certain conditions;\n" ); outArea.setEditable(false); IGMCanvas = new ImageGMap(epsEnv, (ICF)this); mPositionDatum.IGMCanvas = IGMCanvas; mMapDatum.IGMCanvas = IGMCanvas; hThread = new Thread(IGMCanvas,"EPS thread"); hThread.start(); // System.out.println(" blp= " + IGMCanvas.bottomLeftPos.toString(Pone.MALL)); // System.out.println(" ny pos"+ (new Pos(epsEnv.initLong,epsEnv.initLat))); // System.out.println(" env: " +epsEnv); //Add small things at the bottom of the window. // bottomPanel.add(chbx); // posFormat.addItem("Positions as d.dddd"); // // posFormat.addItem("Positions as d³mm.mm\'"); // posFormat.addItem("Positions as dgmm.mm\'"); // bottomPanel.add("West",posFormat); zoomSlider=new Scrollbar(Scrollbar.HORIZONTAL, 100, 5, 1, 1000); zoomSlider.addAdjustmentListener(new ZoomAdapter()); try { zoomSlider.setSize(50,20); } catch (NoSuchMethodError ex) { CAux.perr("Hmmm, you better upgrade your VM/browser",1); } bottomPanel.add("East",zoomLabel); bottomPanel.add("Center",zoomSlider); bottomPanel.add("North",pLabel); mainContainer.add("South", bottomPanel); loadWPBut = new Button("Load Waypoints"); loadRTBut = new Button("Load Routes"); addWPBut = new Button("Add cursor WP"); addPWPBut = new Button("Add Position WP"); gotoWPBut = new Button("Goto Waypoint"); gotoPosBut = new Button("Goto Position"); addRTBut = new Button("Add Route"); addWPRTBut = new Button("Add WP to Route"); markWPBut = new Button("Mark WP"); loadTRBut = new Button("Load Track"); SetPSizeMI.addActionListener(new WsizeAC()); loadWPBut.addActionListener(new LoadWPButAC()); loadRTBut.addActionListener(new LoadRTButAC()); addWPBut.addActionListener(new addWPButAC()); addPWPBut.addActionListener(new addPWPButAC()); gotoWPBut.addActionListener(new gotoWPButAC()); gotoPosBut.addActionListener(new gotoWPButAC()); addWPRTBut.addActionListener(new addWPRTButAC()); loadTRBut.addActionListener(new LoadTRButAC()); loadPanel.add(loadWPBut); loadPanel.add(loadTRBut); loadPanel.add(loadRTBut); loadPanel.add(markWPBut); loadPanel.add(addWPBut); loadPanel.add(addPWPBut); loadPanel.add(gotoWPBut); loadPanel.add(gotoPosBut); loadPanel.add(addRTBut); loadPanel.add(addWPRTBut); //WActionPanel.add("Center",loadPanel); IGMPanel.add("West", vert); IGMPanel.add("South", horz); IGMPanel.add("Center",IGMCanvas); // IGMPanel.add("Center",IGMCanvas); northPanel.add(loadPanel); mainContainer.add("North", northPanel); mainContainer.add("Center", IGMPanel); mainContainer.add("South",bottomPanel); markWPBut.addActionListener(new markWPAC()); addRTBut.addActionListener(new addRtAC()); wpPanel.add(NMEALabel); wpPanel.add(loadFileArea); wpPanel.add(posPanelLat); wpPanel.add(posPanelLong); wpPanel.add(waypointList); wpPanel.add(routeList); wpPanel.add(RouteWPLLabel); wpPanel.add(routeWPList); wpPanel.add(outArea); mainContainer.add("East", wpPanel); mainContainer.validate(); if (theWindow != null) { theWindow.setPreferredSize(GMenv.prefSize); theWindow.pack(); CAux.perr("Window size :"+GMenv.prefSize,0); } } static String readline(BufferedReader dis) throws IOException { String inputLine; if (GMenv.useFShield) { inputLine = fShield.sreadLine(dis); } else { inputLine = dis.readLine(); } return(inputLine); } Label getNMEALabel() { return (NMEALabel); } void setNMEALabel(String nl) { NMEALabel.setText(nl); } void setLLPos(Pos wpos) { posPanelLat.setPone(wpos.y); posPanelLong.setPone(wpos.x); } void setupPos() { if (GMenv.posFormat==Pone.DMS) { posPanelLat = new PoneInputDMS(true); posPanelLong = new PoneInputDMS(false); } else if (GMenv.posFormat==Pone.DMM) { posPanelLat = new PoneInputDM(true); posPanelLong = new PoneInputDM(false); } else { posPanelLat = new PoneInputDDD(true); posPanelLong = new PoneInputDDD(false); } } void setMenuNames_english() { exitMI.setName("EXit"); saveOptionsMI.setName("Options"); mf.setName("Files"); mb.add(mf); mb.add(msave); mb.add(mDelete); mb.add(mSet); mb.add(mCompute); if (GMenv.GPSconnect) { //Comment out next line to avoid compiling GPS stuff gps1.setup(gpsMenu); mb.add(gpsMenu); } mb.add(mHelp); if (CAux.tLevel > 1) { MenuItem mTestPack = new MenuItem("valider dol etc"); mb.add(mTest); mTest.add(mTestPack); mTestPack.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { CAux.perr("Test validate",2); if (theApplet != null) { CAux.perr("App Test parems ="+theApplet.getParameterInfo(),2); CAux.perr("App Test parent ="+theApplet.getParent(),2); CAux.perr("App Test size ="+theApplet.getSize(),2); if (theApplet.getParent() != null) { CAux.perr("App Test parent sz="+theApplet.getParent().getSize(),2); //CAux.perr("App Test parent sz="+theApplet.getSize(),2); theApplet.getParent().validate(); } } mainContainer.invalidate(); mainContainer.doLayout(); mainContainer.validate(); } } ); } } static String urlDecode (String us) { // FIXME, this is really for URLDecoder in java 1.2 // but I want it to work with java 1.1 String us0 = us.replace('/',File.separatorChar).replace('|',':'); if (us0.charAt(0)=='\\') { us0 = us0.substring(1); } if (us0.length()>3 && us0.substring(1,4).toLowerCase().equals("%7c")) { us0 = us0.substring(0,1) + ":" + us0.substring(4); } CAux.perr("url decode=" + us0,1); return(us0); } public Datum mapDatum(){ return mMapDatum.theDatum; } int inputInt(int defaultInput) { int ri; try { ri =Integer.parseInt(loadFileArea.getText().trim()); } catch (NumberFormatException me) { CAux.perr(loadFileArea.getText().trim()+" Not an integer",-3); ri = defaultInput; } return(ri); } void redoInputPanel() { loadPanel.invalidate(); wpPanel.invalidate(); routeWPList.invalidate(); waypointList.invalidate(); routeList.invalidate(); loadWPBut.invalidate(); loadTRBut.invalidate(); loadRTBut.invalidate(); WPLPanel.invalidate(); IGMPanel.invalidate(); wpPanel.invalidate(); posPanelLat.invalidate(); posPanelLong.invalidate(); //KKKK mainContainer.pack(); mainContainer.validate(); } void saveOptions() { try { DataOutputStream dos; File oFile = new File(urlDecode(propURL.getFile())); dos = new DataOutputStream(fShield.fos(oFile)); //dos = new DataOutputStream(propURL.openStream()); //dos = ep.getOutputStream(); CAux.perr("start writing options",2); fShield.swrite(dos,"#EPS options file\n"); CAux.perr("After comment",2); fShield.swrite(dos,"eps.winHeight="+GMenv.prefSize.height+"\n"); fShield.swrite(dos,"eps.winWidth="+GMenv.prefSize.width+"\n"); fShield.swrite(dos,"eps.dgpsServer="+GMenv.dgpsSrvMI.toString()+"\n"); fShield.swrite(dos,"eps.dgpsPort="+GMenv.dgpsPortMI.toString()+"\n"); fShield.swrite(dos,"eps.chartdir="+epsEnv.chartdir+"\n"); if (GMenv.wpfile.wval != null) { fShield.swrite(dos,"eps.wpts="+ GMenv.wpfile.wval +"\n"); } if (GMenv.rtfile.wval != null) { fShield.swrite(dos,"eps.routes=" + GMenv.rtfile.wval + "\n"); } if (GMenv.trfile.wval != null) { fShield.swrite(dos,"eps.track=" + GMenv.trfile.wval + "\n"); } fShield.swrite(dos,"eps.initZoom="+epsEnv.initZoom +"\n"); fShield.swrite(dos,"eps.ChartHeight="+epsEnv.ch +"\n"); fShield.swrite(dos,"eps.ChartWidth="+epsEnv.cw+"\n"); fShield.swrite(dos,"eps.fileFormat="+Pone.ffString(fileFormat)+"\n"); fShield.swrite(dos,"eps.posFormat="+GMenv.posFormat+"\n"); fShield.swrite(dos,"eps.units="+epsEnv.units+"\n"); fShield.swrite(dos,"eps.commapi="+epsEnv.commAPI+"\n"); //fShield.swrite(dos,"eps.UTCoff=" + epsEnv.UTC_off+"\n"); fShield.swrite(dos,"eps.ChartDatum="+epsEnv.chartDatum.theDatum.name+"\n"); fShield.swrite(dos,"eps.PositionDatum="+epsEnv.positionDatum.theDatum.name+"\n"); fShield.swrite(dos,"eps.initLongitude=" + epsEnv.initLong+"\n"); fShield.swrite(dos,"eps.initLatitude="+ epsEnv.initLat+"\n"); //fShield.swrite(dos,"eps.gpstranspgm="+ epsEnv.gtpgm+"\n"); fShield.swrite(dos,"eps.portName="+ GMenv.portName.wval+"\n"); fShield.swrite(dos,"eps.trackColor="+ Integer.toHexString(GMenv.getColor(GMenv.TRACKCOLOR).getRGB())+"\n"); fShield.swrite(dos,"eps.routeColor="+ Integer.toHexString(GMenv.getColor(GMenv.ROUTECOLOR).getRGB())+"\n"); fShield.swrite(dos,"eps.waypointColor=" + Integer.toHexString(GMenv.getColor(GMenv.WAYPOINTCOLOR).getRGB())+"\n"); fShield.swrite(dos,"eps.nFontSize="+ GMenv.nFontSize+"\n"); fShield.swrite(dos,"eps.annoFontSize="+ GMenv.annoFontSize+"\n"); // fShield.swrite(dos,"eps.epscomm="+ Garmincomm.epscomm+"\n"); dos.close(); } catch (SecurityException me) { System.out.println(" Security problem " + me); outArea.setText("Could not save options\n" + "You can edit the options in the file "+propURL.getFile()); } catch (IOException me) { System.out.println(" File IOException RT: " + me); outArea.setText("Could not save options\n" + "You can edit the options in the file "+propURL.getFile()); } } public int sign (int x){ return (x>0?1:-1); } Pos getPos() { Pos theP = new Pos(posPanelLong.getPone(), posPanelLat.getPone(), mPositionDatum.theDatum); return theP.toDatum(mMapDatum.theDatum); } void doRtWpList() { Route cr; activeRoute = routeList.getSelectedIndex(); if (activeRoute>=0) { cr = RouteC.routes[activeRoute]; // System.out.println(" new Route "+ cr.name); cr.wpts.flushList(routeWPList,true); RouteWPLLabel.setText("WP's in "+ cr.name.trim()+":"); } } void setZoom(int zsv) { CAux.perr("setZoom "+zsv,2); zzoom = (float) zsv/zoom; zoom = zsv; horz.setValue(500); vert.setValue(500); zoomLabel.setText("zoom: "+zoom+" %"); // System.out.println(" zoom:" + zoom +" ty=" + IGMCanvas.ty0 + " tx0="+IGMCanvas.tx0); IGMCanvas.ttx = IGMCanvas.tx0 = (int) (zzoom* IGMCanvas.ttx + (zzoom-1f)*IGMCanvas.ScreenWidth/2f); IGMCanvas.tty = IGMCanvas.ty0 = (int) (zzoom * (IGMCanvas.tty) + (zzoom-1f)*IGMCanvas.ScreenHeight/2f); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(500); } void newZoom(float nz) { int newZoom = (int)(((float)zoom)*nz); CAux.perr("newZoom "+ nz,2); if (newZoomzoomSlider.getMaximum()) { zoomSlider.setValue(zoomSlider.getMaximum()); } else { zoomSlider.setValue(newZoom); } setZoom(newZoom); } class TrDelMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { TrackC.deleteAll(); IGMCanvas.FullPaint = true; IGMCanvas.repaint(200); } } class AllDelMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { aWP.theWP.deleteAll(); RouteC.deleteAll(); TrackC.deleteAll(); try { waypointList.removeAll(); routeWPList.removeAll(); routeList.removeAll(); } catch (NoSuchMethodError ex) { waypointList.removeAll(); routeWPList.removeAll(); routeList.removeAll(); } epsEnv.rtfile.update(null); epsEnv.trfile.update(null); epsEnv.wpfile.update(null); IGMCanvas.FullPaint= true; IGMCanvas.repaint(200); } } class WpDelMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { int activeWP = waypointList.getSelectedIndex(); if (activeWP>=0) { Route wroute; wroute = RouteC.findWPinRoute(aWP.theWP.wayPoints[activeWP]); if (wroute!=null){ outArea.setText("Cannot delete waypoint in route "+ wroute.name+ "\n"); } else { aWP.theWP.delete(activeWP); aWP.theWP.flushList(waypointList,false); IGMCanvas.FullPaint = true; IGMCanvas.repaint(500); } } IGMCanvas.FullPaint = true; IGMCanvas.repaint(100); } } class RtwpDelMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { int activeRT = routeList.getSelectedIndex(); if (activeRT>=0) { int activeWP = routeWPList.getSelectedIndex(); if (activeWP>=0) { RouteC.routes[activeRT].wpts.delete(activeWP); RouteC.routes[activeRT].wpts.flushList(routeWPList,true); IGMCanvas.FullPaint = true; IGMCanvas.repaint(100); } // RouteC.flushList(routeList); } } } class RtDelMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { int activeRT = routeList.getSelectedIndex(); if (activeRT>=0) { int numRouteList; numRouteList = routeWPList.getItemCount(); RouteC.delete(activeRT); if (numRouteList>0) { // netscape problem routeWPList.removeAll(); IGMCanvas.FullPaint = true; IGMCanvas.repaint(100); } RouteC.flushList(routeList); } } } class SetIPWMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { Pos tpos = getPos(); epsEnv.initLat = tpos.y.p; epsEnv.initLong= tpos.x.p; //epsEnv.initLat = epsEnv.initLat - epsEnv.initLat % (epsEnv.ch/60d); //epsEnv.initLong= epsEnv.initLong - epsEnv.initLong % (epsEnv.cw/60d); try { SetIPWMI. setLabel("Initial position: "+ (new Pos(epsEnv.initLong, epsEnv.initLat, mMapDatum.theDatum)).toString(GMenv.posFormat)); } catch (Exception ex) { CAux.perr("stupid label error",2); } } } class PrintMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { if (theWindow==null) { CAux.perr("does not work in applet",0); return; } try { PrintJob pjob = fShield.getPrintJob(toolK, theWindow, "eps"); if (pjob == null) { System.out.println("pjob=null"); } else { Graphics pg = pjob.getGraphics(); if (pg == null) { System.out.println("printing, pg=" + pg); } else { theWindow.printAll(pg); pg.dispose(); // flush page } pjob.end(); } } catch (Exception ex) { System.out.println("print error" + ex); ex.printStackTrace(); } } } class PrintChartMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { if (theWindow==null) { CAux.perr("does not work int applet",0); return; } try { PrintJob pjob = fShield.getPrintJob(toolK, theWindow, "eps"); if (pjob == null) { System.out.println("pjob=null"); } else { Graphics pg = pjob.getGraphics(); if (pg == null) { System.out.println("printing, pg=" + pg); } else { IGMCanvas.printAll(pg); pg.dispose(); // flush page } pjob.end(); } } catch (Exception ex) { System.out.println("print error" + ex); ex.printStackTrace(); } } } class WpMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { aWP.theWP.output(outArea,fileFormat,epsEnv.UTC_off,mPositionDatum.theDatum, loadFileArea.getText().trim(),epsEnv); } } class RMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { RouteC.output(outArea,fileFormat,epsEnv.UTC_off,mPositionDatum.theDatum, loadFileArea.getText().trim(),epsEnv); } } class TrMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { TrackC.output(outArea,fileFormat,epsEnv.UTC_off,mPositionDatum.theDatum, loadFileArea.getText().trim(),epsEnv); } } class FfGPSTRANSMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { fileFormat=Pone.ffGPSTRANS; } } class FfGRMMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { fileFormat=Pone.ffGRM; } } class FfGLMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { fileFormat=Pone.ffGARLINK; } } class pfDDDMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { GMenv.posFormat=Pone.DDD; setupPos(); redoInputPanel(); } } class pfDMMMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { GMenv.posFormat=Pone.MDD; setupPos(); redoInputPanel(); } } class pfDMSMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { GMenv.posFormat=Pone.DMM; setupPos(); redoInputPanel(); } } class ExitMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { Thread deadThread; if (GMenv.GPSconnect) { gps1.GPSstop(); } deadThread=hThread; hThread = null; deadThread.interrupt(); if (inAnApplet) { System.out.println("Exit EPS applet"); theApplet.setVisible(false); if (theWindow != null) { theWindow.dispose(); } } else { System.out.println("Exit EPS application "); System.exit(0); } } } class SaveOptionsMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { saveOptions(); } } class gotoPosButAC implements ActionListener { public void actionPerformed(ActionEvent event) { IGMCanvas.ggoto(getPos()); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(50); } } class gotoWPButAC implements ActionListener { public void actionPerformed(ActionEvent event) { int activeWP; WayPoint theWP=null; String wpName=loadFileArea.getText().trim().toUpperCase(); activeWP = waypointList.getSelectedIndex(); if (activeWP>=0) { // System.out.println(" goto active WP " + activeWP); theWP = aWP.theWP.wayPoints[activeWP]; // System.out.println(" active WP is "+ theWP.name); } else if (wpName != null && wpName.length()>0) { theWP=aWP.theWP.findWP(wpName); } if (theWP != null) { IGMCanvas.ggoto(theWP.wpos); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(50); } IGMCanvas.FullPaint = true; IGMCanvas.repaint(100); } } class addRtAC implements ActionListener { public void actionPerformed(ActionEvent event) { String rName = loadFileArea.getText().trim().toUpperCase(); if (rName != null && rName.length()>0) { RouteC.insertRoute(outArea, routeList, new Route(rName)); } } } class addWPRTButAC implements ActionListener { public void actionPerformed(ActionEvent event) { WayPoint theWP=null; int activeWP; String wpName; wpName = loadFileArea.getText().trim().toUpperCase(); activeRoute = routeList.getSelectedIndex(); RouteWPLLabel.setText("WP's in "+ RouteC.routes[activeRoute].name.trim() + ":"); if (activeRoute >= 0) { // System.out.println(" AWR active Route "+activeRoute); activeWP = waypointList.getSelectedIndex(); if (activeWP>=0) { // System.out.println(" active WP " + activeWP); theWP = aWP.theWP.wayPoints[activeWP]; // System.out.println(" active WP is "+ theWP.name); } else if (wpName != null && wpName.length()>0) { if (!((theWP=aWP.theWP.findWP(wpName))!=null)) { if (IGMCanvas.cCursor != null){ theWP = new WayPoint(wpName,IGMCanvas.cCursor); aWP.theWP.insertWP(outArea,waypointList,theWP,false); } } } if (theWP != null){ RouteC.routes[activeRoute].wpts.insertWP(outArea,routeWPList,theWP,true); IGMCanvas.AnnoPaint = true; IGMCanvas.musync.upd(500); } } } } class WsizeAC implements ActionListener { public void actionPerformed(ActionEvent event) { GMenv.prefSize.height = mainContainer.getSize().height; GMenv.prefSize.width = mainContainer.getSize().width; } } class LoadWPButAC implements ActionListener { public void actionPerformed(ActionEvent event) { //System.out.println(" read "+ loadFileArea.getText()); aWP.theWP.readWayPoints(outArea,waypointList,epsEnv.epsBase, loadFileArea.getText().trim(), fileFormat, epsEnv); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(500); } } class LoadTRButAC implements ActionListener { public void actionPerformed(ActionEvent event) { TrackC.readTracks(epsEnv.epsBase, loadFileArea.getText(),fileFormat,epsEnv); IGMCanvas.FullPaint = true; IGMCanvas.repaint(100); } } class LoadRTButAC implements ActionListener { public void actionPerformed(ActionEvent event) { RouteC.readRoutes(outArea,routeList,routeWPList, waypointList, epsEnv.epsBase, loadFileArea.getText().trim(), fileFormat, epsEnv); IGMCanvas.FullPaint = true; IGMCanvas.repaint(100); } } class distanceAC implements ActionListener { public void actionPerformed(ActionEvent event) { int activeWP; activeWP = waypointList.getSelectedIndex(); WayPoint theWP=null; if (markedWP==null) { outArea.setText("You Must mark a waypoint to compute a distance\n"); } else if (activeWP<0) { outArea.setText("You meust select a waypoint to compute a distance.\n"); } else { theWP = aWP.theWP.wayPoints[activeWP]; outArea.setText(distFormat.format(theWP.wpos.dist(markedWP.wpos)*GMenv.lengthMul+0.005)+ " "+GMenv.lengthUnitName + " from \n" + markedWP.name.trim()+" to\n"+ theWP.name.trim()); } } } class PCdistanceAC implements ActionListener { public void actionPerformed(ActionEvent event) { Pos ppos, cpos; int activeWP; cpos = IGMCanvas.cCursor; if (cpos == null){ outArea.setText("Cursor must be set\n"); } else { ppos = getPos(); if (ppos == null) { outArea.setText("Positions must be set in pos. panel\n"); } else { // FIXME rounding outArea.setText(distFormat.format(cpos.dist(ppos)*GMenv.lengthMul+0.0049999999)+ " "+GMenv.lengthUnitName + " from\n" + cpos.toString(GMenv.posFormat)+" to\n"+ ppos.toString(GMenv.posFormat)); } } } } class courseAC implements ActionListener { public void actionPerformed(ActionEvent event) { int activeWP; activeWP = waypointList.getSelectedIndex(); WayPoint theWP=null; if (markedWP==null) { outArea.setText("You Must mark a waypoint to compute a course.\n"); } else if (activeWP<0) { outArea.setText("You must select a waypoint to compute a course\n"); } else { theWP = aWP.theWP.wayPoints[activeWP]; CAux.perr("MC:"+markedWP.wpos.icoursedg(theWP.wpos),1); outArea.setText((int) (theWP.wpos.icoursedg(markedWP.wpos)+0.5)+ //"\u00B0"+ " degrees" + ": initial course from " + markedWP.name.trim()+" to "+ theWP.name.trim()); } } } class markWPAC implements ActionListener { public void actionPerformed(ActionEvent event) { int activeWP; activeWP = waypointList.getSelectedIndex(); if (activeWP>=0) { markedWP = aWP.theWP.wayPoints[activeWP]; CAux.perr("mark flush ", 2); aWP.theWP.flushList(waypointList,false); if (activeWP>=0) { waypointList.deselect(activeWP); } CAux.perr("Setting wp mark at " + activeWP, 2); waypointList.replaceItem("* " + markedWP.name, activeWP); CAux.perr("Set mark at " + markedWP,2); } } } class FileNMEAMIAC implements ActionListener { public void actionPerformed(ActionEvent event) { CAux.perr("File NMEA",2); NMEAdata fNMEA = new NMEAdata(IGMCanvas, NMEALabel); fNMEA.readFile(outArea, epsEnv.epsBase, loadFileArea.getText().trim()); } } class setInitZoomAC implements ActionListener { public void actionPerformed(ActionEvent event) { String lv = loadFileArea.getText().trim(); epsEnv.initZoom = (int)IGMCanvas.yres; zoom = 100; zoomSlider.setValue(100); zoomLabel.setText("zoom: "+zoom+"%"); } } class addWPButAC implements ActionListener { public void actionPerformed(ActionEvent event) { if (IGMCanvas.cCursor != null){ String nwp = loadFileArea.getText().trim(); if (nwp.length()>0) { aWP.theWP.insertWP(outArea,waypointList, new WayPoint(nwp.toUpperCase(), IGMCanvas.cCursor),false); IGMCanvas.AnnoPaint = true; IGMCanvas.repaint(50); } } } } class addPWPButAC implements ActionListener { public void actionPerformed(ActionEvent event) { Pos np; np = getPos(); aWP.theWP.insertWP(outArea,waypointList, new WayPoint(loadFileArea.getText().trim().toUpperCase(), np),false); IGMCanvas.AnnoPaint = true; IGMCanvas.repaint(50); } } class RTListAdapter implements ItemListener { public void itemStateChanged(ItemEvent event) { Route cr; activeRoute = routeList.getSelectedIndex(); if (activeRoute>=0){ cr = RouteC.routes[activeRoute]; // System.out.println(" new Route "+ cr.name); cr.wpts.flushList(routeWPList,true); RouteWPLLabel.setText("WP's in "+ cr.name.trim()+":"); } } } class WPListAdapter implements ItemListener { ICF theCF; WPListAdapter (ICF cf) { theCF = cf; } public void itemStateChanged(ItemEvent event) { //Object target = event.getItem(); Pos wpos; if (event.getStateChange() == ItemEvent.SELECTED) { int activeWP = 0; WayPoint theWP=null; try { activeWP = waypointList.getSelectedIndex(); } catch (Exception ex) { CAux.perr("J++ err a: " + ex, 1); } if (activeWP >= 0) { theWP = aWP.theWP.wayPoints[activeWP]; wpos = theWP.wpos.toDatum(mPositionDatum.theDatum); setLLPos(wpos); } } else if (event.getStateChange() == ItemEvent.DESELECTED) { int activeWP = 0; WayPoint theWP=null; CAux.perr("deselect MS?+ " + event, 2); // stupid MS J++ try { activeWP = waypointList.getSelectedIndex(); } catch (Exception ex) { CAux.perr("J++ err: " + ex, 1); } posPanelLat.reset(); posPanelLong.reset(); if (activeWP >=0){ waypointList.deselect(activeWP); } } } } class UnitMetricAC implements ActionListener { public void actionPerformed(ActionEvent event) { epsEnv.setMetric(); IGMCanvas.FullPaint = true; doRtWpList(); IGMCanvas.musync.upd(50); } } class UnitKmMetricAC implements ActionListener { public void actionPerformed(ActionEvent event) { epsEnv.setKmMetric(); IGMCanvas.FullPaint = true; doRtWpList(); IGMCanvas.musync.upd(50); } } class UnitNauticalAC implements ActionListener { public void actionPerformed(ActionEvent event) { epsEnv.setNautical(); IGMCanvas.FullPaint = true; doRtWpList(); IGMCanvas.musync.upd(50); } } class UnitStatuteAC implements ActionListener { public void actionPerformed(ActionEvent event) { epsEnv.setStatute(); IGMCanvas.FullPaint = true; doRtWpList(); IGMCanvas.musync.upd(50); } } class annoFontSizeAC implements ActionListener { public void actionPerformed(ActionEvent event) { GMenv.annoFontSize = inputInt(GMenv.annoFontSize); annoFontB = new Font("Helvetica", Font.BOLD, GMenv.annoFontSize); annoFont = new Font("Helvetica", Font.PLAIN, GMenv.annoFontSize); mainContainer.invalidate(); //KKKK mainContainer.pack(); mainContainer.validate(); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(300); } } class setColorAC implements ActionListener { int colId; public setColorAC(int cn) { colId = cn; } public void actionPerformed(ActionEvent event) { GMenv.setColor(colId, new Color((int)Long.parseLong(loadFileArea.getText().trim(),16))); IGMCanvas.invalidate(); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(50); } } class fontSizeAC implements ActionListener { public void actionPerformed(ActionEvent event) { GMenv.nFontSize = inputInt(GMenv.nFontSize); nFont = new Font("Helvetica", Font.PLAIN, GMenv.nFontSize); mainContainer.setFont(nFont); //doLayout(); redoInputPanel(); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(50); } } class WPAListAdapter implements ActionListener { public void actionPerformed(ActionEvent event) { int activeWP; Pos wpos; WayPoint theWP=null; activeWP = waypointList.getSelectedIndex(); theWP = aWP.theWP.wayPoints[activeWP]; wpos = theWP.wpos.toDatum(mPositionDatum.theDatum); setLLPos(wpos); IGMCanvas.ggoto(theWP.wpos); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(50); } } class ZoomAdapter implements AdjustmentListener { public void adjustmentValueChanged(AdjustmentEvent event) { setZoom(zoomSlider.getValue()); } } class PanAdapter implements AdjustmentListener { boolean isVert; PanAdapter(boolean isv) { isVert=isv; } public void adjustmentValueChanged(AdjustmentEvent event) { int atp = event.getAdjustmentType(); CAux.perr(" pandap vt "+ event + " atp="+atp,12); switch (atp) { case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED : case AdjustmentEvent.TRACK : case AdjustmentEvent.UNIT_DECREMENT: case AdjustmentEvent.UNIT_INCREMENT: case AdjustmentEvent.BLOCK_DECREMENT: case AdjustmentEvent.BLOCK_INCREMENT: if (isVert) { int nv = vert.getValue(); if (nv<=25 && atp==AdjustmentEvent.UNIT_DECREMENT) { vert.setValue(500); IGMCanvas.ty0 += 500; } else if (nv>=999 && atp ==AdjustmentEvent.UNIT_INCREMENT) { vert.setValue(500); IGMCanvas.ty0 -= 500; } nv = vert.getValue(); if (nv==0) { vert.setValue(1); nv=1; } else if (nv>=1000) { vert.setValue(999); } IGMCanvas.tty = IGMCanvas.ty0 +(500 - nv); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(300); // IGMCanvas.repaint(1000); } else /*HORZ */ { int nv = horz.getValue(); if (nv>=999 && atp == AdjustmentEvent.UNIT_INCREMENT) { horz.setValue(500); IGMCanvas.tx0 += 500; } else if (nv<=1 && atp==AdjustmentEvent.UNIT_DECREMENT) { horz.setValue(500); IGMCanvas.tx0 -= 500; } nv = horz.getValue(); if (nv==0) { horz.setValue(1); nv = 1; } else if (nv >= 1000) { horz.setValue(999); } // System.out.println(" horz = "+nv); IGMCanvas.ttx = IGMCanvas.tx0 + nv - 500; CAux.perr("horz = "+horz.getValue(),2); IGMCanvas.FullPaint = true; IGMCanvas.musync.upd(300); } default: { } } } } }