Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
QxBytes committed Mar 25, 2021
0 parents commit 0688be2
Show file tree
Hide file tree
Showing 104 changed files with 3,074 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/jxl.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.xls
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Chemistry Lab</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/com/qxbytes/chemlab/DetailedItem.java=UTF-8
encoding//src/com/qxbytes/chemlab/PicturePane.java=UTF-8
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Binary file added bin/com/qxbytes/chemlab/AnalyzePane$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/AnalyzePane$2.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/AnalyzePane$3.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/AnalyzePane$4.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/AnalyzePane$5.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/AnalyzePane.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/ChemIO.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/Comparators.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/ConversionPane.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/DC.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/DetailedItem$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/DetailedItem$2.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/DetailedItem$3.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/DetailedItem$4.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/DetailedItem.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/Element.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/ElementDisplay$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/ElementDisplay$2.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/ElementDisplay.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/ElementItemListener.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/ExcelHandler.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/IO.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/InformationPane.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/Main.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/PeriodicConstants.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/PeriodicTable.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/PicturePane.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/PosCon.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SelectionPane$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SelectionPane$2.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SelectionPane$3.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SelectionPane$4.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SelectionPane$5.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SelectionPane$6.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SelectionPane.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SortElement.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SortPane$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SortPane$2.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/SortPane.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/TestMain.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/Utils.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/WebButton$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/WebButton.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/Webbrowser.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/calculateListener.class
Binary file not shown.
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/com/qxbytes/chemlab/lexographicComparator.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/numberComparator.class
Binary file not shown.
Binary file added bin/com/qxbytes/chemlab/sizeComparator.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/Creator$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/Creator.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/IonIsotopePane.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/PButton$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/PButton.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/PItem.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/PLUGINMANIFEST.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/Pair.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/Plugin.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/SElement.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/SandFrame$1.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/SandFrame.class
Binary file not shown.
Binary file added bin/com/qxbytes/plugins/Sandbox.class
Binary file not shown.
Binary file added lib/jxl.jar
Binary file not shown.
90 changes: 90 additions & 0 deletions src/com/qxbytes/chemlab/AnalyzePane.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.qxbytes.chemlab;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
*
* @author QxBytes
*
*/
public class AnalyzePane extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
public AnalyzePane() {
super();
setLayout(new GridLayout(1,0));
add(new JLabel("Sort & Analyze"));
JButton eng = new JButton("Electronegativity");
eng.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
SelectionPane.getInpane().sort(new electronegativityComparator());
new SortPane(SelectionPane.getInpane(),"Electronegativity- Least to Greatest");
}

});
add(eng);
JButton size = new JButton("Atomic Radius");
size.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent arg0) {
SelectionPane.getInpane().sort(new sizeComparator());
new SortPane(SelectionPane.getInpane(),"Size- Smallest to Largest");
}

});
add(size);
JButton alpha = new JButton("Alphabetize");
alpha.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
SelectionPane.getInpane().sort(new lexographicComparator());
new SortPane(SelectionPane.getInpane(),"Alphabetize- a-z");
}

});
add(alpha);
JButton sort = new JButton("Num. Sort");
sort.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
SelectionPane.getInpane().sort(new numberComparator());
new SortPane(SelectionPane.getInpane(),"Atom. Num- Low-High");
}

});
add(sort);
JButton anlz = new JButton("Analyze");
anlz.setBackground(Color.GREEN);
anlz.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
double totalmass = 0;
int totalatoms = 0;
for (int i = 0 ; i < SelectionPane.getInpane().size() ;i++) {
for (int x = 0 ; x < SelectionPane.getInpane().get(i).getAbscount() ; x++) {
totalmass += SelectionPane.getInpane().get(i).getWeight();
totalatoms+=1;
}
}
new ConversionPane(totalatoms, totalmass, "Convert");

}

});
add(anlz);
}
}
5 changes: 5 additions & 0 deletions src/com/qxbytes/chemlab/ChemIO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.qxbytes.chemlab;

public class ChemIO {

}
58 changes: 58 additions & 0 deletions src/com/qxbytes/chemlab/Comparators.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.qxbytes.chemlab;

