Code: Select all
public JInternalFrame OpenOption(JFileChooser path) throws FileNotFoundException
{
String p=path.toString();
File f=path.getSelectedFile();
JInternalFrame iFrame=new JInternalFrame(f.getAbsolutePath(),true,true,true,true);
iFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
iFrame.setSize(900, 500);
Scanner scan=new Scanner(path.getSelectedFile()).useDelimiter("\\s*(=>|,|;|\\s)\\s*");
XYSeries series = new XYSeries(path.getSelectedFile());
while (scan.useDelimiter("\\s*(=>|,|;|\\s)\\s*").hasNextDouble())
{
series.add(scan.useDelimiter("\\s*(=>|,|;|\\s)\\s*").nextDouble(),scan.useDelimiter("\\s*(=>|,|;|\\s)\\s*").nextDouble());
}
scan.close();
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart
("","Wave number cm"+'\u2212'+'\u00B9',"Intensity",
xyDataset, PlotOrientation.VERTICAL, false, true, false);
chart.getPlot().setBackgroundPaint( Color.WHITE);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainGridlinePaint(new Color(0xC0,0xC0,0xC0));
plot.setRangeGridlinePaint(new Color(0xC0,0xC0,0xC0));
plot.setRangeZeroBaselineVisible(true);
plot.setDomainZeroBaselineVisible(true);
plot.configureRangeAxes();
System.out.println(plot.isRangeZeroBaselineVisible());
//XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
plot.getDomainAxis().setRange(plot.getDomainAxis().getRange().getLowerBound() - 0.10,
plot.getDomainAxis().getRange().getUpperBound() + 0.10);
//JPanel chartPanel = new ChartPanel(chart);
ChartPanel chartPan = new ChartPanel(chart);
chartPan.setFillZoomRectangle(true);
chartPan.setMouseWheelEnabled(true);
//chartPanel.setPreferredSize(new Dimension(500, 270));
chartPan.setBounds(100,100,640,480);
chartPan.setMinimumDrawWidth( 0 );
chartPan.setMinimumDrawHeight( 0 );
chartPan.setMaximumDrawWidth( 1920 );
chartPan.setMaximumDrawHeight( 1200 );
chartPan.restoreAutoBounds();
iFrame.add(chartPan);
iFrame.pack();
iFrame.setVisible(true);
return iFrame;
}