You are on page 1of 26

Appendix

Source Code:
package data;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import java.awt.BorderLayout;
import java.awt.Color;

import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Image;
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;
import javax.swing.SwingConstants;
//import org.eclipse.wb.swing.FocusTraversalOnArray;
import org.ghost4j.document.PDFDocument;
import org.ghost4j.renderer.SimpleRenderer;
import java.io.IOException;
import java.util.List;
//import org.eclipse.wb.swing.FocusTraversalOnArray;
import org.ghost4j.document.PDFDocument;
import org.ghost4j.renderer.SimpleRenderer;
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;
public class Main extends JFrame {
static Rengine re;
static REXP x;
private JPanel contentPane;
JFileChooser fileDialog;
File file;
BufferedReader br;
String hd[],ln,wd;
JComboBox combof;
JLabel lb,lb1,lb2;
JSpinner spinner;
JPanel clus_north,cluster_panel,clus_west,clus_south;
private JTextArea textArea;
private JLabel label;
Image img,img1;
JScrollPane jp;
JFrame fm;
private JButton
btnFullScreen,btnFullScreen1,btnFullScreen2,btnFullScreen3,btnFullScreen4;
private JPanel Classify_panel;
private JPanel Classify_north;
private JLabel label_1;
private JButton button,button2;
private JPanel Classify_west,neural_panel,neural_north,neural_west;
private JComboBox comboBox1;
private JButton button_1;
private JLabel label1,label11;
private JLabel label2,label_21,label21;
private JComboBox comboBox,comboBox11,comboBox21,comboBox31;
private JLabel label3,label31,label41;

private JComboBox comboBox2;


private JLabel label4;
private JPanel TimeDecompose;
private JPanel panel;
private JLabel label_2;
private JButton button_2;
private JPanel Decompose_west;
private JButton button_3;
private JPanel panel_2;
private JLabel lblSelectDecompositionFrequency;
private JSpinner spinner_1;
private JLabel label5;
private JPanel panel_3;
private JPanel panel_4;
private JLabel label_3;
private JButton button_4;
private JPanel panel_5;
private JButton button_5;
private JLabel mylabel;
private JLabel lbel;
private JComboBox comboBox_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Throwable e) {
e.printStackTrace();
}
re=new Rengine(args, false ,new TextConsole());
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Main frame = new Main();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Main() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 50, 900, 600);
contentPane = new JPanel();

contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));


contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
contentPane.add(tabbedPane, BorderLayout.CENTER);
cluster_panel = new JPanel();
tabbedPane.addTab("Clustering", null, cluster_panel, null);
cluster_panel.setLayout(new BorderLayout(0, 0));
clus_north = new JPanel();
clus_north.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
cluster_panel.add(clus_north, BorderLayout.NORTH);
clus_west = new JPanel();
clus_west.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
clus_west.setToolTipText("Arguments");
cluster_panel.add(clus_west, BorderLayout.WEST);
clus_west.setLayout(new GridLayout(10,1,10,10));
JPanel cluswest1 = new JPanel();
clus_west.add(cluswest1);
lb1 = new JLabel("Number of Clusters ");
lb1.setFont(new Font("Arial", Font.PLAIN, 13));
lb1.setEnabled(false);
cluswest1.add(lb1);
spinner = new JSpinner();
spinner.setEnabled(false);
cluswest1.add(spinner);
JPanel cluswest2 = new JPanel();
clus_west.add(cluswest2);
lb2 = new JLabel("Choose Field for cluster Evaluation");
lb2.setEnabled(false);
lb2.setFont(new Font("Arial", Font.PLAIN, 13));
//cluswest2.add(lb2);
combof = new JComboBox();
combof.setEnabled(false);
combof.setFont(new Font("Arial", Font.PLAIN, 13));
//combof.setMaximumRowCount(20);
//clus_west.add(combof);

clus_south = new JPanel();

cluster_panel.add(clus_south, BorderLayout.SOUTH);
clus_south.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
textArea = new JTextArea();
textArea.setRows(5);
textArea.setColumns(90);
jp=new JScrollPane(textArea);
textArea.setEnabled(false);
textArea.setEditable(false);
label=new JLabel();
jp=new JScrollPane(label);
cluster_panel.add(jp, BorderLayout.CENTER);
label.setIcon(null);
label.setBackground(Color.WHITE);
label.setSize(clus_center.getWidth(), clus_center.getHeight());
lb = new JLabel("Choose File");
lb.setFont(new Font("Arial", Font.PLAIN, 11));
clus_north.add(lb);
fileDialog = new JFileChooser();
JButton btn1 = new JButton("Browse");
btn1.setFont(new Font("Arial", Font.PLAIN, 13));
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int returnVal = fileDialog.showOpenDialog(clus_north);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = fileDialog.getSelectedFile();
lb.setText("File Selected :"+ file.getName());
try{
combof.removeAllItems();
br=new BufferedReader(new FileReader(file));
ln=br.readLine();
hd=ln.split(",");
for(int i=0;i<hd.length;i++){
combof.addItem(hd[i]);
}
combof.setEnabled(true);
lb.setEnabled(true);
lb1.setEnabled(true);
lb2.setEnabled(true);
spinner.setEnabled(true);
textArea.setEnabled(true);
textArea.setEditable(false);
}
catch(Exception er){
System.out.println(er);
}}}});
clus_north.add(btn1);
JButton startbtn = new JButton("Start");
startbtn.setFont(new Font("Arial", Font.PLAIN, 13));

startbtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try{
System.out.println(file.getAbsolutePath());
String str=file.getAbsolutePath();
str=str.replaceAll("\\\\", "/");
int noc=(Integer)spinner.getValue();
System.out.println(noc);
re.eval("library(fpc)");
re.eval("library(cluster)");
re.eval("df<-read.csv(\""+str+"\")");
if(noc<=1){
re.eval("pamk.result<-pamk(df)");
}
else{
re.eval("pamk.result<-pamk(df,"+noc+")");
}
String cbvar=(String)combof.getSelectedItem();
x=re.eval("table(pamk.result$pamobject$clustering,df$"+cbvar+")");
textArea.setText(re.eval("table(pamk.result$pamobject$clustering,
df$"+cbvar+")").toString());
wd=re.eval("getwd()").toString();
re.eval("pdf('Temp.pdf')");
re.eval("layout(matrix(c(1,2),1,2))");
re.eval("clusplot(pamk.result$pamobject,main=\"Clustering \",label=2)");
re.eval("dev.off()");
PDFDocument document = new PDFDocument();
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
System.out.println(part[1]+"\\Temp.pdf");
document.load(new File(part[1]+"\\Temp.pdf"));
SimpleRenderer renderer = new SimpleRenderer();
renderer.setResolution(300);
List<Image> images = renderer.render(document);
try {
for (int i = 0; i < images.size(); i++) {
ImageIO.write((RenderedImage) images.get(i), "png",new File((i + 1) + ".png"));
}
} catch (IOException e) {
System.out.println("ERROR: " + e.getMessage());
}
ImageIcon ic=new ImageIcon(part[1]+"\\1.png");
img=ic.getImage();
img=img.getScaledInstance(label.getWidth(), label.getHeight(),
java.awt.Image.SCALE_SMOOTH);
label.setIcon(new ImageIcon(img));
}catch(Exception e){
System.out.println(e);
}

}
});
clus_west.add(startbtn);
btnFullScreen = new JButton("Full Screen");
clus_west.add(btnFullScreen);
btnFullScreen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
fm=new JFrame();
fm.setUndecorated(true);
try {
fm.getContentPane().add(new Component(){
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
BufferedImage img = ImageIO.read(new File(part[1]+"\\1.png"));
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
});
} catch (IOException e) {
e.printStackTrace();
}
fm.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
fm.dispose();;
}
});
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
gs.setFullScreenWindow(fm);
fm.validate();
}});
//Classify code next ------------------------------------------------------------Classify_panel = new JPanel();
tabbedPane.addTab("Classification", null, Classify_panel, null);
Classify_panel.setLayout(new BorderLayout(0, 0));
Classify_north = new JPanel();
Classify_north.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
Classify_panel.add(Classify_north, BorderLayout.NORTH);
label_1 = new JLabel("Choose File");
label_1.setFont(new Font("Arial", Font.PLAIN, 11));
Classify_north.add(label_1);
Classify_west = new JPanel();
Classify_west.setToolTipText("Arguments");
Classify_west.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
Classify_panel.add(Classify_west, BorderLayout.WEST);
Classify_west.setLayout(new GridLayout(10, 1, 10, 10));
label1 = new JLabel("
First Variable
");
label1.setHorizontalAlignment(SwingConstants.CENTER);
label1.setEnabled(false);

Classify_west.add(label1);
comboBox1 = new JComboBox();
comboBox1.setMaximumRowCount(30);
comboBox1.setFont(new Font("Arial", Font.PLAIN, 13));
comboBox1.setEnabled(false);
Classify_west.add(comboBox1);
label2 = new JLabel("Second Variable ");
label2.setHorizontalAlignment(SwingConstants.CENTER);
label2.setEnabled(false);
Classify_west.add(label2);
comboBox = new JComboBox();
comboBox.setEnabled(false);
Classify_west.add(comboBox);
button = new JButton("Browse");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int returnVal = fileDialog.showOpenDialog(Classify_north);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = fileDialog.getSelectedFile();
label_1.setText("File Selected :"+ file.getName());
try{
comboBox.removeAllItems();
comboBox1.removeAllItems();
comboBox2.removeAllItems();
comboBox_1.removeAllItems();
br=new BufferedReader(new FileReader(file));
ln=br.readLine();
hd=ln.split(",");
for(int i=0;i<hd.length;i++){
comboBox.addItem(hd[i]);
comboBox1.addItem(hd[i]);
comboBox2.addItem(hd[i]);
comboBox_1.addItem(hd[i]);
}
comboBox.setEnabled(true);
comboBox1.setEnabled(true);
comboBox2.setEnabled(true);
comboBox_1.setEnabled(true);
label1.setEnabled(true);
label2.setEnabled(true);
label3.setEnabled(true);
lbel.setEnabled(true);
}
catch(Exception er){
System.out.println(er);
}
}
}});
button.setFont(new Font("Arial", Font.PLAIN, 13));

Classify_north.add(button);
label4 = new JLabel();
Classify_panel.add(label4, BorderLayout.CENTER);
button_1 = new JButton("Start");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String str=file.getAbsolutePath();
str=str.replaceAll("\\\\", "/");
re.eval("library(party)");
re.eval("df<-read.csv(\""+str+"\")");
String cbvar2=(String)comboBox.getSelectedItem();
String cbvar3=(String)comboBox1.getSelectedItem();
String cbvar4=(String)comboBox2.getSelectedItem();
String cbvars=(String)comboBox_1.getSelectedItem();
if (cbvar2=="")
{
cbvar2=" ";
}
String str1=file.getName(),namestr="";
char c;
for(int i=0;i<str1.length()&& str1.charAt(i)!='.';i++)
{
c=str1.charAt(i);
namestr+=c;
}
re.eval("df_ctree <- ctree("+cbvars+" ~ +"+cbvar2+" +"+cbvar3+"+"+cbvar4+" , data=df)");
re.eval("pdf('Temp.pdf')");
re.eval("plot(df_ctree)");
re.eval("dev.off()");
wd=re.eval("getwd()").toString();
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"")
PDFDocument document = new PDFDocument();
document.load(new File(part[1]+"\\Temp.pdf"));
SimpleRenderer renderer = new SimpleRenderer();
renderer.setResolution(300);
List<Image> images = renderer.render(document);
try {
for (int i = 0; i < images.size(); i++) {
ImageIO.write((RenderedImage)images.get(i),"png",new File((i + 1)+".png"));
}
} catch(IOException e) {
System.out.println("ERROR: " + e.getMessage());
}
ImageIcon ic1=new ImageIcon(part[1]+"\\1.png");
img=ic1.getImage();

img=img.getScaledInstance(label4.getWidth(), label4.getHeight(),
java.awt.Image.SCALE_SMOOTH);
label4.setIcon(new ImageIcon(img));
}catch(Exception e){
System.out.println(e);
}}});
label3 = new JLabel("Third Variable ");
label3.setHorizontalAlignment(SwingConstants.CENTER);
label3.setEnabled(false);
Classify_west.add(label3);
comboBox2 = new JComboBox();
comboBox2.setEnabled(false);
Classify_west.add(comboBox2);
lbel = new JLabel("Select Field");
lbel.setHorizontalAlignment(SwingConstants.CENTER);
lbel.setEnabled(false);
Classify_west.add(lbel);
comboBox_1 = new JComboBox();
comboBox_1.setEnabled(false);
Classify_west.add(comboBox_1);
button_1.setFont(new Font("Arial", Font.PLAIN, 13));
Classify_west.add(button_1);
btnFullScreen1 = new JButton("Full Screen");
Classify_west.add(btnFullScreen1);
btnFullScreen1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
fm=new JFrame();
fm.setUndecorated(true);
try {
fm.getContentPane().add(new Component(){
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
BufferedImage img = ImageIO.read(new File(part[1]+"\\1.png"));
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
}});
} catch (IOException e) {
e.printStackTrace();
}
fm.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
fm.dispose();;
}
});
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
gs.setFullScreenWindow(fm);
fm.validate();

}
});
//Time Decompose ----------------------------------------------------------TimeDecompose = new JPanel();
tabbedPane.addTab("Time Decomposition", null, TimeDecompose, null);
TimeDecompose.setLayout(new BorderLayout(0, 0));
panel = new JPanel();
panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
TimeDecompose.add(panel, BorderLayout.NORTH);
panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
label_2 = new JLabel("Choose File");
label_2.setFont(new Font("Arial", Font.PLAIN, 11));
panel.add(label_2);
button_2 = new JButton("Browse");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int returnVal = fileDialog.showOpenDialog(clus_north);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = fileDialog.getSelectedFile();
label_2.setText("File Selected :"+ file.getName());
try{
br=new BufferedReader(new FileReader(file));
ln=br.readLine();
hd=ln.split(",");
label_2.setEnabled(true);
spinner_1.setEnabled(true);
lblSelectDecompositionFrequency.setEnabled(true);
}
catch(Exception er){
System.out.println(er);
}}
}});
button_2.setFont(new Font("Arial", Font.PLAIN, 13));
panel.add(button_2);
Decompose_west = new JPanel();
Decompose_west.setToolTipText("Arguments");
Decompose_west.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
TimeDecompose.add(Decompose_west, BorderLayout.WEST);
Decompose_west.setLayout(new GridLayout(10, 1, 10, 10));
panel_2 = new JPanel();
Decompose_west.add(panel_2);
lblSelectDecompositionFrequency = new JLabel("Select decomposition frequency");
lblSelectDecompositionFrequency.setFont(new Font("Arial", Font.PLAIN, 13));
lblSelectDecompositionFrequency.setEnabled(false);
panel_2.add(lblSelectDecompositionFrequency);
spinner_1 = new JSpinner();
spinner_1.setEnabled(false);
panel_2.add(spinner_1);
label5 = new JLabel();

TimeDecompose.add(label5, BorderLayout.CENTER);
button_3 = new JButton("Start");
button_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String str=file.getAbsolutePath();
str=str.replaceAll("\\\\", "/");
int noc=(Integer)spinner.getValue();
System.out.println(noc);
String str1=file.getName(),namestr="";
char c;
for(int i=0;i<str1.length()&& str1.charAt(i)!='.';i++)
{
c=str1.charAt(i);
namestr+=c;
}
System.out.println(namestr);
re.eval("library(fpc)");
re.eval("df<-read.csv(\""+str+"\")");
if(noc==0){
re.eval("apts <- ts(df, frequency=12)");
}
else{
re.eval("apts <- ts(df,frequency="+noc+")");
re.eval("f <- decompose(apts)");
}
textArea.setText(re.eval("f <- decompose(apts)").toString());
wd=re.eval("getwd()").toString();
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
System.out.println(part[1]);
//re.eval("png('Temp.png')");
re.eval("pdf('Temp.pdf')");
re.eval("layout(matrix(c(1,2),1,2))");
re.eval("plot(f)");
re.eval("dev.off()");
PDFDocument document = new PDFDocument();
document.load(new File(part[1]+"\\Temp.pdf"));
SimpleRenderer renderer = new SimpleRenderer();
renderer.setResolution(300);
List<Image> images = renderer.render(document);
try {
for (int i = 0; i < images.size(); i++) {
ImageIO.write((RenderedImage)images.get(i),"png",new File((i + 1)+".png"));
}
} catch(IOException e) {
System.out.println("ERROR: " + e.getMessage());
}
ImageIcon ic1=new ImageIcon(part[1]+"\\1.png");
System.out.println(ic1.toString());

Image img1=ic1.getImage();
img1=img1.getScaledInstance(label5.getWidth(),label5.getHeight(),java.awt.Image.SCALE_
SMOOTH);
label5.setIcon(new ImageIcon(img1));
}catch(Exception e){
System.out.println(e);
}}});
Decompose_west.add(button_3);
button_3.setFont(new Font("Arial", Font.PLAIN, 13));
btnFullScreen2 = new JButton("Full Screen");
Decompose_west.add(btnFullScreen2);
btnFullScreen2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
fm=new JFrame();
fm.setUndecorated(true);
try {
fm.getContentPane().add(new Component(){
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
BufferedImage img = ImageIO.read(new File(part[1]+"\\1.png"));
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
}});
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fm.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
fm.dispose();;
}});
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
gs.setFullScreenWindow(fm);
fm.validate();
}
});
//Seasonal Analysis ------------------------------------------------------------------------------panel_3 = new JPanel();
tabbedPane.addTab("Seasonal Analysis", null, panel_3, null);
panel_3.setLayout(new BorderLayout(0, 0));
panel_4 = new JPanel();
panel_4.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
panel_3.add(panel_4, BorderLayout.NORTH);
label_3 = new JLabel("Choose File");
label_3.setFont(new Font("Arial", Font.PLAIN, 11));
panel_4.add(label_3);
button_4 = new JButton("Browse");

button_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int returnVal = fileDialog.showOpenDialog(clus_north);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = fileDialog.getSelectedFile();
label_3.setText("File Selected :"+ file.getName());
try{
combof.removeAllItems();
br=new BufferedReader(new FileReader(file));
ln=br.readLine();
hd=ln.split(",");
}
catch(Exception er){
System.out.println(er);
}
}
}});
button_4.setFont(new Font("Arial", Font.PLAIN, 13));
panel_4.add(button_4);
panel_5 = new JPanel();
panel_3.add(panel_5, BorderLayout.SOUTH);
button_5 = new JButton("Start");
button_5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String str=file.getAbsolutePath();
str=str.replaceAll("\\\\", "/");
String str1=file.getName(),namestr="";
char c;
for(int i=0;i<str1.length()&& str1.charAt(i)!='.';i++)
{
c=str1.charAt(i);
namestr+=c;
}
System.out.println(namestr);
re.eval("library(fpc)");
re.eval("df<-read.csv(\""+str+"\")");
re.eval("apts <- ts(df, frequency=12)");
re.eval("f <- decompose(apts)");
re.eval("f$figure");
re.eval("pdf('Temp.pdf')");
re.eval("plot(f$figure,type="+"'b'"+", xaxt="+"'n'"+", xlab="+"''"+")");
re.eval("monthNames <- months(ISOdate(2011,1:12,1))");
re.eval("axis(1, at=1:12, labels=monthNames, las=2)");
textArea.setText(re.eval("f$figure"+"monthNames <months(ISOdate(2011,1:12,1))"+"axis(1, at=1:12, labels=monthNames, las=2)").toString());
re.eval("dev.off()");
wd=re.eval("getwd()").toString();
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");

PDFDocument document = new PDFDocument();


document.load(new File(part[1]+"\\Temp.pdf"));
SimpleRenderer renderer = new SimpleRenderer();
renderer.setResolution(300);
List<Image> images = renderer.render(document);
try {
for (int i = 0; i < images.size(); i++) {
ImageIO.write((RenderedImage)images.get(i),"png",new File((i + 1)+".png"));
}
} catch(IOException e) {
System.out.println("ERROR: " + e.getMessage());
}
ImageIcon ic1=new ImageIcon(part[1]+"\\1.png");
img=ic1.getImage();
img=img.getScaledInstance(mylabel.getHeight(), mylabel.getHeight(),
java.awt.Image.SCALE_SMOOTH);
mylabel.setIcon(new ImageIcon(img));
}catch(Exception e){
System.out.println(e);
}}});
button_5.setFont(new Font("Arial", Font.PLAIN, 13));
panel_5.add(button_5);
mylabel = new JLabel();
mylabel.setHorizontalAlignment(SwingConstants.CENTER);
panel_3.add(mylabel, BorderLayout.CENTER);
btnFullScreen3 = new JButton("Full Screen");
panel_5.add(btnFullScreen3);
btnFullScreen3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
fm=new JFrame();
fm.setUndecorated(true);
try {
fm.getContentPane().add(new Component(){
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
BufferedImage img = ImageIO.read(new File(part[1]+"\\1.png"));
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
}});
} catch (IOException e) {
e.printStackTrace();
}
fm.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
fm.dispose();;
}
});
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

GraphicsDevice gs = ge.getDefaultScreenDevice();
gs.setFullScreenWindow(fm);
fm.validate();
}
});
//Seasonal Analysis over --------------------------------------------------------------------------neural_panel = new JPanel();
tabbedPane.addTab("Neural Network", null, neural_panel, null);
neural_panel.setLayout(new BorderLayout(0, 0));
neural_north = new JPanel();
neural_north.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
neural_panel.add(neural_north, BorderLayout.NORTH);
label_21 = new JLabel("Choose File");
label_21.setFont(new Font("Arial", Font.PLAIN, 11));
neural_north.add(label_21);
neural_west = new JPanel();
neural_west.setToolTipText("Arguments");
neural_west.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
neural_panel.add(neural_west, BorderLayout.WEST);
neural_west.setLayout(new GridLayout(10, 1, 10, 10));
label11 = new JLabel("First Variable(Y node) ");
label11.setHorizontalAlignment(SwingConstants.CENTER);
label11.setEnabled(false);
neural_west.add(label11);
comboBox11 = new JComboBox();
comboBox11.setMaximumRowCount(30);
comboBox11.setFont(new Font("Arial", Font.PLAIN, 13));
comboBox11.setEnabled(false);
neural_west.add(comboBox11);
label21 = new JLabel("Second Variable(X node) ");
label21.setHorizontalAlignment(SwingConstants.CENTER);
label21.setEnabled(false);
neural_west.add(label21);
comboBox21 = new JComboBox();
comboBox21.setEnabled(false);
neural_west.add(comboBox21);
label31 = new JLabel("Third Variable(Z node) ");
label31.setHorizontalAlignment(SwingConstants.CENTER);
label31.setEnabled(false);
neural_west.add(label31);
comboBox31 = new JComboBox();
comboBox31.setEnabled(false);
neural_west.add(comboBox31);
button2 = new JButton("Browse");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int returnVal1 = fileDialog.showOpenDialog(neural_north);
if (returnVal1 == JFileChooser.APPROVE_OPTION) {
file = fileDialog.getSelectedFile();
label_21.setText("File Selected :"+ file.getName());

try{
comboBox21.removeAllItems();
comboBox11.removeAllItems();
comboBox31.removeAllItems();
br=new BufferedReader(new FileReader(file));
ln=br.readLine();
hd=ln.split(",");
for(int i=0;i<hd.length;i++){
comboBox21.addItem(hd[i]);
comboBox11.addItem(hd[i]);
comboBox31.addItem(hd[i]);
}
comboBox21.setEnabled(true);
comboBox11.setEnabled(true);
comboBox31.setEnabled(true);
label11.setEnabled(true);
label21.setEnabled(true);
label31.setEnabled(true);
}
catch(Exception er){
System.out.println(er);
}
}}});
button2.setFont(new Font("Arial", Font.PLAIN, 13));
neural_north.add(button_2);
button_2 = new JButton("Start");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String str=file.getAbsolutePath();
str=str.replaceAll("\\\\", "/");
re.eval("library(neuralnet)");
re.eval("dataset<-read.csv(\""+str+"\")");
Stringcbvar21=(String)comboBox11.getSelectedItem();//y node
String cbvar31=(String)comboBox21.getSelectedItem();//x node
String cbvar41=(String)comboBox31.getSelectedItem();//z node
if (cbvar21=="")
{
cbvar21=" ";
}
String str2=file.getName(),namestr="";
char c1;
for(int i=0;i<str2.length()&&
str2.charAt(i)!='.';i++)
{
c1=str2.charAt(i);
namestr+=c1;
}
re.eval("trainset <- dataset[1:100, ]");

re.eval("creditnet <- neuralnet("+cbvar21+" ~ "+cbvar31+" + "+cbvar41+" ,trainset, hidden =


4, lifesign = 'minimal', linear.output = FALSE, threshold = 0.1)");
wd=re.eval("getwd()").toString();
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
re.eval("pdf('Temp.pdf')");
re.eval("plot(creditnet, rep = 'best')");
re.eval("dev.off()");
PDFDocument document = new PDFDocument();
document.load(new File(part[1]+"\\Temp.pdf"));
SimpleRenderer renderer = new SimpleRenderer();
renderer.setResolution(300);
List<Image> images = renderer.render(document);
try {
for (int i = 0; i < images.size(); i++) {
ImageIO.write((RenderedImage)images.get(i),"png",new File((i + 1)+".png"));
}
} catch(IOException e) {
System.out.println("ERROR: " + e.getMessage());
}
ImageIcon ic1=new ImageIcon(part[1]+"\\1.png");
img1=ic1.getImage();
img1=img1.getScaledInstance(label41.getWidth(), label41.getHeight(),
java.awt.Image.SCALE_SMOOTH);
label41.setIcon(new ImageIcon(img1));
}
catch(Exception e){}
}});
label41 = new JLabel();
neural_panel.add(label41, BorderLayout.CENTER);
button_2.setFont(new Font("Arial", Font.PLAIN, 13));
neural_west.add(button_2);
JButton testx,testz;
testx = new JButton("Prediction test of x");
testx.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String cbvar21=(String)comboBox11.getSelectedItem();//y node
String cbvar31=(String)comboBox21.getSelectedItem();//x node
String cbvar41=(String)comboBox31.getSelectedItem();//z node
wd=re.eval("getwd()").toString();
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
re.eval("pdf('neuraltestx.pdf')");
re.eval(cbvar31+".test<-seq(from=0, to=1, by=0.01)");
re.eval(cbvar21+".fit<-compute(creditnet, covariate=matrix(c("+cbvar31+".test, rep(0.5,
length("+cbvar31+".test))), nrow=length("+cbvar31+".test), ncol=2))$net.result");
re.eval("plot("+cbvar21+"~"+cbvar31+", trainset)");

