List of usage examples for java.awt.event ItemListener ItemListener
ItemListener
From source file:TreeColapse.java
@SuppressWarnings("unchecked") public TreeColapse() throws IOException { // create a simple graph for the demo graph = new DelegateForest<Node, Integer>(); createTree();//ww w .j a v a2 s. c o m layout = new TreeLayout<Node, Integer>(graph); collapser = new TreeCollapser(); radialLayout = new RadialTreeLayout<Node, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); vv = new VisualizationViewer<Node, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); //vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>()); vv.getRenderContext().setVertexLabelTransformer(new Transformer<Node, String>() { public String transform(Node e) { return (e.getName()); } }); vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); 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, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // layout.setRadial(true); vv.setGraphLayout(radialLayout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { // layout.setRadial(false); vv.setGraphLayout(layout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JButton collapse = new JButton("Collapse"); collapse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = new HashSet(vv.getPickedVertexState().getPicked()); if (picked.size() == 1) { Object root = picked.iterator().next(); Forest inGraph = (Forest) layout.getGraph(); try { collapser.collapse(vv.getGraphLayout(), inGraph, root); } catch (InstantiationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JButton expand = new JButton("Expand"); expand.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = vv.getPickedVertexState().getPicked(); for (Object v : picked) { if (v instanceof Forest) { Forest inGraph = (Forest) layout.getGraph(); collapser.expand(inGraph, (Forest) v); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); 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(collapse); controls.add(expand); content.add(controls, BorderLayout.SOUTH); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.LoadGenericDRDataController.java
/** * Private methods//from w w w . j av a 2 s .c o m */ //init view private void initDataLoadingPanel() { dataLoadingPanel = new DRDataLoadingPanel(); /** * Action Listeners. */ //Popup file selector and import and parse the file dataLoadingPanel.getChooseFileButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Open a JFile Chooser JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle( "Choose a tabular file (XLS, XLSX, CSV, TSV) for the import of the experiment"); // to select only appropriate files fileChooser.setFileFilter(new FileFilter() { @Override public boolean accept(File f) { if (f.isDirectory()) { return true; } int index = f.getName().lastIndexOf("."); String extension = f.getName().substring(index + 1); return extension.equals("xls") || extension.equals("xlsx") || extension.equals("csv") || extension.equals("tsv"); } @Override public String getDescription() { return (".xls, .xlsx, .csv and .tsv files"); } }); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setAcceptAllFileFilterUsed(false); // in response to the button click, show open dialog int returnVal = fileChooser.showOpenDialog(dataLoadingPanel); if (returnVal == JFileChooser.APPROVE_OPTION) { File chosenFile = fileChooser.getSelectedFile(); // // create and execute a new swing worker with the selected file for the import // ImportExperimentSwingWorker importExperimentSwingWorker = new ImportExperimentSwingWorker(chosenFile); // importExperimentSwingWorker.execute(); parseDRFile(chosenFile); if (doseResponseController.getImportedDRDataHolder().getDoseResponseData() != null) { dataLoadingPanel.getFileLabel().setText(chosenFile.getAbsolutePath()); doseResponseController.getGenericDRParentPanel().getNextButton().setEnabled(true); } } else { JOptionPane.showMessageDialog(dataLoadingPanel, "Command cancelled by user", "", JOptionPane.INFORMATION_MESSAGE); } } }); dataLoadingPanel.getLogTransformCheckBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { doseResponseController.setLogTransform(true); } else { doseResponseController.setLogTransform(false); } } }); }
From source file:org.datacleaner.windows.DataHubDatastoreDialog.java
@Inject public DataHubDatastoreDialog(WindowContext windowContext, MutableDatastoreCatalog datastoreCatalog, @Nullable DataHubDatastore originalDatastore, UserPreferences userPreferences) { super(originalDatastore, datastoreCatalog, windowContext, userPreferences); _hostTextField = WidgetFactory.createTextField("Hostname"); _portTextField = WidgetFactory.createTextField("Port"); _usernameTextField = WidgetFactory.createTextField("Username"); _passwordTextField = WidgetFactory.createPasswordField(); // _contextPathTextField = // WidgetFactory.createTextField("Context path"); _securityModeSelector = new JComboBox<>( new String[] { DataHubSecurityMode.DEFAULT.toString(), DataHubSecurityMode.CAS.toString() }); _securityModeSelector.setEditable(false); _urlLabel = DCLabel.bright(""); _urlLabel.setForeground(WidgetUtils.BG_COLOR_LESS_BRIGHT); _urlLabel.setBorder(new EmptyBorder(5, 0, 5, 0)); final DCDocumentListener genericDocumentListener = new DCDocumentListener() { @Override// ww w . jav a 2s .com protected void onChange(DocumentEvent event) { validateAndUpdate(); updateUrlLabel(); } }; _httpsCheckBox = new JCheckBox("Use HTTPS?", false); _httpsCheckBox.setOpaque(false); _httpsCheckBox.setForeground(WidgetUtils.BG_COLOR_BRIGHTEST); _httpsCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { updateUrlLabel(); validateAndUpdate(); } }); _acceptUnverifiedSslPeersCheckBox = new JCheckBox("Accept unverified SSL peers?", false); _acceptUnverifiedSslPeersCheckBox.setOpaque(false); _acceptUnverifiedSslPeersCheckBox.setForeground(WidgetUtils.BG_COLOR_BRIGHTEST); _acceptUnverifiedSslPeersCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { validateAndUpdate(); } }); _hostTextField.getDocument().addDocumentListener(genericDocumentListener); _portTextField.getDocument().addDocumentListener(genericDocumentListener); _usernameTextField.getDocument().addDocumentListener(genericDocumentListener); _passwordTextField.getDocument().addDocumentListener(genericDocumentListener); _securityModeSelector.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { validateAndUpdate(); updateUrlLabel(); } }); _testButton = WidgetFactory.createDefaultButton("Test connection", IconUtils.ACTION_REFRESH); _testButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { final DataHubRepoConnection connection = createConnection(); final String getTenantInfoUrl = connection.getUserInfoUrl(); final HttpGet request = new HttpGet(getTenantInfoUrl); try (final MonitorHttpClient monitorHttpClient = connection.getHttpClient()) { final HttpResponse response = monitorHttpClient.execute(request); final StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() == HttpStatus.SC_OK || statusLine.getStatusCode() == HttpStatus.SC_CREATED) { // read response as JSON. final InputStream content = response.getEntity().getContent(); final UserInfo userInfo; try { userInfo = new ObjectMapper().readValue(content, UserInfo.class); } finally { FileHelper.safeClose(content); } LOGGER.info("Get tenant info request responded with tenant name: {}", userInfo.tenant); JOptionPane.showMessageDialog(DataHubDatastoreDialog.this, "Connection successful!"); } else { final String reasonPhrase = statusLine.getReasonPhrase(); WidgetUtils.showErrorMessage("Server reported error", "Server replied with status " + statusLine.getStatusCode() + ":\n" + reasonPhrase); } } catch (Exception e) { // TODO: This dialog is shown behind the modal dialog WidgetUtils.showErrorMessage("Connection failed", "Connecting to DataHub failed. Did you remember to fill in all the necessary fields?", e); } validateAndUpdate(); } }); if (originalDatastore != null) { _hostTextField.setText(originalDatastore.getHost()); _portTextField.setText(originalDatastore.getPort() + ""); _httpsCheckBox.setSelected(originalDatastore.isHttps()); _acceptUnverifiedSslPeersCheckBox.setSelected(originalDatastore.isAcceptUnverifiedSslPeers()); if (originalDatastore.getSecurityMode().equals(DataHubSecurityMode.CAS)) { _securityModeSelector.setSelectedIndex(1); } else { _securityModeSelector.setSelectedIndex(0); } _datastoreNameTextField.setText(originalDatastore.getName()); _datastoreNameTextField.setEditable(false); _usernameTextField.setText(originalDatastore.getUsername()); _passwordTextField.setText(originalDatastore.getPassword()); } else { _hostTextField.setText("localhost"); _portTextField.setText("8080"); } updateUrlLabel(); }
From source file:gridvisual.GridVisualize.java
public GridVisualize() { // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree();/*from w w w . java 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); for (String v : layout.getGraph().getVertices()) { java.awt.Point p = nodeTable.get(new Integer(Integer.parseInt(v))).coord; layout.setLocation(v, p); } /* Transformer<Integer,Paint> vertexPaint = new Transformer<Integer,Paint>() { public Paint transform(Integer i) { return Color.GREEN; } };*/ /* Transformer<Integer, Paint> vertexPaint = new Transformer<Integer, Paint>() { private final Color[] palette = {Color.GREEN, Color.BLUE, Color.RED}; public Paint transform(Integer i) { return palette[i.intValue() % palette.length]; } };*/ vv.getRenderContext().setVertexFillPaintTransformer(new MyTransformer(this.nodeTable)); }
From source file:com.funambol.foundation.admin.SIFSyncSourceConfigPanel.java
/** * Create the panel//from w w w.j a v a 2 s.co m * * @throws Exception if error occures during creation of the panel */ private void init() { this.setLayout(null); // // Set properties of label, position and border referred to the title //of the panel // titledBorder1 = new TitledBorder(""); panelName.setFont(titlePanelFont); panelName.setText("Edit SIF SyncSource"); panelName.setBounds(new Rectangle(14, 5, 316, 28)); panelName.setAlignmentX(SwingConstants.CENTER); panelName.setBorder(titledBorder1); int y = 60; int dy = 30; int x1 = 14; int x2 = 170; int w1 = 150; int w2 = 350; int h = 18; sourceUriLabel.setText("Source URI: "); sourceUriLabel.setFont(defaultFont); sourceUriLabel.setBounds(x1, y, w1, h); sourceUriValue.setFont(defaultFont); sourceUriValue.setBounds(x2, y, w2, h); y += dy; nameLabel.setText("Name: "); nameLabel.setFont(defaultFont); nameLabel.setBounds(x1, y, w1, h); nameValue.setFont(defaultFont); nameValue.setBounds(x2, y, w2, h); y += dy; typeLabel.setText("Type: "); typeLabel.setFont(defaultFont); typeLabel.setBounds(x1, y, w1, h); typeCombo.setFont(defaultFont); typeCombo.setBounds(x2, y, 100, h); typeCombo.addItem(TYPE_SIF_C); typeCombo.addItem(TYPE_SIF_E); typeCombo.addItem(TYPE_SIF_N); typeCombo.addItem(TYPE_SIF_T); typeCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { handleTypeSelected(); } }); handleTypeSelected(); y += dy; directoryLabel.setText("Source Directory: "); directoryLabel.setFont(defaultFont); directoryLabel.setBounds(x1, y, w1, h); directoryValue.setFont(defaultFont); directoryValue.setBounds(x2, y, w2, h); y += dy; twinPropertiesLabel.setText("Twin properties: "); twinPropertiesLabel.setFont(defaultFont); twinPropertiesLabel.setBounds(x1, y, w1, h); descrTwinPropLabel.setText("(Used to identify twins)"); descrTwinPropLabel.setFont(defaultFont); descrTwinPropLabel.setBounds(x1, (y + 15), w1, h); twinPropertiesValue.setFont(defaultFont); twinPropertiesValue.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); twinPropertiesValue.setAutoscrolls(true); scrollTable = new JScrollPane(twinPropertiesValue); scrollTable.setWheelScrollingEnabled(true); scrollTable.setBounds(x2, y, 200, 66); scrollTable.setColumnHeader(null); scrollTable.setMinimumSize(new Dimension(200, 66)); scrollTable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); y += 45; y += dy; multiUserLabel.setText("MultiUser: "); multiUserLabel.setFont(defaultFont); multiUserLabel.setBounds(x1, y, w1, h); multiUserValue.setSelected(false); multiUserValue.setBounds(x2, y, h, h); y += 5; y += dy; confirmButton.setFont(defaultFont); confirmButton.setText("Add"); confirmButton.setBounds(x2, y, 70, 25); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); if (getState() == STATE_INSERT) { SIFSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(SIFSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand())); } else { SIFSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(SIFSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); // // Add all components to the panel // this.add(panelName, null); this.add(sourceUriLabel, null); this.add(sourceUriValue, null); this.add(nameLabel, null); this.add(nameValue, null); this.add(typeLabel, null); this.add(typeCombo, null); this.add(directoryLabel, null); this.add(directoryValue, null); this.add(twinPropertiesLabel, null); this.add(scrollTable, null); this.add(descrTwinPropLabel, null); this.add(multiUserLabel, null); this.add(multiUserValue, null); this.add(confirmButton, null); }
From source file:treeai.Vertex.java
@SuppressWarnings("unchecked") public JUNGTree() { // create a simple graph for the demo graph = new DelegateForest<Vertex, Integer>(); createTree();// w w w .ja v a2 s.co m layout = new TreeLayout<Vertex, Integer>(graph); collapser = new TreeCollapser(); radialLayout = new RadialTreeLayout<Vertex, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); vv = new VisualizationViewer<Vertex, Integer>(layout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction()); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller()); vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); rings = new Rings(); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); 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, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // layout.setRadial(true); vv.setGraphLayout(radialLayout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { // layout.setRadial(false); vv.setGraphLayout(layout); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JButton collapse = new JButton("Collapse"); collapse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = new HashSet(vv.getPickedVertexState().getPicked()); if (picked.size() == 1) { Object root = picked.iterator().next(); Forest inGraph = (Forest) layout.getGraph(); try { collapser.collapse(vv.getGraphLayout(), inGraph, root); } catch (InstantiationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); JButton expand = new JButton("Expand"); expand.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Collection picked = vv.getPickedVertexState().getPicked(); for (Object v : picked) { if (v instanceof Forest) { Forest inGraph = (Forest) layout.getGraph(); collapser.expand(inGraph, (Forest) v); } vv.getPickedVertexState().clear(); vv.repaint(); } } }); 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(collapse); controls.add(expand); content.add(controls, BorderLayout.SOUTH); }
From source file:com.funambol.json.admin.CalendarSyncSourceAdminPanel.java
/** * Create the panel// w ww .jav a2 s .c o m * @throws Exception if error occures during creation of the panel */ private void init() { this.setLayout(null); // set properties of label, position and border // referred to the title of the panel titledBorder = new TitledBorder(""); panelName.setFont(titlePanelFont); panelName.setText(getPanelName()); panelName.setBounds(new Rectangle(14, 5, 316, 28)); panelName.setAlignmentX(SwingConstants.CENTER); panelName.setBorder(titledBorder); final int LABEL_X = 14; final int VALUE_X = 170; int y = 60; final int GAP_X = 150; final int GAP_Y = 30; sourceUriLabel.setText("Source URI: "); sourceUriLabel.setFont(defaultFont); sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18)); sourceUriValue.setFont(defaultFont); sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18)); y += GAP_Y; // New line nameLabel.setText("Name: "); nameLabel.setFont(defaultFont); nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18)); nameValue.setFont(defaultFont); nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18)); y += GAP_Y; // New line typeLabel.setText("Client Type: "); typeLabel.setFont(defaultFont); typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18)); typeCombo.setFont(defaultFont); typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18)); typeCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { updateEntityTypeCheckBoxes(); } }); y += GAP_Y; // New line datastoretypeLabel.setText("Datastore Type: "); datastoretypeLabel.setFont(defaultFont); datastoretypeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18)); datastoretypeCombo.setFont(defaultFont); datastoretypeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18)); y += GAP_Y; // New line int x = LABEL_X; y = addExtraComponents(x, y, GAP_X, GAP_Y); // Add other components, if needed y += GAP_Y; // New line confirmButton.setFont(defaultFont); confirmButton.setText("Add"); confirmButton.setBounds(VALUE_X, y, 70, 25); // What happens when the confirmButton is pressed? confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); if (getState() == STATE_INSERT) { CalendarSyncSourceAdminPanel.this.actionPerformed(new ActionEvent( CalendarSyncSourceAdminPanel.this, ACTION_EVENT_INSERT, event.getActionCommand())); } else { CalendarSyncSourceAdminPanel.this.actionPerformed(new ActionEvent( CalendarSyncSourceAdminPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } } catch (Exception e) { notifyError(new AdminException(e.getMessage(), e)); } } }); // Adds all components to the panel this.add(panelName, null); this.add(nameLabel, null); this.add(sourceUriLabel, null); this.add(sourceUriValue, null); this.add(nameValue, null); this.add(typeLabel, null); this.add(typeCombo, null); this.add(confirmButton, null); this.add(eventValue, null); this.add(taskValue, null); this.add(datastoretypeLabel, null); this.add(datastoretypeCombo, null); }
From source file:com.intuit.tank.tools.debugger.AgentDebuggerFrame.java
/** * @throws HeadlessException//from ww w. j a v a2 s. c o m */ public AgentDebuggerFrame(final boolean isStandalone, String serviceUrl) throws HeadlessException { super("Intuit Tank Agent Debugger"); workingDir = PanelBuilder.createWorkingDir(this, serviceUrl); setSize(new Dimension(1024, 800)); setBounds(new Rectangle(getSize())); setPreferredSize(getSize()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); this.standalone = isStandalone; addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { quit(); } }); errorIcon = ActionProducer.getIcon("bullet_error.png", IconSize.SMALL); modifiedIcon = ActionProducer.getIcon("bullet_code_change.png", IconSize.SMALL); skippedIcon = ActionProducer.getIcon("skip.png", IconSize.SMALL); this.glassPane = new InfiniteProgressPanel(); setGlassPane(glassPane); debuggerActions = new ActionProducer(this, serviceUrl); requestResponsePanel = new RequestResponsePanel(this); requestResponsePanel.init(); testPlanChooser = new JComboBox(); testPlanChooser.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent event) { if (event.getItem() != null) { HDTestPlan selected = (HDTestPlan) event.getItem(); if (!selected.equals(currentTestPlan)) { setCurrentTestPlan(selected); } } } }); tankClientChooser = new JComboBox<TankClientChoice>(); debuggerActions.setChoiceComboBoxOptions(tankClientChooser); actionComponents = new ActionComponents(standalone, testPlanChooser, tankClientChooser, debuggerActions); addScriptChangedListener(actionComponents); setJMenuBar(actionComponents.getMenuBar()); Component topPanel = PanelBuilder.createTopPanel(actionComponents); Component bottomPanel = PanelBuilder.createBottomPanel(this); Component contentPanel = PanelBuilder.createContentPanel(this); final JPopupMenu popup = actionComponents.getPopupMenu(); scriptEditorTA.setPopupMenu(null); scriptEditorTA.addMouseListener(new MouseAdapter() { int lastHash; @Override public void mousePressed(MouseEvent e) { maybeShow(e); } @Override public void mouseReleased(MouseEvent e) { maybeShow(e); } private void maybeShow(MouseEvent e) { if (lastHash == getHash(e)) { return; } if (e.isPopupTrigger()) { // select the line try { int offset = scriptEditorTA.viewToModel(e.getPoint()); Rectangle modelToView = scriptEditorTA.modelToView(offset); Point point = new Point(modelToView.x + 1, e.getPoint().y); if (modelToView.contains(point)) { if (!multiSelect) { int line = scriptEditorTA.getLineOfOffset(offset); scriptEditorTA.setCurrentLine(line); } popup.show(e.getComponent(), e.getX(), e.getY()); } } catch (BadLocationException e1) { e1.printStackTrace(); } } else if (e.isShiftDown()) { int line = scriptEditorTA.getCaretLineNumber(); int start = Math.min(line, lastLine); int end = Math.max(line, lastLine); multiSelect = end - start > 1; if (multiSelect) { multiSelectStart = start; multiSelectEnd = end; try { scriptEditorTA.setEnabled(true); scriptEditorTA.select(scriptEditorTA.getLineStartOffset(start), scriptEditorTA.getLineEndOffset(end)); scriptEditorTA.setEnabled(false); } catch (BadLocationException e1) { e1.printStackTrace(); multiSelect = false; } } } else { multiSelect = false; lastLine = scriptEditorTA.getCaretLineNumber(); } lastHash = getHash(e); } private int getHash(MouseEvent e) { return new HashCodeBuilder().append(e.getButton()).append(e.getSource().hashCode()) .append(e.getPoint()).toHashCode(); } }); JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); mainSplit.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); mainSplit.setTopComponent(contentPanel); mainSplit.setBottomComponent(bottomPanel); mainSplit.setDividerLocation(600); mainSplit.setResizeWeight(0.8D); mainSplit.setDividerSize(5); add(topPanel, BorderLayout.NORTH); add(mainSplit, BorderLayout.CENTER); WindowUtil.centerOnScreen(this); pack(); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher(new KeyEventDispatcher() { @Override public boolean dispatchKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { handleKeyEvent(e); } return false; } }); }
From source file:com.google.code.facebook.graph.sna.applet.RadialTreeLensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * /*from w w w .j av a 2 s .c om*/ */ public RadialTreeLensDemo() { // create a simple graph for the demo // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); Dimension preferredSize = new Dimension(600, 600); final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>( radialLayout, preferredSize); vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Integer> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // 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 graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); rings = new Rings(); vv.addPreRenderPaintable(rings); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); 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, 1 / 1.1f, vv.getCenter()); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); JPanel modeControls = new JPanel(new BorderLayout()); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); hyperControls.add(hyperView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modeControls); content.add(controls, BorderLayout.SOUTH); }
From source file:edu.uci.ics.jung.samples.RadialTreeLensDemo.java
/** * create an instance of a simple graph with controls to * demo the zoomand hyperbolic features. * //from ww w .ja v a 2s .c o m */ @SuppressWarnings({ "unchecked", "rawtypes" }) public RadialTreeLensDemo() { // create a simple graph for the demo // create a simple graph for the demo graph = new DelegateForest<String, Integer>(); createTree(); layout = new TreeLayout<String, Integer>(graph); radialLayout = new RadialTreeLayout<String, Integer>(graph); radialLayout.setSize(new Dimension(600, 600)); Dimension preferredSize = new Dimension(600, 600); final VisualizationModel<String, Integer> visualizationModel = new DefaultVisualizationModel<String, Integer>( radialLayout, preferredSize); vv = new VisualizationViewer<String, Integer>(visualizationModel, preferredSize); PickedState<String> ps = vv.getPickedVertexState(); PickedState<Integer> pes = vv.getPickedEdgeState(); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Integer>(pes, Color.black, Color.cyan)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); // 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 graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); rings = new Rings(); vv.addPreRenderPaintable(rings); hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv, new HyperbolicShapeTransformer(vv, vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), new ModalLensGraphMouse()); 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, 1 / 1.1f, vv.getCenter()); } }); final JRadioButton hyperView = new JRadioButton("Hyperbolic View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener()); JMenuBar menubar = new JMenuBar(); menubar.add(graphMouse.getModeMenu()); gzsp.setCorner(menubar); JPanel controls = new JPanel(); JPanel zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel hyperControls = new JPanel(new GridLayout(3, 2)); hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens")); zoomControls.add(plus); zoomControls.add(minus); JPanel modeControls = new JPanel(new BorderLayout()); modeControls.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modeControls.add(graphMouse.getModeComboBox()); hyperControls.add(hyperView); controls.add(zoomControls); controls.add(hyperControls); controls.add(modeControls); content.add(controls, BorderLayout.SOUTH); }