import java.util.Comparator;
/**
*
* @author QxBytes
*
*/
public class Comparators {

}
class electronegativityComparator implements Comparator<Element> {
@Override
public int compare(Element o1, Element o2) {
//Distance from fluorine
// sqrt((y2-y1)^2 + (x2-x1)^2)
int d1x = Math.abs(17-o1.getGroup());
int d1y = Math.abs(2 -o1.getPeriod());
int distance = d1x + d1y;

int d2x = Math.abs(17-o2.getGroup());
int d2y = Math.abs(2 -o1.getPeriod());
int distance2 = d2x + d2y;

return distance2-distance;
}

}
class sizeComparator implements Comparator<Element> {

@Override
public int compare(Element o1, Element o2) {
if (o1.getPeriod() > o2.getPeriod()) {
return 1;
} else if (o1.getGroup() > o2.getGroup()){
return -1;
}
return 0;
}

}
class lexographicComparator implements Comparator<Element> {

@Override
public int compare(Element o1, Element o2) {
return o1.getName().compareTo(o2.getName());
}

}
class numberComparator implements Comparator<Element> {

@Override
public int compare(Element o1, Element o2) {

return o1.getNum()-o2.getNum();
}

}
140 changes: 140 additions & 0 deletions src/com/qxbytes/chemlab/ConversionPane.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package com.qxbytes.chemlab;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.imageio.ImageIO;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*
* @author QxBytes
*
*/
public class ConversionPane {
public ConversionPane(int atoms, double mass, String name) {
JFrame frame = new JFrame(SelectionPane.getFrame().getTitle().substring(10).replaceAll("1", ""));
//atoms, particles, moles, molecular mass, grams
frame.setSize(300, 400);
frame.setLocationRelativeTo(null);

JPanel root = new JPanel(new GridLayout(6,2));
frame.setLayout(new GridLayout(2,1));

JPanel database = new JPanel(new GridLayout(0,1));

root.add(new JLabel("Atoms: "));
JTextField atom = new JTextField("0");
root.add(atom);
root.add(new JLabel("Particles: "));
JTextField part = new JTextField("0");
root.add(part);
root.add(new JLabel("Mole: "));
JTextField mole = new JTextField("0");
root.add(mole);
root.add(new JLabel("Mole/Grams: "));
JTextField gmol = new JTextField(mass+"");
root.add(gmol);
root.add(new JLabel("Grams: "));
JTextField gram = new JTextField("0");
root.add(gram);
root.add(new JLabel("Atoms/Particle: "));
JTextField aprt = new JTextField(atoms+"");
root.add(aprt);

atom.addActionListener(new calculateListener(atom,part,mole,gmol,gram,aprt,0));
part.addActionListener(new calculateListener(atom,part,mole,gmol,gram,aprt,1));
mole.addActionListener(new calculateListener(atom,part,mole,gmol,gram,aprt,2));
gram.addActionListener(new calculateListener(atom,part,mole,gmol,gram,aprt,3));

frame.add(root);

try {
frame.setIconImage(ImageIO.read(PeriodicTable.class.getResourceAsStream("icon.png")));
} catch (Exception qq) {

}

JEditorPane jep = new JEditorPane();
jep.setEditable(false);

try {
WebButton compound = new WebButton("Check Compounds Database","https://pubchem.ncbi.nlm.nih.gov/compound/");
WebButton substance = new WebButton("Check Substances Databse","https://pubchem.ncbi.nlm.nih.gov/substance/");
WebButton wiki = new WebButton("Check Wikipedia","https://en.wikipedia.org/wiki/");

database.add(compound);
database.add(substance);
database.add(wiki);

frame.add(database);
} catch (Exception e) {

}
frame.setVisible(true);
}
}
class calculateListener implements ActionListener {
JTextField atom, part, mole, gmol, gram, aprt;
int num;
int atoms;
double avgNum = 6.022 * Math.pow(10, 23);
public calculateListener(JTextField atm, JTextField par, JTextField mol, JTextField gmo, JTextField gra, JTextField apr, int num) {
atom = atm;
part = par;
mole = mol;
gmol = gmo;
gram = gra;
aprt = apr;
//function
this.num = num;
//total atoms
}
@Override
public void actionPerformed(ActionEvent arg0) {
try {

double atm = Double.parseDouble(atom.getText());
double par = Double.parseDouble(part.getText());
double mol = Double.parseDouble(mole.getText());
double gmo = Double.parseDouble(gmol.getText());
double gra = Double.parseDouble(gram.getText());
double apr = Double.parseDouble(aprt.getText());
switch (num) {
case 0://given: Atoms
par = atm / apr;
mol = par / avgNum;
gra = mol * gmo;
break;
case 1://given: Particles
atm = par * apr;
mol = par / avgNum;
gra = mol * gmo;
break;
case 2://given: Moles
par = avgNum * mol;
atm = par * apr;
gra = mol * gmo;
break;
case 3://given: Grams (OK)
mol = gra / gmo;
par = mol * avgNum;
atm = par * apr;
break;
}

atom.setText(atm+"");
part.setText(par+"");
mole.setText(mol+"");
gram.setText(gra+"");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Enter a number\nMake sure no fields are blank.", "Error", JOptionPane.INFORMATION_MESSAGE);
}
}

}
41 changes: 41 additions & 0 deletions src/com/qxbytes/chemlab/DC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.qxbytes.chemlab;

import java.awt.Toolkit;
/**
* Display Constants
* @author QxBytes
*
*/
public class DC {
public static int WIDTH = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
public static int HEIGHT = (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight();

public static boolean EXTDMODE = true;

public static int NORMWIDTHPT = DC.WIDTH;
public static int NORMHEIGHTPT = (int)(DC.HEIGHT*.7);
public static int NORMWIDTHSL = DC.WIDTH;
public static int NORMHEIGHTSL = 200;
public static int NORMYSL = (int)(DC.HEIGHT*.7);

public static int EXTDWIDTHPT = (int)(DC.WIDTH)-250;
public static int EXTDHEIGHTPT = DC.HEIGHT-100;
public static int EXTDWIDTHSL = 250;
public static int EXTDHEIGHTSL = DC.HEIGHT-100;
public static int EXTDXSL = (int)(DC.WIDTH-250);

public static int PW = EXTDWIDTHPT;
public static int PH = EXTDHEIGHTPT;
public static int SW = EXTDWIDTHSL;
public static int SH = EXTDHEIGHTSL;
public static int SY = 0;
public static int SX = EXTDXSL;

// public static int PW = NORMWIDTHPT;
// public static int PH = NORMHEIGHTPT;
// public static int SW = NORMWIDTHSL;
// public static int SH = NORMHEIGHTSL;
// public static int SY = NORMYSL;
// public static int SX = 0;

}
Loading

0 comments on commit 0688be2

Please sign in to comment.