diff --git a/src/main/java/edu/rpi/legup/controller/EditorElementController.java b/src/main/java/edu/rpi/legup/controller/EditorElementController.java
new file mode 100644
index 000000000..52aa67cfe
--- /dev/null
+++ b/src/main/java/edu/rpi/legup/controller/EditorElementController.java
@@ -0,0 +1,43 @@
+package edu.rpi.legup.controller;
+
+import edu.rpi.legup.app.GameBoardFacade;
+import edu.rpi.legup.app.LegupPreferences;
+import edu.rpi.legup.history.*;
+import edu.rpi.legup.model.Puzzle;
+import edu.rpi.legup.model.elements.Element;
+import edu.rpi.legup.model.gameboard.CaseBoard;
+import edu.rpi.legup.model.rules.*;
+import edu.rpi.legup.model.tree.TreeElement;
+import edu.rpi.legup.model.tree.TreeElementType;
+import edu.rpi.legup.ui.proofeditorui.rulesview.RuleButton;
+import edu.rpi.legup.ui.proofeditorui.treeview.TreeElementView;
+import edu.rpi.legup.ui.proofeditorui.treeview.TreePanel;
+import edu.rpi.legup.ui.proofeditorui.treeview.TreeView;
+import edu.rpi.legup.ui.proofeditorui.treeview.TreeViewSelection;
+import edu.rpi.legup.ui.puzzleeditorui.elementsview.ElementButton;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import static edu.rpi.legup.app.GameBoardFacade.getInstance;
+
+public class EditorElementController implements ActionListener {
+ protected Object lastSource;
+
+ public EditorElementController() {
+ super();
+ }
+
+ public void buttonPressed(Element element) {
+ // TODO: implement what happens when element is pressed
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ lastSource = e.getSource();
+ ElementButton button = (ElementButton) lastSource;
+ buttonPressed(button.getElement());
+ }
+}
diff --git a/src/main/java/edu/rpi/legup/model/elements/Element.java b/src/main/java/edu/rpi/legup/model/elements/Element.java
new file mode 100644
index 000000000..0fdabe383
--- /dev/null
+++ b/src/main/java/edu/rpi/legup/model/elements/Element.java
@@ -0,0 +1,77 @@
+package edu.rpi.legup.model.elements;
+
+import edu.rpi.legup.model.rules.RuleType;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public abstract class Element {
+ protected String elementID;
+ protected String elementName;
+ protected String description;
+
+ protected String imageName;
+ protected ImageIcon image;
+
+ protected ElementType elementType;
+
+ private final String INVALID_USE_MESSAGE;
+
+ public Element(String elementID, String elementName, String description, String imageName) {
+ this.elementID = elementID;
+ this.elementName = elementName;
+ this.description = description;
+ this.imageName = imageName;
+ this.INVALID_USE_MESSAGE = "Invalid use of the rule " + this.elementName;
+ loadImage();
+ }
+
+ private void loadImage() {
+ if (imageName != null) {
+ this.image = new ImageIcon(ClassLoader.getSystemResource(imageName));
+ //Resize images to be 100px wide
+ Image image = this.image.getImage();
+ if(this.image.getIconWidth() < 120) return;
+ int height = (int) (100 * ((double) this.image.getIconHeight() / this.image.getIconWidth()));
+ if(height==0){
+ System.out.println("height is 0 error");
+ System.out.println("height: "+this.image.getIconHeight());
+ System.out.println("width: "+this.image.getIconWidth());
+ return;
+ }
+ BufferedImage bimage = new BufferedImage(100, height, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g = bimage.createGraphics();
+ g.drawImage(image, 0, 0, 100, height, null);
+ this.image = new ImageIcon(bimage);
+ }
+ }
+ public String getElementName() {
+ return elementName;
+ }
+
+ public void setElementName(String elementName) {
+ this.elementName = elementName;
+ }
+
+ public String getElementID() {
+ return elementID;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public ImageIcon getImageIcon() {
+ return image;
+ }
+
+ public ElementType getElementType() {
+ return elementType;
+ }
+
+ public String getInvalidUseOfRuleMessage()
+ {
+ return this.INVALID_USE_MESSAGE;
+ }
+}
diff --git a/src/main/java/edu/rpi/legup/model/elements/ElementType.java b/src/main/java/edu/rpi/legup/model/elements/ElementType.java
new file mode 100644
index 000000000..85ec9be36
--- /dev/null
+++ b/src/main/java/edu/rpi/legup/model/elements/ElementType.java
@@ -0,0 +1,5 @@
+package edu.rpi.legup.model.elements;
+
+public enum ElementType {
+ NURIKABE, TREETENT, LIGHTUP, SKYSCRAPERS
+}
diff --git a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
index 46593bf59..351cef3ea 100644
--- a/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
+++ b/src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
@@ -17,6 +17,8 @@ public class PuzzleEditorPanel extends LegupPanel {
private JMenuBar menuBar;
private JFrame frame;
private JButton[] buttons;
+
+ private JPanel elementPanel;
private JPanel mainPanel;
private FileDialog fileDialog;
private JMenuItem undo, redo;
@@ -57,11 +59,11 @@ public void setMenuBar() {
newPuzzle.addActionListener((ActionEvent) -> promptPuzzle());
if(os.equals("mac")) newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
else newPuzzle.setAccelerator(KeyStroke.getKeyStroke('N', InputEvent.CTRL_DOWN_MASK));
- // file>open
- JMenuItem openPuzzle = new JMenuItem("Open");
+ // file>save
+ JMenuItem savePuzzle = new JMenuItem("Save");
menus[0].add(newPuzzle);
- menus[0].add(openPuzzle);
+ menus[0].add(savePuzzle);
// EDIT
menus[1] = new JMenu("Edit");
diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementButton.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementButton.java
new file mode 100644
index 000000000..a7fe8bf7c
--- /dev/null
+++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementButton.java
@@ -0,0 +1,23 @@
+package edu.rpi.legup.ui.puzzleeditorui.elementsview;
+
+import edu.rpi.legup.model.elements.Element;
+import edu.rpi.legup.model.rules.Rule;
+
+import javax.swing.*;
+
+public class ElementButton extends JButton {
+
+ private Element element;
+ ElementButton(Element e) {
+ super(e.getImageIcon());
+ this.element = e;
+ }
+
+ public Element getElement() {
+ return element;
+ }
+
+ public void setElement(Element e) {
+ this.element = e;
+ }
+}
diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java
new file mode 100644
index 000000000..892f96918
--- /dev/null
+++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementFrame.java
@@ -0,0 +1,61 @@
+package edu.rpi.legup.ui.puzzleeditorui.elementsview;
+
+import edu.rpi.legup.controller.EditorElementController;
+import edu.rpi.legup.controller.RuleController;
+import edu.rpi.legup.ui.proofeditorui.rulesview.BasicRulePanel;
+import edu.rpi.legup.ui.proofeditorui.rulesview.CaseRulePanel;
+import edu.rpi.legup.ui.proofeditorui.rulesview.ContradictionRulePanel;
+import edu.rpi.legup.ui.proofeditorui.rulesview.RulePanel;
+
+import javax.swing.*;
+import javax.swing.border.TitledBorder;
+import java.awt.*;
+
+public class ElementFrame extends JPanel {
+ private static final String checkBox = " \u2714 ";
+ private static final String xBox = " \u2718 ";
+ private static final String htmlHead = "";
+ private static final String htmlTail = "";
+
+ private JTabbedPane tabbedPane;
+ private JLabel status;
+ private ButtonGroup buttonGroup;
+
+ private EditorElementController controller;
+
+ public ElementFrame(EditorElementController controller) {
+ this.controller = controller;
+
+ this.tabbedPane = new JTabbedPane();
+ this.status = new JLabel();
+ this.buttonGroup = new ButtonGroup();
+
+ setLayout(new BorderLayout());
+ setMinimumSize(new Dimension(250, 256));
+ setPreferredSize(new Dimension(330, 256));
+
+ add(tabbedPane);
+ add(status, BorderLayout.SOUTH);
+
+ TitledBorder title = BorderFactory.createTitledBorder("Rules");
+ title.setTitleJustification(TitledBorder.CENTER);
+ setBorder(title);
+ }
+
+ public ButtonGroup getButtonGroup() {
+ return buttonGroup;
+ }
+
+ public void resetSize() {
+ int buttonWidth = ((ElementPanel) tabbedPane.getSelectedComponent()).getElementButtons()[0].getWidth();
+ this.setMinimumSize(new Dimension(2 * buttonWidth + 64, this.getHeight()));
+ }
+
+ public EditorElementController getController() {
+ return controller;
+ }
+
+ public JTabbedPane getTabbedPane() {
+ return tabbedPane;
+ }
+}
diff --git a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java
index ee6d119e0..4c2429031 100644
--- a/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java
+++ b/src/main/java/edu/rpi/legup/ui/puzzleeditorui/elementsview/ElementPanel.java
@@ -1,4 +1,82 @@
package edu.rpi.legup.ui.puzzleeditorui.elementsview;
-public class ElementPanel {
+import edu.rpi.legup.model.rules.Rule;
+import edu.rpi.legup.ui.WrapLayout;
+import edu.rpi.legup.model.elements.Element;
+import edu.rpi.legup.ui.proofeditorui.rulesview.RuleButton;
+
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class ElementPanel extends JPanel {
+ protected ImageIcon icon;
+ protected String name;
+ protected String toolTip;
+ protected ElementButton[] elementButtons;
+ protected ElementFrame elementFrame;
+ protected List extends Element> elements;
+
+ public ElementPanel(ElementFrame eFrame) {
+ this.elementFrame = eFrame;
+ this.elements = new ArrayList<>();
+ setLayout(new WrapLayout());
+ }
+ public void setRules(List extends Element> elements) {
+ this.elements = elements;
+ clearButtons();
+
+ elementButtons = new ElementButton[elements.size()];
+
+ for (int i = 0; i < elements.size(); i++) {
+ Element element = elements.get(i);
+ elementButtons[i] = new ElementButton(element);
+ elementFrame.getButtonGroup().add(elementButtons[i]);
+
+ elementButtons[i].setToolTipText(element.getElementName() + ": " + element.getDescription());
+ elementButtons[i].addActionListener(elementFrame.getController());
+ add(elementButtons[i]);
+ }
+ revalidate();
+ }
+
+ protected void clearButtons() {
+ if (elementButtons != null) {
+ removeAll();
+ for (int x = 0; x < elementButtons.length; ++x) {
+ elementButtons[x].removeActionListener(elementFrame.getController());
+ }
+ }
+ }
+
+ public ElementButton[] getElementButtons() {
+ return elementButtons;
+ }
+
+ public ImageIcon getIcon() {
+ return icon;
+ }
+
+ public void setIcon(ImageIcon icon) {
+ this.icon = icon;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getToolTip() {
+ return toolTip;
+ }
+
+ public void setToolTip(String toolTip) {
+ this.toolTip = toolTip;
+ }
}
+