diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..bef3308
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7308bbc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.xls
\ No newline at end of file
diff --git a/.project b/.project
new file mode 100644
index 0000000..7dd7322
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ Chemistry Lab
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..6284d7e
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -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
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..3a21537
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -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
diff --git a/bin/com/qxbytes/chemlab/AnalyzePane$1.class b/bin/com/qxbytes/chemlab/AnalyzePane$1.class
new file mode 100644
index 0000000..517b60f
Binary files /dev/null and b/bin/com/qxbytes/chemlab/AnalyzePane$1.class differ
diff --git a/bin/com/qxbytes/chemlab/AnalyzePane$2.class b/bin/com/qxbytes/chemlab/AnalyzePane$2.class
new file mode 100644
index 0000000..6dfcf9b
Binary files /dev/null and b/bin/com/qxbytes/chemlab/AnalyzePane$2.class differ
diff --git a/bin/com/qxbytes/chemlab/AnalyzePane$3.class b/bin/com/qxbytes/chemlab/AnalyzePane$3.class
new file mode 100644
index 0000000..ed92bcd
Binary files /dev/null and b/bin/com/qxbytes/chemlab/AnalyzePane$3.class differ
diff --git a/bin/com/qxbytes/chemlab/AnalyzePane$4.class b/bin/com/qxbytes/chemlab/AnalyzePane$4.class
new file mode 100644
index 0000000..db09154
Binary files /dev/null and b/bin/com/qxbytes/chemlab/AnalyzePane$4.class differ
diff --git a/bin/com/qxbytes/chemlab/AnalyzePane$5.class b/bin/com/qxbytes/chemlab/AnalyzePane$5.class
new file mode 100644
index 0000000..8d4939d
Binary files /dev/null and b/bin/com/qxbytes/chemlab/AnalyzePane$5.class differ
diff --git a/bin/com/qxbytes/chemlab/AnalyzePane.class b/bin/com/qxbytes/chemlab/AnalyzePane.class
new file mode 100644
index 0000000..79b9260
Binary files /dev/null and b/bin/com/qxbytes/chemlab/AnalyzePane.class differ
diff --git a/bin/com/qxbytes/chemlab/ChemIO.class b/bin/com/qxbytes/chemlab/ChemIO.class
new file mode 100644
index 0000000..c0eca08
Binary files /dev/null and b/bin/com/qxbytes/chemlab/ChemIO.class differ
diff --git a/bin/com/qxbytes/chemlab/Comparators.class b/bin/com/qxbytes/chemlab/Comparators.class
new file mode 100644
index 0000000..10240ff
Binary files /dev/null and b/bin/com/qxbytes/chemlab/Comparators.class differ
diff --git a/bin/com/qxbytes/chemlab/ConversionPane.class b/bin/com/qxbytes/chemlab/ConversionPane.class
new file mode 100644
index 0000000..3170cf6
Binary files /dev/null and b/bin/com/qxbytes/chemlab/ConversionPane.class differ
diff --git a/bin/com/qxbytes/chemlab/DC.class b/bin/com/qxbytes/chemlab/DC.class
new file mode 100644
index 0000000..cec0e8a
Binary files /dev/null and b/bin/com/qxbytes/chemlab/DC.class differ
diff --git a/bin/com/qxbytes/chemlab/DetailedItem$1.class b/bin/com/qxbytes/chemlab/DetailedItem$1.class
new file mode 100644
index 0000000..b404310
Binary files /dev/null and b/bin/com/qxbytes/chemlab/DetailedItem$1.class differ
diff --git a/bin/com/qxbytes/chemlab/DetailedItem$2.class b/bin/com/qxbytes/chemlab/DetailedItem$2.class
new file mode 100644
index 0000000..fec298a
Binary files /dev/null and b/bin/com/qxbytes/chemlab/DetailedItem$2.class differ
diff --git a/bin/com/qxbytes/chemlab/DetailedItem$3.class b/bin/com/qxbytes/chemlab/DetailedItem$3.class
new file mode 100644
index 0000000..2cfab7b
Binary files /dev/null and b/bin/com/qxbytes/chemlab/DetailedItem$3.class differ
diff --git a/bin/com/qxbytes/chemlab/DetailedItem$4.class b/bin/com/qxbytes/chemlab/DetailedItem$4.class
new file mode 100644
index 0000000..493d16e
Binary files /dev/null and b/bin/com/qxbytes/chemlab/DetailedItem$4.class differ
diff --git a/bin/com/qxbytes/chemlab/DetailedItem.class b/bin/com/qxbytes/chemlab/DetailedItem.class
new file mode 100644
index 0000000..01cb12f
Binary files /dev/null and b/bin/com/qxbytes/chemlab/DetailedItem.class differ
diff --git a/bin/com/qxbytes/chemlab/Element.class b/bin/com/qxbytes/chemlab/Element.class
new file mode 100644
index 0000000..4eb324a
Binary files /dev/null and b/bin/com/qxbytes/chemlab/Element.class differ
diff --git a/bin/com/qxbytes/chemlab/ElementDisplay$1.class b/bin/com/qxbytes/chemlab/ElementDisplay$1.class
new file mode 100644
index 0000000..d613294
Binary files /dev/null and b/bin/com/qxbytes/chemlab/ElementDisplay$1.class differ
diff --git a/bin/com/qxbytes/chemlab/ElementDisplay$2.class b/bin/com/qxbytes/chemlab/ElementDisplay$2.class
new file mode 100644
index 0000000..31f4004
Binary files /dev/null and b/bin/com/qxbytes/chemlab/ElementDisplay$2.class differ
diff --git a/bin/com/qxbytes/chemlab/ElementDisplay.class b/bin/com/qxbytes/chemlab/ElementDisplay.class
new file mode 100644
index 0000000..5d63a04
Binary files /dev/null and b/bin/com/qxbytes/chemlab/ElementDisplay.class differ
diff --git a/bin/com/qxbytes/chemlab/ElementItemListener.class b/bin/com/qxbytes/chemlab/ElementItemListener.class
new file mode 100644
index 0000000..1a9e368
Binary files /dev/null and b/bin/com/qxbytes/chemlab/ElementItemListener.class differ
diff --git a/bin/com/qxbytes/chemlab/ExcelHandler.class b/bin/com/qxbytes/chemlab/ExcelHandler.class
new file mode 100644
index 0000000..405bcf4
Binary files /dev/null and b/bin/com/qxbytes/chemlab/ExcelHandler.class differ
diff --git a/bin/com/qxbytes/chemlab/IO.class b/bin/com/qxbytes/chemlab/IO.class
new file mode 100644
index 0000000..0dcd840
Binary files /dev/null and b/bin/com/qxbytes/chemlab/IO.class differ
diff --git a/bin/com/qxbytes/chemlab/InformationPane.class b/bin/com/qxbytes/chemlab/InformationPane.class
new file mode 100644
index 0000000..3b6a583
Binary files /dev/null and b/bin/com/qxbytes/chemlab/InformationPane.class differ
diff --git a/bin/com/qxbytes/chemlab/Main.class b/bin/com/qxbytes/chemlab/Main.class
new file mode 100644
index 0000000..e37560f
Binary files /dev/null and b/bin/com/qxbytes/chemlab/Main.class differ
diff --git a/bin/com/qxbytes/chemlab/PeriodicConstants.class b/bin/com/qxbytes/chemlab/PeriodicConstants.class
new file mode 100644
index 0000000..4ffe87c
Binary files /dev/null and b/bin/com/qxbytes/chemlab/PeriodicConstants.class differ
diff --git a/bin/com/qxbytes/chemlab/PeriodicTable.class b/bin/com/qxbytes/chemlab/PeriodicTable.class
new file mode 100644
index 0000000..1bd8c7b
Binary files /dev/null and b/bin/com/qxbytes/chemlab/PeriodicTable.class differ
diff --git a/bin/com/qxbytes/chemlab/PicturePane.class b/bin/com/qxbytes/chemlab/PicturePane.class
new file mode 100644
index 0000000..56c0236
Binary files /dev/null and b/bin/com/qxbytes/chemlab/PicturePane.class differ
diff --git a/bin/com/qxbytes/chemlab/PosCon.class b/bin/com/qxbytes/chemlab/PosCon.class
new file mode 100644
index 0000000..76ba5cb
Binary files /dev/null and b/bin/com/qxbytes/chemlab/PosCon.class differ
diff --git a/bin/com/qxbytes/chemlab/SelectionPane$1.class b/bin/com/qxbytes/chemlab/SelectionPane$1.class
new file mode 100644
index 0000000..a7906ce
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SelectionPane$1.class differ
diff --git a/bin/com/qxbytes/chemlab/SelectionPane$2.class b/bin/com/qxbytes/chemlab/SelectionPane$2.class
new file mode 100644
index 0000000..04e2371
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SelectionPane$2.class differ
diff --git a/bin/com/qxbytes/chemlab/SelectionPane$3.class b/bin/com/qxbytes/chemlab/SelectionPane$3.class
new file mode 100644
index 0000000..b0901b0
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SelectionPane$3.class differ
diff --git a/bin/com/qxbytes/chemlab/SelectionPane$4.class b/bin/com/qxbytes/chemlab/SelectionPane$4.class
new file mode 100644
index 0000000..1cc0022
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SelectionPane$4.class differ
diff --git a/bin/com/qxbytes/chemlab/SelectionPane$5.class b/bin/com/qxbytes/chemlab/SelectionPane$5.class
new file mode 100644
index 0000000..d5a38bb
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SelectionPane$5.class differ
diff --git a/bin/com/qxbytes/chemlab/SelectionPane$6.class b/bin/com/qxbytes/chemlab/SelectionPane$6.class
new file mode 100644
index 0000000..0458efa
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SelectionPane$6.class differ
diff --git a/bin/com/qxbytes/chemlab/SelectionPane.class b/bin/com/qxbytes/chemlab/SelectionPane.class
new file mode 100644
index 0000000..6f20bfc
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SelectionPane.class differ
diff --git a/bin/com/qxbytes/chemlab/SortElement.class b/bin/com/qxbytes/chemlab/SortElement.class
new file mode 100644
index 0000000..6044bed
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SortElement.class differ
diff --git a/bin/com/qxbytes/chemlab/SortPane$1.class b/bin/com/qxbytes/chemlab/SortPane$1.class
new file mode 100644
index 0000000..efa333a
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SortPane$1.class differ
diff --git a/bin/com/qxbytes/chemlab/SortPane$2.class b/bin/com/qxbytes/chemlab/SortPane$2.class
new file mode 100644
index 0000000..dfefbda
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SortPane$2.class differ
diff --git a/bin/com/qxbytes/chemlab/SortPane.class b/bin/com/qxbytes/chemlab/SortPane.class
new file mode 100644
index 0000000..894821f
Binary files /dev/null and b/bin/com/qxbytes/chemlab/SortPane.class differ
diff --git a/bin/com/qxbytes/chemlab/TestMain.class b/bin/com/qxbytes/chemlab/TestMain.class
new file mode 100644
index 0000000..c08fee0
Binary files /dev/null and b/bin/com/qxbytes/chemlab/TestMain.class differ
diff --git a/bin/com/qxbytes/chemlab/Utils.class b/bin/com/qxbytes/chemlab/Utils.class
new file mode 100644
index 0000000..19fa788
Binary files /dev/null and b/bin/com/qxbytes/chemlab/Utils.class differ
diff --git a/bin/com/qxbytes/chemlab/WebButton$1.class b/bin/com/qxbytes/chemlab/WebButton$1.class
new file mode 100644
index 0000000..d814f57
Binary files /dev/null and b/bin/com/qxbytes/chemlab/WebButton$1.class differ
diff --git a/bin/com/qxbytes/chemlab/WebButton.class b/bin/com/qxbytes/chemlab/WebButton.class
new file mode 100644
index 0000000..6c1b0af
Binary files /dev/null and b/bin/com/qxbytes/chemlab/WebButton.class differ
diff --git a/bin/com/qxbytes/chemlab/Webbrowser.class b/bin/com/qxbytes/chemlab/Webbrowser.class
new file mode 100644
index 0000000..aaec5ab
Binary files /dev/null and b/bin/com/qxbytes/chemlab/Webbrowser.class differ
diff --git a/bin/com/qxbytes/chemlab/calculateListener.class b/bin/com/qxbytes/chemlab/calculateListener.class
new file mode 100644
index 0000000..802f98f
Binary files /dev/null and b/bin/com/qxbytes/chemlab/calculateListener.class differ
diff --git a/bin/com/qxbytes/chemlab/electronegativityComparator.class b/bin/com/qxbytes/chemlab/electronegativityComparator.class
new file mode 100644
index 0000000..4eb4da6
Binary files /dev/null and b/bin/com/qxbytes/chemlab/electronegativityComparator.class differ
diff --git a/bin/com/qxbytes/chemlab/icon.png b/bin/com/qxbytes/chemlab/icon.png
new file mode 100644
index 0000000..568bc10
Binary files /dev/null and b/bin/com/qxbytes/chemlab/icon.png differ
diff --git a/bin/com/qxbytes/chemlab/lexographicComparator.class b/bin/com/qxbytes/chemlab/lexographicComparator.class
new file mode 100644
index 0000000..002b7e7
Binary files /dev/null and b/bin/com/qxbytes/chemlab/lexographicComparator.class differ
diff --git a/bin/com/qxbytes/chemlab/numberComparator.class b/bin/com/qxbytes/chemlab/numberComparator.class
new file mode 100644
index 0000000..52838ce
Binary files /dev/null and b/bin/com/qxbytes/chemlab/numberComparator.class differ
diff --git a/bin/com/qxbytes/chemlab/sizeComparator.class b/bin/com/qxbytes/chemlab/sizeComparator.class
new file mode 100644
index 0000000..1b7cde6
Binary files /dev/null and b/bin/com/qxbytes/chemlab/sizeComparator.class differ
diff --git a/bin/com/qxbytes/plugins/Creator$1.class b/bin/com/qxbytes/plugins/Creator$1.class
new file mode 100644
index 0000000..02c1f23
Binary files /dev/null and b/bin/com/qxbytes/plugins/Creator$1.class differ
diff --git a/bin/com/qxbytes/plugins/Creator.class b/bin/com/qxbytes/plugins/Creator.class
new file mode 100644
index 0000000..744e5b5
Binary files /dev/null and b/bin/com/qxbytes/plugins/Creator.class differ
diff --git a/bin/com/qxbytes/plugins/IonIsotopePane.class b/bin/com/qxbytes/plugins/IonIsotopePane.class
new file mode 100644
index 0000000..cf9b135
Binary files /dev/null and b/bin/com/qxbytes/plugins/IonIsotopePane.class differ
diff --git a/bin/com/qxbytes/plugins/PButton$1.class b/bin/com/qxbytes/plugins/PButton$1.class
new file mode 100644
index 0000000..066c9fc
Binary files /dev/null and b/bin/com/qxbytes/plugins/PButton$1.class differ
diff --git a/bin/com/qxbytes/plugins/PButton.class b/bin/com/qxbytes/plugins/PButton.class
new file mode 100644
index 0000000..5d76e15
Binary files /dev/null and b/bin/com/qxbytes/plugins/PButton.class differ
diff --git a/bin/com/qxbytes/plugins/PItem.class b/bin/com/qxbytes/plugins/PItem.class
new file mode 100644
index 0000000..5abb894
Binary files /dev/null and b/bin/com/qxbytes/plugins/PItem.class differ
diff --git a/bin/com/qxbytes/plugins/PLUGINMANIFEST.class b/bin/com/qxbytes/plugins/PLUGINMANIFEST.class
new file mode 100644
index 0000000..06906c3
Binary files /dev/null and b/bin/com/qxbytes/plugins/PLUGINMANIFEST.class differ
diff --git a/bin/com/qxbytes/plugins/Pair.class b/bin/com/qxbytes/plugins/Pair.class
new file mode 100644
index 0000000..8ea679c
Binary files /dev/null and b/bin/com/qxbytes/plugins/Pair.class differ
diff --git a/bin/com/qxbytes/plugins/Plugin.class b/bin/com/qxbytes/plugins/Plugin.class
new file mode 100644
index 0000000..8777e01
Binary files /dev/null and b/bin/com/qxbytes/plugins/Plugin.class differ
diff --git a/bin/com/qxbytes/plugins/SElement.class b/bin/com/qxbytes/plugins/SElement.class
new file mode 100644
index 0000000..5f13ca5
Binary files /dev/null and b/bin/com/qxbytes/plugins/SElement.class differ
diff --git a/bin/com/qxbytes/plugins/SandFrame$1.class b/bin/com/qxbytes/plugins/SandFrame$1.class
new file mode 100644
index 0000000..cfedfee
Binary files /dev/null and b/bin/com/qxbytes/plugins/SandFrame$1.class differ
diff --git a/bin/com/qxbytes/plugins/SandFrame.class b/bin/com/qxbytes/plugins/SandFrame.class
new file mode 100644
index 0000000..2007991
Binary files /dev/null and b/bin/com/qxbytes/plugins/SandFrame.class differ
diff --git a/bin/com/qxbytes/plugins/Sandbox.class b/bin/com/qxbytes/plugins/Sandbox.class
new file mode 100644
index 0000000..3545eac
Binary files /dev/null and b/bin/com/qxbytes/plugins/Sandbox.class differ
diff --git a/lib/jxl.jar b/lib/jxl.jar
new file mode 100644
index 0000000..4a1fc64
Binary files /dev/null and b/lib/jxl.jar differ
diff --git a/src/com/qxbytes/chemlab/AnalyzePane.java b/src/com/qxbytes/chemlab/AnalyzePane.java
new file mode 100644
index 0000000..d7c2f08
--- /dev/null
+++ b/src/com/qxbytes/chemlab/AnalyzePane.java
@@ -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);
+ }
+}
diff --git a/src/com/qxbytes/chemlab/ChemIO.java b/src/com/qxbytes/chemlab/ChemIO.java
new file mode 100644
index 0000000..323e541
--- /dev/null
+++ b/src/com/qxbytes/chemlab/ChemIO.java
@@ -0,0 +1,5 @@
+package com.qxbytes.chemlab;
+
+public class ChemIO {
+
+}
diff --git a/src/com/qxbytes/chemlab/Comparators.java b/src/com/qxbytes/chemlab/Comparators.java
new file mode 100644
index 0000000..104b97b
--- /dev/null
+++ b/src/com/qxbytes/chemlab/Comparators.java
@@ -0,0 +1,58 @@
+package com.qxbytes.chemlab;
+
+import java.util.Comparator;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Comparators {
+
+}
+class electronegativityComparator implements Comparator {
+ @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 {
+
+ @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 {
+
+ @Override
+ public int compare(Element o1, Element o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+
+}
+class numberComparator implements Comparator {
+
+ @Override
+ public int compare(Element o1, Element o2) {
+
+ return o1.getNum()-o2.getNum();
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/qxbytes/chemlab/ConversionPane.java b/src/com/qxbytes/chemlab/ConversionPane.java
new file mode 100644
index 0000000..24bf1b1
--- /dev/null
+++ b/src/com/qxbytes/chemlab/ConversionPane.java
@@ -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);
+ }
+ }
+
+}
diff --git a/src/com/qxbytes/chemlab/DC.java b/src/com/qxbytes/chemlab/DC.java
new file mode 100644
index 0000000..7490f4e
--- /dev/null
+++ b/src/com/qxbytes/chemlab/DC.java
@@ -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;
+
+}
diff --git a/src/com/qxbytes/chemlab/DetailedItem.java b/src/com/qxbytes/chemlab/DetailedItem.java
new file mode 100644
index 0000000..abcc77c
--- /dev/null
+++ b/src/com/qxbytes/chemlab/DetailedItem.java
@@ -0,0 +1,219 @@
+package com.qxbytes.chemlab;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class DetailedItem extends JPanel implements IO{
+ /**
+ *
+ */
+ private JPanel toolbar = new JPanel(new GridLayout(1,0));
+ //removal
+ private JPanel parent;
+ private List inpane;
+ private List di;
+
+ private Element e;
+ private JPanel thiscomponent = this;
+
+ private static final long serialVersionUID = 1L;
+ private JTextField l;
+ private JPanel root;
+ private PicturePane pic;
+ private JPanel data;
+
+ private JButton delete1;
+ private JButton delete;
+ private JButton add;
+ private JButton export;
+
+ private int count;
+ public DetailedItem(JPanel parent, Element e, List inpane, List di) {
+ setBackground(Color.WHITE);
+
+ this.setLayout(new BorderLayout());
+
+ count = e.getAbscount();
+
+ root = new JPanel(new GridLayout(1,2));
+ pic = new PicturePane(e);
+ data = new JPanel(new GridLayout(14,1));
+ delete = new JButton("X");
+ export = new JButton("â–²");
+ delete1 = new JButton("-1");
+ add = new JButton("+1");
+
+ this.e = e;
+ this.parent = parent;
+ this.inpane = inpane;
+ this.di = di;
+
+ this.setPreferredSize(new Dimension(200,200));
+
+ List lbs = Utils.eString(e);
+
+ for (int i = 0 ; i < lbs.size() ; i++) {
+ lbs.get(i).setEditable(false);
+ lbs.get(i).setBackground(new Color(255,255,0));
+ lbs.get(i).setBorder(BorderFactory.createLineBorder(e.getStateColor()));
+ data.add(lbs.get(i));
+ }
+
+ root.add(pic);
+ root.add(data);
+
+ this.add(root, BorderLayout.CENTER);
+
+ delete.setForeground(Color.RED);
+ delete.setBackground(Color.RED);
+
+ export.setForeground(Color.CYAN);
+ export.setBackground(Color.GREEN);
+
+ delete.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ delete();
+ }
+
+ });
+
+ delete1.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ delete1();
+ }
+
+ });
+
+ add.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ add();
+ }
+
+ });
+
+ export.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent q) {
+ List t = new ArrayList();
+ t.add(e);
+ Export(t);
+ }
+
+ });
+
+ toolbar.add(delete);
+ toolbar.add(delete1);
+ toolbar.add(add);
+ toolbar.add(export);
+
+ this.add(toolbar, BorderLayout.SOUTH);
+
+ l = new JTextField(e.getName() + " x " + count);
+ l.setEditable(false);
+ this.add(l,BorderLayout.NORTH);
+ }
+ public void delete() {
+ for (int i = 0 ; i < inpane.size() ; i++) {
+ if (inpane.get(i).equals(e)) {
+ inpane.get(i).setAbscount(1);
+ }
+ }
+
+ inpane.remove(e);
+ parent.remove(thiscomponent);
+ parent.revalidate();
+ parent.repaint();
+ di.remove(this);
+ }
+ public void delete1() {
+ if (count == 1) {
+ delete();
+ return;
+ }
+
+ this.setCount(this.getCount()-1);
+ for (int i = 0 ; i < inpane.size() ; i++) {
+ if (inpane.get(i).equals(e)) {
+ inpane.get(i).setAbscount(inpane.get(i).getAbscount()-1);
+ }
+ }
+ }
+ public void add() {
+ SelectionPane.showDetailedPane(e);
+ }
+ /**
+ * @return the count
+ */
+ public int getCount() {
+ return count;
+ }
+ /**
+ * @param count the count to set
+ */
+ public void setCount(int count) {
+ this.count = count;
+ this.l.setText(e.getName() + " x " + count);
+ }
+ /**
+ * @return the inpane
+ */
+ public List getInpane() {
+ return inpane;
+ }
+
+
+ /**
+ * @param inpane the inpane to set
+ */
+ public void setInpane(List inpane) {
+ this.inpane = inpane;
+ }
+
+ public boolean equals(DetailedItem di) {
+ return di.equals(this.toString());
+ }
+ @Override
+ public String toString() {
+ return e.toAbsoluteData();
+ }
+ @Override
+ public void Export(List e) {
+ JFrame f = new JFrame("" + e.get(0).getName());
+ f.setSize(200, 300);
+
+ JTextArea jta = new JTextArea();
+ jta.setText(e.get(0).toAbsoluteData());
+ f.add(jta);
+
+ f.setVisible(true);
+ }
+ @Override
+ public List Import() {
+ return null;
+
+ }
+}
diff --git a/src/com/qxbytes/chemlab/Element.java b/src/com/qxbytes/chemlab/Element.java
new file mode 100644
index 0000000..9dbb76d
--- /dev/null
+++ b/src/com/qxbytes/chemlab/Element.java
@@ -0,0 +1,466 @@
+package com.qxbytes.chemlab;
+
+import java.awt.Color;
+import java.util.List;
+
+import javax.swing.JTextField;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Element {
+ private int num;
+ private String symbol;
+ private String name;
+
+ private int group;
+ private String groupname;
+ private int period;
+ private String periodname;
+ private double weight;
+ private int massnum;
+ private int state = 0;
+ private int amount = 0;
+ private int abscount = 1;
+
+ private boolean radioactive = false;
+ private boolean artificial = false;
+ private boolean metal = true;
+ /*
+ *
+ * Constructors
+ *
+ */
+ public Element() {
+ this (PeriodicConstants.getElement().get(0));
+ }
+ /**
+ *
+ * @param n
+ * @param sym
+ * @param name
+ * @param weight
+ * @param group
+ * @param period
+ * @param metal
+ * @param state
+ * @param massnum
+ */
+ public Element(int n, String sym, String name, double weight, int group, int period, boolean metal, int state, int massnum) {
+ this.num = n;
+ this.symbol = sym;
+ this.name = name;
+ this.weight = weight;
+ this.group = group;
+ this.period = period;
+ this.metal = metal;
+ this.state = state;
+ this.massnum = massnum;
+ pre();
+ }
+ /**
+ *
+ * @param n
+ * @param sym
+ * @param name
+ * @param weight
+ * @param group
+ * @param period
+ * @param massnum
+ */
+ public Element(int n, String sym, String name, double weight, int group, int period, int massnum) {
+ this.num = n;
+ this.symbol = sym;
+ this.name = name;
+ this.weight = weight;
+ this.group = group;
+ this.period = period;
+ this.massnum = massnum;
+ pre();
+ }
+ public Element(Element e) {
+ this.num = e.getNum();
+ this.symbol = e.getSymbol();
+ this.name = e.getName();
+ this.weight = e.getWeight();
+ this.group = e.getGroup();
+ this.period = e.getPeriod();
+ this.massnum = e.getMassnum();
+ this.metal = e.isMetal();
+ this.state = e.getState();
+
+ pre();
+ }
+ public void pre() {
+ if (this.getNum() >= 92) {
+ this.setState(-1);
+ this.setArtificial(true);
+ }
+ }
+ /*
+ * Display on screen
+ */
+
+ public Color getStateColor() {
+ if (this.getState() == -1 ) {
+ return Color.GREEN;
+ } else if (this.getState() == 0) {
+ return Color.DARK_GRAY;
+ } else if (this.getState() == 1) {
+ return Color.CYAN;
+ }
+ return Color.ORANGE;
+
+ }
+ public Color getMetalColor() {
+ if (this.isMetal()) {
+ return Color.BLUE;
+ } else {
+ return Color.RED;
+ }
+ }
+ /*
+ * Algorithms
+ */
+ public String getCharge() {
+ if ((this.getGroup() < 13 && this.getGroup() > 2 ) || this.getGroup() == 18) {
+ return 0+"";
+ }
+ if (this.getGroup() < 3) {
+ return "+"+this.getGroup();
+ } else if (this.getGroup() == 13) {
+ return "+3";
+ } else if (this.getGroup() == 14) {
+ return "±4";
+ } else {
+ return ""+(-(18 - this.getGroup()));
+ }
+ }
+ public double getAbsCharge() {
+ if ((this.getGroup() < 13 && this.getGroup() > 2 ) || this.getGroup() == 18) {
+ return 0;
+ }
+ if (this.getGroup() < 3) {
+ return this.getGroup();
+ } else if (this.getGroup() == 13) {
+ return 3;
+ } else if (this.getGroup() == 14) {
+ return 4;
+ } else {
+ return (-(18 - this.getGroup()));
+ }
+ }
+ public int getS1() {
+ if (this.getElectrons() > 2) {
+ return 2;
+ } else {
+ return this.getElectrons();
+ }
+ }
+ public int getS2() {
+ if (this.getElectrons() > 10) {
+ return 8;
+ } else if (this.getElectrons() > 2){
+ return this.getElectrons()-2;
+ }
+ return 0;
+ }
+ public int getS3() {
+ if (this.getElectrons() > 28) {
+ return 18;
+ } else if (this.getElectrons() > 10) {
+ return this.getElectrons()-10;
+ }
+ return 0;
+ }
+ public int getS4() {
+ if (this.getElectrons() > 60) {
+ return 32;
+ } else if (this.getElectrons() > 28) {
+ return this.getElectrons()-28;
+ }
+ return 0;
+ }
+ public int getNeutrons() {
+ return this.massnum - this.getNum();
+ }
+ public boolean isTransition() {
+ if (this.getCharge().equals("0") && group != 18) {
+ return true;
+ }
+ return false;
+ }
+ public boolean isNoble() {
+ if (this.getGroup() == 18) return true;
+ return false;
+ }
+ public String getBalancedEquation(Element e1) {
+ if (isTransition() && e1.isTransition()) {
+ return "Double Transition";
+ }
+ if (isNoble() || e1.isNoble()) {
+ return "Too Noble";
+ }
+
+ if (e1.getAbsCharge() == getAbsCharge()) {
+ return "Two metals/Nonmetals";
+ }
+
+ if (isTransition() || e1.isTransition()) {
+ return 1 + e1.getSymbol() + " " + 1 + getSymbol();
+
+ }
+ //Proper Practice to put last first
+ if (getAbsCharge() > 0) {
+ return Math.abs(getAbsCharge()) + e1.getSymbol() + " " + Math.abs(e1.getAbsCharge()) + getSymbol();
+ }
+ //Normal SOP
+ return Math.abs(e1.getAbsCharge()) + getSymbol() + " " + Math.abs(getAbsCharge()) + e1.getSymbol();
+
+ }
+ public int getElectrons() {
+ return getNum();
+ }
+ /*
+ *
+ * Where Getters and Setters Start
+ *
+ */
+
+ /**
+ * @return the num
+ */
+ public int getNum() {
+ return num;
+ }
+ /**
+ * @param num the num to set
+ */
+ public void setNum(int num) {
+ this.num = num;
+ }
+ /**
+ * @return the symbol
+ */
+ public String getSymbol() {
+ return symbol;
+ }
+ /**
+ * @param symbol the symbol to set
+ */
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return the group
+ */
+ public int getGroup() {
+ return group;
+ }
+ /**
+ * @param group the group to set
+ */
+ public void setGroup(int group) {
+ this.group = group;
+ }
+ /**
+ * @return the groupname
+ */
+ public String getGroupname() {
+ return groupname;
+ }
+ /**
+ * @param groupname the groupname to set
+ */
+ public void setGroupname(String groupname) {
+ this.groupname = groupname;
+ }
+ /**
+ * @return the period
+ */
+ public int getPeriod() {
+ return period;
+ }
+ /**
+ * @param period the period to set
+ */
+ public void setPeriod(int period) {
+ this.period = period;
+ }
+ /**
+ * @return the periodname
+ */
+ public String getPeriodname() {
+ return periodname;
+ }
+ /**
+ * @param periodname the periodname to set
+ */
+ public void setPeriodname(String periodname) {
+ this.periodname = periodname;
+ }
+ /**
+ * @return the weight
+ */
+ public double getWeight() {
+ return weight;
+ }
+ /**
+ * @param weight the weight to set
+ */
+ public void setWeight(double weight) {
+ this.weight = weight;
+ }
+ /**
+ * @return the state
+ */
+ public int getState() {
+ return state;
+ }
+ /**
+ * @param state the state to set
+ */
+ public void setState(int state) {
+ this.state = state;
+ }
+ /**
+ * @return the radioactive
+ */
+ public boolean isRadioactive() {
+ return radioactive;
+ }
+ /**
+ * @param radioactive the radioactive to set
+ */
+ public void setRadioactive(boolean radioactive) {
+ this.radioactive = radioactive;
+ }
+ /**
+ * @return the artificial
+ */
+ public boolean isArtificial() {
+ return artificial;
+ }
+ /**
+ * @param artificial the artificial to set
+ */
+ public void setArtificial(boolean artificial) {
+ this.artificial = artificial;
+ }
+ /**
+ * @return the metal
+ */
+ public boolean isMetal() {
+ return metal;
+ }
+ /**
+ * @param metal the metal to set
+ */
+ public void setMetal(boolean metal) {
+ this.metal = metal;
+ }
+ /**
+ * @return the massnum
+ */
+ public int getMassnum() {
+ return massnum;
+ }
+ /**
+ * @param massnum the massnum to set
+ */
+ public void setMassnum(int massnum) {
+ this.massnum = massnum;
+ }
+ /**
+ * @return the amount
+ */
+ public int getAmount() {
+ return amount;
+ }
+ /**
+ * @param amount the amount to set
+ */
+ public void setAmount(int amount) {
+ this.amount = amount;
+ }
+ /**
+ * @return the abscount
+ */
+ public int getAbscount() {
+ return abscount;
+ }
+ /**
+ * @param abscount the abscount to set
+ */
+ public void setAbscount(int abscount) {
+ this.abscount = abscount;
+ }
+ /**
+ * ToString
+ */
+ @Override
+ public String toString() {
+ if (amount == 0) {
+ return "";
+ }
+ return this.getSymbol()+this.getAmount();
+ }
+ /**
+ *
+ * @param n
+ * @param sym
+ * @param name
+ * @param weight
+ * @param group
+ * @param period
+ * @param metal
+ * @param state
+ * @param massnum
+ */
+ public String toData() {
+ String returned = "";
+
+ returned += ("" + num);
+ returned += (":" + symbol);
+ returned += (":" + name);
+ returned += (":" + weight);
+ returned += (":" + group);
+ returned += (":" + period);
+ returned += (":" + metal);
+ returned += (":" + state);
+ returned += (":" + massnum);
+
+ return returned;
+ }
+ /**
+ * Returns absolute data including all functions -amount.
+ */
+ public String toAbsoluteData() {
+ List lbs = Utils.eString(this);
+
+ String x = "";
+ for (JTextField j : lbs) {
+ x += j.getText() + "\n";
+ }
+ return x;
+ }
+ /**
+ * Compares absolute data. Does not include amounts.
+ */
+ public boolean equals(Element e) {
+ return this.toAbsoluteData().equals(e.toAbsoluteData());
+ }
+}
diff --git a/src/com/qxbytes/chemlab/ElementDisplay.java b/src/com/qxbytes/chemlab/ElementDisplay.java
new file mode 100644
index 0000000..b9c3900
--- /dev/null
+++ b/src/com/qxbytes/chemlab/ElementDisplay.java
@@ -0,0 +1,94 @@
+package com.qxbytes.chemlab;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class ElementDisplay extends JButton {
+ private Element e;
+ private boolean hover = false;
+ private List selected = new ArrayList();
+ public ElementDisplay(Element e, List selected) {
+ super();
+ this.e = e;
+ this.selected = selected;
+ this.setToolTipText(Utils.getElementTooltip(e));
+ this.setBorder(BorderFactory.createLineBorder(e.getMetalColor()));
+ this.addMouseListener(new ElementItemListener(this));
+ this.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ selected.add(e);
+
+ SelectionPane.showDetailedPane(e);
+
+ //double atom = 0;
+ for (int i = 0 ; i < selected.size() ; i++) {
+ //atom += selected.get(i).getWeight() ;
+ }
+ //System.out.println("Total: " + atom);
+ }
+
+ });
+ }
+ public ElementDisplay(Element e) {
+ super();
+ this.e = e;
+ this.setBorder(BorderFactory.createLineBorder(e.getMetalColor()));
+ this.addMouseListener(new ElementItemListener(this));
+ this.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ SelectionPane.showDetailedPane(e);
+ }
+
+ });
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ public void paintComponent(Graphics g) {
+ g.setColor(Color.GRAY);
+ g.fillRect(0,0, this.getWidth(), this.getHeight());
+
+ g.setColor(e.getStateColor());
+
+ g.setFont(new Font("Sans Serif",Font.PLAIN,12));
+ g.drawString(e.getNum()+"",0,12);
+ g.drawString(e.getCharge()+"", 30, 18);
+ g.setFont(new Font("Sans Serif",Font.PLAIN,32));
+ g.drawString(e.getSymbol(), 2, 40);
+ g.setFont(new Font("Sans Serif",Font.PLAIN,10));
+ g.drawString(e.getName(), 0, 60);
+ g.setFont(new Font("Sans Serif",Font.PLAIN,12));
+ g.drawString(e.getMassnum()+"", 0, 80);
+ g.drawString(e.getWeight()+"", 0, 92);
+
+ if (hover) {
+ g.setColor(new Color(100,200,200,100));
+ g.fillRect(0, 0, this.getWidth(), this.getHeight());
+ g.setColor(Color.GREEN);
+ g.drawString("+Add", this.getWidth()/2-17, this.getHeight()/2+5);
+ }
+ }
+ public List getSelected() {
+ return selected;
+ }
+ public void setHover(boolean h) {
+ hover = h;
+ }
+
+}
diff --git a/src/com/qxbytes/chemlab/ElementItemListener.java b/src/com/qxbytes/chemlab/ElementItemListener.java
new file mode 100644
index 0000000..b533ecc
--- /dev/null
+++ b/src/com/qxbytes/chemlab/ElementItemListener.java
@@ -0,0 +1,45 @@
+package com.qxbytes.chemlab;
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class ElementItemListener implements MouseListener {
+ ElementDisplay d;
+ public ElementItemListener(ElementDisplay d) {
+ this.d = d;
+ }
+ @Override
+ public void mouseClicked(MouseEvent arg0) {
+
+
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent arg0) {
+ d.setHover(true);
+ d.repaint();
+ }
+
+ @Override
+ public void mouseExited(MouseEvent arg0) {
+ d.setHover(false);
+ d.repaint();
+ }
+
+ @Override
+ public void mousePressed(MouseEvent arg0) {
+
+
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent arg0) {
+
+
+ }
+
+}
diff --git a/src/com/qxbytes/chemlab/ExcelHandler.java b/src/com/qxbytes/chemlab/ExcelHandler.java
new file mode 100644
index 0000000..7d65249
--- /dev/null
+++ b/src/com/qxbytes/chemlab/ExcelHandler.java
@@ -0,0 +1,82 @@
+package com.qxbytes.chemlab;
+
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import jxl.Cell;
+import jxl.Sheet;
+import jxl.Workbook;
+import jxl.read.biff.BiffException;
+import jxl.write.Label;
+import jxl.write.Number;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+import jxl.write.WriteException;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class ExcelHandler {
+ public static void testHandler() throws BiffException, IOException, WriteException
+ {
+ WritableWorkbook wworkbook;
+ wworkbook = Workbook.createWorkbook(new File("output.xls"));
+ WritableSheet wsheet = wworkbook.createSheet("First Sheet", 0);
+ Label label = new Label(0, 2, "A label record");
+ wsheet.addCell(label);
+ Number number = new Number(3, 4, 3.1459);
+ wsheet.addCell(number);
+ wworkbook.write();
+ wworkbook.close();
+
+ Workbook workbook = Workbook.getWorkbook(new File("output.xls"));
+ Sheet sheet = workbook.getSheet(0);
+ Cell cell1 = sheet.getCell(0, 2);
+ System.out.println(cell1.getContents());
+ Cell cell2 = sheet.getCell(3, 4);
+ System.out.println(cell2.getContents());
+ workbook.close();
+ }
+ /**
+ * Assume Elements is already sorted and compressed
+ * @param elements
+ * @throws BiffException
+ * @throws IOException
+ * @throws WriteException
+ */
+ public static void exportToExcel(List elements) throws BiffException, IOException, WriteException {
+ WritableWorkbook wworkbook;
+ wworkbook = Workbook.createWorkbook(new File("ChemEX" + System.currentTimeMillis() + ".xls"));
+ WritableSheet wsheet = wworkbook.createSheet("export", 0);
+ wsheet.addCell(new Label(0,0,"Atom Num"));
+ wsheet.addCell(new Label(1,0,"Symbol"));
+ wsheet.addCell(new Label(2,0,"Name"));
+ wsheet.addCell(new Label(3,0,"Charge"));
+ wsheet.addCell(new Label(4,0,"Atom Weight"));
+ wsheet.addCell(new Label(5,0,"Mass Num"));
+ wsheet.addCell(new Label(6,0,"P/N/E"));
+ wsheet.addCell(new Label(7,0,"State"));
+ wsheet.addCell(new Label(8,0,"Metal?"));
+ wsheet.addCell(new Label(9,0,"Artificial?"));
+ wsheet.addCell(new Label(10,0,"Radioactive?"));
+ wsheet.addCell(new Label(11,0,"Row"));
+ wsheet.addCell(new Label(12,0,"Column"));
+ wsheet.addCell(new Label(13,0,"Elec. in Shell#"));
+ wsheet.addCell(new Label(14,0,"# of atoms"));
+
+ for (int row = 1 ; row < elements.size()+1 ; row++) {
+ List temp = Utils.esString(elements.get(row-1));
+ temp.add(elements.get(row-1).getAbscount()+"");
+ for (int column = 0 ; column < 15 ; column++) {
+ wsheet.addCell(new Label(column,row,temp.get(column)));
+ }
+ }
+
+ wworkbook.write();
+ wworkbook.close();
+ }
+}
diff --git a/src/com/qxbytes/chemlab/IO.java b/src/com/qxbytes/chemlab/IO.java
new file mode 100644
index 0000000..5a137ef
--- /dev/null
+++ b/src/com/qxbytes/chemlab/IO.java
@@ -0,0 +1,12 @@
+package com.qxbytes.chemlab;
+
+import java.util.List;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public interface IO {
+ void Export(List e);
+ List Import();
+}
diff --git a/src/com/qxbytes/chemlab/InformationPane.java b/src/com/qxbytes/chemlab/InformationPane.java
new file mode 100644
index 0000000..f4c8f65
--- /dev/null
+++ b/src/com/qxbytes/chemlab/InformationPane.java
@@ -0,0 +1,26 @@
+package com.qxbytes.chemlab;
+
+import java.awt.GridLayout;
+import java.util.List;
+
+import javax.swing.JFrame;
+import javax.swing.JTextField;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class InformationPane {
+ public InformationPane(List data, String name) {
+ JFrame frame = new JFrame(name);
+ frame.setLayout(new GridLayout(data.size(),1));
+ for (int i = 0 ; i < data.size() ; i++) {
+ JTextField x = new JTextField(data.get(i));
+
+ x.setEditable(false);
+ frame.add(x);
+ }
+
+ frame.setVisible(true);
+ }
+}
diff --git a/src/com/qxbytes/chemlab/Main.java b/src/com/qxbytes/chemlab/Main.java
new file mode 100644
index 0000000..5a25c5e
--- /dev/null
+++ b/src/com/qxbytes/chemlab/Main.java
@@ -0,0 +1,14 @@
+package com.qxbytes.chemlab;
+
+import javax.swing.UIManager;
+
+public class Main {
+ public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {
+
+ }
+ new PeriodicTable();
+ }
+}
diff --git a/src/com/qxbytes/chemlab/PeriodicConstants.java b/src/com/qxbytes/chemlab/PeriodicConstants.java
new file mode 100644
index 0000000..2b8b80a
--- /dev/null
+++ b/src/com/qxbytes/chemlab/PeriodicConstants.java
@@ -0,0 +1,119 @@
+package com.qxbytes.chemlab;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.qxbytes.plugins.SElement;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class PeriodicConstants {
+ static List e = new ArrayList();
+ public static void loadElements() {
+ e.removeAll(e);
+
+ e.add(new Element(0,"?","Unstable",0.00,0,0,false,0,0));
+
+ e.add(new Element(1,"H","Hydrogen",1.0078,17,1,false,2,1));
+ e.add(new Element(2,"He","Helium",4.0026,18,1,false,2,4));
+
+ e.add(new Element(3,"Li","Lithium",6.938,1,2,7));
+ e.add(new Element(4,"Be","Beryllium",9.0122,2,2,9));
+ e.add(new Element(5,"B","Boron",10.806,13,2,11));
+ e.add(new Element(6,"C","Carbon",12.009,14,2,false,0,12));
+ e.add(new Element(7,"N","Nitrogen",14.006,15,2,false,2,14));
+ e.add(new Element(8,"O","Oxygen",15.999,16,2,false,2,16));
+ e.add(new Element(9,"F","Fluorine",18.998,17,2,false,2,19));
+ e.add(new Element(10,"Ne","Neon",20.180,18,2,false,2,20));
+
+ e.add(new Element(11,"Na","Sodium",22.99,1,3,23));
+ e.add(new Element(12,"Mg","Magnesium",24.305,2,3,24));
+ e.add(new Element(13,"Al","Aluminum",26.982,13,3,27));
+ e.add(new Element(14,"Si","Silicon",28.084,14,3,28));
+ e.add(new Element(15,"P","Phosphorus",30.974,15,3,false,0,31));
+ e.add(new Element(16,"S","Sulfur",32.059,16,3,false,0,32));
+ e.add(new Element(17,"Cl","Chlorine",35.446,17,3,false,2,35));
+ e.add(new Element(18,"Ar","Argon",39.948,18,3,false,2,40));
+
+ e.add(new Element(19,"K","Potassium",39.098,1,4,39));
+ e.add(new Element(20,"Ca","Calcium",40.078,2,4,40));
+ e.add(new Element(21,"Sc","Scandium",44.956,3,4,45));
+ e.add(new Element(22,"Ti","Titanium",47.867,4,4,48));
+ e.add(new Element(23,"V","Vanadium",50.942,5,4,51));
+ e.add(new Element(24,"Cr","Chromium",51.996,6,4,52));
+ e.add(new Element(25,"Mn","Maganese",54.938,7,4,55));
+ e.add(new Element(26,"Fe","Iron",55.845,8,4,56));
+ e.add(new Element(27,"Co","Cobalt",58.933,9,4,59));
+ e.add(new Element(28,"Ni","Nickel",58.693,10,4,59));
+ e.add(new Element(29,"Cu","Copper",63.546,11,4,64));
+ e.add(new Element(30,"Zn","Zinc",65.38,12,4,65));
+ e.add(new Element(31,"Ga","Gallium",69.723,13,4,70));
+ e.add(new Element(32,"Ge","Germanium",72.63,14,4,73));
+ e.add(new Element(33,"As","Arsenic",74.922,15,4,75));
+ e.add(new Element(34,"Se","Selenium",78.96,16,4,false,0,79));
+ e.add(new Element(35,"Br","Bromine",79.904,17,4,false,1,80));
+ e.add(new Element(36,"Kr","Krypton",83.798,18,4,false,2,84));
+
+ e.add(new Element(37,"Rb","Rubidium",85.468,1,5,85));
+ e.add(new Element(38,"Sr","Strontium",87.62,2,5,88));
+ e.add(new Element(39,"Y","Yttrium",88.906,3,5,89));
+ e.add(new Element(40,"Zr","Zirconium",91.224,4,5,91));
+ e.add(new Element(41,"Nb","Niobium",92.906,5,5,93));
+ e.add(new Element(42,"Mo","Molybdenum",95.96,6,5,96));
+ e.add(new Element(43,"Tc","Technetium",98.9062,7,5,98));
+ e.add(new Element(44,"Ru","Ruthenium",101.07,8,5,101));
+ e.add(new Element(45,"Rh","Rhodium",102.91,9,5,103));
+ e.add(new Element(46,"Pd","Palladium",106.42,10,5,106));
+ e.add(new Element(47,"Ag","Silver",101.87,11,5,108));
+ e.add(new Element(48,"Cd","Cadmium",112.41,12,5,112));
+ e.add(new Element(49,"In","Indium",113.82,13,5,115));
+ e.add(new Element(50,"Sn","Tin",118.71,14,5,119));
+ e.add(new Element(51,"Sb","Antimony",121.76,15,5,122));
+ e.add(new Element(52,"Te","Tellurium",127.6,16,5,128));
+ e.add(new Element(53,"I","Iodine",126.90,17,5,127));
+ e.add(new Element(54,"Xe","Xenon",131.29,18,5,false,2,131));
+ }
+ public static List getElement() {
+ return e;
+ }
+ /**
+ * Not implemented
+ * @param e
+ * @return
+ */
+ public static String getElectronConfig(Element e) {
+
+
+ return "";
+ }
+ public static Element getElement(String x) {
+ for (int i = 0 ; i < e.size() ; i++) {
+ if (getElement().get(i).getSymbol().equals(x) || getElement().get(i).getName().equalsIgnoreCase(x)) {
+ return getElement().get(i);
+ }
+ }
+ return null;
+ }
+ public static Element getElementFromIndex(int num) {
+ if (num > getElement().size()) return getElement().get(0);
+ return getElement().get(num+1);
+ }
+ /**
+ * Obtain a sandbox element. It may, or may not, exist.
+ * @param pro
+ * @param neu
+ * @param elec
+ * @return Sandbox Element
+ */
+ public static SElement getElement(int pro, int neu, int elec) {
+ PeriodicConstants.loadElements();
+
+ if (pro > 0 && pro < getElement().size()) {
+ return new SElement(PeriodicConstants.getElement().get(pro+1),neu,elec);
+ } else {
+ return new SElement(pro,neu,elec);
+ }
+ }
+}
diff --git a/src/com/qxbytes/chemlab/PeriodicTable.java b/src/com/qxbytes/chemlab/PeriodicTable.java
new file mode 100644
index 0000000..619c874
--- /dev/null
+++ b/src/com/qxbytes/chemlab/PeriodicTable.java
@@ -0,0 +1,75 @@
+package com.qxbytes.chemlab;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+import javax.swing.BorderFactory;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import com.qxbytes.plugins.PLUGINMANIFEST;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class PeriodicTable {
+ private List buttons = new ArrayList();
+ private List ELEMENTS = new ArrayList();
+ private List selected = new ArrayList();
+ public PeriodicTable() {
+ PeriodicConstants.loadElements();
+ ELEMENTS = PeriodicConstants.getElement();
+
+ JFrame frame = new JFrame("QChem- Periodic Table");
+ frame.setLayout(new BorderLayout());
+ frame.setSize(DC.PW,DC.PH);
+ frame.setResizable(false);
+ frame.setLocationRelativeTo(null);
+ frame.setLocation(0, 0);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ try {
+ frame.setIconImage(ImageIO.read(PeriodicTable.class.getResourceAsStream("icon.png")));
+ } catch (Exception e) {
+
+ }
+
+ JPanel table = new JPanel(new GridLayout(5,18));
+
+ int counter = 1;
+ for (int y = 0 ; y < 5 ; y++) {
+ for (int x = 0 ; x < 18 ; x++) {
+ if (counter < ELEMENTS.size()
+ && ELEMENTS.get(counter).getPeriod()-1 == y && ELEMENTS.get(counter).getGroup()-1 == x) {
+ ElementDisplay button = new ElementDisplay(ELEMENTS.get(counter),selected);
+ buttons.add(button);
+ table.add(button);
+
+ counter++;
+ } else {
+ /*
+ * Filler
+ */
+ JPanel temp = new JPanel();
+ temp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ table.add(temp);
+ }
+ }
+ }
+
+ frame.add(table,BorderLayout.CENTER);
+
+ AnalyzePane analysis = new AnalyzePane();
+ frame.add(analysis,BorderLayout.NORTH);
+
+ PLUGINMANIFEST pm = new PLUGINMANIFEST();
+ frame.add(pm,BorderLayout.SOUTH);
+
+ frame.setVisible(true);
+ }
+}
diff --git a/src/com/qxbytes/chemlab/PicturePane.java b/src/com/qxbytes/chemlab/PicturePane.java
new file mode 100644
index 0000000..b37eea0
--- /dev/null
+++ b/src/com/qxbytes/chemlab/PicturePane.java
@@ -0,0 +1,118 @@
+package com.qxbytes.chemlab;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+
+import javax.swing.JPanel;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class PicturePane extends JPanel {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ Element e;
+ public PicturePane(Element e) {
+ this.e = e;
+ }
+ public void paintComponent(Graphics g) {
+
+ g.setColor(new Color(175,250,250));
+ g.fillRect(0, 0, this.getWidth(), this.getHeight());
+ g.setColor(Color.BLACK);
+
+ g.drawOval(0, 0, this.getWidth(), this.getWidth());//2
+
+ g.drawOval(10, 10, this.getWidth()-20, this.getWidth()-20);//8
+
+ g.drawOval(20, 20, this.getWidth()-40, this.getWidth()-40);//18
+
+ g.drawOval(30, 30, this.getWidth()-60, this.getWidth()-60);//32
+
+ //radii
+ int s4 = (this.getWidth())/2;
+ int s3 = (this.getWidth()-20)/2;
+ int s2 = (this.getWidth()-40)/2;
+ int s1 = (this.getWidth()-60)/2;
+
+ int m = this.getWidth()/2;
+
+ double co = Math.PI / 180;
+
+ double a1 = 360 / 2 * co;
+ double a2 = 360 / 8 * co;
+ double a3 = 360 / 18 * co;
+ double a4 = 360 / 32 * co;
+
+ g.setColor(Color.RED);
+
+ Color v = new Color(180,0,210);
+
+ for (int i = 0 ; i < e.getS1() ; i++) {
+ if (e.getS1() < 2) {
+ g.setColor(v);
+ }
+ float x = (float) (s1*Math.cos(a1*i) + m)-3;
+ float y = (float) (s1*Math.sin(a1*i) + m)-3;
+ g.fillOval((int)x, (int)y, 5, 5);
+ }
+
+ for (int i = 0 ; i < e.getS2() ; i++) {
+ if (e.getS2() < 8) {
+ g.setColor(v);
+ }
+ float x = (float) (s2*Math.cos(a2*i) + m)-3;
+ float y = (float) (s2*Math.sin(a2*i) + m)-3;
+ g.fillOval((int)x, (int)y, 5, 5);
+ }
+
+ for (int i = 0 ; i < e.getS3() ; i++) {
+ if (e.getS3() < 18) {
+ g.setColor(v);
+ }
+ float x = (float) (s3*Math.cos(a3*i) + m)-3;
+ float y = (float) (s3*Math.sin(a3*i) + m)-3;
+ g.fillOval((int)x, (int)y, 5, 5);
+ }
+
+ for (int i = 0 ; i < e.getS4() ; i++) {
+ if (e.getS4() < 32) {
+ g.setColor(v);
+ }
+ float x = (float) (s4*Math.cos(a4*i) + m)-3;
+ float y = (float) (s4*Math.sin(a4*i) + m)-3;
+ g.fillOval((int)x, (int)y, 5, 5);
+ }
+
+ int mn = m-e.getNeutrons()/4;
+ int nr = e.getNeutrons()/2;
+
+ int mp = m-e.getNum()/4;
+ int pr = e.getNum()/2;
+ g.setColor(Color.RED);
+
+ g.drawOval(mn,mn,nr,nr);
+
+ g.setColor(Color.ORANGE);
+
+ g.drawOval(mp,mp,pr,pr);
+
+ g.setColor(e.getStateColor());
+ g.setFont(new Font("Sans Serif",Font.PLAIN,32));
+ g.drawString(e.getSymbol(), 20, this.getWidth()+32);
+
+ g.setFont(new Font("Sans Serif",Font.PLAIN,12));
+ g.drawString(e.getCharge(), 50, this.getWidth()+20);
+
+ g.setColor(Color.BLACK);
+ g.setFont(new Font("Sans Serif",Font.PLAIN,16));
+ g.drawString(e.getNum() + "P/" + e.getNeutrons() + "N", m-32, m);
+
+ g.setColor(e.getStateColor());
+ g.drawRect(0, 0, this.getWidth()-1, this.getHeight()-1);
+ }
+}
diff --git a/src/com/qxbytes/chemlab/PosCon.java b/src/com/qxbytes/chemlab/PosCon.java
new file mode 100644
index 0000000..951171c
--- /dev/null
+++ b/src/com/qxbytes/chemlab/PosCon.java
@@ -0,0 +1,14 @@
+package com.qxbytes.chemlab;
+/**
+ * Position Control
+ * @author QxBytes
+ *
+ */
+public interface PosCon {
+ int MFSX = 780;
+ int MFSY = 550;
+
+ int DFXS = 250;
+ int DFYS = 700;
+
+}
diff --git a/src/com/qxbytes/chemlab/SelectionPane.java b/src/com/qxbytes/chemlab/SelectionPane.java
new file mode 100644
index 0000000..a699cb6
--- /dev/null
+++ b/src/com/qxbytes/chemlab/SelectionPane.java
@@ -0,0 +1,272 @@
+package com.qxbytes.chemlab;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class SelectionPane {
+ private static JFrame frame;
+
+ private static JPanel root;
+ private static JScrollPane sroot;
+
+ private static JMenuBar jmb;
+
+ private static JMenu menu;
+ private static JMenuItem in;
+ private static JMenuItem out;
+ private static JMenuItem export;
+
+ private static JMenu select;
+ private static JMenuItem all;
+
+ private static JTextField parser;
+
+ private static JMenuItem removeAll;
+
+ private static List inpane = new ArrayList();
+ private static List di = new ArrayList();
+ public static void showDetailedPane(Element e) {
+ if (frame == null || frame.isVisible() == false) {
+ System.out.println("Initialized");
+ frame = new JFrame();
+ frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ frame.setLayout(new BorderLayout());
+ frame.setSize(DC.SW,DC.SH);
+ frame.setLocationRelativeTo(null);
+ frame.setLocation(DC.SX,DC.SY);
+ frame.setResizable(true);
+
+ inpane.clear();
+ di.clear();
+
+ inpane.removeAll(inpane);
+ di.removeAll(di);
+
+ inpane = new ArrayList();
+ di = new ArrayList();
+
+ jmb = new JMenuBar();
+ menu = new JMenu("File");
+ in = new JMenuItem("Open");
+ out = new JMenuItem("Save");
+ export = new JMenuItem("Export to Spreadsheet");
+ select = new JMenu("Select");
+ all = new JMenuItem("All Elements");
+
+ parser = new JTextField();
+
+ removeAll = new JMenuItem("Delete Selection");
+ removeAll.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ int times = di.size();
+ for (int i = 0 ; i < times ; i++) {
+ di.get(0).delete();
+ }
+ frame.dispose();
+ }
+
+ });
+
+ JFileChooser jfc = new JFileChooser();
+
+ in.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+
+ int x = jfc.showOpenDialog(frame);
+ if (x == JFileChooser.APPROVE_OPTION) {
+ List from = Utils.fromSaveData(jfc.getSelectedFile());
+ removeAll.doClick();
+ for (int i = 0 ; i < from.size() ; i++) {
+ SelectionPane.showDetailedPane(from.get(i));
+ }
+ }
+ }
+
+ });
+ out.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int x = jfc.showSaveDialog(frame);
+ if (x == JFileChooser.APPROVE_OPTION) {
+ Utils.toSaveData(inpane, jfc.getSelectedFile());
+ System.out.println("Successfully Exported");
+ }
+ }
+
+ });
+ export.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ try {
+ ExcelHandler.exportToExcel(inpane);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ });
+ all.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ for (int i = 1 ; i < PeriodicConstants.getElement().size() ; i++) {
+ SelectionPane.showDetailedPane(new Element(PeriodicConstants.getElement().get(i)));
+ }
+ }
+
+ });
+ parser.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ try {
+ int x = Integer.parseInt(parser.getText().substring(0, 1));
+ String symbol = parser.getText().substring(1);
+ Element add = PeriodicConstants.getElement(symbol);
+ if (add == null) {
+ for (int i = 0 ; i < inpane.size() ; i++) {
+ if (inpane.get(i).getSymbol().equals(symbol)) {
+ add = inpane.get(i);
+ }
+ }
+ }
+ for (int i = 0 ; i < x ; i++) {
+ SelectionPane.showDetailedPane(add);
+ }
+ parser.setText("");
+ } catch (Exception e) {
+ parser.setText("Syntax Error(Max 9)");
+ }
+ }
+
+ });
+ if (DC.EXTDMODE) {
+ root = new JPanel(new GridLayout(0,1));
+ } else {
+ root = new JPanel(new GridLayout(1,0));
+ }
+
+ sroot = new JScrollPane();
+
+ frame.add(sroot,BorderLayout.CENTER);
+
+ //frame.add(root, BorderLayout.CENTER);
+
+ frame.add(parser, BorderLayout.SOUTH);
+
+ frame.add(removeAll, BorderLayout.NORTH);
+
+ menu.add(out);
+ menu.add(in);
+ menu.add(export);
+
+ select.add(all);
+ select.add(removeAll);
+
+ jmb.add(menu);
+ jmb.add(select);
+
+ frame.setJMenuBar(jmb);
+
+ try {
+ frame.setIconImage(ImageIO.read(PeriodicTable.class.getResourceAsStream("icon.png")));
+ } catch (Exception qq) {
+
+ }
+
+ frame.repaint();
+
+ root.setBackground(Color.WHITE);
+
+ sroot.setViewportView(root);
+ }
+
+
+
+ if (!SortElement.addElement(inpane, e)) {
+ //did not find duplicate
+ di.add(new DetailedItem(root,e,inpane,di));
+ root.add(di.get(di.size()-1));
+ frame.setVisible(true);
+ if (!DC.EXTDMODE) {
+ sroot.getHorizontalScrollBar().setValue(di.size()*200);
+ } else {
+ sroot.getVerticalScrollBar().setValue(di.size()*200);
+ }
+ root.revalidate();
+ root.repaint();
+ } else {
+ //found duplicate=OK
+ for (int i = 0 ; i < di.size() ; i++) {
+ //loop=OK
+ if (di.get(i).toString().equals(new DetailedItem(root,e,inpane,di).toString())) {
+ di.get(i).setCount(di.get(i).getCount()+1);
+ if (!DC.EXTDMODE) {
+ sroot.getHorizontalScrollBar().setValue(200*i);
+ } else {
+ sroot.getVerticalScrollBar().setValue(200*i);
+ }
+ }
+ }
+ root.revalidate();
+ root.repaint();
+ }
+
+ frame.setTitle("Selected: " + SortElement.writeFormula(inpane));
+ frame.setVisible(true);
+ }
+ public static void replaceContents(List e ) {
+ removeAll.doClick();
+ List x = Utils.compress(e);
+ for (int i = 0 ; i < x.size() ; i++) {
+ SelectionPane.showDetailedPane(x.get(i));
+ }
+ }
+
+ /**
+ * @return the inpane
+ */
+ public static List getInpane() {
+ return inpane;
+ }
+
+ /**
+ * @param inpane the inpane to set
+ */
+ public static void setInpane(List inpane) {
+ SelectionPane.inpane = inpane;
+ }
+ /**
+ * @return the frame
+ */
+ public static JFrame getFrame() {
+ return frame;
+ }
+
+
+}
diff --git a/src/com/qxbytes/chemlab/SortElement.java b/src/com/qxbytes/chemlab/SortElement.java
new file mode 100644
index 0000000..d545a74
--- /dev/null
+++ b/src/com/qxbytes/chemlab/SortElement.java
@@ -0,0 +1,96 @@
+package com.qxbytes.chemlab;
+
+import java.util.ArrayList;
+import java.util.List;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class SortElement {
+ @Deprecated
+ public static List sort(List elements) {
+ PeriodicConstants.loadElements();
+ List allelements = PeriodicConstants.getElement();
+ List data = new ArrayList(elements);
+ /*
+ * Every slot of data/One piece of data
+ */
+ for (int x = 0 ; x < data.size() ; x++) {
+ /*
+ * To every element
+ */
+ for (int i = 0 ; i < allelements.size() ; i++) {
+ if (data.get(x).toData().equals(allelements.get(i).toData())) {
+ allelements.get(i).setAmount(allelements.get(i).getAmount()+1);
+ //System.out.println(allelements.get(i).getAmount());
+ break;
+ }
+ }
+ }
+ return allelements;
+ }
+ /**
+ * Adds an element; assumes compressed; if duplicate found, will increase count by one.
+ * @param elements
+ * @param e
+ * @return If succeeded in finding a duplicate.
+ */
+ public static boolean addElement(List elements, Element e) {
+ //Utils.compress(elements);
+ for (int i = 0 ; i < elements.size() ; i++) {
+ if (elements.get(i).equals(e)) {
+ elements.get(i).setAbscount(elements.get(i).getAbscount()+1);
+ return true;
+ }
+ }
+ elements.add(e);
+ return false;
+ }
+ private static List altSort(List elements) {
+ PeriodicConstants.loadElements();
+ List allelements = new ArrayList();
+ List data = new ArrayList(elements);
+ for (int i = 0 ; i < data.size() ; i++) {
+ data.get(i).setAmount(0);
+ }
+
+ /*
+ *
+ */
+ allelements.add(data.get(0));
+ /*
+ * Every slot of data/One piece of data
+ */
+ for (int x = 0 ; x < data.size() ; x++) {
+ /*
+ * To every element
+ */
+ for (int i = 0 ; i < allelements.size() ; i++) {
+ if (data.get(x).toData().equals(allelements.get(i).toData())) {
+ allelements.get(i).setAmount(allelements.get(i).getAmount()+1);
+ //System.out.println(allelements.get(i).getAmount());
+ break;
+ }
+ if (i == allelements.size()-1) {
+ allelements.add(data.get(x));
+ }
+ }
+ }
+ return allelements;
+ }
+ public static String writeFormula(List elements) {
+ List x = altSort(Utils.decompress(elements));
+
+ String display = "";
+ for (int i = 0 ; i < x.size() ; i++ ) {
+ display += x.get(i).toString();
+ }
+ return display;
+ }
+ public static void swap(List e,int in1, int in2) {
+ Element temp = e.get(in1);
+ e.set(in1, e.get(in2));
+ e.set(in2, temp);
+ }
+}
diff --git a/src/com/qxbytes/chemlab/SortPane.java b/src/com/qxbytes/chemlab/SortPane.java
new file mode 100644
index 0000000..0d5d8a5
--- /dev/null
+++ b/src/com/qxbytes/chemlab/SortPane.java
@@ -0,0 +1,89 @@
+package com.qxbytes.chemlab;
+
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class SortPane {
+ private List e = new ArrayList();
+ private List selected = new ArrayList();
+ private JMenuItem toSelection = new JMenuItem("Export to Selection");
+ private JMenuItem export = new JMenuItem("Export to Spreadsheet");
+ private JMenu jm = new JMenu("Options");
+ private JMenuBar jmb = new JMenuBar();
+ private List param;
+ public SortPane(List e, String title) {
+ e = Utils.decompress(e);
+ param = e;
+
+ JFrame f = new JFrame(title);
+ f.setSize(700, 300);
+ f.setLayout(new GridLayout(1,1));
+ f.setLocation(0, 0);
+
+ JPanel panel = new JPanel(new GridLayout(1,e.size()));
+ panel.setPreferredSize(new Dimension(100*e.size(),300));
+ for (int i = 0 ; i < e.size() ; i++) {
+ ElementDisplay ed = new ElementDisplay(e.get(i),selected);
+ ed.setPreferredSize(new Dimension(100,300));
+ this.e.add(ed);
+ panel.add(new ElementDisplay(e.get(i),selected));
+ }
+
+ JScrollPane jsp = new JScrollPane();
+ jsp.setViewportView(panel);
+
+ f.add(jsp);
+
+ toSelection.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ SelectionPane.replaceContents(param);
+ }
+
+ });
+ export.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ try {
+ ExcelHandler.exportToExcel(param);
+ } catch (Exception x) {
+
+ }
+ }
+
+ });
+
+ jm.add(toSelection);
+ jm.add(export);
+
+ jmb.add(jm);
+
+ f.setJMenuBar(jmb);
+
+ try {
+ f.setIconImage(ImageIO.read(PeriodicTable.class.getResourceAsStream("icon.png")));
+ } catch (Exception qq) {
+
+ }
+
+ f.setVisible(true);
+ }
+}
diff --git a/src/com/qxbytes/chemlab/TestMain.java b/src/com/qxbytes/chemlab/TestMain.java
new file mode 100644
index 0000000..2177187
--- /dev/null
+++ b/src/com/qxbytes/chemlab/TestMain.java
@@ -0,0 +1,11 @@
+package com.qxbytes.chemlab;
+
+public class TestMain {
+ public static void main (String[] args) {
+ try {
+ ExcelHandler.testHandler();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/com/qxbytes/chemlab/Utils.java b/src/com/qxbytes/chemlab/Utils.java
new file mode 100644
index 0000000..40106bb
--- /dev/null
+++ b/src/com/qxbytes/chemlab/Utils.java
@@ -0,0 +1,276 @@
+package com.qxbytes.chemlab;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JTextField;
+
+import com.qxbytes.plugins.SElement;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Utils {
+ public static List eString(Element e) {
+ List lbs = new ArrayList();
+
+ lbs.add(new JTextField("Atom Num: " + e.getNum()+""));
+ lbs.add(new JTextField("Symbol: " + e.getSymbol()));
+ lbs.add(new JTextField("Name: " + e.getName()));
+ lbs.add(new JTextField("Charge: " + e.getCharge()));
+ lbs.add(new JTextField("Atom Wght: "+e.getWeight()+""));
+ lbs.add(new JTextField("Mass Num: " + e.getMassnum()+""));
+
+ lbs.add(new JTextField("P/N/E :" + e.getNum() + ":"+(e.getMassnum()-e.getNum()) + ":"+e.getNum()));
+
+ lbs.add(new JTextField("State: " + e.getState()+""));
+
+ lbs.add(new JTextField("Metal: "+e.isMetal()+""));
+ lbs.add(new JTextField("Art: " +e.isArtificial()+""));
+ lbs.add(new JTextField("Rad: " +e.isRadioactive()+""));
+
+ lbs.add(new JTextField("Row: "+e.getPeriod()+""));
+ lbs.add(new JTextField("Column: "+e.getGroup()+""));
+
+ lbs.add(new JTextField(":E/1:" + e.getS1()+"/2:" + e.getS2()+"/3:" + e.getS3()+"/4:" + e.getS4()));
+
+ return lbs;
+ }
+ public static List esString(Element e) {
+ List x = new ArrayList();
+ List xx = eString(e);
+ for (int i = 0 ; i < xx.size() ; i++) {
+ x.add(xx.get(i).getText().substring(xx.get(i).getText().indexOf(":")+1));
+ }
+ return x;
+ }
+ /**
+ *
+ * @param e
+ * @return Decompressed List (Does not change original)
+ */
+ public static List decompress(List e) {
+ List returned = new ArrayList();
+ for (int i = 0 ; i < e.size() ; i++) {
+ for (int x = 0 ; x < e.get(i).getAbscount() ; x++) {
+ List t = parseValues(e.get(i).toData(), ':');
+
+ int n = Integer.parseInt(t.get(0));
+ String sym = t.get(1);
+ String name = t.get(2);
+ double weight = Double.parseDouble(t.get(3));
+ int group = Integer.parseInt(t.get(4));
+ int period = Integer.parseInt(t.get(5));
+ boolean metal = Boolean.parseBoolean(t.get(6));
+ int state = Integer.parseInt(t.get(7));
+ int massnum = Integer.parseInt(t.get(8));
+
+ if (t.size() > 9) {
+ int pro = Integer.parseInt(t.get(9));
+ int neu = Integer.parseInt(t.get(10));
+ int ele = Integer.parseInt(t.get(11));
+
+ Element xx = new Element(pro,sym,name,weight,group,period,metal,state,massnum);
+ SElement xxx = new SElement(xx,neu,ele);
+
+ returned.add(xxx);
+ } else {
+ Element xx = new Element(n,sym,name,weight,group,period,metal,state,massnum);
+ returned.add(xx);
+ }
+
+ //returned.add(new Element(n,sym,name,weight,group,period,metal,state,massnum));
+ }
+ }
+ return returned;
+ }
+ /**
+ *
+ * @param e
+ * @return Compressed List (Does not change original)
+ */
+ public static List compress(List e) {
+ List inpane = new ArrayList();
+ for (int i = 0 ; i < e.size() ; i++) {
+ SortElement.addElement(inpane, e.get(i));
+ }
+ return inpane;
+ }
+ /**
+ * Precondition: Decompressed(Automatic)
+ * Postcondition: Compressed
+ * @param e
+ * @return
+ */
+ public static void toSaveData(List e, File f) {
+ try {
+ List d = Utils.decompress(e);
+ FileWriter fw = new FileWriter(f);
+ BufferedWriter bw = new BufferedWriter(fw);
+ for (int i = 0 ; i < d.size() ; i++) {
+ bw.write(d.get(i).toData() + "\n");
+ System.out.println(">" + d.get(i).getAbscount());
+ }
+ bw.close();
+ } catch (Exception ee) {
+ }
+ }
+ /**
+ * Precondition: Decompressed(Automatic)
+ * Postcondition: Compressed
+ * @param f
+ * @return
+ */
+ public static List fromSaveData(File f) {
+ List returned = new ArrayList();
+ try {
+
+ List data = Files.readAllLines(f.toPath());
+
+ for (int i = 0 ; i < data.size() ; i++) {
+ List t = parseValues(data.get(i), ':');
+ /*
+ *
+ * @param n
+ * @param sym
+ * @param name
+ * @param weight
+ * @param group
+ * @param period
+ * @param metal
+ * @param state
+ * @param massnum
+ */
+ int n = Integer.parseInt(t.get(0));
+ String sym = t.get(1);
+ String name = t.get(2);
+ double weight = Double.parseDouble(t.get(3));
+ int group = Integer.parseInt(t.get(4));
+ int period = Integer.parseInt(t.get(5));
+ boolean metal = Boolean.parseBoolean(t.get(6));
+ int state = Integer.parseInt(t.get(7));
+ int massnum = Integer.parseInt(t.get(8));
+
+ if (t.size() > 9) {
+ int pro = Integer.parseInt(t.get(9));
+ int neu = Integer.parseInt(t.get(10));
+ int ele = Integer.parseInt(t.get(11));
+
+ Element xx = new Element(pro,sym,name,weight,group,period,metal,state,massnum);
+ SElement xxx = new SElement(xx,neu,ele);
+
+ SortElement.addElement(returned, xxx);
+ } else {
+ Element xx = new Element(n,sym,name,weight,group,period,metal,state,massnum);
+ SortElement.addElement(returned, xx);
+ }
+
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return returned;
+ }
+ public static List getParamNames() {
+ String d = "param n@param sym@param name@param weight@param group@param period@param metal@param state@param massnum";
+ List e = Utils.parseValues(d, '@');
+
+ return e;
+ }
+ /**
+ * Reverse Operation of toFormattedString
+ * @param data
+ * @return
+ */
+ public static Element fromFormattedString(String data) {
+ List t = parseValues(data, ':');
+ try {
+ int n = Integer.parseInt(t.get(0));
+ String sym = t.get(1);
+ String name = t.get(2);
+ double weight = Double.parseDouble(t.get(3));
+ int group = Integer.parseInt(t.get(4));
+ int period = Integer.parseInt(t.get(5));
+ boolean metal = Boolean.parseBoolean(t.get(6));
+ int state = Integer.parseInt(t.get(7));
+ int massnum = Integer.parseInt(t.get(8));
+
+ if (t.size() > 9) {
+ int pro = Integer.parseInt(t.get(9));
+ int neu = Integer.parseInt(t.get(10));
+ int ele = Integer.parseInt(t.get(11));
+
+ Element xx = new Element(pro,sym,name,weight,group,period,metal,state,massnum);
+ SElement xxx = new SElement(xx,neu,ele);
+
+ return xxx;
+ } else {
+ Element xx = new Element(n,sym,name,weight,group,period,metal,state,massnum);
+ return xx;
+ }
+
+ //xx = new Element(n,sym,name,weight,group,period,metal,state,massnum);
+ } catch (Exception e) {
+ return PeriodicConstants.getElement().get(0);
+ }
+ //return xx;
+ }
+ /**
+ * Reverse operation of fromFormattedString
+ * @param e
+ */
+ public static String toFormattedString(Element e) {
+ return e.toData();
+ }
+ public static List toDisplayableData(Element e) {
+ List x = parseValues(e.toData(),':');
+ List xx = new ArrayList();
+ for (int i = 0 ; i < x.size() ; i++) {
+ xx.add(new JTextField(x.get(i)));
+ }
+ return xx;
+ }
+ public static List parseValues(String x, char separator) {
+ List values = new ArrayList();
+ String addto = "";
+ for (int i = 0 ; i < x.length() ; i++) {
+ if (x.charAt(i) == separator) {
+ values.add(addto);
+ addto = "";
+ } else {
+ addto += x.charAt(i);
+ }
+ }
+ if (!addto.equals("")) {
+ values.add(addto);
+ }
+ return values;
+ }
+ public static String getElementTooltip(Element x) {
+ try {
+ URL url = null;
+ try {
+ url = new URL("https://periodictable.com/GridImages/big/"+x.getNum()+".JPG");
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ return "Error: Server unresponsive";
+ }
+ //String more = "\"https://en.wikipedia.org/wiki/" + x.getName();
+ String tt = "";
+ System.out.println(tt);
+ return tt;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "Error: No internet
";
+ }
+}
diff --git a/src/com/qxbytes/chemlab/WebButton.java b/src/com/qxbytes/chemlab/WebButton.java
new file mode 100644
index 0000000..9d6c790
--- /dev/null
+++ b/src/com/qxbytes/chemlab/WebButton.java
@@ -0,0 +1,47 @@
+package com.qxbytes.chemlab;
+
+import java.awt.Desktop;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.swing.JButton;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class WebButton extends JButton {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public WebButton(String name, String prefix) {
+ super(name);
+
+ this.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ if (Desktop.isDesktopSupported()) {
+ try {
+ Desktop.getDesktop().browse(new URI(prefix + SelectionPane.getFrame().getTitle().substring(10).replaceAll("1", "")));
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ });
+ }
+
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ }
+}
diff --git a/src/com/qxbytes/chemlab/Webbrowser.java b/src/com/qxbytes/chemlab/Webbrowser.java
new file mode 100644
index 0000000..0423362
--- /dev/null
+++ b/src/com/qxbytes/chemlab/Webbrowser.java
@@ -0,0 +1,35 @@
+package com.qxbytes.chemlab;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.swing.JEditorPane;
+import javax.swing.JScrollPane;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Webbrowser extends JScrollPane {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public Webbrowser(URL url) {
+ super();
+ JEditorPane editorPane = new JEditorPane();
+ try {
+ editorPane.setPage(url);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ this.setViewportView(editorPane);
+ this.repaint();
+ }
+}
diff --git a/src/com/qxbytes/chemlab/icon.png b/src/com/qxbytes/chemlab/icon.png
new file mode 100644
index 0000000..568bc10
Binary files /dev/null and b/src/com/qxbytes/chemlab/icon.png differ
diff --git a/src/com/qxbytes/plugins/Creator.java b/src/com/qxbytes/plugins/Creator.java
new file mode 100644
index 0000000..169d38a
--- /dev/null
+++ b/src/com/qxbytes/plugins/Creator.java
@@ -0,0 +1,111 @@
+package com.qxbytes.plugins;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JSpinner;
+
+import com.qxbytes.chemlab.Element;
+import com.qxbytes.chemlab.ElementDisplay;
+import com.qxbytes.chemlab.PeriodicConstants;
+import com.qxbytes.chemlab.PicturePane;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Creator extends PItem {
+ JFrame f;
+ JSpinner protons;
+ JSpinner neutrons;
+ JSpinner electrons;
+ JButton button;
+ PicturePane p;
+ ElementDisplay ed;
+ IonIsotopePane iip;
+ Element e;
+ @Override
+ public void doStuff() {
+ e = PeriodicConstants.getElement().get(0);
+ ed = new ElementDisplay(e);
+ p = new PicturePane(e);
+ iip = new IonIsotopePane(e);
+
+ f = new JFrame();
+ f.setSize(700, 350);
+ f.setLocationRelativeTo(null);
+ f.setLayout(new BorderLayout());
+
+ protons = new JSpinner();
+ neutrons = new JSpinner();
+ electrons = new JSpinner();
+ button = new JButton("Update");
+
+ JPanel top = new JPanel();
+ JPanel center = new JPanel(new GridLayout(1,0));
+
+ top.add(new JLabel("Protons:"));
+ top.add(protons);
+ top.add(new JLabel("Neutrons:"));
+ top.add(neutrons);
+ top.add(new JLabel("Electrons:"));
+ top.add(electrons);
+
+ button.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ int i = (Integer)protons.getValue();
+ int ii = (Integer)neutrons.getValue();
+ int iii = (Integer)electrons.getValue();
+
+ SElement base;
+ if (i < PeriodicConstants.getElement().size()) {
+ base = new SElement(PeriodicConstants.getElement().get(i),ii,iii);
+ base.setProtons(i);
+
+ f.setTitle("(partial extrapolation)");
+ } else {
+ base = new SElement(i,ii,iii);
+
+ f.setTitle("(extrapolated)");
+ }
+
+ p = new PicturePane(base);
+
+ ed = new ElementDisplay(base);
+
+ iip = new IonIsotopePane(base);
+
+ center.removeAll();
+ center.add(p);
+ center.add(ed);
+ center.add(iip);
+
+ f.add(center,BorderLayout.CENTER);
+
+ f.revalidate();
+ }
+
+ });
+
+ center.add(p);
+ center.add(ed);
+ center.add(iip);
+
+ f.add(center, BorderLayout.CENTER);
+
+ f.add(button,BorderLayout.SOUTH);
+
+ f.add(top,BorderLayout.NORTH);
+
+ f.setVisible(true);
+ }
+
+}
diff --git a/src/com/qxbytes/plugins/IonIsotopePane.java b/src/com/qxbytes/plugins/IonIsotopePane.java
new file mode 100644
index 0000000..f501100
--- /dev/null
+++ b/src/com/qxbytes/plugins/IonIsotopePane.java
@@ -0,0 +1,79 @@
+package com.qxbytes.plugins;
+
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import com.qxbytes.chemlab.Element;
+import com.qxbytes.chemlab.PeriodicConstants;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class IonIsotopePane extends JPanel {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ SElement se;
+ List data = new ArrayList();
+ public IonIsotopePane(Element e) {
+
+ }
+ public IonIsotopePane(SElement se) {
+ this.se = se;
+ this.setLayout(new GridLayout(0,2));
+ /*
+ * Assume that this element needs to be completely extrapolated
+ */
+ //charge
+ int ion = se.getNum() - se.getElectrons();
+
+ //isotope ratio
+ int iso = se.getNeutrons();
+ int predictedstable = (int) (se.getNum() * 1.6);
+
+ //name
+ String element = se.getName()+"-" + (se.getNeutrons()+se.getNum());
+
+ //massn
+ int massn = iso + se.getNum();
+
+ double weight = massn;
+
+ /*
+ * Partial extrapolation
+ */
+ if (PeriodicConstants.getElementFromIndex(se.getNum()-1).getNum() == se.getNum()) {
+ int difference = PeriodicConstants.getElementFromIndex(se.getNum()-1).getNeutrons()-se.getNeutrons();
+ weight = PeriodicConstants.getElementFromIndex(se.getNum()-1).getWeight()-difference;
+ predictedstable = PeriodicConstants.getElementFromIndex(se.getNum()-1).getNeutrons();
+ }
+
+
+ data.add(new JTextField("Isotope: "));
+ data.add(new JTextField(""+iso));
+ data.add(new JTextField("Ion: "));
+ data.add(new JTextField(""+ion));
+ data.add(new JTextField("Element: "));
+ data.add(new JTextField(element));
+ data.add(new JTextField("Massnum(ex): "));
+ data.add(new JTextField(massn+""));
+ data.add(new JTextField("Weight(ex): "));
+ data.add(new JTextField(weight+""));
+ data.add(new JTextField("Stable Isotope: "));
+ data.add(new JTextField(predictedstable+""));
+
+ for (JTextField x : data) {
+ x.setEditable(false);
+ add(x);
+ }
+
+ }
+
+
+}
diff --git a/src/com/qxbytes/plugins/PButton.java b/src/com/qxbytes/plugins/PButton.java
new file mode 100644
index 0000000..133ebc4
--- /dev/null
+++ b/src/com/qxbytes/plugins/PButton.java
@@ -0,0 +1,39 @@
+package com.qxbytes.plugins;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JButton;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class PButton extends JButton {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private List windows = new ArrayList();
+
+ public PButton(String name) {
+ this.setName(name);
+ this.setText(name);
+ this.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ for (int i = 0 ; i < windows.size() ; i++) {
+ windows.get(i).doStuff();
+ }
+ }
+
+ });
+ }
+ public void addFrame(PItem p) {
+ windows.add(p);
+ }
+}
diff --git a/src/com/qxbytes/plugins/PItem.java b/src/com/qxbytes/plugins/PItem.java
new file mode 100644
index 0000000..94fad96
--- /dev/null
+++ b/src/com/qxbytes/plugins/PItem.java
@@ -0,0 +1,14 @@
+package com.qxbytes.plugins;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public abstract class PItem {
+
+ /**
+ * Overload me to do things.
+ * Initialization should occur here
+ */
+ public abstract void doStuff();
+}
diff --git a/src/com/qxbytes/plugins/PLUGINMANIFEST.java b/src/com/qxbytes/plugins/PLUGINMANIFEST.java
new file mode 100644
index 0000000..603d373
--- /dev/null
+++ b/src/com/qxbytes/plugins/PLUGINMANIFEST.java
@@ -0,0 +1,30 @@
+package com.qxbytes.plugins;
+
+import javax.swing.JPanel;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class PLUGINMANIFEST extends JPanel {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ /**
+ * Instantiate all plugins here
+ */
+ public PLUGINMANIFEST() {
+ PButton pair = new PButton("Pair First 2 Elements");
+ pair.addFrame(new Pair());
+ add(pair);
+
+ PButton sandbox = new PButton("Create Element from Scratch");
+ sandbox.addFrame(new Sandbox());
+ add(sandbox);
+ PButton creator = new PButton("Element, Isotope, Ion");
+ creator.addFrame(new Creator());
+ add(creator);
+ }
+}
diff --git a/src/com/qxbytes/plugins/Pair.java b/src/com/qxbytes/plugins/Pair.java
new file mode 100644
index 0000000..228da22
--- /dev/null
+++ b/src/com/qxbytes/plugins/Pair.java
@@ -0,0 +1,62 @@
+package com.qxbytes.plugins;
+
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import com.qxbytes.chemlab.Element;
+import com.qxbytes.chemlab.PicturePane;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Pair extends PItem {
+ private List pair;
+ private JFrame f;
+ public Pair() {
+ super();
+
+ }
+ public void doStuff() {
+ f = new JFrame();
+ pair = Plugin.getPair();
+
+ if (pair == null || pair.get(1) == null) {
+ f.dispose();
+ return;
+ }
+
+ f.setTitle(pair.get(0).getName() + "+" + pair.get(1).getName());
+ f.setSize(200,300);
+ f.setLocationRelativeTo(null);
+ f.setLayout(new GridLayout(2,1));
+
+ JPanel top = new JPanel(new GridLayout(1,2));
+
+ top.add(new PicturePane(pair.get(0)));
+ top.add(new PicturePane(pair.get(1)));
+
+ f.add(top);
+
+ JPanel bot = new JPanel(new GridLayout(0,2));
+
+ List data = new ArrayList();
+ data.add(new JTextField("Formula:"));
+ data.add(new JTextField(pair.get(0).getBalancedEquation(pair.get(1))));
+
+ for (int i = 0 ; i < data.size() ; i++) {
+ data.get(i).setEditable(false);
+
+ bot.add(data.get(i));
+ }
+
+ f.add(bot);
+
+ f.setVisible(true);
+ }
+}
diff --git a/src/com/qxbytes/plugins/Plugin.java b/src/com/qxbytes/plugins/Plugin.java
new file mode 100644
index 0000000..c343a9c
--- /dev/null
+++ b/src/com/qxbytes/plugins/Plugin.java
@@ -0,0 +1,73 @@
+package com.qxbytes.plugins;
+
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+
+import com.qxbytes.chemlab.SelectionPane;
+import com.qxbytes.chemlab.Element;
+import com.qxbytes.chemlab.Utils;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Plugin {
+ private JButton activator;
+ private JFrame frame;
+
+ public Plugin(String name, int sx, int sy) {
+ frame = new JFrame(name);
+ frame.setSize(300, 300);
+ frame.setLocationRelativeTo(null);
+
+ activator = new JButton(name);
+ }
+ public Plugin(String name) {
+ frame = new JFrame(name);
+ frame.setLocationRelativeTo(null);
+
+ activator = new JButton(name);
+ }
+ public Plugin() {
+ frame = new JFrame("Plug-in");
+ frame.setLocationRelativeTo(null);
+
+ activator = new JButton("Plug-in");
+ }
+
+ /**
+ * Gets the current selection
+ * @return Compressed selection
+ */
+ public static List getSelected() {
+ return SelectionPane.getInpane();
+ }
+ /**
+ * Gets the first two elements (doubles included) to analyze
+ * @return A pair of elements in a List
+ */
+ public static List getPair() {
+ if (Utils.decompress(getSelected()).isEmpty() || Utils.decompress(getSelected()).size() < 2) {
+ System.out.println("!");
+ return null;
+ }
+ List returned = Utils.decompress(getSelected()).subList(0, 2);
+ return returned;
+ }
+ /**
+ * Gets the standard button to trigger the opening of the plugin
+ * @return The button
+ */
+ public JButton b() {
+ return activator;
+ }
+ /**
+ * Gets the standard frame for the plugin to run in
+ * @return The frame
+ */
+ public JFrame f() {
+ return frame;
+ }
+}
diff --git a/src/com/qxbytes/plugins/SElement.java b/src/com/qxbytes/plugins/SElement.java
new file mode 100644
index 0000000..e18e5c6
--- /dev/null
+++ b/src/com/qxbytes/plugins/SElement.java
@@ -0,0 +1,67 @@
+package com.qxbytes.plugins;
+
+import com.qxbytes.chemlab.Element;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class SElement extends Element {
+ int protons;
+ int neutrons;
+ int electrons;
+ public SElement (int pro, int neu, int ele) {
+ protons = pro;
+ neutrons = neu;
+ electrons = ele;
+ super.pre();
+ }
+ public SElement (Element pro, int neutrons, int electrons) {
+ super(pro);
+
+ this.setProtons(pro.getNum());
+ this.setNeutrons(neutrons);
+ this.setElectrons(electrons);
+ }
+ public int getElectrons() {
+ return electrons;
+ }
+ public int getNeutrons() {
+ return neutrons;
+ }
+ public int getNum() {
+ return protons;
+ }
+ public int getMassnum() {
+ return protons+neutrons;
+ }
+ /**
+ * @param protons the protons to set
+ */
+ public void setProtons(int protons) {
+ this.protons = protons;
+ }
+ /**
+ * @param neutrons the neutrons to set
+ */
+ public void setNeutrons(int neutrons) {
+ this.neutrons = neutrons;
+ }
+ /**
+ * @param electrons the electrons to set
+ */
+ public void setElectrons(int electrons) {
+ this.electrons = electrons;
+ }
+
+ public String toData() {
+ String r = super.toData();
+
+ r += ":" + protons;
+ r += ":" + neutrons;
+ r += ":" + electrons;
+
+ return r;
+ }
+
+}
diff --git a/src/com/qxbytes/plugins/SandFrame.java b/src/com/qxbytes/plugins/SandFrame.java
new file mode 100644
index 0000000..58b9beb
--- /dev/null
+++ b/src/com/qxbytes/plugins/SandFrame.java
@@ -0,0 +1,97 @@
+package com.qxbytes.plugins;
+
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import com.qxbytes.chemlab.Element;
+import com.qxbytes.chemlab.ElementDisplay;
+import com.qxbytes.chemlab.PeriodicConstants;
+import com.qxbytes.chemlab.PicturePane;
+import com.qxbytes.chemlab.Utils;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class SandFrame {
+ JFrame f;
+ Element e;
+ ElementDisplay ed;
+ PicturePane pp;
+ List labels = new ArrayList();
+ List data;
+ public SandFrame() {
+ f = new JFrame();
+ e = PeriodicConstants.getElement().get(0);
+ ed = new ElementDisplay(e);
+ pp = new PicturePane(e);
+
+ f.setLayout(new GridLayout(1,0));
+ f.setSize(600, 300);
+ f.setLocationRelativeTo(null);
+
+ JPanel info = new JPanel(new GridLayout(0,2));
+
+ List temp = Utils.getParamNames();
+ for (int i = 0 ; i < temp.size() ; i++) {
+ labels.add(new JTextField(temp.get(i)));
+ labels.get(labels.size()-1).setEditable(false);
+ }
+
+ data = Utils.toDisplayableData(e);
+
+ int ln = 0;
+ int dn = 0;
+ for (int i = 0 ; i < labels.size() + data.size() ; i++) {
+ if (i % 2 == 0) {
+ //label
+ info.add(labels.get(ln));
+ ln++;
+ } else {
+ //data
+ data.get(dn).addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent ex) {
+ String x = "";
+
+ for (int i = 0 ; i < data.size() ; i++) {
+ x+= data.get(i).getText()+":";
+ }
+
+ e = Utils.fromFormattedString(x);
+
+ f.remove(pp);
+ f.remove(ed);
+
+ pp = new PicturePane(e);
+ ed = new ElementDisplay(e);
+
+ f.add(pp);
+ f.add(ed);
+
+ f.revalidate();
+ f.repaint();
+
+ }
+
+ });
+ info.add(data.get(dn));
+ dn++;
+ }
+ }
+
+ f.add(info);
+ f.add(pp);
+ f.add(ed);
+
+ f.setVisible(true);
+ }
+}
diff --git a/src/com/qxbytes/plugins/Sandbox.java b/src/com/qxbytes/plugins/Sandbox.java
new file mode 100644
index 0000000..d975c21
--- /dev/null
+++ b/src/com/qxbytes/plugins/Sandbox.java
@@ -0,0 +1,15 @@
+package com.qxbytes.plugins;
+/**
+ *
+ * @author QxBytes
+ *
+ */
+public class Sandbox extends PItem {
+ public Sandbox() {
+ super();
+ }
+ public void doStuff() {
+ new SandFrame();
+ }
+}
+
\ No newline at end of file