Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sun.image.codec.jpeg.JPEGCodec;
- import com.sun.image.codec.jpeg.JPEGImageEncoder;
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics2D;
- import java.awt.event.ActionEvent;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.AbstractAction;
- import javax.swing.JButton;
- import javax.swing.JFileChooser;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.JToolBar;
- import org.jfree.chart.*;
- import org.jfree.chart.axis.ValueAxis;
- import org.jfree.chart.plot.PlotOrientation;
- import org.jfree.data.xy.*;
- public class Profilee {
- double last=0;
- ChartFrame frame1;
- JFreeChart chart;
- ChartUtilities cu=new ChartUtilitiesImpl();
- public void generateProfile(double[] pointValue,double[] distance){
- ArrayList pv=new ArrayList();
- ArrayList dist=new ArrayList();
- pv.add(pointValue);
- dist.add(distance);
- XYSeries series = new XYSeries("");
- for(int i=0;i<pointValue.length-1;i++){
- series.add(last,pointValue[i]);
- last=distance[i];
- }
- XYDataset xyDataset = new XYSeriesCollection(series);
- chart= ChartFactory.createXYAreaChart("Profile View Of Contour", "Distance", "Contour Value", xyDataset, PlotOrientation.VERTICAL, true, true, false);
- ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
- //rangeAxis.setLowerBound(-3);
- rangeAxis.zoomRange(0,15); //Taken It approximately
- frame1=new ChartFrame("XYLine Chart",chart);
- frame1.setVisible(true);
- frame1.setSize(1300,700);
- }
- public static void main(String ar[]){
- Profilee pro=new Profilee();
- double[] pv={3,2,3,0,5,-2,10};
- double[] dist={1,4,8,12,14,20,24};
- pro.generateProfile(pv, dist);
- }
- private static class ChartUtilitiesImpl extends ChartUtilities {
- public ChartUtilitiesImpl() {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement