Advertisement
parth9365

zoomRange

Apr 20th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. import com.sun.image.codec.jpeg.JPEGCodec;
  2. import com.sun.image.codec.jpeg.JPEGImageEncoder;
  3. import java.awt.BorderLayout;
  4. import java.awt.Component;
  5. import java.awt.Dimension;
  6. import java.awt.Graphics2D;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.image.BufferedImage;
  9. import java.io.File;
  10. import java.io.FileOutputStream;
  11. import java.io.IOException;
  12. import java.util.ArrayList;
  13. import java.util.logging.Level;
  14. import java.util.logging.Logger;
  15. import javax.swing.AbstractAction;
  16. import javax.swing.JButton;
  17. import javax.swing.JFileChooser;
  18. import javax.swing.JFrame;
  19. import javax.swing.JOptionPane;
  20. import javax.swing.JToolBar;
  21. import org.jfree.chart.*;
  22. import org.jfree.chart.axis.ValueAxis;
  23. import org.jfree.chart.plot.PlotOrientation;
  24. import org.jfree.data.xy.*;
  25.  
  26. public class Profilee  {
  27.  
  28.  
  29.  
  30.     double last=0;
  31.     ChartFrame frame1;
  32.  
  33.     JFreeChart chart;
  34.     ChartUtilities cu=new ChartUtilitiesImpl();
  35.  
  36.     public void generateProfile(double[] pointValue,double[] distance){
  37.         ArrayList pv=new ArrayList();
  38.         ArrayList dist=new ArrayList();
  39.  
  40.         pv.add(pointValue);
  41.         dist.add(distance);
  42.  
  43.         XYSeries series = new XYSeries("");
  44.         for(int i=0;i<pointValue.length-1;i++){
  45.  
  46.               series.add(last,pointValue[i]);
  47.               last=distance[i];
  48.          }
  49.  
  50.  
  51.  
  52.       XYDataset xyDataset = new XYSeriesCollection(series);
  53.       chart= ChartFactory.createXYAreaChart("Profile View Of Contour", "Distance", "Contour Value", xyDataset, PlotOrientation.VERTICAL, true, true, false);
  54.  
  55.       ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
  56.  
  57.       //rangeAxis.setLowerBound(-3);
  58.       rangeAxis.zoomRange(0,15);        //Taken It approximately
  59.       frame1=new ChartFrame("XYLine Chart",chart);
  60.  
  61.       frame1.setVisible(true);
  62.       frame1.setSize(1300,700);
  63.     }
  64.  
  65.  
  66.     public static void main(String ar[]){
  67.         Profilee pro=new Profilee();
  68.         double[] pv={3,2,3,0,5,-2,10};
  69.         double[] dist={1,4,8,12,14,20,24};
  70.         pro.generateProfile(pv, dist);
  71.  
  72.  
  73.  
  74.     }
  75.  
  76.     private static class ChartUtilitiesImpl extends ChartUtilities {
  77.  
  78.         public ChartUtilitiesImpl() {
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement