Results 1 to 20 of 21
-
Anyone else get this private message?
Received via private message:
Originally Posted by anthony582
Anyone else get this?
His code:
Java Code:/** * @(#)Project.java * * Project application * <Project 2e jaar Groep 5> !!! * @author Degrande Anthony & Gert-jan Soenen * @version 1.00 2011/2/15 * * Beschrijving : (vervang door je eigen beschrijving) !!! * Een standaard-programma met een paneel met een knop, * tekstvak en event-afhandeling, aan te passen naargelang * wat je nodig hebt ... * */ //package com.atmel.atusbhidjni; import com.atmel.atusbhidjni.AtUsbHidJni; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; import java.text.*; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.Container; import java.awt.GridLayout; import java.awt.Image; import java.awt.Toolkit; import java.awt.TextField; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Date; import javax.swing.Timer; import java.io.*; import flanagan.math.Fmath; import flanagan.integration.Integration; import flanagan.integration.IntegralFunction; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.MeterPlot; import org.jfree.data.general.*; import org.jfree.chart.plot.DialShape; import org.jfree.data.Range; import org.jfree.ui.RefineryUtilities; import org.jfree.chart.plot.*; import org.jfree.chart.plot.JThermometer.*; import org.jfree.chart.plot.ThermometerPlot.*; import org.jdesktop.swingx.JXMapViewer; import org.jdesktop.swingx.mapviewer.GeoPosition; import org.jdesktop.swingx.mapviewer.Waypoint; import org.jdesktop.swingx.mapviewer.WaypointPainter; import org.jdesktop.swingx.mapviewer.WaypointRenderer; import org.jdesktop.swingx.mapviewer.wms.WMSService; import org.jdesktop.swingx.mapviewer.wms.WMSTileFactory; import org.jdesktop.swingx.*; public class Project extends JFrame { public static void main(String[] argumentenRij) { JFrame frame = new Project(); frame.setSize(1000,760); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTabbedPane tab = new JTabbedPane(); frame.add(tab, BorderLayout.CENTER); frame.setTitle("Virtueel Dashboard - Project 2e jaar: Groep 5"); Paneel paneel = new Paneel(); Paneel1 paneel1 = new Paneel1(); Paneel2 paneel2 = new Paneel2(); Paneel3 paneel3 = new Paneel3(); frame.setContentPane( tab ); frame.setVisible(true); frame.setResizable(false); frame.setLocationRelativeTo(null); tab.addTab("Meetwaarden", paneel); tab.addTab("GPS MAP", paneel1); int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; JScrollPane jsp=new JScrollPane(paneel2,v,h); tab.addTab("Info", jsp); tab.addTab("Help", paneel3); paneel1.setBackground(Color.GRAY); paneel2.setBackground(Color.WHITE); } } class Paneel extends JPanel { public DefaultValueDataset data = new DefaultValueDataset(0.0); private MeterPlot meterplot = new MeterPlot(this.data); private JFreeChart meterchart = new JFreeChart("Snelheid", JFreeChart.DEFAULT_TITLE_FONT, this.meterplot, false); private ChartPanel panelMeter = new ChartPanel(this.meterchart); public JThermometer thermo1 = new JThermometer(); private JLabel InfoLabel, TemperatuurLabel, StatusLabel, GrafiekLabel; public JLabel VersnellingsLabelX, VersnellingsLabelY, Longtitude, Latitude; private JButton StartKnop, TestKnop, StopKnop, EnkeleTestKnop; private JPanel deze; public Simulatie d; public UsbThread thr; public JTextArea datalog; public JTextField CommandLine; public JScrollPane scrollAccelero; public ArrayList<Info> informatie; private ArrayList<Punten> grafiekpunten; private JRadioButton TempRadio, GPSRadio, AccRadio, USBStartRadio, USBRestartRadio; public AtUsbHidJni usbDevice = null; ClockLabel clock = new ClockLabel(); public boolean Geklikt, Test; public double beginsnelheid, maxValue, sub1, sub2, sub3, range1, range2, range3, ticksize; private int Keuze, Start; public Paneel() { String libraryPath = System.getProperty("user.dir") + "\\AtUsbHidJni"; try { usbDevice = new AtUsbHidJni(); } catch (UnsatisfiedLinkError ex) { System.out.println("Verbinding niet goed!"); /* System.err.println("AtUsbHid.AtUsbHid():UnsatisfiedLinkError"); JOptionPane.showMessageDialog(null, "AtUsbHid.AtUsbHid():UnsatisfiedLinkError\n" + "Can't find " + libraryPath + ".dll", "AtUsbHidJni.java error", JOptionPane.ERROR_MESSAGE); System.exit(0); */ } catch (SecurityException ex) { System.out.println("Beveiligingsrisco!"); /* JOptionPane.showMessageDialog(null, "AtUsbHid.AtUsbHid():SecurityException", "AtUsbHidJni.java error", JOptionPane.ERROR_MESSAGE); System.exit(0); */ } catch (NullPointerException ex) { System.out.println("U zoekt iets die er niet is!"); /* JOptionPane.showMessageDialog(null, "AtUsbHid.AtUsbHid():NullPointerException", "AtUsbHidJni.java error", JOptionPane.ERROR_MESSAGE); System.err.println("AtUsbHid.AtUsbHid():NullPointerException"); System.exit(0); */ } if(usbDevice.loadLibraryUsbHid() == false) { System.out.println("Can't load library"); /* JOptionPane.showMessageDialog(null, "DemoAtUsbHid.main():LoadLibrary", "AtUsbHidGui.java error", JOptionPane.ERROR_MESSAGE); System.exit(0); */ } deze = this; maxValue = 35.0; setLayout( null ); this.thermo1.addSubtitle("Motor temperatuur"); sub1 = 20.0; sub2 = 27.5; sub3 = 35.0; thermo1.setRange(0.0, sub3); thermo1.setSubrangeInfo(0, 0.0,sub1,0,0); thermo1.setSubrangeInfo(1, sub1, sub2,0,0); thermo1.setSubrangeInfo(2, sub2, sub3,0,0); thermo1.setValuePaint(Color.BLUE); this.meterplot.setDialShape(DialShape.CHORD); range1 = 0.25; range2 = 0.4; range3 = 0.5; meterplot.addInterval(new MeterInterval("Normal", new Range(0.0, range1), Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0))); meterplot.addInterval(new MeterInterval("Warning", new Range(range1, range2), Color.lightGray, new BasicStroke(2.0F), new Color(255, 140, 0))); meterplot.addInterval(new MeterInterval("Critical", new Range(range2, range3), Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0))); meterplot.setNeedlePaint(Color.BLACK); meterplot.setTickPaint(Color.BLACK); meterplot.setValuePaint(Color.WHITE); meterplot.setUnits("Km/h"); meterplot.setRange(new Range(0.0, range3)); ticksize = 0.05; meterplot.setTickSize(ticksize); meterplot.setDialBackgroundPaint(Color.gray); meterplot.setTickLabelPaint(Color.BLACK); InfoLabel = new JLabel ("Klik op 'Startup!' om te beginnen."); StatusLabel = new JLabel ("Gestopt!"); GrafiekLabel = new JLabel ("Temperatuur i.f.v. de tijd"); VersnellingsLabelX = new JLabel ("Versnelling X: "); VersnellingsLabelY = new JLabel ("Versnelling Y: "); TemperatuurLabel = new JLabel ("Laatst gemeten temperatuur:"); Longtitude = new JLabel("Longtitude : "); Latitude = new JLabel("Latitude : "); StartKnop = new JButton( "USB data" ); StartKnop.addActionListener( new StartKnopHandler() ); TestKnop = new JButton( "Test run" ); TestKnop.addActionListener( new TestKnopHandler() ); StopKnop = new JButton( "Stop alles" ); StopKnop.addActionListener( new StopKnopHandler() ); EnkeleTestKnop = new JButton( "Functie test" ); EnkeleTestKnop.addActionListener( new EnkeleTestKnopHandler() ); datalog = new JTextArea(10,30); datalog.setEditable(false); JScrollPane log = new JScrollPane(datalog); datalog.setForeground(Color.WHITE); datalog.setBackground(Color.BLACK); datalog.setText("Voer 'help' in voor meer informatie over de mogelijke commando's"); datalog.append("Datalog: Datum - Temperatuur - (x, y):" + "\n"); CommandLine = new JTextField("> Commando's kunnen hier ingegeven worden. Typ 'Help' voor een overzicht."); CommandLine.setBackground(Color.BLACK); CommandLine.setForeground(Color.WHITE); CommandLine.addActionListener( new CommandLineHandler() ); CommandLine.setCaretColor(Color.WHITE); informatie = new ArrayList<Info>(); grafiekpunten = new ArrayList<Punten>(); TempRadio = new JRadioButton("Temperatuur"); TempRadio.setMnemonic(KeyEvent.VK_B); TempRadio.setActionCommand("Temperatuur"); GPSRadio = new JRadioButton("GPS"); GPSRadio.setMnemonic(KeyEvent.VK_B); GPSRadio.setActionCommand("GPS"); AccRadio = new JRadioButton("Acceleratie"); AccRadio.setMnemonic(KeyEvent.VK_B); AccRadio.setActionCommand("Acceleratie"); USBStartRadio = new JRadioButton("Start USB"); USBStartRadio.setMnemonic(KeyEvent.VK_B); USBStartRadio.setActionCommand("Start USB"); USBRestartRadio = new JRadioButton("Herstart USB"); USBRestartRadio.setMnemonic(KeyEvent.VK_B); USBRestartRadio.setActionCommand("Herstart USB"); ButtonGroup group = new ButtonGroup(); group.add(TempRadio); group.add(GPSRadio); group.add(AccRadio); ButtonGroup group2 = new ButtonGroup(); group2.add(USBStartRadio); group2.add(USBRestartRadio); TempRadio.addActionListener( new TempRadioHandler() ); GPSRadio.addActionListener( new GPSRadioHandler() ); AccRadio.addActionListener( new AccRadioHandler() ); USBRestartRadio.addActionListener( new USBRestartRadioHandler() ); USBStartRadio.addActionListener( new USBStartRadioHandler() ); log.setBounds(0 , 500 , 993, 165); InfoLabel.setBounds(10,5,200,20); StartKnop.setBounds(250,5,90,20); StopKnop.setBounds(350,5,90,20); TestKnop.setBounds(450,5,90,20); StatusLabel.setBounds(590, 5, 200, 20 ); clock.setBounds(10,30,200,20); GrafiekLabel.setBounds(10, 340, 200, 20 ); VersnellingsLabelX.setBounds(415, 200, 200, 20 ); VersnellingsLabelY.setBounds(415, 220, 200, 20 ); TempRadio.setBounds(500, 30, 100, 20); GPSRadio.setBounds(650, 30, 100, 20); AccRadio.setBounds(800, 30, 100, 20); USBRestartRadio.setBounds(250,25,100,20); USBStartRadio.setBounds(250,45,100,20); EnkeleTestKnop.setBounds(400,30,100,20); this.panelMeter.setBounds(650,200,270,270); this.thermo1.setBounds(20,45,200,300); CommandLine.setBounds(0, 665, 993, 30); Longtitude.setBounds(400,60,200,20); Latitude.setBounds(650,60,200,20); add( InfoLabel); add( StatusLabel ); add( StartKnop ); add( TestKnop ); add( StopKnop ); add( TemperatuurLabel ); add( clock ); add( VersnellingsLabelX ); add( VersnellingsLabelY ); add( log ); add( GrafiekLabel ); add( TempRadio ); add( GPSRadio ); add( AccRadio ); add( USBRestartRadio ); add( USBStartRadio ); add( EnkeleTestKnop ); add( this.panelMeter, BorderLayout.CENTER); add( this.thermo1,BorderLayout.CENTER ); add( CommandLine ); add( Longtitude ); add( Latitude ); if (usbDevice.findHidDevice(0x1234, 0x0001) == 1) { System.out.println("Device gevonden"); StartKnop.setEnabled(true); USBStartRadio.setEnabled(true); USBRestartRadio.setEnabled(true); } else { USBStartRadio.setEnabled(false); } } public void paintComponent( Graphics g ) { super.paintComponent( g ); // Code voor het inkleuren van de statusled g.setColor( Color.RED ); g.fillOval (560,5,20,20); if (Geklikt == true){ g.setColor( Color.GREEN ); g.fillOval (560,5,20,20); StatusLabel.setText("Data via USB binnenlezen."); } else if (Test == true){ g.setColor( Color.ORANGE ); g.fillOval (560,5,20,20); StatusLabel.setText("Simulatie."); } else { g.setColor( Color.RED ); g.fillOval (560,5,20,20); StatusLabel.setText("Gestopt!"); } // Einde code inkleuren statusled // Code voor het tekenen van de grafiek van de temperatuur Graphics2D g2 = (Graphics2D)g; int x0 = 25; int y0 = 475; Punten startPunten = new Punten(x0, y0); grafiekpunten.add(startPunten); g2.setPaint (Color.WHITE); g2.fillRect (x0-27, y0-110, 328, 115); // witte achtergrond toevoegen g2.setPaint(Color.BLUE); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawLine (x0, y0-100, x0, y0); // voor de y-as g2.drawLine (x0, y0, y0-200, y0); //voor de x-as g2.drawLine (x0+300, y0, x0-2, y0); // voor 0 waarde g2.drawString ("0", x0-25, y0+5); g2.drawLine (x0+300, y0-14, x0-2, y0-14); // voor 5 int max1 = (int)(maxValue/7); g2.drawString ((Integer.toString(max1)), x0-25, y0-9); g2.drawLine (x0+300, y0-28, x0-2, y0-28); // voor 10 int max2 = (int)((maxValue/7)*2); g2.drawString ((Integer.toString(max2)), x0-25, y0-23); g2.drawLine (x0+300, y0-42, x0-2, y0-42); // voor 15 int max3 = (int)((maxValue/7)*3); g2.drawString ((Integer.toString(max3)), x0-25, y0-37); g2.drawLine (x0+300, y0-57, x0-2, y0-57); // voor 20 int max4 = (int)((maxValue/7)*4); g2.drawString ((Integer.toString(max4)), x0-25, y0-52); g2.drawLine (x0+300, y0-72, x0-2, y0-72); // voor 25 int max5 = (int)((maxValue/7)*5); g2.drawString ((Integer.toString(max5)), x0-25, y0-67); g2.drawLine (x0+300, y0-86, x0-2, y0-86); // voor 30 int max6 = (int)((maxValue/7)*6); g2.drawString ((Integer.toString(max6)), x0-25, y0-81); g2.drawLine (x0+300, y0-100, x0-2, y0-100); // voor 35 int max7 = (int)maxValue;//Double.toString(maxValue); g2.drawString ((Integer.toString(max7)), x0-25, y0-95); double xScale = 300/(informatie.size() + 1); double yScale = 100/maxValue; g2.setPaint(Color.RED); for(int j = 1; j < informatie.size(); j++) { int x = (int)((x0 + (int)(xScale * (j+1)))); int y = (int)(y0 -(int)(yScale * informatie.get(j).gettemperatuur())); Punten tempPunten = new Punten(x , y); grafiekpunten.add(tempPunten); int xlaatst = ((grafiekpunten.get(grafiekpunten.size()-1).getx())); int ylaatst = ((grafiekpunten.get(grafiekpunten.size()-1).gety())); g2.fillOval(xlaatst, ylaatst, 1, 1); int xvorig = (grafiekpunten.get(grafiekpunten.size()-2).getx()); int yvorig = (grafiekpunten.get(grafiekpunten.size()-2).gety()); g2.drawLine( xvorig, yvorig, xlaatst, ylaatst); } // Code voor de grafiek eindigt hier // Code voor de acceleratiegrafiek int accx0 = 450; int accy0 = 350; g2.setPaint(Color.WHITE); g2.fillRect(accx0-75,accy0-75,150,150); g2.setPaint(Color.BLACK); g2.drawString("-1,5G",accx0-115,accy0+5); g2.drawString("+1,5G",accx0-13,accy0-85); g2.drawString("+1,5G",accx0+85,accy0+5); g2.drawString("-1,5G",accx0-13,accy0+90); g2.drawOval(accx0-75,accy0-75,150,150); // 1.5 lijn g2.drawOval(accx0-50,accy0-50,100,100); // 1.0 lijn g2.drawOval(accx0-25,accy0-25,50,50); // 0.5 lijn g2.drawLine(accx0-80,accy0,accx0+80,accy0); // x-as g2.drawLine(accx0,accy0-80,accx0,accy0+80); // y -as g2.setPaint(Color.RED); if(informatie.size() > 0) { int z = accx0 + (int)(informatie.get( informatie.size()-1 ).getacceloX()/2); int q = accy0 - (int)(informatie.get( informatie.size()-1 ).getacceloY()/2); g2.fillOval(z-2, q-2, 4, 4); } // Einde code voor de acceleratiegrafiek } class CommandLineHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { String ingave = ((CommandLine.getText()).toLowerCase()); String[] invoer = ingave.split("-"); if (ingave.equals("help")){ datalog.append("De mogelijke commando's zijn: " +"\n"); datalog.append(" 0. help " +"\n"); datalog.append(" 1. thermo-'maximale temperatuur die kan afgebeeld worden op de thermometer' " +"\n"); datalog.append(" 2. temp-'maximale temperatuur die kan afgebeeld worden op de grafiek' " +"\n"); datalog.append(" 3. speedorange-'maximale snelheid die kan afgbeeld worden op de snelheidsmeter' " +"\n"); datalog.append(" 4. ticksize-'aantal punten waarin de snelheidsmeter wordt verdeeld' " +"\n"); datalog.append(" 5. simstart: start de simulatie " +"\n"); datalog.append(" 6. stop: stopt de simulatie of het binnenlezen via usb. " +"\n"); datalog.append(" 7. usbstart: start het binnenlezen via usb " +"\n"); } else if (invoer[0].equals("temp")){ maxValue = Integer.parseInt(invoer[1]); datalog.append("De nieuwe maximum waarde van de temperatuur is: " + maxValue +"\n"); } else if (invoer[0].equals("thermo")){ sub3 = (Double.parseDouble(invoer[1])); sub2 = ((Double.parseDouble(invoer[1])/7)*6); sub1 = ((Double.parseDouble(invoer[1])/7)*4); thermo1.setRange(0.0, sub3); thermo1.setSubrangeInfo(0, 0.0,sub1,0,0); thermo1.setSubrangeInfo(1, sub1, sub2,0,0); thermo1.setSubrangeInfo(2, sub2, sub3,0,0); datalog.append("Normale temperatuur: " + sub1 +"\n"); datalog.append("Waarschuwings temperatuur: " + sub2 +"\n"); datalog.append("Kritieke temperatuur: " + sub3 +"\n"); } else if (invoer[0].equals("speedorange")){ range1 = ((Double.parseDouble(invoer[1])/7)*4); range2 = ((Double.parseDouble(invoer[1])/7)*6); range3 = (Double.parseDouble(invoer[1])); System.out.println("range1: " +range1); System.out.println("range2: " +range2); System.out.println("range3: " +range3); meterplot.setRange(new Range(0.0, range3)); meterplot.addInterval(new MeterInterval("Normal", new Range(0.0, range1), Color.lightGray, new BasicStroke(2.0F), new Color(0, 255, 0))); meterplot.addInterval(new MeterInterval("Warning", new Range(range1, range2), Color.lightGray, new BasicStroke(2.0F), new Color(255, 140, 0))); meterplot.addInterval(new MeterInterval("Critical", new Range(range2, range3), Color.lightGray, new BasicStroke(2.0F), new Color(255, 0, 0))); meterplot.setTickSize(range3/10); datalog.append("Normale snelheid: " + range1 +"\n"); datalog.append("Waarschuwings snelheid: " + range2 +"\n"); datalog.append("Kritieke snelheid: " + range3 +"\n"); } else if (invoer[0].equals("ticksize")){ ticksize = (Double.parseDouble(invoer[1])); meterplot.setTickSize(ticksize); datalog.append("Nieuwe verdeling is: " + ticksize +"\n"); } else if (invoer[0].equals("simstart")){ Test = true; Geklikt = false; repaint(); TestKnop.setEnabled(false); d = new Simulatie(deze, informatie, Test, VersnellingsLabelX, VersnellingsLabelY, datalog, data, thermo1, Longtitude, Latitude); d.start(); datalog.append("Simulatie gestart om: " + clock.getText() + "\n"); } else if (invoer[0].equals("stop")){ if (Test == true){ d.stop(); datalog.append("Simulatie gestopt om: " + clock.getText() + "\n"); } else if (Geklikt == true){ System.out.println("Gestopt!"); datalog.append("Data binnenlezen via USB gestopt om: " + clock.getText() + "\n"); usbDevice.closeDevice(); } Test = false; Geklikt = false; repaint(); TestKnop.setEnabled(true); } else if (invoer[0].equals("wissen")){ informatie.clear(); repaint(); } else { datalog.append("Commando onbekend! Typ 'Help' voor meer informatie." + "\n"); } } } class StartKnopHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { switch (Start){ case 1: System.out.println("Start"); Geklikt = true; Test = false; System.out.println("Usb device geselecteerd"); usbDevice = new AtUsbHidJni(); UsbThread thr = new UsbThread(deze, usbDevice, datalog); thr.start(); StartKnop.setEnabled(false); repaint(); break; case 2: Geklikt = true; Test = false; System.out.println("Restart"); if (usbDevice.findHidDevice(0x1234, 0x0001) == 1) { System.out.println("Device gevonden"); StartKnop.setEnabled(true); } else { StartKnop.setEnabled(false); } break; default: datalog.append("Maak eerst een keuze!" + "\n"); break; } } } class TestKnopHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { Test = true; Geklikt = false; repaint(); TestKnop.setEnabled(false); d = new Simulatie(deze, informatie, Test, VersnellingsLabelX, VersnellingsLabelY, datalog, data, thermo1, Longtitude, Latitude); d.start(); datalog.append("Simulatie gestart om: " + clock.getText() + "\n"); } } class StopKnopHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { if (Test == true){ d.stop(); datalog.append("Simulatie gestopt om: " + clock.getText() + "\n"); } else if (Geklikt == true){ System.out.println("Gestopt!"); usbDevice.closeDevice(); datalog.append("Data binnenlezen via USB gestopt om: " + clock.getText() + "\n"); } System.out.println(Test + "en" + Geklikt); Test = false; Geklikt = false; repaint(); TestKnop.setEnabled(true); StartKnop.setEnabled(true); USBRestartRadio.setEnabled(true); USBStartRadio.setEnabled(false); } } class EnkeleTestKnopHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { switch (Keuze){ case 1: System.out.println("Temp"); // code voor de puls via usb te zenden break; case 2: System.out.println("GPS"); //code voor de puls via usb te zenden break; case 3: System.out.println("Acc"); //code om de puls via usb te zenden break; default: datalog.append("Maak eerst een keuze!" + "\n"); break; } } } class TempRadioHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { Keuze = 1; } } class GPSRadioHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { Keuze = 2; } } class AccRadioHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { Keuze = 3; } } class USBRestartRadioHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { Start = 2; } } class USBStartRadioHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { Start = 1; } } class ClockLabel extends JLabel implements ActionListener { public ClockLabel() { super("" + new Date()); Timer t = new Timer(1000, this); t.start(); } public void actionPerformed(ActionEvent ae) { setText((new Date()).toString()); } } } class Paneel1 extends JPanel { private JXMapKit jXMapKit1; double test1, test2; public Paneel1() { test1 = 51.22268; test2 = 2.89277; //test1 = Double.parseDouble(bla1.getText()); //test2 = Double.parseDouble(bla2.getText()); setLayout( null ); jXMapKit1 = new JXMapKit(); jXMapKit1.setDefaultProvider(org.jdesktop.swingx.JXMapKit.DefaultProviders.OpenStreetMaps); jXMapKit1.setName("jXMapKit1"); jXMapKit1.setBounds(2,2,985,698); jXMapKit1.setAddressLocation(new GeoPosition(test1,test2)); jXMapKit1.setZoom(1); jXMapKit1.setAddressLocationShown(true); add( jXMapKit1); } public void paintComponent( Graphics g ) { super.paintComponent( g ); } } class Paneel2 extends JPanel { private JLabel image1, image2, image3; public Paneel2() { setLayout(new GridLayout(3,1,0,-100)); image1 = new JLabel(); image2 = new JLabel(); image3 = new JLabel(); image1.setIcon(new javax.swing.ImageIcon("project1.jpg")); image2.setIcon(new javax.swing.ImageIcon("project2.jpg")); image3.setIcon(new javax.swing.ImageIcon("project3.jpg")); add( image1 ); add( image2 ); add( image3 ); } public void paintComponent( Graphics g ) { super.paintComponent( g ); } } class Paneel3 extends JPanel { private JLabel InfoLabel1; public Paneel3() { setLayout( null ); InfoLabel1 = new JLabel ("Klik op 'Startup!' om te beginnen."); InfoLabel1.setBounds(10,5,200,20); add( InfoLabel1); } public void paintComponent( Graphics g ) { super.paintComponent( g ); } } // thread voor de testroutine class Simulatie extends Thread { JPanel g; public JLabel VersnellingsLabelX, VersnellingsLabelY, Longtitude, Latitude; String Temperatuur, VersnellingX, VersnellingY; boolean Test; double acceleratieX, acceleratieY; public JTextArea datalog; public ArrayList<Info> informatie; public double accX; public double beginsnelheid, snelheid, nieuwesnelheid; public double value; public DefaultValueDataset data; public JThermometer thermo1; public Simulatie(JPanel g, ArrayList<Info> informatie, boolean Test, JLabel VersnellingsLabelX, JLabel VersnellingsLabelY, JTextArea datalog, DefaultValueDataset data, JThermometer thermo1, JLabel Longtitude, JLabel Latitude) { this.informatie = informatie; this.g = g; this.Test = Test; this.VersnellingsLabelX = VersnellingsLabelX; this.VersnellingsLabelY = VersnellingsLabelY; this.datalog = datalog; this.data = data; this.thermo1 = thermo1; this.Longtitude = Longtitude; this.Latitude = Latitude; } public void run() { while (Test) { try { //genereren random temperatuur int waarde = (int) (5 * Math.random() + 20); //data[i] = waarde; Temperatuur = Integer.toString(waarde); this.thermo1.setValue(waarde); // genereren random versnelling double acceleratieX = (double) (1.5 * Math.random() + 0); double acceleratieY = (double) (1.5 * Math.random() + 0); int Tempx = (int)(acceleratieX*100); double Tempx2 = Tempx/100.0; int Tempy = (int)(acceleratieY*100); double Tempy2 = Tempy/100.0; int polariteit = (int)Math.round((2 * Math.random() - 1)); int polariteit2 = (int)Math.round((2 * Math.random() - 1)); VersnellingX = Double.toString(Tempx2*polariteit); VersnellingsLabelX.setText("Versnelling X: " +VersnellingX+"G"); VersnellingY = Double.toString(Tempy2*polariteit2); VersnellingsLabelY.setText("Versnelling Y: " +VersnellingY+"G"); Funct1 f1 = new Funct1(); if(informatie.size()==0){ beginsnelheid = 0.0; nieuwesnelheid = 0.0; f1.setaccY(0.0); } else { f1.setaccY(informatie.get(informatie.size()-1).getacceloY()); } Integration intgn1 = new Integration(f1); intgn1.setLimits(0.0, 1.0); nieuwesnelheid = intgn1.trapezium(1000); snelheid = beginsnelheid + nieuwesnelheid; beginsnelheid = snelheid; int snelheidkmh = (int)(snelheid* 3600) / 1000; double snel = snelheidkmh/100.0; this.data.setValue(new Double(Math.abs(snel))); //int GPSlongtitude1 = (int) (360 * Math.random() - 180); int GPSlongtitude1 = 51; //int GPSlongtitude2 = (int) (59 * Math.random()); int GPSlongtitude2 = 13; //int GPSlongtitude3 = (int) (100*(59.99 * Math.random())); int GPSlongtitude3 = (int)(100*(59 * Math.random())); //int GPSlatitude1 = (int) (180 * Math.random() - 90); //int GPSlatitude2 = (int) (59 * Math.random()); //int GPSlatitude3 = (int) (100*(59.99 * Math.random())); int GPSlatitude1 = 2; int GPSlatitude2 = 53; int GPSlatitude3 = (int) (100*(59.99 * Math.random())); double GPSLo = GPSlongtitude1/1.0 + ((GPSlongtitude2)/60.0) + ((GPSlongtitude3)/3600.0); System.out.println(GPSLo); double GPSLa = GPSlatitude1/1.0 + (GPSlatitude2/60.0) + (GPSlatitude3/3600.0); System.out.println(GPSLa); Longtitude.setText("Longtitude: " + GPSlongtitude1+"° "+GPSlongtitude2+"' "+(GPSlongtitude3/100.0)+"\""+"\n"); Latitude.setText("Latitude: " +GPSlatitude1+"° "+GPSlatitude2+"' "+(GPSlatitude3/100.0)+"\""+"\n"); String latitude = (" Latitude: " +GPSlatitude1+"° "+GPSlatitude2+"' "+(GPSlatitude3/100.0)+"\""); String longtitude = (" Longtitude: " + GPSlongtitude1+"° "+GPSlongtitude2+"' "+(GPSlongtitude3/100.0)+"\""); Info tempInfo = new Info(((new Date()).toString()), waarde, (Tempx*polariteit), (Tempy*polariteit2), snel, latitude, longtitude); informatie.add(tempInfo); datalog.append("Gemeten op: "+informatie.get(informatie.size()-1).getdatum()+" Temperatuur:"+ informatie.get(informatie.size()-1).gettemperatuur() +" X-as acceleratie: " +informatie.get(informatie.size()-1).getacceloX() +" Y-as acceleratie: " +informatie.get(informatie.size()-1).getacceloY() + " Snelheid: " +informatie.get(informatie.size()-1).getsnel() +"Km/h" +informatie.get(informatie.size()-1).getlongtitude() +informatie.get(informatie.size()-1).getlatitude() +"\n"); datalog.setCaretPosition(datalog.getDocument().getLength()); //auto scroll g.repaint(); sleep(1000); } catch(InterruptedException e) { } } } } class Info { JPanel g; private int temperatuur, acceloX, acceloY ; private String datum, longtitude, latitude; private double snel; public Info(String datum, int temperatuur, int acceloX, int acceloY, double snel, String latitude, String longtitude ) { this.datum = datum; this.temperatuur = temperatuur; this.acceloX = acceloX; this.acceloY = acceloY; this.snel = snel; this.latitude = latitude; this.longtitude = longtitude; try { BufferedWriter uit; String bestandsnaam = ("d:/Mijn documenten/JCreator LE/MyProjects/Project/" + "datalog"/*+((new Date()).toString())*/+".txt"); uit = new BufferedWriter( new FileWriter(bestandsnaam, true) ); uit.append(this.toString()); uit.newLine(); uit.close(); } catch( IOException e ) { System.out.println("Fout bij het openen, maken of sluiten bestand" ); e.printStackTrace(); } } public String getdatum() { return datum; } public int gettemperatuur() { return temperatuur; } public int getacceloX() { return acceloX; } public int getacceloY() { return acceloY; } public double getsnel() { return snel; } public String getlatitude() { return latitude; } public String getlongtitude() { return longtitude; } public String toString(){ String tekst = ("Gemeten op: "+datum+" Temperatuur:"+temperatuur+"Km/h"+" X-as acceleratie: "+acceloX+"G"+ " Y-as acceleratie: " +acceloY+"G" + "Snelheid: "+snel+"Km/h" +" Longtitude: "+longtitude+" Latitude: " + latitude ); return tekst; } } class Punten { private int x, y ; public Punten(int x, int y ) { this.x = x; this.y = y; } public int getx() { return x; } public int gety() { return y; } } class Funct1 implements IntegralFunction{ public double accY; public void setaccY(double accY){ this.accY = accY; } public double function(double accY){ double y = this.accY/100; return y; } } class UsbThread extends Thread { JPanel g; public AtUsbHidJni usbDevice; public JTextArea datalog; public UsbThread(JPanel g, AtUsbHidJni usbDevice, JTextArea datalog) { this.g = g; this.usbDevice = usbDevice; this.datalog = datalog; } public void run() { System.out.println("Gestart!"); byte[] byteArray = new byte[usbDevice.getOutputReportLength()]; for (int i = 0; i < byteArray.length; i++) { byteArray[i] = (byte) 0; } while( true ){ //System.out.println(Geklikt); byte[] writeByteArray = new byte[2]; byte[] readByteArray = null; delay(100); writeByteArray[0] = (byte) 'l'; writeByteArray[1] = (byte) '1'; usbDevice.writeData(writeByteArray); delay(100); byte data[] = usbDevice.readData(); //System.out.println(data.length + " test "); if (data.length > 0) { for (int i = 0; i < data.length; i++) { //char binnenGekomen = (char)data[i]; //System.out.println(data[i]+"\n"); //datalog.append(binnenGekomen +"\n"); char controle; controle = (char)data[i]; switch (controle){ case 'T': String test = ("Temperatuur: "+(char)data[i+1]+(char)data[i+2]+"°C"+"\n"); datalog.append(test); break; case 'A': if (data[i+1]=='X'&& data[i+5]=='Y'){ String test2 = ("X-versnelling: "+(char)data[i+2]+"."+(char)data[i+3]+(char)data[i+4]+"G"+"\n"); datalog.append(test2); String test3 = ("Y-versnelling: "+(char)data[i+6]+"."+(char)data[i+7]+(char)data[i+8]+"G"+"\n"); datalog.append(test3); } else { datalog.append("Onmogelijke combinatie, fout opgetreden!"); } break; case 'G': break; //default: datalog.append("Komt niet overeen" + "\n"); default: ; break; } datalog.setCaretPosition(datalog.getDocument().getLength()); //auto scroll } } data = null; } } static void delay(int delay){ try { Thread.sleep(delay); } catch (InterruptedException e) { e.printStackTrace(); } } }Last edited by Fubarable; 03-10-2011 at 10:29 PM.
- 03-10-2011, 12:08 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
- 03-11-2011, 06:10 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I didn't received such a private message too.
- 03-11-2011, 07:00 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
- 03-11-2011, 08:50 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
-
- 03-11-2011, 11:39 AM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
I totally agree, those Dutch bastards are nothing but smelly cowards, they'd sell their own mother for a bit of code, they stink and they're always drunk (because of the stolen booze). They're all slimebags I'm telling you; don't trust them! Dijkstra was a faggot! A fruitcake!
kind regards,
Jos ;-)When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-11-2011, 01:02 PM #8
It's all that Grolsch, what else did you expect?
- 03-11-2011, 01:20 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
- 03-18-2011, 08:35 AM #10
Member
- Join Date
- Mar 2011
- Posts
- 2
- Rep Power
- 0
What a nice persons you all are.
What a shame ur just too dumb and lazy to help others.
Figured it out myself by now, all i wanted was some advice.
And how nice of you to just display it public.
So far for helping others. Idiot..
- 03-18-2011, 08:50 AM #11
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
He wasn't being rude at all, did you honestly expect him to stop what he is doing and read through all your code to help you fix errors? This isn't a forum for people to pour over large amounts of code. People are busy and have other things in there personal life. He didn't post the code to ridicule you, simply to show what you wanted him to read and fix. Part of programming is learning to test and fix your own code, which you have. Clearly analyzing the code helped you solve it, maybe you should have just done that originally?
If you wanted help you could have posted a question on the forums, instead of PMing someone randomly with a huge codeblock. It may have even helped you to post here with an example of what your problem is(instead of a huge block).
I'm sorry that your fragile ego was hurt, however; this is the internet, if your skin isn't thick you may want to consider not participating with people. People out there are rude, mean(whatever words you want to use as well), and you can't expect someone to simply spend there time with fixing all your problems.
The people on these forums spend a lot of time helping lots of people with mostly trivial problems. Im glad you solved your problem, next time sit back and think, only come to the forums as a last resort(after plenty of thinking). You may just find that 9 times out of 10 you will figure your problem out yourself.
That being said, have a good day, and enjoy your(This is an assumption) ban which is soon to follow.Last edited by sunde887; 03-18-2011 at 08:53 AM.
- 03-18-2011, 08:51 AM #12
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
- 03-18-2011, 09:08 AM #13
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
No, it's filthy; I suspect the pharmaceutical industries pushing the stuff to get us hooked so they can sell more of that poison to us poor victims; even those preposterous ceramic top bottles ... don't trust that stuff ... not even when it's in your fridge ...
kind regards,
Jos (<--- victim ;-)When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-18-2011, 09:16 AM #14
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
What beer do you suggest?
- 03-18-2011, 09:20 AM #15
Member
- Join Date
- Mar 2011
- Posts
- 2
- Rep Power
- 0
Ban away, i don't care
Don't forget to delete my code before i sue you.Last edited by anthony582; 03-18-2011 at 09:22 AM.
- 03-18-2011, 09:34 AM #16
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
- 03-18-2011, 09:35 AM #17
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
- 03-18-2011, 09:37 AM #18
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,408
- Blog Entries
- 7
- Rep Power
- 17
- 03-18-2011, 09:40 AM #19
:D :D :DDon't forget to delete my code before i sue you.
Thanks for the laugh
db
- 03-18-2011, 11:02 AM #20
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
To mrajan regarding private message for blackjack source code
By Fubarable in forum New To JavaReplies: 5Last Post: 07-02-2010, 01:16 AM -
Ideas about private to private IP networking over the Internet
By mr_anderson in forum Advanced JavaReplies: 7Last Post: 06-28-2010, 07:52 AM -
has private access error message
By ibrahimyoussof in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 04-13-2010, 04:01 PM -
Who has received private message from codeforme
By Fubarable in forum Forum LobbyReplies: 4Last Post: 04-13-2010, 03:00 AM -
Java Private Message System
By javaNumpsy in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 03-29-2010, 05:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks