Search in sources :

Example 6 with Tree

use of org.concord.energy3d.model.Tree in project energy3d by concord-consortium.

the class SceneManager method autoSelectBuilding.

public Foundation autoSelectBuilding(final boolean ask) {
    Foundation foundation = null;
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart == null || selectedPart instanceof Tree || selectedPart instanceof Human) {
        SceneManager.getInstance().setSelectedPart(null);
        int count = 0;
        HousePart hp = null;
        for (final HousePart x : Scene.getInstance().getParts()) {
            if (x instanceof Foundation) {
                count++;
                hp = x;
            }
        }
        if (count == 1) {
            SceneManager.getInstance().setSelectedPart(hp);
            foundation = (Foundation) hp;
        } else {
            if (ask) {
                if (count > 1) {
                    JOptionPane.showMessageDialog(MainFrame.getInstance(), "There are multiple buildings. You must select a building first.", "No Selection", JOptionPane.WARNING_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no building.", "No Building", JOptionPane.WARNING_MESSAGE);
                }
            }
        }
    } else {
        final HousePart topContainer = selectedPart.getTopContainer();
        if (selectedPart instanceof Foundation) {
            foundation = (Foundation) selectedPart;
        } else if (topContainer instanceof Foundation) {
            selectedPart.setEditPointsVisible(false);
            SceneManager.getInstance().setSelectedPart(topContainer);
            foundation = (Foundation) topContainer;
        } else {
            if (ask) {
                JOptionPane.showMessageDialog(MainFrame.getInstance(), "You must select a building first.", "No Selection", JOptionPane.WARNING_MESSAGE);
            }
        }
    }
    return foundation;
}
Also used : Human(org.concord.energy3d.model.Human) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 7 with Tree

use of org.concord.energy3d.model.Tree in project energy3d by concord-consortium.

the class SceneManager method newPart.

private HousePart newPart() {
    final HousePart drawn;
    setGridsVisible(false);
    if (operation == Operation.DRAW_WALL) {
        drawn = new Wall();
        drawn.setColor(Scene.getInstance().getWallColor());
    } else if (operation == Operation.DRAW_DOOR) {
        drawn = new Door();
        drawn.setColor(Scene.getInstance().getDoorColor());
    } else if (operation == Operation.DRAW_WINDOW) {
        drawn = new Window();
    } else if (operation == Operation.DRAW_ROOF_PYRAMID) {
        drawn = new PyramidRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_HIP) {
        drawn = new HipRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_SHED) {
        drawn = new ShedRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_GAMBREL) {
        drawn = new GambrelRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_CUSTOM) {
        drawn = new CustomRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_FLOOR) {
        drawn = new Floor();
        drawn.setColor(Scene.getInstance().getFloorColor());
    } else if (operation == Operation.DRAW_SOLAR_PANEL) {
        drawn = new SolarPanel();
    } else if (operation == Operation.DRAW_RACK) {
        drawn = new Rack();
    } else if (operation == Operation.DRAW_MIRROR) {
        drawn = new Mirror();
    } else if (operation == Operation.DRAW_PARABOLIC_TROUGH) {
        drawn = new ParabolicTrough();
    } else if (operation == Operation.DRAW_PARABOLIC_DISH) {
        drawn = new ParabolicDish();
    } else if (operation == Operation.DRAW_FRESNEL_REFLECTOR) {
        drawn = new FresnelReflector();
    } else if (operation == Operation.DRAW_SENSOR) {
        drawn = new Sensor();
    } else if (operation == Operation.DRAW_FOUNDATION) {
        drawn = new Foundation();
        setGridsVisible(Scene.getInstance().isSnapToGrids());
        drawn.setColor(Scene.getInstance().getFoundationColor());
    } else if (operation == Operation.DRAW_DOGWOOD) {
        drawn = new Tree(Tree.DOGWOOD);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_ELM) {
        drawn = new Tree(Tree.ELM);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_OAK) {
        drawn = new Tree(Tree.OAK);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_LINDEN) {
        drawn = new Tree(Tree.LINDEN);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_COTTONWOOD) {
        drawn = new Tree(Tree.COTTONWOOD);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_MAPLE) {
        drawn = new Tree(Tree.MAPLE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_PINE) {
        drawn = new Tree(Tree.PINE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JANE) {
        drawn = new Human(Human.JANE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JENI) {
        drawn = new Human(Human.JENI);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JILL) {
        drawn = new Human(Human.JILL);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JACK) {
        drawn = new Human(Human.JACK);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JOHN) {
        drawn = new Human(Human.JOHN);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JOSE) {
        drawn = new Human(Human.JOSE);
        setGridsVisible(true);
    } else {
        return null;
    }
    Scene.getInstance().add(drawn, false);
    addPartCommand = new AddPartCommand(drawn);
    return drawn;
}
Also used : Window(org.concord.energy3d.model.Window) Human(org.concord.energy3d.model.Human) Floor(org.concord.energy3d.model.Floor) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) ShedRoof(org.concord.energy3d.model.ShedRoof) Door(org.concord.energy3d.model.Door) GambrelRoof(org.concord.energy3d.model.GambrelRoof) CustomRoof(org.concord.energy3d.model.CustomRoof) ParabolicDish(org.concord.energy3d.model.ParabolicDish) PyramidRoof(org.concord.energy3d.model.PyramidRoof) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) AddPartCommand(org.concord.energy3d.undo.AddPartCommand) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HipRoof(org.concord.energy3d.model.HipRoof) Mirror(org.concord.energy3d.model.Mirror) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) Sensor(org.concord.energy3d.model.Sensor)

Example 8 with Tree

use of org.concord.energy3d.model.Tree in project energy3d by concord-consortium.

the class SceneManager method move.

public void move(final Vector3 v) {
    if (SceneManager.getInstance().getSolarHeatMap()) {
        EnergyPanel.getInstance().updateRadiationHeatMap();
    }
    final MovePartCommand c = new MovePartCommand(selectedPart, v);
    if (selectedPart == null) {
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p instanceof Foundation) {
                ((Foundation) p).move(v, p.getGridSize());
            }
        }
        Scene.getInstance().redrawAll();
    } else if (selectedPart instanceof Foundation) {
        final Foundation f = (Foundation) selectedPart;
        if (f.isGroupMaster()) {
            final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
            for (final Foundation x : g) {
                x.move(v, selectedPart.getGridSize());
            }
        } else {
            f.move(v, selectedPart.getGridSize());
        }
    } else if (selectedPart instanceof FoundationPolygon) {
        ((Foundation) selectedPart.getContainer()).moveAllWithinPolygon(v);
    } else if (selectedPart instanceof Roof) {
        if (viewMode == ViewMode.TOP_VIEW) {
            final Foundation f = selectedPart.getTopContainer();
            if (f.isGroupMaster()) {
                final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
                for (final Foundation x : g) {
                    x.move(v, selectedPart.getGridSize());
                }
            } else {
                f.move(v, selectedPart.getGridSize());
            }
        }
    } else if (selectedPart instanceof Window) {
        final Window w = (Window) selectedPart;
        w.move(v);
        w.draw();
    } else if (selectedPart instanceof SolarCollector) {
        final SolarCollector sc = (SolarCollector) selectedPart;
        sc.move(v, selectedPart.getGridSize());
        selectedPart.draw();
    } else if (selectedPart instanceof Tree) {
        final Tree t = (Tree) selectedPart;
        t.move(v, selectedPart.getGridSize());
        t.draw();
    } else if (selectedPart instanceof Human) {
        final Human h = (Human) selectedPart;
        h.move(v, selectedPart.getGridSize());
        h.draw();
    }
    undoManager.addEdit(c);
    SceneManager.getInstance().refresh();
    Scene.getInstance().setEdited(true);
}
Also used : Window(org.concord.energy3d.model.Window) Human(org.concord.energy3d.model.Human) Roof(org.concord.energy3d.model.Roof) GambrelRoof(org.concord.energy3d.model.GambrelRoof) ShedRoof(org.concord.energy3d.model.ShedRoof) PyramidRoof(org.concord.energy3d.model.PyramidRoof) HipRoof(org.concord.energy3d.model.HipRoof) CustomRoof(org.concord.energy3d.model.CustomRoof) MovePartCommand(org.concord.energy3d.undo.MovePartCommand) SolarCollector(org.concord.energy3d.model.SolarCollector) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) ArrayList(java.util.ArrayList) List(java.util.List) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) FoundationPolygon(org.concord.energy3d.model.FoundationPolygon)

Example 9 with Tree

use of org.concord.energy3d.model.Tree in project energy3d by concord-consortium.

the class SceneManager method mouseMoved.

private void mouseMoved() {
    if (!mouseControlEnabled) {
        return;
    }
    final int x = mouseState.getX();
    final int y = mouseState.getY();
    if (Scene.getInstance().getDisableShadowInAction()) {
        if (mouseState.getButtonState(MouseButton.LEFT) == ButtonState.DOWN || mouseState.getButtonState(MouseButton.RIGHT) == ButtonState.DOWN) {
            if (MainPanel.getInstance().getShadowButton().isSelected()) {
                shadowPass.setEnabled(false);
            }
        } else {
            if (MainPanel.getInstance().getShadowButton().isSelected()) {
                shadowPass.setEnabled(true);
            }
        }
    }
    try {
        if (selectedPart != null) {
            if (!selectedPart.isDrawCompleted()) {
                selectedPart.setPreviewPoint(x, y);
                if (selectedPart instanceof Meshable) {
                    // don't draw grid if it sits on an imported mesh
                    selectedPart.setGridsVisible(((Meshable) selectedPart).getMeshLocator() == null);
                }
            } else if (objectMoveStartPoint != null) {
                if ((operation == Operation.RESIZE || selectedPart instanceof Foundation)) {
                    final PickedHousePart pick = SelectUtil.pickPart(x, y, collisionLand);
                    if (pick != null) {
                        if (selectedPart instanceof Foundation) {
                            final Foundation foundation = (Foundation) selectedPart;
                            final Vector3 pickPoint = pick.getPoint().clone();
                            // if (!foundation.insideBuilding(pickPoint.getX(), pickPoint.getY(), true)) { // only move the building when clicking outside
                            final Vector3 d = pickPoint.multiply(1, 1, 0, null).subtractLocal(objectMoveStartPoint.multiply(1, 1, 0, null));
                            if (foundation.isGroupMaster()) {
                                final List<Foundation> g = Scene.getInstance().getFoundationGroup(foundation);
                                for (final Foundation f : g) {
                                    final ArrayList<Vector3> movePoints = objectGroupMovePoints.get(f);
                                    if (movePoints != null) {
                                        // just in case this foundation's move point hasn't been included yet
                                        f.move(d, movePoints);
                                    }
                                }
                            } else {
                                foundation.move(d, objectMovePoints);
                            }
                        }
                    }
                } else if (selectedPart instanceof Tree) {
                    final PickedHousePart pick = SelectUtil.pickPart(x, y, collisionLand);
                    if (pick != null) {
                        final Vector3 d = pick.getPoint().multiply(1, 1, 0, null).subtractLocal(objectMoveStartPoint.multiply(1, 1, 0, null));
                        ((Tree) selectedPart).move(d, objectMovePoints);
                    }
                } else if (selectedPart instanceof Window) {
                    final PickedHousePart pick = SelectUtil.pickPart(x, y, selectedPart.getContainer());
                    if (pick != null) {
                        final Vector3 d = pick.getPoint().subtract(objectMoveStartPoint, null);
                        ((Window) selectedPart).move(d, objectMovePoints);
                    }
                }
            }
        }
        hoveredPart = null;
        if ((operation == Operation.SELECT || operation == Operation.RESIZE) && mouseState.getButtonState(MouseButton.LEFT) == ButtonState.UP && mouseState.getButtonState(MouseButton.MIDDLE) == ButtonState.UP && mouseState.getButtonState(MouseButton.RIGHT) == ButtonState.UP) {
            final PickedHousePart pickedPart = SelectUtil.selectHousePart(x, y, false);
            pick = pickedPart == null ? null : pickedPart.getUserData();
            final HousePart housePart = pick == null ? null : pick.getHousePart();
            if (pick != null) {
                hoveredPart = housePart;
                if (pick.getEditPointIndex() != -1) {
                    lastSelectedEditPointMouseState = mouseState;
                }
            }
        }
        mouseState = null;
    } catch (final Throwable t) {
        t.printStackTrace();
        BugReporter.report(t);
    }
    EventQueue.invokeLater(new // this method is run by the main Energy3D thread, so invoke the Swing code later
    Runnable() {

        @Override
        public void run() {
            final Component canvasComponent = (Component) canvas;
            canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            if (!zoomLock && (operation == Operation.SELECT || operation == Operation.RESIZE) && hoveredPart != null) {
                if (hoveredPart instanceof Tree || hoveredPart instanceof Human) {
                    canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
                } else if (hoveredPart instanceof SolarCollector) {
                    if (pick.getEditPointIndex() >= 0) {
                        canvasComponent.setCursor(Cursor.getPredefinedCursor(pick.getEditPointIndex() == 0 ? Cursor.MOVE_CURSOR : Cursor.HAND_CURSOR));
                    }
                } else {
                    if (pick.getEditPointIndex() == -1) {
                        if (hoveredPart instanceof Window) {
                            // for windows, there is no apparent move point
                            canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
                        }
                    }
                }
            }
        }
    });
}
Also used : Window(org.concord.energy3d.model.Window) Human(org.concord.energy3d.model.Human) ArrayList(java.util.ArrayList) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) Meshable(org.concord.energy3d.model.Meshable) SolarCollector(org.concord.energy3d.model.SolarCollector) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) ArrayList(java.util.ArrayList) List(java.util.List) Component(java.awt.Component) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 10 with Tree

use of org.concord.energy3d.model.Tree in project energy3d by concord-consortium.

the class EnergyAngularAnalysis method show.

public void show(final String title) {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    String s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
    if (selectedPart instanceof Foundation) {
        s = s.replaceAll("Foundation", "Building");
        if (selectedPart.getChildren().isEmpty()) {
            JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no building on this foundation.", "No Building", JOptionPane.WARNING_MESSAGE);
            return;
        }
        if (!isBuildingComplete((Foundation) selectedPart)) {
            if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "The selected building has not been completed.\nAre you sure to continue?", "Incomplete Building", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }
    } else if (selectedPart instanceof Tree) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "Energy analysis is not applicable to a tree.", "Not Applicable", JOptionPane.WARNING_MESSAGE);
        return;
    }
    final JDialog dialog = new JDialog(MainFrame.getInstance(), title + ": " + s, true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    graph.parent = dialog;
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    final JMenuItem miClear = new JMenuItem("Clear Previous Results");
    final JMenuItem miView = new JMenuItem("View Raw Data...");
    final JMenuItem miCopyImage = new JMenuItem("Copy Image");
    final JMenu menu = new JMenu("Options");
    menu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            miClear.setEnabled(graph.hasRecords());
            miView.setEnabled(graph.hasData());
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    menuBar.add(menu);
    miClear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            final int i = JOptionPane.showConfirmDialog(dialog, "Are you sure that you want to clear all the previous results\nrelated to the selected object?", "Confirmation", JOptionPane.YES_NO_OPTION);
            if (i != JOptionPane.YES_OPTION) {
                return;
            }
            graph.clearRecords();
            graph.repaint();
            TimeSeriesLogger.getInstance().logClearGraphData(graph.getClass().getSimpleName());
        }
    });
    menu.add(miClear);
    miView.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            DataViewer.viewRawData(dialog, graph, false);
        }
    });
    menu.add(miView);
    miCopyImage.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            new ClipImage().copyImageToClipboard(graph);
        }
    });
    menu.add(miCopyImage);
    final JMenu showTypeMenu = new JMenu("Types");
    showTypeMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            showTypeMenu.removeAll();
            final Set<String> dataNames = graph.getDataNames();
            if (!dataNames.isEmpty()) {
                JMenuItem mi = new JMenuItem("Show All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final String name : dataNames) {
                            graph.hideData(name, false);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowCurve(graph.getClass().getSimpleName(), "All", true);
                    }
                });
                showTypeMenu.add(mi);
                mi = new JMenuItem("Hide All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final String name : dataNames) {
                            graph.hideData(name, true);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowCurve(graph.getClass().getSimpleName(), "All", false);
                    }
                });
                showTypeMenu.add(mi);
                showTypeMenu.addSeparator();
                for (final String name : dataNames) {
                    final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(name, !graph.isDataHidden(name));
                    cbmi.addItemListener(new ItemListener() {

                        @Override
                        public void itemStateChanged(final ItemEvent e) {
                            graph.hideData(name, !cbmi.isSelected());
                            graph.repaint();
                            TimeSeriesLogger.getInstance().logShowCurve(graph.getClass().getSimpleName(), name, cbmi.isSelected());
                        }
                    });
                    showTypeMenu.add(cbmi);
                }
            }
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    menuBar.add(showTypeMenu);
    final JMenu showRunsMenu = new JMenu("Runs");
    showRunsMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(final MenuEvent e) {
            showRunsMenu.removeAll();
            if (!AngularGraph.records.isEmpty()) {
                JMenuItem mi = new JMenuItem("Show All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final Results r : AngularGraph.records) {
                            graph.hideRun(r.getID(), false);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowRun(graph.getClass().getSimpleName(), "All", true);
                    }
                });
                showRunsMenu.add(mi);
                mi = new JMenuItem("Hide All");
                mi.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        for (final Results r : AngularGraph.records) {
                            graph.hideRun(r.getID(), true);
                        }
                        graph.repaint();
                        TimeSeriesLogger.getInstance().logShowRun(graph.getClass().getSimpleName(), "All", false);
                    }
                });
                showRunsMenu.add(mi);
                showRunsMenu.addSeparator();
                for (final Results r : AngularGraph.records) {
                    final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(Integer.toString(r.getID()), !graph.isRunHidden(r.getID()));
                    cbmi.addItemListener(new ItemListener() {

                        @Override
                        public void itemStateChanged(final ItemEvent e) {
                            graph.hideRun(r.getID(), !cbmi.isSelected());
                            graph.repaint();
                            TimeSeriesLogger.getInstance().logShowRun(graph.getClass().getSimpleName(), "" + r.getID(), cbmi.isSelected());
                        }
                    });
                    showRunsMenu.add(cbmi);
                }
            }
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });
    menuBar.add(showRunsMenu);
    final JPanel contentPane = new JPanel(new BorderLayout());
    dialog.setContentPane(contentPane);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEtchedBorder());
    contentPane.add(panel, BorderLayout.CENTER);
    panel.add(graph, BorderLayout.CENTER);
    final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    runButton = new JButton("Run");
    runButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            runButton.setEnabled(false);
            runAnalysis(dialog);
        }
    });
    buttonPanel.add(runButton);
    final JButton button = new JButton("Close");
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            stopAnalysis();
            if (graph.hasData()) {
                final Object[] options = { "Yes", "No", "Cancel" };
                final int i = JOptionPane.showOptionDialog(dialog, "Do you want to keep the results of this run?", "Confirmation", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]);
                if (i == JOptionPane.CANCEL_OPTION) {
                    return;
                }
                if (i == JOptionPane.YES_OPTION) {
                    graph.keepResults();
                }
            }
            windowLocation.setLocation(dialog.getLocationOnScreen());
            dialog.dispose();
        }
    });
    buttonPanel.add(button);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            stopAnalysis();
            windowLocation.setLocation(dialog.getLocationOnScreen());
            dialog.dispose();
        }
    });
    dialog.pack();
    if (windowLocation.x > 0 && windowLocation.y > 0) {
        dialog.setLocation(windowLocation);
    } else {
        dialog.setLocationRelativeTo(MainFrame.getInstance());
    }
    dialog.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) Set(java.util.Set) FlowLayout(java.awt.FlowLayout) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) BorderLayout(java.awt.BorderLayout) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) JMenuItem(javax.swing.JMenuItem) HousePart(org.concord.energy3d.model.HousePart) MenuEvent(javax.swing.event.MenuEvent) ClipImage(org.concord.energy3d.util.ClipImage) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) ItemListener(java.awt.event.ItemListener) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

Tree (org.concord.energy3d.model.Tree)28 HousePart (org.concord.energy3d.model.HousePart)26 Foundation (org.concord.energy3d.model.Foundation)24 Human (org.concord.energy3d.model.Human)19 Window (org.concord.energy3d.model.Window)12 Rack (org.concord.energy3d.model.Rack)10 Roof (org.concord.energy3d.model.Roof)9 SolarPanel (org.concord.energy3d.model.SolarPanel)9 Wall (org.concord.energy3d.model.Wall)8 Vector3 (com.ardor3d.math.Vector3)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 JDialog (javax.swing.JDialog)7 Door (org.concord.energy3d.model.Door)7 Floor (org.concord.energy3d.model.Floor)7 SolarCollector (org.concord.energy3d.model.SolarCollector)7 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)6 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 JPanel (javax.swing.JPanel)6