Example usage for java.awt.event ItemListener ItemListener

List of usage examples for java.awt.event ItemListener ItemListener

Introduction

In this page you can find the example usage for java.awt.event ItemListener ItemListener.

Prototype

ItemListener

Source Link

Usage

From source file:com.microsoft.intellij.forms.CreateWebSiteForm.java

public CreateWebSiteForm(@org.jetbrains.annotations.Nullable Project project, List<WebSite> webSiteList) {
    super(project, true, IdeModalityType.PROJECT);

    this.project = project;
    for (WebSite ws : webSiteList) {
        webSiteNames.add(ws.getName());/*from w  w  w. ja v a 2 s  .  com*/
    }
    setTitle("New Web App Container");

    subscriptionComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getItem() instanceof Subscription) {
                subscription = (Subscription) itemEvent.getItem();
                fillResourceGroups("");
            }
        }
    });

    groupComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
                if (createResGrpLabel.equals(itemEvent.getItem())) {
                    resourceGroup = null;
                    showcreateResourceGroupForm();
                } else if (itemEvent.getItem() instanceof String) {
                    resourceGroup = (String) itemEvent.getItem();
                    fillWebHostingPlans("");
                }
            }
        }
    });

    webHostingPlanComboBoxItemListner = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
                String selectedItem = (String) itemEvent.getItem();
                if (selectedItem.equals(createWebHostingPlanLabel)) {
                    showCreateWebHostingPlanForm();
                } else {
                    WebHostingPlanCache plan = hostingPlanMap.get(selectedItem);
                    pupulateServicePlanDetails(plan);
                }
            }
        }
    };

    defaultJDK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            enableCustomJDK(false);
            enableCustomJDKUser(false);
            customJDK.setSelected(false);
            customJDKUser.setSelected(false);
        }
    });

    customJDK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            enableCustomJDK(true);
            enableCustomJDKUser(false);
            defaultJDK.setSelected(false);
            customJDKUser.setSelected(false);
        }
    });

    customJDKUser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            enableCustomJDK(false);
            enableCustomJDKUser(true);
            defaultJDK.setSelected(false);
            customJDK.setSelected(false);
        }
    });

    storageNames.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            storageComboListener();
        }
    });

    customUrl.getDocument().addDocumentListener(createServerUrlListener());

    accLink.setAction(new AccountsAction());

    defaultJDK.setSelected(true);
    enableCustomJDK(false);
    enableCustomJDKUser(false);

    List<String> containerList = new ArrayList<String>();
    for (WebAppsContainers type : WebAppsContainers.values()) {
        containerList.add(type.getName());
    }
    webContainerComboBox.setModel(new DefaultComboBoxModel(containerList.toArray()));
    linkPrice.setURI(URI.create(message("lnkWebAppPrice")));
    linkPrice.setText("Pricing");
    init();
    webAppCreated = "";
    fillSubscriptions();
}

From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java

/**
 * Class Constructor.//ww w  . ja v a 2 s . c  o  m
 */
public BusinessQueryPanel(final FindParamsPanel findParamsPanel, ConfigurationType uiConfigurationType)
        throws JAXRException {
    super(findParamsPanel, uiConfigurationType);

    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    objectTypeLabel = new JLabel(resourceBundle.getString("title.objectType"), SwingConstants.LEADING);

    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(objectTypeLabel, c);
    add(objectTypeLabel);

    //TODO: SwingBoost: Localize this
    TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types...");
    objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode));

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(objectTypeCombo, c);
    add(objectTypeCombo);
    objectTypeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String objectType = getObjectType().toString();
        }
    });

    //The caseSensitive CheckBox
    caseSensitiveCheckBox = new JCheckBox(resourceBundle.getString("title.caseSensitiveSearch"));
    caseSensitiveCheckBox.setSelected(false);
    caseSensitiveCheckBox.setEnabled(true);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(caseSensitiveCheckBox, c);
    add(caseSensitiveCheckBox);

    //The name Text
    nameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(nameLabel, c);
    add(nameLabel);

    nameText = new JTextField();
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(nameText, c);
    add(nameText);

    nameText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //The description text
    descLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(descLabel, c);
    add(descLabel);

    descText = new JTextField();
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(descText, c);
    add(descText);

    descText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //Classifications
    classificationsLabel = new JLabel(resourceBundle.getString("title.classifications"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(classificationsLabel, c);
    add(classificationsLabel);

    classificationsList = new ClassificationsList();
    classificationsList.setEditable(true);
    classificationsList.setVisibleRowCount(3);

    JScrollPane classificationsListScrollPane = new JScrollPane(classificationsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    classificationsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(classificationsListScrollPane, c);
    add(classificationsListScrollPane);

    //Identifiers
    identifiersLabel = new JLabel(resourceBundle.getString("title.externalIdentifiers"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 9;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(identifiersLabel, c);
    add(identifiersLabel);

    extIdsList = new ExternalIdentifiersList();
    extIdsList.setEditable(true);
    extIdsList.setVisibleRowCount(3);

    JScrollPane extIdsListScrollPane = new JScrollPane(extIdsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    extIdsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 10;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(extIdsListScrollPane, c);
    add(extIdsListScrollPane);

    //External Links
    linksLabel = new JLabel(resourceBundle.getString("title.externalLinks"), SwingConstants.TRAILING);
    c.gridx = 0;
    c.gridy = 11;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(linksLabel, c);
    add(linksLabel);

    linksList = new ExternalLinksList();
    linksList.setEditable(true);
    linksList.setVisibleRowCount(3);

    JScrollPane linksListScrollPane = new JScrollPane(linksList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    linksListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 12;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(linksListScrollPane, c);
    add(linksListScrollPane);

    //add listener for 'locale' bound property
    RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this);
}

From source file:boundary.GraphPane.java

public GraphPane(Dominoes domino) {

    // create a simple graph for the demo
    graph = new DelegateForest<String, String>();

    if (domino.getType() == DominoType.SUPPORT)
        graph = new UndirectedSparseGraph<String, String>();
    else//  ww  w .j  a  v  a2  s  . c  o  m
        graph = new DirectedSparseGraph<String, String>();

    createTree(domino);

    treeLayout = new FRLayout<>(graph);
    //treeLayout = new CircleLayout(graph);

    vv = new VisualizationViewer<String, String>(treeLayout, new Dimension(400, 400));

    vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<String, Paint>() {

        @Override
        public Paint transform(String i) {
            return (Paint) nodes.get(i).getColor();
        }
    });

    vv.getRenderContext().setVertexLabelTransformer(new Transformer<String, String>() {

        @Override
        public String transform(String arg0) {
            return "";
        }
    });

    vv.getRenderContext().setEdgeLabelTransformer(new Transformer<String, String>() {

        @Override
        public String transform(String arg0) {
            return "";
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<String, Paint>() {

        @Override
        public Paint transform(String arg0) {
            return edges.get(arg0).getColor();
        }
    });

    final PickedState<String> pickedState = vv.getPickedVertexState();
    pickedState.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            Object obj = e.getItem();

            if (obj instanceof String) {
                String vertexId = (String) obj;

                nodes.get(vertexId).setHighlighted(pickedState.isPicked(vertexId));
            }

        }
    });

    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new Transformer<String, String>() {

        @Override
        public String transform(String arg0) {
            return nodes.get(arg0).getUserData();
        }
    });
    //vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
    ;
    graphMouse.setZoomAtMouse(false);

    vv.getRenderContext().setEdgeIncludePredicate(edgePredicate);

    vv.getRenderContext().setVertexIncludePredicate(vertexPredicate);

    SwingNode s = new SwingNode();
    s.setContent(panel);

    this.setTop(addTransformingModeOptions());
    this.setBottom(addThresholdSlider(domino.getMat().findMinValue(), domino.getMat().findMaxValue()));
    this.setCenter(s);
    //this.getChildren().add(borderPane);  
}

From source file:de.jakop.ngcalsync.application.TrayStarter.java

private ItemListener createSchedulerItemListener(final Settings settings, final Application application) {

    return new ItemListener() {

        @Override/*  ww  w  .  j av  a 2 s. com*/
        public void itemStateChanged(final ItemEvent e) {
            try {
                final boolean started = e.getStateChange() == ItemEvent.SELECTED;
                toggleScheduler(started, settings, application);
                settings.setSchedulerStarted(started);
                settings.save();
            } catch (final ConfigurationException ex) {
                throw new RuntimeException(ex);
            }
        }
    };
}

From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java

/**
 * Constructor/*from w  ww. jav  a 2s . c o m*/
 * @param parent
 *          the parent frame
 * @param fitMaanovaResult
 *          the fitmaanova result that we'll plot residuals for
 */
public ResidualPlotPanel(JFrame parent, FitMaanovaResult fitMaanovaResult) {
    this.chartConfigurationDialog = new SimpleChartConfigurationDialog(parent);
    this.chartConfigurationDialog.addOkActionListener(new ActionListener() {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            ResidualPlotPanel.this.updateDataPoints();
        }
    });

    this.fitMaanovaResult = fitMaanovaResult;
    this.dyeCount = this.fitMaanovaResult.getParentExperiment().getDyeCount();
    this.arrayCount = this.fitMaanovaResult.getParentExperiment().getMicroarrayCount();

    this.setLayout(new BorderLayout());

    JPanel chartAndControlPanel = new JPanel(new BorderLayout());
    this.add(chartAndControlPanel, BorderLayout.CENTER);

    this.chartPanel = new MaanovaChartPanel();
    this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    this.chartPanel.addComponentListener(this.chartComponentListener);
    this.chartPanel.addAreaSelectionListener(this.areaSelectionListener);
    this.chartPanel.addMouseListener(this.chartMouseListener);
    this.chartPanel.addMouseMotionListener(this.myMouseMotionListener);
    this.chartPanel.setLayout(null);
    chartAndControlPanel.add(this.chartPanel, BorderLayout.CENTER);

    ItemListener updateDataItemListener = new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            ResidualPlotPanel.this.forgetGraphState();
            ResidualPlotPanel.this.updateDataPoints();
        }
    };

    if (this.dyeCount <= 1) {
        this.controlPanel = null;
        this.dyeComboBox = null;
    } else {
        this.dyeComboBox = new JComboBox();
        for (int i = 0; i < this.dyeCount; i++) {
            this.dyeComboBox.addItem("Dye #" + (i + 1));
        }
        this.dyeComboBox.addItemListener(updateDataItemListener);

        this.controlPanel = new JPanel(new FlowLayout());
        this.controlPanel.add(this.dyeComboBox);
        chartAndControlPanel.add(this.controlPanel, BorderLayout.NORTH);
    }

    this.add(this.createMenu(), BorderLayout.NORTH);

    this.forgetGraphState();
    this.updateDataPoints();

    this.toolTip = new JToolTip();
}

From source file:com.google.code.facebook.graph.sna.applet.BalloonLayoutDemo.java

public BalloonLayoutDemo() {

    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();//from  w  ww  .  j a  v a 2s . c o  m

    layout = new TreeLayout<String, Integer>(graph);
    radialLayout = new BalloonLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(900, 900));
    vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings(radialLayout);

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());

    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    vv.scaleToLayout(scaler);

    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, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Balloon");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        layout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });
    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);
    controls.add(hyperView);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:org.jax.maanova.madata.gui.ArrayScatterPlotPanel.java

/**
 * Constructor/*from   w ww . j  a  v a2s .  c o m*/
 * @param parent
 *          the parent frame
 * @param experiment
 *          the microarray experiment that we're going to be plotting data
 *          for
 */
public ArrayScatterPlotPanel(JFrame parent, MicroarrayExperiment experiment) {
    this.chartConfigurationDialog = new SimpleChartConfigurationDialog(parent);
    this.chartConfigurationDialog.addOkActionListener(new ActionListener() {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent e) {
            ArrayScatterPlotPanel.this.updateDataPoints();
        }
    });

    this.experiment = experiment;
    this.dyeCount = experiment.getDyeCount();

    this.setLayout(new BorderLayout());

    JPanel chartAndControlPanel = new JPanel(new BorderLayout());
    this.add(chartAndControlPanel, BorderLayout.CENTER);

    this.chartPanel = new MaanovaChartPanel();
    this.chartPanel.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    this.chartPanel.addMouseMotionListener(this.myMouseMotionListener);
    this.chartPanel.addMouseListener(this.chartMouseListener);
    this.chartPanel.addComponentListener(this.chartComponentListener);
    this.chartPanel.addAreaSelectionListener(this.areaSelectionListener);
    this.chartPanel.setLayout(null);
    chartAndControlPanel.add(this.chartPanel, BorderLayout.CENTER);

    ItemListener updateDataItemListener = new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            ArrayScatterPlotPanel.this.forgetGraphState();
            ArrayScatterPlotPanel.this.updateDataPoints();
        }
    };

    this.array1ComboBox = this.initializeArrayComboBox(this.dyeCount);
    this.array1ComboBox.addItemListener(updateDataItemListener);
    this.array2ComboBox = this.initializeArrayComboBox(this.dyeCount);
    this.array2ComboBox.setSelectedIndex(1);
    this.array2ComboBox.addItemListener(updateDataItemListener);

    this.controlPanel = new JPanel(new FlowLayout());
    this.controlPanel.add(this.array1ComboBox);
    this.controlPanel.add(new JLabel("vs."));
    this.controlPanel.add(this.array2ComboBox);
    chartAndControlPanel.add(this.controlPanel, BorderLayout.NORTH);

    this.add(this.createMenu(), BorderLayout.NORTH);

    this.forgetGraphState();
    this.updateDataPoints();

    this.toolTip = new JToolTip();
}

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

@SuppressWarnings({ "unchecked", "rawtypes" })
public BalloonLayoutDemo() {

    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();/*from   ww w .  j a v  a2 s. c o m*/

    layout = new TreeLayout<String, Integer>(graph);
    radialLayout = new BalloonLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(900, 900));
    vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings(radialLayout);

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());

    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    vv.scaleToLayout(scaler);

    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, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Balloon");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        layout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });
    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);
    controls.add(hyperView);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:org.kse.gui.dialogs.sign.DSignMidlet.java

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;/*from   www. j  av  a  2s.c  o m*/
    gbcLbl.gridwidth = 1;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;
    gbcLbl.weightx = 0;

    GridBagConstraints gbcCtrl = new GridBagConstraints();
    gbcCtrl.gridx = 1;
    gbcCtrl.gridwidth = 1;
    gbcCtrl.gridheight = 1;
    gbcCtrl.insets = new Insets(5, 5, 5, 5);
    gbcCtrl.anchor = GridBagConstraints.WEST;
    gbcCtrl.fill = GridBagConstraints.NONE;
    gbcCtrl.weightx = 1;

    GridBagConstraints gbcBrws = new GridBagConstraints();
    gbcBrws.gridx = 2;
    gbcBrws.gridwidth = 1;
    gbcBrws.gridheight = 1;
    gbcBrws.insets = new Insets(5, 5, 5, 5);
    gbcBrws.anchor = GridBagConstraints.WEST;
    gbcBrws.fill = GridBagConstraints.NONE;
    gbcBrws.weightx = 1;

    jlInputJad = new JLabel(res.getString("DSignMidlet.jlInputJad.text"));
    GridBagConstraints gbc_jlInputJad = (GridBagConstraints) gbcLbl.clone();
    gbc_jlInputJad.gridy = 0;

    jtfInputJad = new JTextField(30);
    jtfInputJad.setCaretPosition(0);
    jtfInputJad.setToolTipText(res.getString("DSignMidlet.jtfInputJad.tooltip"));
    GridBagConstraints gbc_jtfInputJad = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfInputJad.gridy = 0;

    jbInputJadBrowse = new JButton(res.getString("DSignMidlet.jbInputJadBrowse.text"));
    PlatformUtil.setMnemonic(jbInputJadBrowse,
            res.getString("DSignMidlet.jbInputJadBrowse.mnemonic").charAt(0));
    jbInputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbInputJadBrowse.tooltip"));
    jbInputJadBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                inputJadBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbInputJadBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbInputJadBrowse.gridy = 0;

    jlSignDirectly = new JLabel(res.getString("DSignMidlet.jlSignDirectly.text"));
    GridBagConstraints gbc_jlSignDirectly = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSignDirectly.gridy = 1;

    jcbSignDirectly = new JCheckBox();
    jcbSignDirectly.setSelected(true);
    jcbSignDirectly.setToolTipText(res.getString("DSignMidlet.jcbSignDirectly.tooltip"));
    GridBagConstraints gbc_jcbSignDirectly = (GridBagConstraints) gbcCtrl.clone();
    gbc_jcbSignDirectly.gridy = 1;

    jcbSignDirectly.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent evt) {
            jtfOutputJad.setEnabled(!jcbSignDirectly.isSelected());
            jbOutputJadBrowse.setEnabled(!jcbSignDirectly.isSelected());
        }
    });

    jlOutputJad = new JLabel(res.getString("DSignMidlet.jlOutputJad.text"));
    GridBagConstraints gbc_jlOutputJad = (GridBagConstraints) gbcLbl.clone();
    gbc_jlOutputJad.gridy = 2;

    jtfOutputJad = new JTextField(30);
    jtfOutputJad.setEnabled(false);
    jtfOutputJad.setCaretPosition(0);
    jtfOutputJad.setToolTipText(res.getString("DSignMidlet.jtfOutputJad.tooltip"));
    GridBagConstraints gbc_jtfOutputJad = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfOutputJad.gridy = 2;

    jbOutputJadBrowse = new JButton(res.getString("DSignMidlet.jbOutputJadBrowse.text"));
    PlatformUtil.setMnemonic(jbOutputJadBrowse,
            res.getString("DSignMidlet.jbOutputJadBrowse.mnemonic").charAt(0));
    jbOutputJadBrowse.setToolTipText(res.getString("DSignMidlet.jbOutputJadBrowse.tooltip"));
    jbOutputJadBrowse.setEnabled(false);
    jbOutputJadBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                outputJadBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbOutputJadBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbOutputJadBrowse.gridy = 2;

    jlJar = new JLabel(res.getString("DSignMidlet.jlJar.text"));
    GridBagConstraints gbc_jlJar = (GridBagConstraints) gbcLbl.clone();
    gbc_jlJar.gridy = 3;

    jtfJar = new JTextField(30);
    jtfJar.setCaretPosition(0);
    jtfJar.setToolTipText(res.getString("DSignMidlet.jtfJar.tooltip"));
    GridBagConstraints gbc_jtfJar = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfJar.gridy = 3;

    jbJarBrowse = new JButton(res.getString("DSignMidlet.jbJarBrowse.text"));
    PlatformUtil.setMnemonic(jbJarBrowse, res.getString("DSignMidlet.jbJarBrowse.mnemonic").charAt(0));
    jbJarBrowse.setToolTipText(res.getString("DSignMidlet.jbJarBrowse.tooltip"));
    jbJarBrowse.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignMidlet.this);
                jarBrowsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignMidlet.this);
            }
        }
    });
    GridBagConstraints gbc_jbJarBrowse = (GridBagConstraints) gbcBrws.clone();
    gbc_jbJarBrowse.gridy = 3;

    jpOptions = new JPanel(new GridBagLayout());
    jpOptions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()));

    jpOptions.add(jlInputJad, gbc_jlInputJad);
    jpOptions.add(jtfInputJad, gbc_jtfInputJad);
    jpOptions.add(jbInputJadBrowse, gbc_jbInputJadBrowse);
    jpOptions.add(jlSignDirectly, gbc_jlSignDirectly);
    jpOptions.add(jcbSignDirectly, gbc_jcbSignDirectly);
    jpOptions.add(jlOutputJad, gbc_jlOutputJad);
    jpOptions.add(jtfOutputJad, gbc_jtfOutputJad);
    jpOptions.add(jbOutputJadBrowse, gbc_jbOutputJadBrowse);
    jpOptions.add(jlJar, gbc_jlJar);
    jpOptions.add(jtfJar, gbc_jtfJar);
    jpOptions.add(jbJarBrowse, gbc_jbJarBrowse);

    jbOK = new JButton(res.getString("DSignMidlet.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });

    jbCancel = new JButton(res.getString("DSignMidlet.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpOptions, BorderLayout.NORTH);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });

    setResizable(false);

    getRootPane().setDefaultButton(jbOK);

    pack();
}

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);

        }//w ww  .ja v  a  2s . co  m
    });
    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);
}