Created
September 20, 2017 04:03
-
-
Save Technopdia/64ab6b76f90e5a16f24f9fdace348671 to your computer and use it in GitHub Desktop.
LPP plotter using Java and Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Open the files sent by the java program | |
try: | |
e1 = open("Equation1.txt","r") | |
e2 = open("Equation2.txt","r") | |
e3 = open("Equation3.txt","r") | |
l = open("Limits.txt","r") | |
z = open("Objective_Function.txt","r") | |
except EOFError: | |
print "Error opening the files!" | |
exit(0) | |
#****************************************************** | |
#Create Empty lists to store the data from the text file | |
eqn1 = [] | |
eqn2 = [] | |
eqn3 = [] | |
lim = [] | |
obj = [] | |
#Store the data in the lists from the files | |
#Store details of equation 1 | |
for i in e1: | |
eqn1.append(int(i)) | |
#Store Details of Equation 2 | |
for i in e2: | |
eqn2.append(int(i)) | |
#Store Details of Equation 2 | |
for i in e3: | |
eqn3.append(int(i)) | |
#Store the details of X and Y limits | |
for i in l: | |
lim.append(int(i)) | |
#Store the details of Objective functions | |
for i in z: | |
obj.append(int(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import pylab as pl | |
import fileread as f | |
import os | |
#END OF IMPORTS | |
#****************************************************** | |
#Initializattions for the variables | |
#Equation 1 Coefficients and constant | |
x1c = f.eqn1[0] #Coefficient of x | |
y1c = f.eqn1[1] #Coefficient of y | |
c1 = f.eqn1[2] #Constant | |
#Equation 2 Coefficients and constant | |
x2c = f.eqn2[0] #Coefficient of x | |
y2c = f.eqn2[1] #Coefficient of y | |
c2 = f.eqn2[2] #Constant | |
#Equation 2 Coefficients and constant | |
x3c = f.eqn3[0] #Coefficient of x | |
y3c = f.eqn3[1] #Coefficient of y | |
c3 = f.eqn3[2] #Constant | |
#********************************************************** | |
#X and Y Limits | |
xlim = f.lim[0] | |
ylim = f.lim[1] | |
#*********************************************************** | |
#Start solving the equations! | |
#Solve Equation 1 | |
def Eqn1(x, x1c, y1c, c1): | |
return ((c1-(x1c * x))/y1c) | |
xvals = np.arange(0, 10, 1) # Grid of 1 spacing from 0 to 10 | |
yvals = Eqn1(xvals, x1c, y1c, c1) # Evaluate function on xvals | |
plt.plot(xvals, yvals) # Create line plot with yvals against xvals | |
#Solve Equation 2 | |
def Eqn2(x, x2c, y2c, c2): | |
return ((c2 - (x2c * x)) / y2c) | |
xvals = np.arange(0, 10, 1) # Grid of 1 spacing from 0 to 10 | |
yvals = Eqn2(xvals, x2c, y2c, c2) # Evaluate function on xvals | |
plt.plot(xvals, yvals) # Create line plot with yvals against xvals | |
#Solve Equation 3 | |
def Eqn3(x, x3c, y3c, c3): | |
return ((c3 - (x3c * x)) / y3c) | |
xvals = np.arange(0, 10, 1) # Grid of 1 spacing from 0 to 10 | |
yvals = Eqn3(xvals, x3c, y3c, c3) # Evaluate function on xvals | |
plt.plot(xvals, yvals) # Create line plot with yvals against xvals | |
#****************************************************************** | |
# set axis limits | |
pl.xlim(0.0, xlim) | |
pl.ylim(0.0,ylim) | |
# Show the figure | |
plt.show() | |
os.system("SolveGUI.py") | |
#plt.show() # Show the figure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/* | |
* GUI_Plot.java | |
* | |
* Created on 12 Apr, 2017, 10:41:20 PM | |
*/ | |
/** | |
* | |
* @author Technopedia | |
*/ | |
import java.io.*; | |
public class GUI_Plot extends javax.swing.JFrame { | |
/** Creates new form GUI_Plot */ | |
public GUI_Plot() { | |
initComponents(); | |
} | |
/*Method to Copy files from one directory to other directories | |
* | |
*This method is used in cse th java and python files | |
*are located in different folders | |
*/ | |
private static void copyFileUsingStream(File source, File dest) throws IOException{ | |
InputStream is = null; | |
OutputStream os = null; | |
try{ | |
is = new FileInputStream(source); | |
os = new FileOutputStream(dest); | |
byte[] buffer = new byte[1024]; | |
int length; | |
while((length = is.read(buffer)) > 0){ | |
os.write(buffer,0,length); | |
} | |
}catch(IOException e){ | |
System.out.print(e); | |
is.close(); | |
os.close();; | |
} | |
} | |
@SuppressWarnings("unchecked") | |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
private void initComponents() { | |
jRadioButton1 = new javax.swing.JRadioButton(); | |
jLabel1 = new javax.swing.JLabel(); | |
jLabel2 = new javax.swing.JLabel(); | |
Y1 = new javax.swing.JTextField(); | |
X1 = new javax.swing.JTextField(); | |
C2 = new javax.swing.JTextField(); | |
C1 = new javax.swing.JTextField(); | |
X2 = new javax.swing.JTextField(); | |
Y2 = new javax.swing.JTextField(); | |
jButton1 = new javax.swing.JButton(); | |
jButton2 = new javax.swing.JButton(); | |
jLabel3 = new javax.swing.JLabel(); | |
jLabel4 = new javax.swing.JLabel(); | |
jLabel5 = new javax.swing.JLabel(); | |
jLabel6 = new javax.swing.JLabel(); | |
jLabel7 = new javax.swing.JLabel(); | |
jLabel8 = new javax.swing.JLabel(); | |
jLabel9 = new javax.swing.JLabel(); | |
jLabel10 = new javax.swing.JLabel(); | |
jLabel11 = new javax.swing.JLabel(); | |
jLabel12 = new javax.swing.JLabel(); | |
jLabel13 = new javax.swing.JLabel(); | |
jLabel14 = new javax.swing.JLabel(); | |
jLabel15 = new javax.swing.JLabel(); | |
jLabel16 = new javax.swing.JLabel(); | |
ZX = new javax.swing.JTextField(); | |
jLabel17 = new javax.swing.JLabel(); | |
jLabel18 = new javax.swing.JLabel(); | |
jLabel19 = new javax.swing.JLabel(); | |
ZY = new javax.swing.JTextField(); | |
jLabel20 = new javax.swing.JLabel(); | |
jLabel21 = new javax.swing.JLabel(); | |
jLabel22 = new javax.swing.JLabel(); | |
XLIM = new javax.swing.JTextField(); | |
YLIM = new javax.swing.JTextField(); | |
jButton3 = new javax.swing.JButton(); | |
jButton4 = new javax.swing.JButton(); | |
jLabel23 = new javax.swing.JLabel(); | |
X3 = new javax.swing.JTextField(); | |
Y3 = new javax.swing.JTextField(); | |
C3 = new javax.swing.JTextField(); | |
jLabel24 = new javax.swing.JLabel(); | |
jLabel25 = new javax.swing.JLabel(); | |
jLabel26 = new javax.swing.JLabel(); | |
jLabel27 = new javax.swing.JLabel(); | |
jLabel28 = new javax.swing.JLabel(); | |
jButton5 = new javax.swing.JButton(); | |
jRadioButton1.setText("jRadioButton1"); | |
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |
setMinimumSize(null); | |
setResizable(false); | |
jLabel1.setFont(new java.awt.Font("Serif", 0, 24)); | |
jLabel1.setText("Equation 1"); | |
jLabel2.setFont(new java.awt.Font("Serif", 0, 24)); | |
jLabel2.setText("Equation 2"); | |
Y1.setFont(new java.awt.Font("Dialog", 0, 24)); | |
Y1.setToolTipText(""); | |
X1.setFont(new java.awt.Font("Dialog", 0, 24)); | |
X1.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
X1ActionPerformed(evt); | |
} | |
}); | |
C2.setFont(new java.awt.Font("Dialog", 0, 24)); | |
C2.setToolTipText(""); | |
C1.setFont(new java.awt.Font("Dialog", 0, 24)); | |
C1.setToolTipText(""); | |
X2.setFont(new java.awt.Font("Dialog", 0, 24)); | |
X2.setToolTipText(""); | |
Y2.setFont(new java.awt.Font("Dialog", 0, 24)); | |
Y2.setToolTipText(""); | |
jButton1.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jButton1.setText("OK"); | |
jButton1.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton1ActionPerformed(evt); | |
} | |
}); | |
jButton2.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jButton2.setText("OK"); | |
jButton2.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton2ActionPerformed(evt); | |
} | |
}); | |
jLabel3.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel3.setText("x"); | |
jLabel4.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel4.setText("y"); | |
jLabel5.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel5.setText("c1"); | |
jLabel6.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel6.setText("x"); | |
jLabel7.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel7.setText("y"); | |
jLabel8.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel8.setText("c2"); | |
jLabel9.setFont(new java.awt.Font("Serif", 1, 48)); | |
jLabel9.setText("LPPy"); | |
jLabel10.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel10.setText("+"); | |
jLabel11.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel11.setText("="); | |
jLabel12.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel12.setText("+"); | |
jLabel13.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel13.setText("="); | |
jLabel14.setFont(new java.awt.Font("Serif", 0, 24)); | |
jLabel14.setText("Objective Function"); | |
jLabel15.setFont(new java.awt.Font("SansSerif", 1, 36)); | |
jLabel15.setText("Z"); | |
jLabel16.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel16.setText("="); | |
ZX.setFont(new java.awt.Font("Dialog", 0, 24)); | |
jLabel17.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel17.setText("+"); | |
jLabel18.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel18.setText("x"); | |
jLabel19.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel19.setText("y"); | |
ZY.setFont(new java.awt.Font("Dialog", 0, 24)); | |
jLabel20.setFont(new java.awt.Font("Serif", 0, 24)); | |
jLabel20.setText("Limits"); | |
jLabel21.setFont(new java.awt.Font("Dialog", 0, 24)); | |
jLabel21.setText("X:"); | |
jLabel22.setFont(new java.awt.Font("Dialog", 0, 24)); | |
jLabel22.setText("Y:"); | |
XLIM.setFont(new java.awt.Font("Dialog", 0, 24)); | |
YLIM.setFont(new java.awt.Font("Dialog", 0, 24)); | |
jButton3.setFont(new java.awt.Font("SansSerif", 1, 18)); | |
jButton3.setText("OK"); | |
jButton3.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton3ActionPerformed(evt); | |
} | |
}); | |
jButton4.setFont(new java.awt.Font("SansSerif", 1, 18)); | |
jButton4.setText("OK"); | |
jButton4.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton4ActionPerformed(evt); | |
} | |
}); | |
jLabel23.setFont(new java.awt.Font("Serif", 0, 24)); | |
jLabel23.setText("Equation 3"); | |
X3.setFont(new java.awt.Font("Dialog", 0, 24)); | |
X3.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
X3ActionPerformed(evt); | |
} | |
}); | |
Y3.setFont(new java.awt.Font("Dialog", 0, 24)); | |
C3.setFont(new java.awt.Font("Dialog", 0, 24)); | |
jLabel24.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel24.setText("x"); | |
jLabel25.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel25.setText("+"); | |
jLabel26.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel26.setText("y"); | |
jLabel27.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel27.setText("="); | |
jLabel28.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jLabel28.setText("c3"); | |
jButton5.setFont(new java.awt.Font("Dialog", 1, 18)); | |
jButton5.setText("OK"); | |
jButton5.addActionListener(new java.awt.event.ActionListener() { | |
public void actionPerformed(java.awt.event.ActionEvent evt) { | |
jButton5ActionPerformed(evt); | |
} | |
}); | |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |
getContentPane().setLayout(layout); | |
layout.setHorizontalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addContainerGap() | |
.addComponent(jLabel20)) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(79, 79, 79) | |
.addComponent(jLabel21) | |
.addGap(33, 33, 33) | |
.addComponent(XLIM, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(182, 182, 182) | |
.addComponent(jLabel22) | |
.addGap(47, 47, 47) | |
.addComponent(YLIM, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE))) | |
.addContainerGap(472, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | |
.addContainerGap() | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(42, 42, 42) | |
.addComponent(X1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(32, 32, 32) | |
.addComponent(jLabel3)) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(211, 211, 211) | |
.addComponent(jLabel10) | |
.addGap(52, 52, 52) | |
.addComponent(Y1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(18, 18, 18) | |
.addComponent(jLabel4)) | |
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
.addGap(634, 634, 634)) | |
.addGroup(layout.createSequentialGroup() | |
.addContainerGap() | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jLabel14) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(54, 54, 54) | |
.addComponent(jLabel15) | |
.addGap(89, 89, 89) | |
.addComponent(jLabel16) | |
.addGap(71, 71, 71) | |
.addComponent(ZX, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLabel18) | |
.addGap(66, 66, 66) | |
.addComponent(jLabel17) | |
.addGap(51, 51, 51) | |
.addComponent(ZY, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(27, 27, 27) | |
.addComponent(jLabel19))) | |
.addContainerGap(435, Short.MAX_VALUE)) | |
.addGroup(layout.createSequentialGroup() | |
.addContainerGap() | |
.addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addContainerGap(831, Short.MAX_VALUE)) | |
.addGroup(layout.createSequentialGroup() | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addContainerGap() | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(40, 40, 40) | |
.addComponent(X2, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(33, 33, 33) | |
.addComponent(jLabel6)) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(132, 132, 132) | |
.addComponent(jLabel24) | |
.addGap(68, 68, 68) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jLabel12) | |
.addComponent(jLabel25)) | |
.addGap(52, 52, 52) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) | |
.addComponent(Y3, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE) | |
.addComponent(Y2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE))))) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(52, 52, 52) | |
.addComponent(X3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLabel11)) | |
.addGroup(layout.createSequentialGroup() | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) | |
.addGroup(layout.createSequentialGroup() | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
.addComponent(jLabel26)) | |
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() | |
.addGap(31, 31, 31) | |
.addComponent(jLabel7))) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 109, Short.MAX_VALUE) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | |
.addComponent(jLabel13) | |
.addComponent(jLabel27)))) | |
.addGap(79, 79, 79) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) | |
.addComponent(C3, 0, 0, Short.MAX_VALUE) | |
.addComponent(C2, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)) | |
.addComponent(C1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
.addGap(23, 23, 23) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jLabel8) | |
.addComponent(jLabel28) | |
.addComponent(jLabel5)) | |
.addGap(145, 145, 145) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jButton1) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE) | |
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(5, 5, 5) | |
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | |
.addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING))) | |
.addGap(112, 112, 112)) | |
.addGroup(layout.createSequentialGroup() | |
.addComponent(jLabel9) | |
.addContainerGap(550, Short.MAX_VALUE)))) | |
); | |
layout.setVerticalGroup( | |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addComponent(jLabel9) | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jLabel1) | |
.addGap(63, 63, 63) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel3) | |
.addComponent(X1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(Y1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel4) | |
.addComponent(jLabel10)) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel11) | |
.addComponent(C1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))) | |
.addGap(48, 48, 48) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addComponent(jLabel2) | |
.addGap(66, 66, 66) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(X2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel6))) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(102, 102, 102) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(4, 4, 4) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(C2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel8) | |
.addComponent(jLabel13))) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(Y2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel12) | |
.addComponent(jLabel26))))) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(36, 36, 36) | |
.addComponent(jLabel23) | |
.addGap(18, 18, 18) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(Y3, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(X3, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(C3, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE) | |
.addComponent(jLabel25) | |
.addComponent(jLabel7) | |
.addComponent(jLabel24) | |
.addComponent(jLabel27) | |
.addComponent(jLabel28)))) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(78, 78, 78) | |
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE))) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(47, 47, 47) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addGroup(layout.createSequentialGroup() | |
.addComponent(jLabel14) | |
.addGap(35, 35, 35) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel15) | |
.addComponent(jLabel16))) | |
.addGroup(layout.createSequentialGroup() | |
.addGap(69, 69, 69) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
.addComponent(ZX, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel17) | |
.addComponent(jLabel18) | |
.addComponent(ZY, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel19))))) | |
.addGap(18, 18, 18) | |
.addComponent(jLabel20) | |
.addGap(28, 28, 28) | |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
.addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(XLIM, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addComponent(YLIM, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))) | |
.addGroup(layout.createSequentialGroup() | |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE) | |
.addGap(78, 78, 78) | |
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))) | |
.addGap(32, 32, 32)) | |
); | |
pack(); | |
}// </editor-fold>//GEN-END:initComponents | |
private void X1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_X1ActionPerformed | |
}//GEN-LAST:event_X1ActionPerformed | |
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed | |
//Write into the file | |
String fileName = "Equation1.txt"; | |
//Preparing to write into a file | |
BufferedWriter bufferedWriter = null; | |
try{ | |
FileWriter fileWriter = new FileWriter(fileName); | |
bufferedWriter = new BufferedWriter(fileWriter); | |
//Write the co-efficient of equation1 into the file Equation1.txt | |
bufferedWriter.write(X1.getText()+"\n"); | |
bufferedWriter.write(Y1.getText()+"\n"); | |
bufferedWriter.write(C1.getText()+"\n"); | |
// bufferedWriter.newLine(); | |
} catch(IOException ex){ | |
System.out.print("Error in opening the file!\n"); | |
}finally{ | |
try{ | |
if(bufferedWriter != null){ | |
bufferedWriter.close(); | |
} | |
}catch(IOException e){ | |
System.out.print(e); | |
} | |
} | |
//Path of source file | |
File source = new File("C:\\Users\\Technopedia\\Documents\\NetBeansProjects\\GUI_FOR_GRAPH_PLOT\\Equation1.txt"); | |
//Path of Destination file | |
File dest = new File("C:\\Users\\Technopedia\\PycharmProjects\\OR\\GraphicalMethod\\Equation1.txt"); | |
try{ | |
copyFileUsingStream(source,dest); | |
} catch(IOException e){ | |
System.out.print(e); | |
} | |
}//GEN-LAST:event_jButton1ActionPerformed | |
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed | |
//Equation 2 | |
String fileName = "Equation2.txt"; | |
BufferedWriter bufferedWriter = null; | |
try{ | |
FileWriter fileWriter = new FileWriter(fileName); | |
bufferedWriter = new BufferedWriter(fileWriter); | |
bufferedWriter.write(X2.getText()+"\n"); | |
bufferedWriter.write(Y2.getText()+"\n"); | |
bufferedWriter.write(C2.getText()+"\n"); | |
} catch(IOException ex){ | |
System.out.print("Error in opening the file!\n"); | |
}finally{ | |
try{ | |
if(bufferedWriter != null){ | |
bufferedWriter.close(); | |
} | |
}catch(IOException e){ | |
System.out.print(e); | |
} | |
} | |
File source = new File("C:\\Users\\Technopedia\\Documents\\NetBeansProjects\\GUI_FOR_GRAPH_PLOT\\Equation2.txt"); | |
File dest = new File("C:\\Users\\Technopedia\\PycharmProjects\\OR\\GraphicalMethod\\Equation2.txt"); | |
try{ | |
copyFileUsingStream(source,dest); | |
} catch(IOException e){ | |
System.out.print(e); | |
} | |
}//GEN-LAST:event_jButton2ActionPerformed | |
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed | |
//Objective Function | |
String fileName = "Objective_Function.txt"; | |
BufferedWriter bufferedWriter = null; | |
try{ | |
FileWriter fileWriter = new FileWriter(fileName); | |
bufferedWriter = new BufferedWriter(fileWriter); | |
bufferedWriter.write(ZX.getText()+"\n"); | |
bufferedWriter.write(ZY.getText()+"\n"); | |
} catch(IOException ex){ | |
System.out.print("Error in opening the file!\n"); | |
}finally{ | |
try{ | |
if(bufferedWriter != null){ | |
bufferedWriter.close(); | |
} | |
}catch(IOException e){ | |
System.out.print(e); | |
} | |
} | |
File source = new File("C:\\Users\\Technopedia\\Documents\\NetBeansProjects\\GUI_FOR_GRAPH_PLOT\\Objective_Function.txt"); | |
File dest = new File("C:\\Users\\Technopedia\\PycharmProjects\\OR\\GraphicalMethod\\Objective_Function.txt"); | |
try{ | |
copyFileUsingStream(source,dest); | |
} catch(IOException e){ | |
System.out.print(e); | |
} | |
}//GEN-LAST:event_jButton3ActionPerformed | |
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed | |
//X and Y limits | |
String fileName = "Limits.txt"; | |
BufferedWriter bufferedWriter = null; | |
try{ | |
FileWriter fileWriter = new FileWriter(fileName); | |
bufferedWriter = new BufferedWriter(fileWriter); | |
bufferedWriter.write(XLIM.getText()+"\n"); | |
bufferedWriter.write(YLIM.getText()+"\n"); | |
} catch(IOException ex){ | |
System.out.print("Error in opening the file!\n"); | |
}finally{ | |
try{ | |
if(bufferedWriter != null){ | |
bufferedWriter.close(); | |
} | |
}catch(IOException e){ | |
System.out.print(e); | |
} | |
} | |
File source = new File("C:\\Users\\Technopedia\\Documents\\NetBeansProjects\\GUI_FOR_GRAPH_PLOT\\Limits.txt"); | |
File dest = new File("C:\\Users\\Technopedia\\PycharmProjects\\OR\\GraphicalMethod\\Limits.txt"); | |
try{ | |
copyFileUsingStream(source,dest); | |
} catch(IOException e){ | |
System.out.print(e); | |
} | |
}//GEN-LAST:event_jButton4ActionPerformed | |
private void X3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_X3ActionPerformed | |
// TODO add your handling code here: | |
}//GEN-LAST:event_X3ActionPerformed | |
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed | |
String fileName = "Equation3.txt"; | |
BufferedWriter bufferedWriter = null; | |
try{ | |
FileWriter fileWriter = new FileWriter(fileName); | |
bufferedWriter = new BufferedWriter(fileWriter); | |
bufferedWriter.write(X3.getText()+"\n"); | |
bufferedWriter.write(Y3.getText()+"\n"); | |
bufferedWriter.write(C3.getText()+"\n"); | |
} catch(IOException ex){ | |
System.out.print("Error in opening the file!\n"); | |
}finally{ | |
try{ | |
if(bufferedWriter != null){ | |
bufferedWriter.close(); | |
} | |
}catch(IOException e){ | |
System.out.print(e); | |
} | |
} | |
File source = new File("C:\\Users\\Technopedia\\Documents\\NetBeansProjects\\GUI_FOR_GRAPH_PLOT\\Equation3.txt"); | |
File dest = new File("C:\\Users\\Technopedia\\PycharmProjects\\OR\\GraphicalMethod\\Equation3.txt"); | |
try{ | |
copyFileUsingStream(source,dest); | |
} catch(IOException e){ | |
System.out.print(e); | |
} | |
}//GEN-LAST:event_jButton5ActionPerformed | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String args[]) { | |
java.awt.EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
new GUI_Plot().setVisible(true); | |
} | |
}); | |
} | |
// Variables declaration - do not modify//GEN-BEGIN:variables | |
private javax.swing.JTextField C1; | |
private javax.swing.JTextField C2; | |
private javax.swing.JTextField C3; | |
private javax.swing.JTextField X1; | |
private javax.swing.JTextField X2; | |
private javax.swing.JTextField X3; | |
private javax.swing.JTextField XLIM; | |
private javax.swing.JTextField Y1; | |
private javax.swing.JTextField Y2; | |
private javax.swing.JTextField Y3; | |
private javax.swing.JTextField YLIM; | |
private javax.swing.JTextField ZX; | |
private javax.swing.JTextField ZY; | |
private javax.swing.JButton jButton1; | |
private javax.swing.JButton jButton2; | |
private javax.swing.JButton jButton3; | |
private javax.swing.JButton jButton4; | |
private javax.swing.JButton jButton5; | |
private javax.swing.JLabel jLabel1; | |
private javax.swing.JLabel jLabel10; | |
private javax.swing.JLabel jLabel11; | |
private javax.swing.JLabel jLabel12; | |
private javax.swing.JLabel jLabel13; | |
private javax.swing.JLabel jLabel14; | |
private javax.swing.JLabel jLabel15; | |
private javax.swing.JLabel jLabel16; | |
private javax.swing.JLabel jLabel17; | |
private javax.swing.JLabel jLabel18; | |
private javax.swing.JLabel jLabel19; | |
private javax.swing.JLabel jLabel2; | |
private javax.swing.JLabel jLabel20; | |
private javax.swing.JLabel jLabel21; | |
private javax.swing.JLabel jLabel22; | |
private javax.swing.JLabel jLabel23; | |
private javax.swing.JLabel jLabel24; | |
private javax.swing.JLabel jLabel25; | |
private javax.swing.JLabel jLabel26; | |
private javax.swing.JLabel jLabel27; | |
private javax.swing.JLabel jLabel28; | |
private javax.swing.JLabel jLabel3; | |
private javax.swing.JLabel jLabel4; | |
private javax.swing.JLabel jLabel5; | |
private javax.swing.JLabel jLabel6; | |
private javax.swing.JLabel jLabel7; | |
private javax.swing.JLabel jLabel8; | |
private javax.swing.JLabel jLabel9; | |
private javax.swing.JRadioButton jRadioButton1; | |
// End of variables declaration//GEN-END:variables | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment