Package simtools.diagram

Examples of simtools.diagram.DiagramComponent


    public SourceTree(DataSourcePool pool) {
        super(pool);
        addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) {
                    DiagramComponent d = JSynoptic.gui.getActiveComponent();
                    if (d != null) {
                        if (!d.getDiagramSelection().isEmpty()) {
                            d.getDiagramSelection().unselect();
                            d.repaint();
                        }
                    }
                }
            }
        });
View Full Code Here


        ShapesContainer sc = JSynoptic.gui.getActiveContainer();
        JPopupMenu popup;
        if (sc == null) {
            popup = new JPopupMenu();
        } else {
            DiagramComponent dc = sc.getComponent();
            if (dc == null) {
                return;
            }
            if (!(dc instanceof ShapesContainer.ShapesComponent)) {
                return;
View Full Code Here

    /**
     * Zoom in or zoom out in current diagram
     * @param zoomIn - if true zoom in, otherwise zoom out
     */
    protected void zoomDiagram(boolean zoomIn){
        DiagramComponent d = getActiveDiagram();
        if (d != null) {
            double newZoom =  (zoomIn)? d.getZoom()*DiagramComponent.ZOOM_FACTOR :  d.getZoom()/DiagramComponent.ZOOM_FACTOR;
            d.setZoom(newZoom);
            int zoomInt = (int) (d.getZoom() * 100) ;
            tfZoom.setText(zoomInt +  "%");
        }
    }
View Full Code Here

     * @return true if all sheets can be saved, false overwise
     */
    protected boolean saveAll() {
        boolean ret = true;
        for (Iterator it = desktopCardPanel.getComponentIterator(); it.hasNext();) {
            DiagramComponent d = (DiagramComponent) it.next();
            desktopCardPanel.selectComponent(d);
            ret &= save();
        }
        return ret;
    }
View Full Code Here

    /**
     * Sets the state of the cut, copy, remove... menu items and buttons
     */
    void setSelectionEditEnabled(boolean state) {
        if (state) {
            DiagramComponent d = getActiveDiagram();
            if (d != null) {
                DiagramSelection sel = d.getDiagramSelection();
                for (int i = 0; i < lockedShapes.size(); ++i) {
                    if (sel.isSelected((Shape) lockedShapes.get(i))) {
                        state = false;
                        break;
                    }
                }
            }
        }
        aCut.setEnabled(state);
        aCopy.setEnabled(state);
        aRemove.setEnabled(state);
        aFront.setEnabled(state);
        aForward.setEnabled(state);
        aBackward.setEnabled(state);
        aBack.setEnabled(state);

        DiagramComponent d = getActiveDiagram();
        boolean canAlign = false, canDistribute = false;
        if (state && (d != null) && (d.getDiagramSelection() != null)) {
            canAlign = (d.getDiagramSelection().getShapeCount() > 1);
            canDistribute = (d.getDiagramSelection().getShapeCount() > 2);
        }
        aLeft.setEnabled(canAlign);
        aRight.setEnabled(canAlign);
        aTop.setEnabled(canAlign);
        aBottom.setEnabled(canAlign);
View Full Code Here

            setShapeToolEnabled(false);
            setDiagramComponentSpecificsEnabled(false);
            updateUndoActions();
    
        } else {
            DiagramComponent dc = (DiagramComponent) d;
            DiagramSelection sel = dc.getDiagramSelection();
            sel.addListener(this);
            selectionChanged(sel);
            setDiagramComponentSpecificsEnabled(true);
            setShapeToolEnabled(true);
           
            // update grid combo box
            if (cbxGrid != null) {
                String si = String.valueOf(dc.getGrid());
                boolean found = false;
                for (int i = 0; i < cbxGrid.getItemCount(); i++) {
                    String s = (String) cbxGrid.getItemAt(i);
                    if (si.equals(s)) {
                        cbxGrid.setSelectedIndex(i);
                        found = true;
                    }
                }
                if (!found) {
                    cbxGrid.getEditor().setItem(si);
                }
            }
            // update grid display check box
            if (tbGridDisplay != null) {
                tbGridDisplay.setSelected(dc.getGridDisplay());
            }
            // update zoom combo box
            if (tfZoom != null) {
                int zoomInt = (int) (dc.getZoom() * 100.0);
                tfZoom.setText(zoomInt +  "%");
            }
           
            // update diagram component shape creator
            if (isEditable && shapeToolBar!=null){
                dc.setElementCreator(shapeToolBar.getCurrentShapeCreateCreator());
            }

           
            // undo actions
            updateUndoActions();
View Full Code Here

            desktopCardPanel.getSelectedComponent().repaint();
        } else if ((e.getSource() == bRedo) || (e.getSource() == miRedo)) {
            redoAction.actionPerformed(e);
            desktopCardPanel.getSelectedComponent().repaint();
        } else if (e.getSource() == bAdjust) {
            DiagramComponent d = getActiveDiagram();
            if (d != null) {
                d.adjust();
            }
            return;
        } else if (e.getSource() == bAlign) {
            DiagramComponent d = getActiveDiagram();
            if (d != null) {
                d.align();
            }
            return;
        } else if (e.getSource() == cbxGrid) {
            DiagramComponent d = getActiveDiagram();
            if (d == null) {
                return;
            }
            int value = 0;
            try {
                value = Long.decode((String) cbxGrid.getSelectedItem()).intValue();
            } catch (Exception eg) {
                value = 0;
            }
            d.setGrid(value);
            return;
        } else if (e.getSource() == tfZoom) {
            DiagramComponent d = getActiveDiagram();
            if (d == null) {
                return;
            }
            int value = 0;
            try {
                String zoomInt =  tfZoom.getText();
                if (zoomInt.endsWith("%")) {
                    zoomInt = zoomInt.substring(0, zoomInt.length() - 1);
                }
                value = Long.decode(zoomInt).intValue();
            } catch (Exception eg) {
                value = 100;
            }

            d.setZoom((double) value / 100.0);

            int zoomInt = (int)( d.getZoom() * 100) ;
            tfZoom.setText(zoomInt +  "%");
            return;

        } else if (e.getSource() == tbGridDisplay) {
            DiagramComponent d = getActiveDiagram();
            if (d == null) {
                return;
            }
            d.setGridDisplay(tbGridDisplay.isSelected());

        } else if (source == miSheetDisplay) {
            setupSheetDisplay();

        } else if ((source == miPrint) || (source == bPrint)) {
            print(getActiveDiagram());

        } else if ((source == miPrintImage) || (source == bPrintImage)) {
            if (!canPrint()) {
                return; // In fact, should not happen at this point
            }
            DiagramComponent d = getActiveDiagram();
            if (d == null) {
                return;
            }
            if (printImage == null) {
                printImage = new PrintToImage();
            }
            try {
                printImage.print(d, this.getActiveContainer().getDiagramParameters().backgr);
            } catch (Exception ex) {
                setStatus(messageWriter.print2args("cannotExport", d.toString(), ex.getMessage()));
                ex.printStackTrace();
            }
        } else if ((source == miSnapShot) || (source == bSnapShot)) {
            if (!canPrint()) {
                return; // In fact, should not happen at this point
            }
            DiagramComponent d = getActiveDiagram();
            if (d == null) {
                return;
            }
            try {
                ImageViewer imageViewer = new ImageViewer(getOwner(), resources.getString("snapshot"));
                imageViewer.setImage(getActiveDiagram(), this.getActiveContainer().getDiagramParameters().backgr);
                imageViewer.setLocation(getOwner().getLocation());
                imageViewer.setSize(desktopCardPanel.getWidth(), desktopCardPanel.getHeight());
                imageViewer.setVisible(true);
            } catch (Exception ex) {
                setStatus(messageWriter.print1args("printFailed", ex.getMessage()));
                ex.printStackTrace();
            }
        } else if (e.getSource() == miChooseLanguage) {
            DefaultListModel listModel = new DefaultListModel();
            int nlang = resources.getIntValue("languageNumber");
            String oldcode = Run.getProperties().getString("jsynoptic.language", "");
            int sel = -1;
            for (int i = 0; i < nlang; ++i) {
                listModel.addElement(resources.getStringValue("languageName" + i));
                if (resources.getStringValue("languageCode" + i).equals(oldcode)) {
                    sel = i;
                }
            }
            JList langlist = new JList(listModel);
            langlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            if (sel != -1) {
                langlist.setSelectedIndex(sel);
            }
            int result = JOptionPane.showConfirmDialog(owner, langlist, resources.getString("chooseLanguageTitle"),
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
            if ((result == JOptionPane.OK_OPTION) && (langlist.getSelectedIndex() != -1)) {
                String code = resources.getStringValue("languageCode" + langlist.getSelectedIndex());
                Run.getProperties().setString("jsynoptic.language", (code != null) ? code : "");
            }
        } else if (e.getSource() == miFindPlugins) {
            setStatus(messageWriter.print0args("lookingForPlugins"));
            new LongAction() {
                protected void doAction() {
                    if (PluginLookup.addPluginPaths(true, owner)) {
                        userProperties.setString("jsynoptic.class.path", PluginLookup.getClassPath());
                        Vector plugins = PluginLookup.lookup();
                        String[] plugs = new String[plugins.size()];
                        boolean[] checked = new boolean[plugins.size()];
                        for (int k = 0; k < plugins.size(); k++) {
                            plugs[k] = (String) plugins.get(k);
                            checked[k] = true;
                        }
                        boolean[] res = CheckBoxList.openDialog(messageWriter.print0args("foundPlugins"), owner, plugs,
                                checked);
                        if (res != null) {
                            String defaultPlugins = "";
                            for (int k = 0; k < plugins.size(); k++) {
                                if (res[k]) {
                                    if (!defaultPlugins.equals("")) {
                                        defaultPlugins += ",";
                                    }
                                    defaultPlugins += plugs[k];
                                }
                            }
                            if (!defaultPlugins.equals("")) {
                                userProperties.setString("jsynoptic.plugins", defaultPlugins);
                                JOptionPane.showMessageDialog(getOwner(),
                                        messageWriter.print0args("restartForPlugins"), messageWriter
                                        .print0args("Plugins:"), JOptionPane.INFORMATION_MESSAGE);
                            }
                        }
                    }
                }
            }.start();
            return;
        } else if (e.getSource() == miPreferencesPanel) {
            // Do always create a new instance of UPE, to have new contents, and
            // not
            // duplication of properties at each dialog call.
            propEditor = new UserPropertiesEditor(owner);
            setStaticProperties(userProperties);
            if (propEditor.showAndUpdate(userProperties, true, Run.productName)) {
                getStaticProperties(userProperties);
            }
            return;
        } else if (e.getSource() == miAbout) {
            if (aboutFrame == null) {
                aboutFrame = new JFrame(messageWriter.print1args("aboutTitle", Run.productName));
                String content = messageWriter.print0args("aboutContent");
                boolean pluginLineWritten = false;
                for (Iterator it = Run.plugins.iterator(); it.hasNext();) {
                    Plugin p = (Plugin) it.next();
                    String text = p.about();
                    if (text == null) {
                        continue;
                    }
                    if (!pluginLineWritten) {
                        content += "<p>" + messageWriter.print0args("Plugins:") + "<ul>";
                        pluginLineWritten = true;
                    }
                    content += "<li>" + p.about() + "</li>";
                }
                if (pluginLineWritten) {
                    content += "</ul></p>";
                }
                JEditorPane jdp = new JEditorPane("text/html", content);
                jdp.setEditable(false);
                aboutFrame.getContentPane().setLayout(new BoxLayout(aboutFrame.getContentPane(), BoxLayout.Y_AXIS));
                // Set Header
                JPanel header = new JPanel(new BorderLayout());
                header.setBackground(Color.WHITE);
                JLabel headerLogo = new JLabel(resources.getIcon("jsynIconHightResIcon"));
                headerLogo.setBackground(Color.WHITE);
                header.add(headerLogo, BorderLayout.WEST);
                JLabel hearderTitle = new JLabel(messageWriter.print1args("aboutVersion", Run.fullProductVersion));
                hearderTitle.setFont(new Font("Dialog", Font.PLAIN, 25));
                hearderTitle.setOpaque(true);
                hearderTitle.setBackground(Color.WHITE);
                header.add(hearderTitle, BorderLayout.EAST);
                aboutFrame.getContentPane().add(header);
                aboutFrame.getContentPane().add(jdp);
                aboutFrame.pack();
                aboutFrame.doLayout();
            }
            aboutFrame.setVisible(true);
            return;
        } else if (e.getSource() == miHelp) {
            if (helpFrame == null) {
                helpFrame = new HelpViewer(getOwner(), messageWriter.print0args("helpContentTitle"));
                helpFrame.setLocation(getOwner().getLocation());
                helpFrame.setSize(getOwner().getWidth(), getOwner().getHeight());
            }
            helpFrame.setVisible(true);
            return;
        } else if (e.getSource() == miSheetInformation) {
            if (!canPrint()) {
                return; // In fact, should not happen at this point
            }
            DiagramComponent d = getActiveDiagram();
            if (d == null) {
                return;
            }
            ShapesContainer c = getActiveContainer();
            if (c == null) {
View Full Code Here

        if ((actionMask & LongAction.LONG_ACTION_PRINT) != 0) {
            lockPrint();
        }
        if ((actionMask & LongAction.LONG_ACTION_SHAPE) != 0) {
            boolean changesDone = false;
            DiagramComponent d = getActiveDiagram();
            DiagramSelection sel = (d == null) ? null : d.getDiagramSelection();
            if (target != null) {
                if (target instanceof Shape) {
                    lockedShapes.add(target);
                    if ((sel != null) && sel.isSelected((Shape) target)) {
                        changesDone = true;
View Full Code Here

        if ((actionMask & LongAction.LONG_ACTION_PRINT) != 0) {
            unlockPrint();
        }
        if ((actionMask & LongAction.LONG_ACTION_SHAPE) != 0) {
            boolean changesDone = false;
            DiagramComponent d = getActiveDiagram();
            DiagramSelection sel = (d == null) ? null : d.getDiagramSelection();
            if (target != null) {
                if (target instanceof Shape) {
                    lockedShapes.remove(target);
                    if ((sel != null) && sel.isSelected((Shape) target)) {
                        changesDone = true;
View Full Code Here

                resources.getString("noAll"),
                resources.getString("cancel")
        };

        for (Iterator it = desktopCardPanel.getComponentIterator(); it.hasNext() && !noToallOption && canCloseSheets;) {           
            DiagramComponent d = (DiagramComponent) it.next();
            if (JSynopticPanels.ASK_USER_TO_SAVE_A_MODIFIED_SHEET && d.hasBeenModified()) {

                if (!yesToallOption){
                    int i = JOptionPane.showOptionDialog(
                            getOwner(),
                            d.getName().substring(1) + messageWriter.print0args("savingBeforeClosingConfirmation"),
                            d.getName().substring(1),
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE,
                            null,
                            buttons,
                            buttons[0]);


                    if ( (i == JOptionPane.CLOSED_OPTION) || (i == 4) ) {
                        canCloseSheets = false;;

                    } else if (i == 0) {
                        desktopCardPanel.selectComponent(d);
                        save();

                    } else if (i == 1) {
                        yesToallOption = true;

                    else if (i == 3) {
                        noToallOption = true;
                    }
                }

                if (yesToallOption){
                    desktopCardPanel.selectComponent(d);
                    save();
                }  
            }
        }
        if(canCloseSheets){
            // clean resources
            for (Iterator it = desktopCardPanel.getComponentIterator(); it.hasNext();) {           
                DiagramComponent d = (DiagramComponent) it.next();

                // release resources
                if(d instanceof ShapesComponent){
                    ShapesContainer sc = (ShapesContainer)((ShapesComponent)d).getContainer();
View Full Code Here

TOP

Related Classes of simtools.diagram.DiagramComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.