Results 1 to 2 of 2
Thread: Using SGT API in netbeans
- 02-12-2009, 02:40 PM #1
- 02-13-2009, 10:20 AM #2
Hi pple,i have researched on the topic and have bn able to come up with the code below.what i want to do next is to set the range of my axes and read values for the trajectory from a file.
my code is as follows:
Your ideas are higly appreciatedJava Code:/* * Example1.java * * Created on 10. Februar 2009, 16:23 */ package sgtTutorial; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.*; import gov.noaa.pmel.sgt.dm.SGTData; import gov.noaa.pmel.sgt.dm.SGTLine; import gov.noaa.pmel.sgt.dm.SimpleLine; import gov.noaa.pmel.sgt.dm.SGTMetaData; import gov.noaa.pmel.sgt.swing.JPlotLayout; import gov.noaa.pmel.util.Point2D; import gov.noaa.pmel.util.Range2D; /** * * @author MUNYA00M */ public class Example1 extends javax.swing.JFrame { private JPlotLayout layout_; /** Creates new form Example1 */ public Example1() { /* * Create JPlotLayout instance for SGTLine data. X and Y axes * are NOT time, and no image is provided. */ layout_ = new JPlotLayout(false, false, false, "Trajectory data", null,false); /* * Batch changes to layout. */ layout_.setBatch(true); /* * Set the titles. */ layout_.setTitles("Xenon Concentration and Poisoning", "Forecast", ""); /* * Change the title sizes from the defaults. (0.25, 0.15) */ layout_.setTitleHeightP(0.2, 0.2); /* * Use a BorderLayout for the JFrame and and the JPlotLayout to * the "Center". Pack the frame and make it visible. */ getContentPane().setLayout(new BorderLayout()); getContentPane().add(layout_, BorderLayout.CENTER); pack(); setVisible(true); /* * Read trajectory data from local file */ SGTData data = readTrajectory("myXenon.txt"); /* * Add the trajectory data to the plot using the data title as the * data description. The description is used in the LineKey. */ layout_.addData(data, data.getTitle()); // At this point am suposed to set the range for my axes.Any idea??? /* * Turn batching off. All batched changes to the JPlotLayout will * now be executed. */ layout_.setBatch(false); initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 514, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 371, Short.MAX_VALUE) ); pack(); }// </editor-fold> /** * @param args the command line arguments */ public static void main(String args[]) { Example1 example = new Example1(); /* * Listen for window closing events and release resources * and exit. */ example.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent event) { JFrame fr = (JFrame)event.getSource(); fr.setVisible(false); fr.dispose(); System.exit(0); } }); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Example1().setVisible(true); } }); } /** * Read data from local file */ SGTLine readTrajectory(String file) { ArrayList alist = new ArrayList(100); String line = null; double PowerLevel = 0, time = 0; Point2D.Double point = null; boolean first = true; String floatName = null; /* * method used to parse the trajectory information. * The file format is * longitude latitude float_id profile_number */ /* * Open reader and get first line */ try { FileInputStream fis = new FileInputStream("myXenon.txt"); BufferedReader in = new BufferedReader(new InputStreamReader(fis)); while ((line = in.readLine()) !=null) { /* * Create a tokenizer and use the default "space" token * separator. */ StringTokenizer st = new StringTokenizer(line," "); if (st.countTokens() >= 2){ time = Double.parseDouble(st.nextToken()); PowerLevel = Double.parseDouble(st.nextToken()); } else { break; } point = new Point2D.Double(time, PowerLevel); alist.add(point); } /* * Read the next line */ line = in.readLine(); } } catch (IOException e) { e.printStackTrace(); }
Similar Threads
-
Hi Am New To Use Netbeans
By arunkumarinfo in forum NetBeansReplies: 1Last Post: 01-23-2009, 04:18 AM -
NetBeans IDE 6.5 - The only IDE you need
By Eranga in forum Reviews / AdvertisingReplies: 2Last Post: 11-26-2008, 09:37 AM -
netbeans
By sweet angle in forum NetBeansReplies: 1Last Post: 08-05-2008, 04:06 AM -
NetBeans 5.5
By Ry4n in forum NetBeansReplies: 3Last Post: 01-26-2008, 06:09 AM -
NetBeans 5.5.1 Help.
By padutch2 in forum New To JavaReplies: 6Last Post: 12-03-2007, 03:01 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks