Example usage for java.awt BorderLayout EAST

List of usage examples for java.awt BorderLayout EAST

Introduction

In this page you can find the example usage for java.awt BorderLayout EAST.

Prototype

String EAST

To view the source code for java.awt BorderLayout EAST.

Click Source Link

Document

The east layout constraint (right side of container).

Usage

From source file:userinterface.graph.SeriesEditorDialog.java

/** This method is called from within the constructor to
 * initialize the form.//  w w w.  j a v  a  2  s .c  o m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    allPanel = new javax.swing.JPanel();
    bottomPanel = new javax.swing.JPanel();
    buttonPanel = new javax.swing.JPanel();
    okayButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    editorPanel = new javax.swing.JPanel();
    tabbedPane = new javax.swing.JTabbedPane();
    toolBar = new javax.swing.JToolBar();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Series Data Editor");
    setAlwaysOnTop(true);
    setMinimumSize(new java.awt.Dimension(550, 350));
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog(evt);
        }
    });

    allPanel.setLayout(new java.awt.BorderLayout());

    allPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bottomPanel.setLayout(new java.awt.BorderLayout());

    buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));

    okayButton.setText("Okay");
    okayButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            okayButtonActionPerformed(evt);
        }
    });

    buttonPanel.add(okayButton);

    cancelButton.setText("Cancel");
    cancelButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
        }
    });

    buttonPanel.add(cancelButton);

    bottomPanel.add(buttonPanel, java.awt.BorderLayout.EAST);

    allPanel.add(bottomPanel, java.awt.BorderLayout.SOUTH);

    editorPanel.setLayout(new java.awt.BorderLayout());

    tabbedPane.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
    editorPanel.add(tabbedPane, java.awt.BorderLayout.CENTER);

    allPanel.add(editorPanel, java.awt.BorderLayout.CENTER);

    toolBar.setFloatable(false);
    allPanel.add(toolBar, java.awt.BorderLayout.NORTH);

    getContentPane().add(allPanel, java.awt.BorderLayout.CENTER);

}

From source file:com.midas.classify.gui.DecisionTreeViewer.java

public DecisionTreeViewer(DelegateTree<TreeNode, TreeEdge> tr, String[] cls) {
    setLayout(new BorderLayout());

    // ---------------------------------------------- //
    // INICIALIZACION DE COMPONENTES DE VISUALIZACION //
    // ---------------------------------------------- //
    tree = tr;//from w ww  .  ja v  a  2s . c om
    classNames = cls;
    classColors = new TreeMap();

    nodeColor = Color.BLUE;
    for (int i = 0; i < cls.length; ++i) {
        classColors.put(cls[i], Color.RED);
    }

    leafNodes = new TreeSet();
    for (TreeNode n : tr.getVertices()) {
        if (tr.isLeaf(n)) {
            for (String s : cls) {
                if (n.toString().startsWith(s)) {
                    leafNodes.add(s);
                    break;
                }
            }
        }
    }

    TreeLayout<TreeNode, TreeEdge> layout = new TreeLayout(tr);

    vv = new VisualizationViewer(layout);
    vv.setBackground(Color.white);

    vv.getRenderContext().setEdgeFontTransformer(new EdgeFontTransformer());
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<TreeNode, TreeEdge>());

    PickedState<TreeNode> picked_state = vv.getPickedVertexState();

    vv.getRenderContext().setVertexFillPaintTransformer(new VertexFillColorTransformer<TreeNode>(picked_state));
    vv.getRenderContext().setVertexDrawPaintTransformer(new VertexDrawColorTransformer<TreeNode>(picked_state));
    vv.getRenderContext().setVertexFontTransformer(new VertexFontTransformer());

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());

    GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv);
    gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final ScalingControl scaler = new CrossoverScalingControl();

    // ---------------------------------------- //
    // INICIALIZACION DE COMPONENTES DE CONTROL //
    // ---------------------------------------- //

    fontChooser = new JFontChooser();

    JPanel pControl = new JPanel(new GridLayout(7, 1, 4, 2));

    JPanel pZoom = new JPanel(new GridLayout(1, 2, 2, 2));
    pZoom.setBorder(new TitledBorder("Zoom"));

    bZoomIn = new JButton("+");
    bZoomIn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });

    bZoomOut = new JButton("-");
    bZoomOut.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });
    pZoom.add(bZoomIn);
    pZoom.add(bZoomOut);

    JPanel pFont = new JPanel(new GridLayout(1, 2, 2, 2));
    pFont.setBorder(new TitledBorder("Fonts"));

    bNodeFont = new JButton("Node Font");
    bNodeFont.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fontChooser.showDialog(null);
            if (r == JFontChooser.OK_OPTION) {
                nodeFont = fontChooser.getSelectedFont();
                vv.repaint();
            }
        }
    });

    bEdgeFont = new JButton("Edge Font");
    bEdgeFont.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fontChooser.showDialog(null);
            if (r == JFontChooser.OK_OPTION) {
                edgeFont = fontChooser.getSelectedFont();
                vv.repaint();
            }
        }
    });

    pFont.add(bNodeFont);
    pFont.add(bEdgeFont);

    bNodeColor = new JButton("Node Color");
    bNodeColor.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            nodeColor = JColorChooser.showDialog(null, "Select color for intern nodes", Color.RED);
            vv.repaint();
        }
    });

    JPanel pMode = new JPanel();
    pMode.setBorder(new TitledBorder("Mode"));

    cbMode = new JComboBox();
    cbMode.addItem(ModalGraphMouse.Mode.TRANSFORMING);
    cbMode.addItem(ModalGraphMouse.Mode.PICKING);
    cbMode.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            gm.setMode((ModalGraphMouse.Mode) e.getItem());
        }
    });

    pMode.add(cbMode);

    JPanel pColors = new JPanel(new GridLayout(1, 2, 2, 2));
    pColors.setBorder(new TitledBorder("Node Colors"));

    cbClasses = new JComboBox(classNames);
    cbClasses.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Color c = JColorChooser.showDialog(null, "Select class color for " + cbClasses.getSelectedItem(),
                    Color.RED);
            classColors.put(cbClasses.getSelectedItem().toString(), c);
            vv.repaint();
        }
    });
    pColors.add(cbClasses);
    pColors.add(bNodeColor);

    JPanel pLabelPosition = new JPanel();
    pLabelPosition.setBorder(new TitledBorder("Label Position"));

    cbLabelPosition = new JComboBox();
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.N);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.NE);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.E);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.SE);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.S);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.SW);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.W);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.NW);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.N);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.CNTR);
    cbLabelPosition.addItem(Renderer.VertexLabel.Position.AUTO);

    cbLabelPosition.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem();
            vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            vv.repaint();
        }
    });
    cbLabelPosition.setSelectedItem(Renderer.VertexLabel.Position.SE);

    pLabelPosition.add(cbLabelPosition);

    chkShowEdgeNames = new JCheckBox("Show Edge Name");
    chkShowEdgeNames.addActionListener(new ActionListener() {
        ToStringLabeller strLabeller = new ToStringLabeller();
        ConstantTransformer none = new ConstantTransformer(null);

        @Override
        public void actionPerformed(ActionEvent e) {
            AbstractButton src = (AbstractButton) e.getSource();
            if (src.isSelected()) {
                vv.getRenderContext().setEdgeLabelTransformer(strLabeller);
            } else {
                vv.getRenderContext().setEdgeLabelTransformer(none);
            }
            vv.repaint();
        }
    });
    chkShowEdgeNames.setSelected(true);

    chkShowNodeNames = new JCheckBox("Show Node Name");
    chkShowNodeNames.addActionListener(new ActionListener() {
        ToStringLabeller strLabeller = new ToStringLabeller();
        ConstantTransformer none = new ConstantTransformer(null);

        @Override
        public void actionPerformed(ActionEvent e) {
            AbstractButton src = (AbstractButton) e.getSource();
            if (src.isSelected()) {
                vv.getRenderContext().setVertexLabelTransformer(strLabeller);
            } else {
                vv.getRenderContext().setVertexLabelTransformer(none);
            }
            vv.repaint();
        }
    });
    chkShowNodeNames.setSelected(true);

    pControl.add(pZoom);
    pControl.add(pFont);
    pControl.add(pMode);
    pControl.add(pLabelPosition);
    pControl.add(pColors);
    pControl.add(chkShowNodeNames);
    pControl.add(chkShowEdgeNames);

    // Agregar componentes al panel
    add(scrollPane);

    JPanel p = new JPanel(new FlowLayout());
    p.add(pControl);
    add(p, BorderLayout.EAST);
}

From source file:org.isatools.isacreatorconfigurator.ontologyconfigurationtool.OntologyConfigUI.java

private JPanel createButtonPanel() {
    // contains the button to confirm selection of ontology plus filter part (if applicable!)
    JPanel buttonPanel = new JPanel(new BorderLayout());

    final JLabel button = new JLabel(confirmButton);
    button.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            button.setIcon(confirmButtonOver);
        }//from   w  w w .  j  ava 2s .  c  o m

        public void mouseExited(MouseEvent mouseEvent) {
            button.setIcon(confirmButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {

            Set<String> ontLabelsToRemove = new HashSet<String>();
            for (String ontLabel : selectedOntologies.keySet()) {
                if (getOntologyByLabel(ontLabel) != null) {
                    selectedOntologies.get(ontLabel)
                            .setBranchToSearchUnder(getOntologyByLabel(ontLabel).getSubsectionToQuery());
                } else {

                    ontLabelsToRemove.add(ontLabel);
                }
            }

            // remove deprecated ontologies :)
            for (String ontology : ontLabelsToRemove) {
                if (selectedOntologies.containsKey(ontology)) {
                    selectedOntologies.remove(ontology);
                }
            }

            firePropertyChange("ontologySelected", "", selectedOntologies);
            setVisible(false);
            dispose();
        }
    });

    buttonPanel.add(button, BorderLayout.EAST);
    return buttonPanel;
}

From source file:edu.uci.ics.jung.samples.PerspectiveTransformerDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoom and perspective features.
 * //from  w  w  w  .ja v  a2 s.c o m
 */
@SuppressWarnings("serial")
public PerspectiveTransformerDemo() {

    // create a simple graph for the demo
    graph = TestGraphs.getOneComponentGraph();

    graphLayout = new FRLayout<String, Number>(graph);
    ((FRLayout<String, Number>) graphLayout).setMaxIterations(1000);

    Dimension preferredSize = new Dimension(600, 600);
    Map<String, Point2D> map = new HashMap<String, Point2D>();
    Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map);
    grid = this.generateVertexGrid(map, preferredSize, 25);
    gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize);

    final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            graphLayout, preferredSize);
    vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    PickedState<Number> pes = vv.getPickedEdgeState();
    vv.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv.getRenderContext().setVertexShapeTransformer(new Transformer<String, Shape>() {

        public Shape transform(String v) {
            return new Rectangle2D.Float(-10, -10, 20, 20);
        }
    });
    vv.setBackground(Color.white);

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<String>());

    Container content = getContentPane();
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp);

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();

    vv.setGraphMouse(graphMouse);

    viewSupport = new PerspectiveViewTransformSupport<String, Number>(vv);
    layoutSupport = new PerspectiveLayoutTransformSupport<String, Number>(vv);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 0.9f, vv.getCenter());
        }
    });
    final JSlider horizontalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(80, super.getPreferredSize().height);
        }
    };

    final JSlider verticalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 80);
        }
    };
    verticalSlider.setOrientation(JSlider.VERTICAL);
    final ChangeListener changeListener = new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int vval = -verticalSlider.getValue();
            int hval = horizontalSlider.getValue();

            Dimension d = vv.getSize();
            PerspectiveTransform pt = null;
            pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval,
                    d.height + hval, -vval, d.height - hval,

                    0, 0, d.width, 0, d.width, d.height, 0, d.height);

            viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            vv.repaint();
        }
    };
    horizontalSlider.addChangeListener(changeListener);
    verticalSlider.addChangeListener(changeListener);

    JPanel perspectivePanel = new JPanel(new BorderLayout());
    JPanel perspectiveCenterPanel = new JPanel(new BorderLayout());
    perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls"));
    final JButton center = new JButton("Center");
    center.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            horizontalSlider.setValue(0);
            verticalSlider.setValue(0);
        }
    });
    ButtonGroup radio = new ButtonGroup();
    JRadioButton normal = new JRadioButton("None");
    normal.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            if (selected) {
                if (viewSupport != null) {
                    viewSupport.deactivate();
                }
                if (layoutSupport != null) {
                    layoutSupport.deactivate();
                }
            }
            center.setEnabled(!selected);
            horizontalSlider.setEnabled(!selected);
            verticalSlider.setEnabled(!selected);
        }
    });

    final JRadioButton perspectiveView = new JRadioButton("In View");
    perspectiveView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton perspectiveModel = new JRadioButton("In Layout");
    perspectiveModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    radio.add(normal);
    radio.add(perspectiveModel);
    radio.add(perspectiveView);
    normal.setSelected(true);

    ButtonGroup graphRadio = new ButtonGroup();
    JRadioButton graphButton = new JRadioButton("Graph");
    graphButton.setSelected(true);
    graphButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(graphLayout);
                vv.repaint();
            }
        }
    });
    JRadioButton gridButton = new JRadioButton("Grid");
    gridButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(gridLayout);
                vv.repaint();
            }
        }
    });
    graphRadio.add(graphButton);
    graphRadio.add(gridButton);

    JPanel modePanel = new JPanel(new GridLayout(2, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Display"));
    modePanel.add(graphButton);
    modePanel.add(gridButton);

    JMenuBar menubar = new JMenuBar();
    menubar.add(graphMouse.getModeMenu());
    gzsp.setCorner(menubar);

    Container controls = new JPanel(new BorderLayout());
    JPanel zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel perspectiveControls = new JPanel(new GridLayout(3, 1));
    zoomControls.add(plus);
    zoomControls.add(minus);
    perspectiveControls.add(normal);
    perspectiveControls.add(perspectiveModel);
    perspectiveControls.add(perspectiveView);

    controls.add(zoomControls, BorderLayout.WEST);
    controls.add(modePanel);
    perspectivePanel.add(perspectiveControls, BorderLayout.WEST);
    perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH);
    perspectivePanel.add(verticalSlider, BorderLayout.EAST);
    perspectiveCenterPanel.add(center);
    perspectivePanel.add(perspectiveCenterPanel);
    controls.add(perspectivePanel, BorderLayout.EAST);

    content.add(controls, BorderLayout.SOUTH);
}

From source file:org.isatools.gui.datamanager.exportisa.ExportISAGUI.java

private JPanel createSouthPanel() {
    JPanel southPanel = new JPanel(new BorderLayout());
    southPanel.setOpaque(false);/*from   w ww. ja  v a 2 s  .c  o m*/

    errorDisplay = new JLabel(warningIcon);
    UIHelper.renderComponent(errorDisplay, UIHelper.VER_11_BOLD, UIHelper.LIGHT_GREY_COLOR, false);
    errorDisplay.setVisible(false);

    southPanel.add(UIHelper.wrapComponentInPanel(errorDisplay), BorderLayout.NORTH);

    southPanel.add(createBackToMainMenuButton(), BorderLayout.WEST);

    final JLabel exportISAButton = new JLabel(exportISAIcon);
    exportISAButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            exportISAButton.setIcon(exportISAIcon);

            if (!selectedOutputFolderExists() && !exportToRepository()) {
                localDirectoryLocation.setBackgroundToError();
            } else {
                if (studyAvailabilityTree.getCheckedStudies(studyAvailabilityTree.getRoot()).size() == 0) {
                    errorDisplay.setText("<html>please select <i>at least one study</i> to export!</html>");
                    errorDisplay.setVisible(true);
                } else {
                    errorDisplay.setVisible(false);
                    firePropertyChange("doISATabExport", "", "doExport");
                }
            }
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            exportISAButton.setIcon(exportISAIcon);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            exportISAButton.setIcon(exportISAIconOver);
        }
    });

    southPanel.add(exportISAButton, BorderLayout.EAST);

    return southPanel;
}

From source file:model.DrawTopologyDiagram.java

@Override
public void init() {

    //create a graph
    Graph<VertexTopology, Number> ig = Graphs.<VertexTopology, Number>synchronizedDirectedGraph(
            new DirectedSparseMultigraph<VertexTopology, Number>());

    ObservableGraph<VertexTopology, Number> og = new ObservableGraph<VertexTopology, Number>(ig);
    og.addGraphEventListener(new GraphEventListener<VertexTopology, Number>() {

        public void handleGraphEvent(GraphEvent<VertexTopology, Number> evt) {
            System.err.println("got " + evt);

        }// www .j  a v  a2 s  . c om
    });
    this.g = og;
    //layouts
    //create a graphdraw
    //        layout = new FRLayout2<String,Number>(g);
    //        layout = new SpringLayout<String,Number>(g);
    //        ((FRLayout)layout).setMaxIterations(200);
    layout = new KKLayout<VertexTopology, Number>(g);

    vv = new VisualizationViewer<VertexTopology, Number>(layout, new Dimension(600, 600));

    createGraph();

    Container content = getContentPane();
    JPanel totalCasesPanel = new JPanel();

    final JPanel scaleGrids = new JPanel(new GridLayout(0, 2));
    scaleGrids.add(new JLabel("   Test Cases      "));
    scaleGrids.add(new JLabel("       "));
    totalCasesPanel.add(scaleGrids);

    JPanel filteredCasesPanel = new JPanel();

    final JPanel filteredGrids = new JPanel(new GridLayout(0, 2));
    filteredGrids.add(new JLabel("   Filtered Cases      "));
    filteredGrids.add(new JLabel("       "));
    filteredCasesPanel.add(filteredGrids);

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    content.setLayout(new BorderLayout());
    content.setBackground(java.awt.Color.lightGray);
    content.setFont(new Font("Serif", Font.PLAIN, 12));

    vv.getModel().getRelaxer().setSleepTime(500);
    vv.setGraphMouse(new DefaultModalGraphMouse<VertexTopology, Number>());

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    vv.setForeground(Color.white);

    FontMetrics fm = vv.getFontMetrics(vv.getFont());
    int width = fm.stringWidth(g.toString());

    Transformer<VertexTopology, Shape> vertexSize = new Transformer<VertexTopology, Shape>() {
        public Shape transform(VertexTopology i) {

            Ellipse2D circle = new Ellipse2D.Double(-20, -20, 40, 40);
            // in this case, the vertex is twice as large                
            return circle;
        }

    };

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller() {
        @Override
        public String transform(Object v) {

            return ((VertexTopology) v).getScreenName();
        }
    });

    vv.getRenderContext().setVertexShapeTransformer(vertexSize);

    //Get picked states
    final PickedState<VertexTopology> pickedState = vv.getPickedVertexState();
    pickedState.addItemListener(new ItemListener() {
        ArrayList<TestCase> outputTestCase = new ArrayList<TestCase>();
        final Map<String, JButton> createdBtns = new HashMap<String, JButton>();

        Map<String, Integer> deviceSelected = new HashMap<String, Integer>(); // not useful

        ArrayList<String> endPointList = new ArrayList<String>();

        @Override
        public void itemStateChanged(ItemEvent e) {
            // TODO Auto-generated method stub
            Object subject = e.getItem();
            if (e.getStateChange() != 1) {
                scaleGrids.removeAll();
                filteredGrids.removeAll();
                endPointList.remove(getScreenName(subject));

                outputTestCase.clear();

                filteredGrids.repaint();
                filteredGrids.add(new JLabel("   Filtered Cases      "));
                filteredGrids.add(new JLabel("       "));

                scaleGrids.repaint();
                scaleGrids.add(new JLabel("   Test Cases      "));
                scaleGrids.add(new JLabel("       "));

                deviceSelected.clear();

            }
            if (e.getStateChange() == 1) {

                for (TestCase testCase : outputTestCase) {
                    scaleGrids.removeAll();
                    scaleGrids.add(new JLabel("   Test Cases      "));
                    scaleGrids.add(new JLabel("       "));

                    filteredGrids.removeAll();
                    filteredGrids.add(new JLabel("   Filtered Cases      "));
                    filteredGrids.add(new JLabel("       "));

                }

                if (subject instanceof VertexTopology) {
                    final VertexTopology edgePicked = (VertexTopology) subject;
                    if (pickedState.isPicked(edgePicked)) {

                        for (TestCase testCase : edgePicked.getTestCaseList()) {
                            if (!outputTestCase.contains(testCase))
                                outputTestCase.add(testCase);
                            System.out.println("The size for reference is " + testCase.inputReferenceMap.size()
                                    + testCase.getName());
                            System.out.println("The size for target is " + testCase.inputTargetMap.size()
                                    + testCase.getName());
                        }

                        if (deviceSelected.get(edgePicked.getScreenName()) != null)
                            deviceSelected.put(edgePicked.getScreenName(),
                                    deviceSelected.get(edgePicked.getScreenName()) + 1);
                        else
                            deviceSelected.put(edgePicked.getScreenName(), 1);

                        endPointList.add(edgePicked.getScreenName());

                    }
                }
            }

            for (TestCase testCase : outputTestCase) {
                JButton btnCase = new JButton(testCase.getName());
                scaleGrids.add(btnCase);

                if (testCase.getInputDeviceList().size() <= endPointList.size())
                    if (testCaseSelected(testCase, endPointList)) {
                        JButton btnCaseFiltered = new JButton(testCase.getName());
                        filteredGrids.add(btnCaseFiltered);
                    }
                ;

            }

            scaleGrids.revalidate();
            scaleGrids.setVisible(true);
        }

    });

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);

    content.setPreferredSize(new Dimension(1400, 900));
    content.add(vv);
    switchLayout = new JButton("Switch to SpringLayout");
    //        switchLayout.addActionListener(new ActionListener() {
    //
    //            @SuppressWarnings("unchecked")
    //            public void actionPerformed(ActionEvent ae) {
    //               Dimension d = new Dimension(600,600);
    //                if (switchLayout.getText().indexOf("Spring") > 0) {
    //                    switchLayout.setText("Switch to FRLayout");
    //                    layout = new SpringLayout<String,Number>(g,
    //                        new ConstantTransformer(EDGE_LENGTH));
    //                    layout.setSize(d);
    //                    vv.getModel().setGraphLayout(layout, d);
    //                } else {
    //                    switchLayout.setText("Switch to SpringLayout");
    //                    layout = new FRLayout<String,Number>(g, d);
    //                    vv.getModel().setGraphLayout(layout, d);
    //                }
    //            }
    //        });

    JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, totalCasesPanel, filteredCasesPanel);
    jSplitPane.setResizeWeight(.5d);

    content.add(switchLayout, BorderLayout.SOUTH);
    content.add(jSplitPane, BorderLayout.EAST);
}

From source file:org.n52.ifgicopter.spf.gui.SPFMainFrame.java

/**
 * the gui representation of the framework
 *//*from   w ww.  j a  v a  2  s .com*/
public SPFMainFrame() {

    /*
     * handled by worker thread.
     */
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    this.setTitle("Sensor Platform Framework");

    this.menu = new JMenuBar();

    try {
        File f = new File("img/icon.png");
        InputStream in;
        if (!f.exists()) {
            in = ImageMapMarker.class.getResourceAsStream("/img/icon.png");
        } else {
            in = new FileInputStream(f);
        }

        this.setIconImage(ImageIO.read(in));
    } catch (IOException e) {
        this.log.warn(e.getMessage(), e);
    }

    /*
     * simple menu bar
     */
    JMenu file = new JMenu("File");
    JMenuItem exit = new JMenuItem("Exit");

    /*
     * shutdown the engine if closed
     */
    exit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            shutdownFrame();
        }
    });

    this.pnp = new JCheckBoxMenuItem("Plug'n'Play mode");
    this.pnp.setSelected(false);

    /*
     * switch the pnp mode
     */
    this.pnp.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean flag = SPFMainFrame.this.pnp.isSelected();

            if (flag && !SPFMainFrame.this.dontShow) {
                JCheckBox checkbox = new JCheckBox("Do not show this message again.");
                String message = "During Plug'n'Play mode the output generation is blocked.";
                Object[] params = { message, checkbox };
                JOptionPane.showMessageDialog(SPFMainFrame.this, params);
                SPFMainFrame.this.dontShow = checkbox.isSelected();
            }

            /*
             * check if we need to restart the output plugins
             */
            if (!flag && SPFMainFrame.this.inputChanged) {
                SPFRegistry.getInstance().restartOutputPlugins();
            }

            SPFRegistry.getInstance().setPNPMode(flag);
        }
    });

    JMenuItem restart = new JMenuItem("Restart");
    restart.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            shutdownFrame(RESTART_CODE);
        }
    });

    JMenuItem managePlugins = new JMenuItem("Manage available Plugins");
    managePlugins.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PluginRegistrationDialog prd = new PluginRegistrationDialog(SPFMainFrame.this);

            if (prd.isCanceled())
                return;

            updateConfigurationFile(prd.getSelectedNewPlugins(), prd.getSelectedOldPlugins());

            int ret = JOptionPane.showConfirmDialog(SPFMainFrame.this,
                    "<html><body><div>" + "Changes will have effect after restart of the application. "
                            + "</div><div>A restart is highly recommended due to memory usage."
                            + "</div><div><br />Restart now?</div></body></html>",
                    "Restart application", JOptionPane.YES_NO_OPTION);

            if (ret == 0) {
                shutdownFrame(RESTART_CODE);
            }
        }
    });
    file.add(managePlugins);

    file.add(this.pnp);
    file.add(new FixedSeparator());
    file.add(restart);
    file.add(new FixedSeparator());
    file.add(exit);
    this.menu.add(file);
    this.inputPluginMenu = new JMenu("InputPlugins");
    this.outputPluginMenu = new JMenu("OutputPlugins");
    this.menu.add(this.inputPluginMenu);
    this.menu.add(this.outputPluginMenu);

    /*
     * help
     */
    this.aboutDialog = new AboutDialog(SPFMainFrame.this);
    JMenu help = new JMenu("Help");
    JMenuItem about = new JMenuItem("About");
    about.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SPFMainFrame.this.aboutDialog.showSelf(SPFMainFrame.this);
        }
    });

    help.add(about);
    this.menu.add(help);
    this.setJMenuBar(this.menu);

    /*
     * the tabbed pane. every tab represents a input plugin
     */
    this.pane = new JTabbedPane();
    this.pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    /*
     * shutdown the engine if closed
     */
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            SPFMainFrame.this.shutdownFrame();
        }

    });

    /*
     * the framework core tab
     */
    this.corePanel = new FrameworkCorePanel();
    this.addTab(this.corePanel, "Framework Core", BLUE_IMAGE);

    /*
     * the map panel
     */
    if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.OVERVIEW_MAP_ENABLED))) {
        this.mapPanel = new MapPanel();
        this.addTab(this.mapPanel, "Overview Map", BLUE_IMAGE);
    }

    /*
     * other stuff
     */
    this.getContentPane().add(this.pane);

    JPanel statusBar = new JPanel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setPreferredSize(new Dimension(200, 25));
    JPanel statusBarWrapper = new JPanel(new BorderLayout());
    statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.WEST);
    statusBarWrapper.add(statusBar);
    statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.EAST);

    this.statusLabel = new JLabel("SPFramework startup finished.");
    statusBar.add(this.statusLabel, BorderLayout.EAST);

    this.outputLabel = new JLabel("(no output yet)");
    statusBar.add(this.outputLabel, BorderLayout.WEST);

    this.getContentPane().add(statusBarWrapper, BorderLayout.SOUTH);

    this.getContentPane().setBackground(this.pane.getBackground());

    this.setPreferredSize(new Dimension(1280, 720));
    this.pack();

    /*
     * full screen?
     */
    if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.MAXIMIZED))) {
        this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    }

    this.setLocationRelativeTo(null);
}

From source file:net.sourceforge.doddle_owl.utils.Utils.java

public static JComponent createEastPanel(JComponent p) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(p, BorderLayout.EAST);
    return panel;
}

From source file:nl.ru.ai.projects.parrot.biomav.editor.BehaviorEditor.java

public BehaviorEditor() {
    ///////// Graph stuff
    graphViewer.addKeyListener(new KeyListener() {
        @Override//  w  w  w.j av a2 s .co  m
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                for (TransitionEdge edge : graphViewer.getPickedEdgeState().getPicked()) {
                    graph.removeEdge(edge);
                }
                for (BehaviorVertex vertex : graphViewer.getPickedVertexState().getPicked()) {
                    graph.removeVertex(vertex);
                }
                e.consume();
                repaint();
            }
        }
    });

    graphViewer.setBackground(Color.GRAY);

    graphViewer.setGraphMouse(graphMouse);
    graphMouse.add(graphMouseEditPlugin);
    graphMouse.add(graphMouseTranslatePlugin);
    graphMouse.add(graphMousePickPlugin);

    // Set label renderer
    VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge> renderer = new VertexLabelAsShapeRenderer<BehaviorVertex, TransitionEdge>(
            graphViewer.getRenderContext());
    graphViewer.getRenderContext().setVertexShapeTransformer(renderer);
    graphViewer.getRenderer().setVertexLabelRenderer(renderer);

    // Set label contents
    graphViewer.getRenderContext().setVertexLabelTransformer(new Transformer<BehaviorVertex, String>() {
        @Override
        public String transform(BehaviorVertex v) {
            return v.getSelectedBehavior();
        }
    });
    graphViewer.getRenderContext().setEdgeLabelTransformer(new Transformer<TransitionEdge, String>() {
        @Override
        public String transform(TransitionEdge e) {
            return e.getTransition();
        }
    });

    // Set fonts
    graphViewer.getRenderContext().setVertexFontTransformer(new Transformer<BehaviorVertex, Font>() {
        @Override
        public Font transform(BehaviorVertex v) {
            return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 20);
        }
    });
    graphViewer.getRenderContext().setEdgeFontTransformer(new Transformer<TransitionEdge, Font>() {
        @Override
        public Font transform(TransitionEdge arg0) {
            return new Font(graphViewer.getFont().getName(), graphViewer.getFont().getStyle(), 16);
        }
    });

    // Fill color dependent on vertex activity
    graphViewer.getRenderContext().setVertexFillPaintTransformer(new Transformer<BehaviorVertex, Paint>() {
        @Override
        public Paint transform(BehaviorVertex vertex) {
            return vertex.isActive() ? Color.ORANGE : Color.RED;
        }
    });

    graphViewer.getPickedVertexState().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            BehaviorVertex vertex = (BehaviorVertex) e.getItem();
            if (e.getStateChange() == ItemEvent.SELECTED) {
                setNewSelectedParameterControlInterface(vertex);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                if (vertex == selectedPCInterface) {
                    setNewSelectedParameterControlInterface(null);
                }
            }
        }
    });
    graphViewer.getPickedEdgeState().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            TransitionEdge edge = (TransitionEdge) e.getItem();
            if (e.getStateChange() == ItemEvent.SELECTED) {
                setNewSelectedParameterControlInterface(edge);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                if (edge == selectedPCInterface) {
                    setNewSelectedParameterControlInterface(null);
                }
            }
        }
    });

    this.addComponentListener(new ComponentListener() {
        @Override
        public void componentShown(ComponentEvent e) {
        }

        @Override
        public void componentResized(ComponentEvent e) {
            graphViewer.getGraphLayout().setSize(graphViewer.getSize());
        }

        @Override
        public void componentMoved(ComponentEvent e) {
        }

        @Override
        public void componentHidden(ComponentEvent e) {
        }
    });

    ///////////// Side panel (parameter control)
    pcInterfacePanel.setPreferredSize(new Dimension(200, 0));
    pcInterfacePanel.setLayout(new BorderLayout());

    pcInterfacePanelContents.setLayout(new GridLayout(0, 2, 0, 5));
    pcInterfacePanel.add(pcInterfacePanelContents, BorderLayout.NORTH);

    ///////////// [this]

    setLayout(new BorderLayout(10, 10));

    add(graphViewer, BorderLayout.CENTER);
    add(pcInterfacePanel, BorderLayout.EAST);
}

From source file:jchrest.gui.VisualSearchPane.java

private JPanel recallSetupPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    panel.add(constructSelector(), BorderLayout.NORTH);
    panel.add(_sceneDisplay);// www.j  a v  a  2s  .co  m
    panel.add(constructButtons(), BorderLayout.EAST);

    return panel;
}