re.eval("lines("+cbvar21+".fit~"+cbvar31+".test, type='l', col='red', lwd=2)");


re.eval("dev.off()");
PDFDocument document = new PDFDocument();
document.load(new File(part[1]+"\\neuraltestx.pdf"));
SimpleRenderer renderer = new SimpleRenderer();
renderer.setResolution(300);
List<Image> images = renderer.render(document);
try {
for (int i = 0; i < images.size(); i++) {
ImageIO.write((RenderedImage)images.get(i),"png",new File((i + 1)+".png"));
}
} catch(IOException e) {
System.out.println("ERROR: " + e.getMessage());
}
label41.removeAll();
ImageIcon ic1=new ImageIcon(part[1]+"\\1.png");
img1=ic1.getImage();
img1=img1.getScaledInstance(label41.getWidth(), label41.getHeight(),
java.awt.Image.SCALE_SMOOTH);
label41.setIcon(new ImageIcon(img1));
}
catch(Exception e){}
}});
testx.setFont(new Font("Arial", Font.PLAIN, 13));
neural_west.add(testx);
testz = new JButton("Prediction test of z");
testz.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String cbvar21=(String)comboBox11.getSelectedItem();//y node
String cbvar31=(String)comboBox21.getSelectedItem();//x node
String cbvar41=(String)comboBox31.getSelectedItem();//z node
wd=re.eval("getwd()").toString();
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
re.eval("pdf('neuraltesty.pdf')");
re.eval(cbvar41+".test<-seq(from=0, to=1, by=0.01)");
re.eval(cbvar21+".fit<-compute(creditnet, covariate=matrix(c(rep(1,
length("+cbvar41+".test)),"+cbvar41+".test), nrow=length("+cbvar41+".test),
ncol=2))$net.result");
re.eval("plot("+cbvar21+"~"+cbvar41+", trainset)");
re.eval("lines("+cbvar21+".fit~"+cbvar41+".test, type='l', col='red', lwd=2)");
re.eval("dev.off()");
PDFDocument document = new PDFDocument();
document.load(new File(part[1]+"\\neuraltesty.pdf"));
SimpleRenderer renderer = new SimpleRenderer();
renderer.setResolution(300);
List<Image> images = renderer.render(document);
try {
for (int i = 0; i < images.size(); i++) {

ImageIO.write((RenderedImage)images.get(i),"png",new File((i + 1)+".png"));


}
} catch(IOException e) {
System.out.println("ERROR: " + e.getMessage());
}
label41.removeAll();
ImageIcon ic1=new ImageIcon(part[1]+"\\1.png");
img1=ic1.getImage();img1=img1.getScaledInstance(label41.getWidth(), label41.getHeight(),
java.awt.Image.SCALE_SMOOTH);
label41.setIcon(new ImageIcon(img1));
}
catch(Exception e){}
}
});
testz.setFont(new Font("Arial", Font.PLAIN, 13));
neural_west.add(testz);
panel_2 = new JPanel();
neural_panel.add(panel_2, BorderLayout.SOUTH);
panel_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
btnFullScreen4 = new JButton("Full Screen");
neural_west.add(btnFullScreen4);
btnFullScreen4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
fm=new JFrame();
fm.setUndecorated(true);
try {
fm.getContentPane().add(new Component(){
String wd1=wd.replaceAll("/", "\\\\");
String part[]=wd1.split("\"");
BufferedImage img = ImageIO.read(new File(part[1]+"\\1.png"));
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
}
});
} catch (IOException e) {
e.printStackTrace();
}
fm.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
fm.dispose();;
}
});
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
gs.setFullScreenWindow(fm);
fm.validate();
}});}}

Screenshots:

Clustering Window

Clustering operation

Classification Window

Classification Operation

Time Decomposition Window

Time Decomposition Operation

Seasonal Analysis Window

Seasonal Analysis Operation

Neural Network Window

Neural Network Operation

Neural Network Prediction Test