List of usage examples for javax.swing Box createVerticalGlue
public static Component createVerticalGlue()
From source file:test.visualization.ClusteringDemo.java
private void setUpView(BufferedReader br) throws IOException { Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; }/*from ww w.j a v a 2 s .c om*/ }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>( vertexFactory, edgeFactory); final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>( new FRLayout<Number, Number>(graph)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() { public Paint transform(Number v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(graph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); //vv.validate(); //vv.repaint(); } } }); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }
From source file:cimat.tesis.sna.visualization.ClusteringDemo.java
private void setUpView(BufferedReader br) throws IOException { Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; }/*from ww w. j a v a2s .co m*/ }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>( vertexFactory, edgeFactory); final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>( new FRLayout<Number, Number>(graph)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() { public Paint transform(Number v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(graph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.ChartDisplayPanel.java
/** * Creates and lays out the controls inside this panel. * <p>//from w w w . j a v a2s . c om * This method is called upon initialization only. * </p> */ private void initControls() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(createChartPanel()); final Box buttonPanel = Box.createVerticalBox(); final List<JButton> buttons = new ArrayList<JButton>(8); btnEnlarged = Utils.createButton(Messages.DI_VIEWENLARGED, Messages.TT_VIEWENLARGED, this); if (Plugin.hasFilter(originalParam.getClass())) { btnFilter = Utils.createButton(Messages.DI_FILTERDATA, Messages.TT_FILTERDATA, this); } else { btnFilter = null; } btnSaveChart = Utils.createButton(Messages.DI_EXPORTCHART, Messages.TT_SAVECHART, this); btnSaveData = Utils.createButton(Messages.DI_EXPORTDATA, Messages.TT_SAVEDATA, this); btnChartSettings = Utils.createButton(Messages.DI_CHARTSETTINGS, Messages.TT_CHARTSETTINGS, this); buttonPanel.add(btnChartSettings); buttons.add(btnChartSettings); buttonPanel.add(btnEnlarged); buttons.add(btnEnlarged); if (btnFilter != null) { buttonPanel.add(btnFilter); buttons.add(btnFilter); } buttonPanel.add(Box.createVerticalStrut(Utils.BORDER_SIZE * 2)); if (decorators != null) { btnsDec = new JButton[decorators.length]; for (int i = 0; i < decorators.length; ++i) { Decorator d = decorators[i]; btnsDec[i] = Utils.createButton(d.getButtonLabel(), d.getButtonToolTip(), this); buttonPanel.add(btnsDec[i]); buttons.add(btnsDec[i]); } buttonPanel.add(Box.createVerticalStrut(Utils.BORDER_SIZE * 2)); } buttonPanel.add(btnSaveChart); buttons.add(btnSaveChart); buttonPanel.add(btnSaveData); buttons.add(btnSaveData); buttonPanel.add(Box.createVerticalStrut(Utils.BORDER_SIZE * 2)); buttonPanel.add(Box.createVerticalGlue()); // Ensure buttons are large enough to fit all possible messages final JButton[] btnsArray = new JButton[buttons.size()]; Utils.setSizes(buttons.toArray(btnsArray), preferred, preferred); add(buttonPanel); add(Box.createHorizontalGlue()); }
From source file:eu.delving.sip.frames.AllFrames.java
public JComponent getSidePanel() { JPanel arrangements = new JPanel(); arrangements.setLayout(new BoxLayout(arrangements, BoxLayout.Y_AXIS)); for (Arrangement a : this.arrangements) { JButton b = new JButton(a); b.setHorizontalTextPosition(JButton.CENTER); b.setVerticalTextPosition(JButton.BOTTOM); b.setFont(new Font("Sans", Font.PLAIN, 10)); arrangements.add(b);/*from w w w . ja v a 2 s .c om*/ arrangements.add(Box.createVerticalStrut(5)); } arrangements.add(Box.createVerticalGlue()); JPanel p = new JPanel(new BorderLayout()); p.add(arrangements, BorderLayout.CENTER); return scrollV(p); }
From source file:org.jdal.swing.PageableTable.java
/** * Create the right menu bar//from w ww .java2s . c o m */ private void createMenu() { rightMenuBar = new JMenuBar(); rightMenuBar.setLayout(new BoxLayout(rightMenuBar, BoxLayout.PAGE_AXIS)); rightMenuBar.setMargin(new Insets(0, 0, 0, 0)); // Add Visibility menu JMenu menu = new JMenu(); menu.setMargin(new Insets(0, 0, 0, 0)); menu.setIcon(visibilityMenuIcon); menu.setMaximumSize(new Dimension(50, 50)); visibilityBox = new VisibilityBox(columnDescriptors); menu.add(visibilityBox); menu.getPopupMenu().addPopupMenuListener(new VisibilityPopupListener()); JMenuItem okMenuItem = new JMenuItem(new OkVisibilityAction()); JMenuItem cancelMenuItem = new JMenuItem(new CancelVisibilityAction()); menu.addSeparator(); menu.add(okMenuItem); menu.add(cancelMenuItem); rightMenuBar.add(menu); JMenu prefsMenu = new JMenu(); prefsMenu.setMargin(new Insets(0, 0, 0, 0)); prefsMenu.setIcon(userMenuIcon); prefsMenu.setMaximumSize(new Dimension(50, 50)); prefsMenu.add(new JMenuItem(new LoadPreferencesAction(this, messageSource .getMessage("PageableTable.loadPreferences", null, "Load Preferences", Locale.getDefault())))); prefsMenu.add(new JMenuItem(new SavePreferencesAction(this, messageSource .getMessage("PageableTable.savePreferences", null, "Save Preferences", Locale.getDefault())))); rightMenuBar.add(prefsMenu); rightMenuBar.add(Box.createVerticalGlue()); // Add menu bar to right add(rightMenuBar, BorderLayout.EAST); }
From source file:org.apereo.learninganalytics.snapp.ClusteringDemo.java
private void setUpView(Graph<Integer, Number> grp, Map<Integer, String> name) { /*//from w w w . j a v a 2 s . c om Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number,Number> pnr = new PajekNetReader<Graph<Number, Number>, Number,Number>(vertexFactory, edgeFactory); final Graph<Number,Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); */ //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm this.usernames = name; final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>( new FRLayout<Integer, Number>(grp)); layout.setSize(new Dimension(500, 500)); vv = new VisualizationViewer<Integer, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() { public Paint transform(Integer v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); vv.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new ChainedTransformer<Integer, String>( new Transformer[] { new ToStringLabeller<String>(), new Transformer<String, String>() { public String transform(String input) { return usernames.get(Integer.parseInt(input)); } } })); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); /* //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); */ DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(grp.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); // Add a restart button so the graph can be redrawn to fit the size of the frame JFrame jf = new JFrame("SNAPP: Find Clusters"); //jf.getContentPane().add(); //Container content = getContentPane(); //content.add(new GraphZoomScrollPane(vv)); jf.getContentPane().add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); //grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); //content.add(south, BorderLayout.SOUTH); jf.getContentPane().add(south, BorderLayout.SOUTH); //jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }
From source file:net.pandoragames.far.ui.swing.FindFilePanel.java
private void initBaseDirPanel(SwingConfig config, ComponentRepository componentRepository) { this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JLabel labelBaseDir = new JLabel(config.getLocalizer().localize("label.base-directory")); labelBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(labelBaseDir); baseDirPathTextField/*from w w w. j av a 2s.co m*/ .setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH, config.getStandardComponentHight())); baseDirPathTextField .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); // baseDirPathTextField.setText( dataModel.getBaseDirectory().getPath() ); baseDirPathTextField.addItem(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setSelectedItem(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setToolTipText(dataModel.getBaseDirectory().getPath()); baseDirPathTextField.setEditable(false); baseDirPathTextField.addItemListener(new BaseDirectoryComboBoxListener(config, dataModel)); JButton openBaseDirFileChooserButton = new JButton(localizer.localize("button.browse")); openBaseDirFileChooserButton.requestFocusInWindow(); class BaseDirectoryRepository extends AbstractFileRepository { public BaseDirectoryRepository(FARConfig cfg, ComponentRepository repository) { super(cfg, repository.getFindForm(), repository.getReplaceForm(), repository.getMessageBox()); } public File getFile() { return farconfig.getBaseDirectory(); } public boolean setFile(File file) { if (isSubdirectory(replaceForm.getBackupDirectory(), file)) { messageBox.error(localizer.localize("message.nested-base-child")); return false; } else if (isSubdirectory(file, replaceForm.getBackupDirectory())) { messageBox.error(localizer.localize("message.nested-base-parent")); return false; } else { baseDirPathTextField.addItem(file.getPath()); baseDirPathTextField.setSelectedItem(file.getPath()); baseDirPathTextField.setToolTipText(file.getPath()); farconfig.setBaseDirectory(file); findForm.setBaseDirectory(file); return true; } } } browseButtonListener = new FindFilePanelBrowseButtonListener(baseDirPathTextField, new BaseDirectoryRepository(config, componentRepository), localizer.localize("label.choose-base-directory"), componentRepository.getFindCommand(), componentRepository.getResetDispatcher()); browseButtonListener.addActionListener(componentRepository.getSearchBaseListener()); openBaseDirFileChooserButton.addActionListener(browseButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(baseDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(lineBaseDir); subdirFlag = new JCheckBox(localizer.localize("label.include-subdir") + ":"); subdirFlag.setSelected(dataModel.isIncludeSubDirs()); subdirFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setIncludeSubDirs((ItemEvent.SELECTED == event.getStateChange())); if (ItemEvent.SELECTED != event.getStateChange()) subdirButton.reset(); } }); subdirFlag.addItemListener(componentRepository.getSearchBaseListener()); componentRepository.getResetDispatcher().addToBeSelected(subdirFlag); browseButtonListener.setSubdirCheckBox(subdirFlag); subdirButton = new SubdirPatternLink(dataModel, localizer, componentRepository.getSearchBaseListener(), componentRepository.getRootWindow()); componentRepository.getResetDispatcher().addResetable(subdirButton); TwoComponentsPanel subdirpanel = new TwoComponentsPanel(subdirFlag, subdirButton); subdirpanel.setAlignmentX(Component.LEFT_ALIGNMENT); this.add(subdirpanel); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); this.add(Box.createVerticalGlue()); }
From source file:org.dishevelled.brainstorm.BrainStorm.java
/** * Layout components./* ww w.ja v a 2 s .c om*/ */ private void layoutComponents() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setBorder(null); scrollPane.setOpaque(true); scrollPane.setBackground(backgroundColor); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); add(placeholder); JPanel flow = new JPanel(); flow.setLayout(new FlowLayout()); flow.setOpaque(false); flow.add(scrollPane); add(flow); add(Box.createVerticalGlue()); add(Box.createVerticalGlue()); }
From source file:gui.WikiCorpusClusteringView.java
/** * * @param br/*from ww w . jav a2 s . com*/ * @throws IOException */ private void setUpView(Graph graph) throws IOException { //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm // final AggregateLayout<Number, Number> layout = // new AggregateLayout<Number, Number>(new FRLayout<Number, Number>(graph)); //layout = new TreeLayout<String,Integer>(graph); Layout<Number, Number> layout = new KKLayout<Number, Number>(graph); layout.setSize(new Dimension(900, 900)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() { public Paint transform(Number v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) { return THIN; } else { return THICK; } } }); //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if (relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(graph.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { //clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), // similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); //clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); //clusterAndRecolor(layout, numEdgesToRemove, similarColors, // groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); Container content = getContentPane(); content.add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); content.add(south, BorderLayout.SOUTH); }
From source file:org.ut.biolab.medsavant.client.view.genetics.TablePanel.java
private void updateSummary() { try {// w w w . j a v a 2 s . c om int numPassingVariants = ResultController.getInstance().getFilteredVariantCount(); System.out.println("Num passing " + numPassingVariants + " " + (new Date()).toLocaleString()); final JPanel blockPanel = new JPanel(); ViewUtil.applyVerticalBoxLayout(blockPanel); ringChart = new RingChart(); int ringDiameter = 200; ringChart.setMinimumSize(new Dimension(ringDiameter, ringDiameter)); ringChart.setMaximumSize(new Dimension(ringDiameter, ringDiameter)); ringChart.setPreferredSize(new Dimension(ringDiameter, ringDiameter)); Ring r1 = new Ring(); r1.addItem("Pass all filters", numPassingVariants, new Color(72, 181, 249)); r1.addItem("Don't pass filters", ResultController.getInstance().getTotalVariantCount() - numPassingVariants, Color.gray); r1.setRingWidth(4); ringChart.setRings(Arrays.asList(r1)); JButton b = ViewUtil.getSoftButton("Load Spreadsheet"); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { updateRequired = true; showWaitCard(); setActivePanel(true); if (searchableTablePanel == null) { new TableInitializer().execute(); } else { updateTableIfRequired(); } } }); FilterEffectivenessPanel fep = new FilterEffectivenessPanel(); blockPanel.add(ViewUtil.centerHorizontally(ringChart)); blockPanel.add(Box.createVerticalStrut(5)); blockPanel.add(fep); blockPanel.add(Box.createVerticalStrut(5)); blockPanel.add(ViewUtil.centerHorizontally(b)); JPanel centered = ViewUtil.getClearPanel(); ViewUtil.applyVerticalBoxLayout(centered); centered.add(Box.createVerticalGlue()); centered.add(blockPanel); centered.add(Box.createVerticalGlue()); summaryContainer.removeAll(); summaryContainer.add(ViewUtil.centerHorizontally(centered), BorderLayout.CENTER); } catch (Exception ex) { LOG.error(TablePanel.class, ex); } }