List of usage examples for javax.swing BoxLayout Y_AXIS
int Y_AXIS
To view the source code for javax.swing BoxLayout Y_AXIS.
Click Source Link
From source file:edu.ucla.stat.SOCR.analyses.gui.AnovaTwoWay.java
protected void setMappingPanel() { listIndex = new int[dataTable.getColumnCount()]; for (int j = 0; j < listIndex.length; j++) listIndex[j] = 1;//w w w. j av a 2s .c om bPanel = new JPanel(new BorderLayout()); bPanel.add(mappingPanel, BorderLayout.CENTER); mappingPanel.add(mappingInnerPanel, BorderLayout.CENTER); addButton1.addActionListener(this); addButton2.addActionListener(this); removeButton1.addActionListener(this); removeButton2.addActionListener(this); lModel1 = new DefaultListModel(); lModel2 = new DefaultListModel(); lModel3 = new DefaultListModel(); int cellWidth = 10; listAdded = new JList(lModel1); listAdded.setSelectedIndex(0); listDepRemoved = new JList(lModel2); listIndepRemoved = new JList(lModel3); paintTable(listIndex); listAdded.setFixedCellWidth(cellWidth); listDepRemoved.setFixedCellWidth(cellWidth); listIndepRemoved.setFixedCellWidth(cellWidth); dependentPane = new JScrollPane(listDepRemoved); FIRST_BUTTON_LABEL = "DEPENDENT"; SECOND_BUTTON_LABEL = "INDEPENDENT"; depLabel = new JLabel(FIRST_BUTTON_LABEL); indLabel = new JLabel(SECOND_BUTTON_LABEL); tools1.add(depLabel); tools2.add(indLabel); tools1.add(addButton1); tools1.add(removeButton1); tools2.add(addButton2); tools2.add(removeButton2); tools1.setFloatable(false); tools2.setFloatable(false); // JPanel choicesPanel = new JPanel(); choicesPanel.setLayout(new BoxLayout(choicesPanel, BoxLayout.Y_AXIS)); interactionOnSwitch = new JRadioButton("On"); interactionOnSwitch.addActionListener(this); interactionOnSwitch.setActionCommand(INTERACTIONON); interactionOnSwitch.setSelected(false); interactionOn = false; interactionOffSwitch = new JRadioButton("Off"); interactionOffSwitch.addActionListener(this); interactionOffSwitch.setActionCommand(INTERACTIONOFF); interactionOffSwitch.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(interactionOnSwitch); group.add(interactionOffSwitch); choicesPanel.add(new JLabel("Turn the interaction:")); choicesPanel.add(interactionOnSwitch); choicesPanel.add(interactionOffSwitch); choicesPanel.setPreferredSize(new Dimension(200, 100)); JPanel emptyPanel = new JPanel(); //mappingInnerPanel.setBackground(Color.RED); mappingInnerPanel.add(new JScrollPane(listAdded)); mappingInnerPanel.add(tools1); mappingInnerPanel.add(dependentPane); // mappingInnerPanel.add(emptyPanel); mappingInnerPanel.add(choicesPanel); mappingInnerPanel.add(tools2); mappingInnerPanel.add(new JScrollPane(listIndepRemoved)); //listIndepRemoved.setBackground(Color.GREEN); }
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private JComponent createQuickOpenPanel(JPanel panel, String title, List<Action> quickOpenActionList, List<File> fileList) { panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); refreshQuickOpenPanel(panel, quickOpenActionList, fileList); JScrollPane scrollPane = new JScrollPane(panel); scrollPane.getVerticalScrollBar().setUnitIncrement(25); scrollPane.setMinimumSize(new Dimension(100, 80)); // Size fits into screen resolution 1024*768 scrollPane.setPreferredSize(new Dimension(180, 200)); JPanel titlePanel = new JPanel(new BorderLayout()); titlePanel.add(scrollPane, BorderLayout.CENTER); titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2), BorderFactory.createTitledBorder(title))); return titlePanel; }
From source file:drusy.ui.panels.SwitchStatePanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Kevin Renella headerPanel = new JPanel(); label1 = new JLabel(); mainPanel = new JPanel(); //======== this ======== setLayout(new BorderLayout()); //======== headerPanel ======== {/*from w w w.j a va 2 s .com*/ headerPanel.setLayout(new BorderLayout()); //---- label1 ---- label1.setText("This panel shows you the users connected on the Switch"); label1.setHorizontalAlignment(SwingConstants.CENTER); headerPanel.add(label1, BorderLayout.CENTER); } add(headerPanel, BorderLayout.NORTH); //======== mainPanel ======== { mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); } add(mainPanel, BorderLayout.CENTER); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java
protected JPanel buildFileSelectionSubPanel() { final JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalGlue()); JButton openButton = new JButton(resourceBundle.getString("Select_file")); openButton.setMnemonic('O'); openButton.setToolTipText(resourceBundle.getString("ToolTip.Select_file")); panel.add(openButton);/*w w w . j av a 2s .c o m*/ panel.add(Box.createRigidArea(new Dimension(10, 10))); JLabel fileLabel = new ABIFileLabel(); panel.add(fileLabel); // Open button listener. openButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int returnVal = fileChooser.showOpenDialog(appWindow); if (returnVal == JFileChooser.APPROVE_OPTION) { abiFile = fileChooser.getSelectedFile(); panel.repaint(); saveButton.setEnabled(true); } } }); panel.setAlignmentX(Component.LEFT_ALIGNMENT); return panel; }
From source file:au.edu.uwa.csse.plot.Clustering.java
private void setUpView(Graph graph) throws IOException { //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>( new FRLayout<Integer, Number>(graph)); vv = new VisualizationViewer<Integer, Number>(layout); vv.setBackground(Color.white); vv.setVertexToolTipTransformer(Plot.vertexLabelTransformer); //Tell the renderer to use our own customized color rendering vv.getRenderContext()//from w ww. j a v a2 s.com .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; } }); //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:netcap.JcaptureConfiguration.java
/** * ????//from w ww. jav a 2 s . c o m * @return */ private JPanel getCaplenPanel() { JPanel caplenPanel = ViewModules.createSimplePanel("", Component.CENTER_ALIGNMENT, -1f, BoxLayout.Y_AXIS); caplenTextField = ViewModules.createTextField(20, "1514", false); JRadioButton wholeRadioButton = ViewModules.createRadioButton("?", Command.WHOLE.getName(), this); wholeRadioButton.setSelected(true); JRadioButton headRadioButton = ViewModules.createRadioButton("", Command.HEAD.getName(), this); JRadioButton otherRadioButton = ViewModules.createRadioButton("", Command.OTHER.getName(), this); ViewModules.addComponent(caplenPanel, caplenTextField, wholeRadioButton, headRadioButton, otherRadioButton); // ????? ViewModules.createButtonGroup(wholeRadioButton, headRadioButton, otherRadioButton); return caplenPanel; }
From source file:MyLink.java
public JPanel KSGenerate() { // create a simple graph for the demo graph = new SparseMultigraph<Integer, MyLink>(); Integer[] v = createVertices(getTermNum()); createEdges(v);//from www .ja v a 2s .com vv = new VisualizationViewer<Integer, MyLink>(new KKLayout<Integer, MyLink>(graph)); //vv.setPreferredSize(new Dimension(540,500)); vv.setPreferredSize(new Dimension(610, 570)); // 570, 640 | 565, 640 | 565, 570 vv.getRenderContext().setVertexLabelTransformer(new UnicodeVertexStringer<Integer>(v)); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.magenta)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.magenta)); VertexIconShapeTransformer<Integer> vertexIconShapeFunction = new VertexIconShapeTransformer<Integer>( new EllipseVertexShapeTransformer<Integer>()); DefaultVertexIconTransformer<Integer> vertexIconFunction = new DefaultVertexIconTransformer<Integer>(); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); loadImages(v, vertexIconFunction.getIconMap()); vertexIconShapeFunction.setIconMap(vertexIconFunction.getIconMap()); vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Integer>( vv.getPickedVertexState(), new Color(0, 102, 255), Color.red)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<MyLink>(vv.getPickedEdgeState(), Color.orange, Color.cyan)); vv.setBackground(Color.white); final int maxSize = findMaxSizeNumber(); File file = new File("./output/DESC_TERM_COUNT.txt"); String s; try { BufferedReader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file))); s = fis.readLine(); userSelectedTermsCount = Integer.parseInt(s); termIndex = new int[userSelectedTermsCount]; int i = 0; while ((s = fis.readLine()) != null) { String[] tmp = s.split("="); termIndex[i] = Integer.parseInt(tmp[1].trim()); i++; } } catch (IOException e) { System.out.println(e.getMessage()); } Transformer<Integer, Shape> vertexSize = new Transformer<Integer, Shape>() { public Shape transform(Integer i) { double sizeInt = termIndex[i]; sizeInt = (double) sizeInt / (double) maxSize; sizeInt = (double) sizeInt * (double) 30 + 10; Ellipse2D circle = new Ellipse2D.Double(sizeInt / 2 * (-1), sizeInt / 2 * (-1), sizeInt, sizeInt); return circle; } }; vv.getRenderContext().setVertexShapeTransformer(vertexSize); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.N); // add my listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>()); // create a frome to hold the graph APanel = new JPanel(); APanel.setLayout(new BoxLayout(APanel, BoxLayout.Y_AXIS)); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(gm); 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()); } }); JCheckBox lo = new JCheckBox("Show Labels"); lo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { showLabels = e.getStateChange() == ItemEvent.SELECTED; vv.repaint(); } }); lo.setSelected(true); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); controls.add(lo); controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox()); vv.setBorder(KSMapBorder); APanel.add(vv); APanel.add(controls); return APanel; }
From source file:FileChooserDemo.java
public FileChooserDemo() { UIManager.LookAndFeelInfo[] installedLafs = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo lafInfo : installedLafs) { try {/*from ww w. j a v a 2 s.c o m*/ Class lnfClass = Class.forName(lafInfo.getClassName()); LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance()); if (laf.isSupportedLookAndFeel()) { String name = lafInfo.getName(); supportedLaFs.add(new SupportedLaF(name, laf)); } } catch (Exception e) { // If ANYTHING weird happens, don't add it continue; } } setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); chooser = new JFileChooser(); previewer = new FilePreviewer(chooser); // Create Custom FileView fileView = new ExampleFileView(); // fileView.putIcon("jpg", new ImageIcon(getClass().getResource("/resources/images/jpgIcon.jpg"))); // fileView.putIcon("gif", new ImageIcon(getClass().getResource("/resources/images/gifIcon.gif"))); // create a radio listener to listen to option changes OptionListener optionListener = new OptionListener(); // Create options openRadioButton = new JRadioButton("Open"); openRadioButton.setSelected(true); openRadioButton.addActionListener(optionListener); saveRadioButton = new JRadioButton("Save"); saveRadioButton.addActionListener(optionListener); customButton = new JRadioButton("Custom"); customButton.addActionListener(optionListener); customField = new JTextField(8) { public Dimension getMaximumSize() { return new Dimension(getPreferredSize().width, getPreferredSize().height); } }; customField.setText("Doit"); customField.setAlignmentY(JComponent.TOP_ALIGNMENT); customField.setEnabled(false); customField.addActionListener(optionListener); ButtonGroup group1 = new ButtonGroup(); group1.add(openRadioButton); group1.add(saveRadioButton); group1.add(customButton); // filter buttons showAllFilesFilterCheckBox = new JCheckBox("Show \"All Files\" Filter"); showAllFilesFilterCheckBox.addActionListener(optionListener); showAllFilesFilterCheckBox.setSelected(true); showImageFilesFilterCheckBox = new JCheckBox("Show JPG and GIF Filters"); showImageFilesFilterCheckBox.addActionListener(optionListener); showImageFilesFilterCheckBox.setSelected(false); accessoryCheckBox = new JCheckBox("Show Preview"); accessoryCheckBox.addActionListener(optionListener); accessoryCheckBox.setSelected(false); // more options setHiddenCheckBox = new JCheckBox("Show Hidden Files"); setHiddenCheckBox.addActionListener(optionListener); showFullDescriptionCheckBox = new JCheckBox("With File Extensions"); showFullDescriptionCheckBox.addActionListener(optionListener); showFullDescriptionCheckBox.setSelected(true); showFullDescriptionCheckBox.setEnabled(false); useFileViewCheckBox = new JCheckBox("Use FileView"); useFileViewCheckBox.addActionListener(optionListener); useFileViewCheckBox.setSelected(false); useEmbedInWizardCheckBox = new JCheckBox("Embed in Wizard"); useEmbedInWizardCheckBox.addActionListener(optionListener); useEmbedInWizardCheckBox.setSelected(false); useControlsCheckBox = new JCheckBox("Show Control Buttons"); useControlsCheckBox.addActionListener(optionListener); useControlsCheckBox.setSelected(true); enableDragCheckBox = new JCheckBox("Enable Dragging"); enableDragCheckBox.addActionListener(optionListener); // File or Directory chooser options ButtonGroup group3 = new ButtonGroup(); justFilesRadioButton = new JRadioButton("Just Select Files"); justFilesRadioButton.setSelected(true); group3.add(justFilesRadioButton); justFilesRadioButton.addActionListener(optionListener); justDirectoriesRadioButton = new JRadioButton("Just Select Directories"); group3.add(justDirectoriesRadioButton); justDirectoriesRadioButton.addActionListener(optionListener); bothFilesAndDirectoriesRadioButton = new JRadioButton("Select Files or Directories"); group3.add(bothFilesAndDirectoriesRadioButton); bothFilesAndDirectoriesRadioButton.addActionListener(optionListener); singleSelectionRadioButton = new JRadioButton("Single Selection", true); singleSelectionRadioButton.addActionListener(optionListener); multiSelectionRadioButton = new JRadioButton("Multi Selection"); multiSelectionRadioButton.addActionListener(optionListener); ButtonGroup group4 = new ButtonGroup(); group4.add(singleSelectionRadioButton); group4.add(multiSelectionRadioButton); // Create show button showButton = new JButton("Show FileChooser"); showButton.addActionListener(this); showButton.setMnemonic('s'); // Create laf combo box lafComboBox = new JComboBox(supportedLaFs); lafComboBox.setEditable(false); lafComboBox.addActionListener(optionListener); // ******************************************************** // ******************** Dialog Type *********************** // ******************************************************** JPanel control1 = new InsetPanel(insets); control1.setBorder(BorderFactory.createTitledBorder("Dialog Type")); control1.setLayout(new BoxLayout(control1, BoxLayout.Y_AXIS)); control1.add(Box.createRigidArea(vpad20)); control1.add(openRadioButton); control1.add(Box.createRigidArea(vpad7)); control1.add(saveRadioButton); control1.add(Box.createRigidArea(vpad7)); control1.add(customButton); control1.add(Box.createRigidArea(vpad4)); JPanel fieldWrapper = new JPanel(); fieldWrapper.setLayout(new BoxLayout(fieldWrapper, BoxLayout.X_AXIS)); fieldWrapper.setAlignmentX(Component.LEFT_ALIGNMENT); fieldWrapper.add(Box.createRigidArea(hpad10)); fieldWrapper.add(Box.createRigidArea(hpad10)); fieldWrapper.add(customField); control1.add(fieldWrapper); control1.add(Box.createRigidArea(vpad20)); control1.add(Box.createGlue()); // ******************************************************** // ***************** Filter Controls ********************** // ******************************************************** JPanel control2 = new InsetPanel(insets); control2.setBorder(BorderFactory.createTitledBorder("Filter Controls")); control2.setLayout(new BoxLayout(control2, BoxLayout.Y_AXIS)); control2.add(Box.createRigidArea(vpad20)); control2.add(showAllFilesFilterCheckBox); control2.add(Box.createRigidArea(vpad7)); control2.add(showImageFilesFilterCheckBox); control2.add(Box.createRigidArea(vpad4)); JPanel checkWrapper = new JPanel(); checkWrapper.setLayout(new BoxLayout(checkWrapper, BoxLayout.X_AXIS)); checkWrapper.setAlignmentX(Component.LEFT_ALIGNMENT); checkWrapper.add(Box.createRigidArea(hpad10)); checkWrapper.add(Box.createRigidArea(hpad10)); checkWrapper.add(showFullDescriptionCheckBox); control2.add(checkWrapper); control2.add(Box.createRigidArea(vpad20)); control2.add(Box.createGlue()); // ******************************************************** // ****************** Display Options ********************* // ******************************************************** JPanel control3 = new InsetPanel(insets); control3.setBorder(BorderFactory.createTitledBorder("Display Options")); control3.setLayout(new BoxLayout(control3, BoxLayout.Y_AXIS)); control3.add(Box.createRigidArea(vpad20)); control3.add(setHiddenCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useFileViewCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(accessoryCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useEmbedInWizardCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(useControlsCheckBox); control3.add(Box.createRigidArea(vpad7)); control3.add(enableDragCheckBox); control3.add(Box.createRigidArea(vpad20)); control3.add(Box.createGlue()); // ******************************************************** // ************* File & Directory Options ***************** // ******************************************************** JPanel control4 = new InsetPanel(insets); control4.setBorder(BorderFactory.createTitledBorder("File and Directory Options")); control4.setLayout(new BoxLayout(control4, BoxLayout.Y_AXIS)); control4.add(Box.createRigidArea(vpad20)); control4.add(justFilesRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(justDirectoriesRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(bothFilesAndDirectoriesRadioButton); control4.add(Box.createRigidArea(vpad20)); control4.add(singleSelectionRadioButton); control4.add(Box.createRigidArea(vpad7)); control4.add(multiSelectionRadioButton); control4.add(Box.createRigidArea(vpad20)); control4.add(Box.createGlue()); // ******************************************************** // **************** Look & Feel Switch ******************** // ******************************************************** JPanel panel = new JPanel(); panel.add(new JLabel("Look and Feel: ")); panel.add(lafComboBox); panel.add(showButton); // ******************************************************** // ****************** Wrap 'em all up ********************* // ******************************************************** JPanel wrapper = new JPanel(); wrapper.setLayout(new BoxLayout(wrapper, BoxLayout.X_AXIS)); add(Box.createRigidArea(vpad20)); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control1); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control2); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control3); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(control4); wrapper.add(Box.createRigidArea(hpad10)); wrapper.add(Box.createRigidArea(hpad10)); add(wrapper); add(Box.createRigidArea(vpad20)); add(panel); add(Box.createRigidArea(vpad20)); }
From source file:fungus.JungObserver.java
public JungObserver(String name) { this.name = name; this.hyphadataPid = Configuration.getPid(name + "." + PAR_HYPHADATA_PROTO); this.hyphalinkPid = Configuration.getPid(name + "." + PAR_HYPHALINK_PROTO); this.mycocastPid = Configuration.getPid(name + "." + PAR_MYCOCAST_PROTO); self = this;/*from ww w .j a v a 2 s .com*/ mainThread = Thread.currentThread(); graph = new DirectedSparseGraph<MycoNode, String>(); edu.uci.ics.jung.algorithms.layout.SpringLayout<MycoNode, String> layout = new edu.uci.ics.jung.algorithms.layout.SpringLayout<MycoNode, String>( graph); layout.setSize(new Dimension(650, 650)); layout.setRepulsionRange(75); //layout.setForceMultiplier(0.75); layout.setStretch(0.85); Dimension preferredSize = new Dimension(650, 650); VisualizationModel<MycoNode, String> visualizationModel = new DefaultVisualizationModel<MycoNode, String>( layout, preferredSize); visualizer = new VisualizationViewer<MycoNode, String>(visualizationModel, preferredSize); visualizer.addGraphMouseListener(new InfoFrameVertexListener()); //visualizer = new BasicVisualizationServer<Node,String>(layout); //visualizer.setPreferredSize(new Dimension(650, 650)); Transformer<MycoNode, String> nodeLabeller = new Transformer<MycoNode, String>() { public String transform(MycoNode n) { return Long.toString(n.getID()); } }; final Shape biomassCircle = new Ellipse2D.Float(-2.5f, -2.5f, 5.0f, 5.0f); final Shape hyphaCircle = new Ellipse2D.Float(-5.0f, -5.0f, 10.0f, 10.0f); Transformer<MycoNode, Shape> shapeTransformer = new Transformer<MycoNode, Shape>() { public Shape transform(MycoNode n) { HyphaData data = n.getHyphaData(); if (data.isBiomass()) { return biomassCircle; } else { return hyphaCircle; } } }; Transformer<MycoNode, Paint> nodeFillRenderer = new Transformer<MycoNode, Paint>() { public Paint transform(MycoNode n) { HyphaData data = (HyphaData) n.getProtocol(hyphadataPid); if (!n.isUp()) { return Color.BLACK; } if (data.isBiomass()) { return Color.BLUE; } else if (data.isExtending()) { return Color.RED; } else if (data.isBranching()) { return Color.YELLOW; } else { return Color.GREEN; } } }; Transformer<MycoNode, Paint> nodeShapeRenderer = new Transformer<MycoNode, Paint>() { public Paint transform(MycoNode n) { HyphaData data = (HyphaData) n.getProtocol(hyphadataPid); if (data.isBiomass()) { return Color.BLUE; } else if (data.isExtending()) { return Color.RED; } else if (data.isBranching()) { return Color.YELLOW; } else { return Color.GREEN; } } }; final Stroke biomassStroke = new BasicStroke(0.25f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f); final Stroke hyphalStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f); Transformer<String, Stroke> edgeStrokeTransformer = new Transformer<String, Stroke>() { public Stroke transform(String s) { Pair<MycoNode> vertices = graph.getEndpoints(s); HyphaData firstData = vertices.getFirst().getHyphaData(); HyphaData secondData = vertices.getSecond().getHyphaData(); if (firstData.isHypha() && secondData.isHypha()) { return hyphalStroke; } else { return biomassStroke; } } }; visualizer.getRenderContext().setVertexFillPaintTransformer(nodeFillRenderer); visualizer.getRenderContext().setVertexShapeTransformer(shapeTransformer); visualizer.getRenderContext().setVertexLabelTransformer(nodeLabeller); visualizer.setVertexToolTipTransformer(new ToStringLabeller<MycoNode>()); visualizer.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = frame.getContentPane(); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); //JScrollPane scrollPane = new JScrollPane(visualizer); //c.add(scrollPane); c.add(visualizer); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); JButton pauseButton = new JButton("pause"); ActionListener pauser = new ActionListener() { public void actionPerformed(ActionEvent e) { //e.consume(); synchronized (self) { stepBlocked = true; noBlock = false; //self.notifyAll(); } } }; pauseButton.addActionListener(pauser); JButton stepButton = new JButton("step"); ActionListener stepper = new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Clicked!\n"); //e.consume(); synchronized (self) { stepBlocked = false; self.notifyAll(); } } }; stepButton.addActionListener(stepper); JButton runButton = new JButton("run"); ActionListener runner = new ActionListener() { public void actionPerformed(ActionEvent e) { //e.consume(); synchronized (self) { stepBlocked = false; noBlock = true; self.notifyAll(); } } }; runButton.addActionListener(runner); buttonPane.add(pauseButton); buttonPane.add(stepButton); buttonPane.add(runButton); c.add(buttonPane); frame.pack(); frame.setVisible(true); }
From source file:TextureByReference.java
public JPanel buildGui() { flipB = new JCheckBox("flip image", true); flipB.addItemListener(this); javax.swing.Box flipBox = new javax.swing.Box(BoxLayout.Y_AXIS); flipBox.add(flipB);/*from w w w . j a v a2s . c o m*/ Component strut1 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut2 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut3 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut4 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut5 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); flipBox.add(strut1); flipBox.add(strut2); flipBox.add(strut3); flipBox.add(strut4); flipBox.add(strut5); yUp = new JRadioButton("y up"); yUp.addActionListener(this); yUp.setSelected(true); yDown = new JRadioButton("y down"); yDown.addActionListener(this); ButtonGroup yGroup = new ButtonGroup(); yGroup.add(yUp); yGroup.add(yDown); JLabel yLabel = new JLabel("Image Orientation:"); javax.swing.Box yBox = new javax.swing.Box(BoxLayout.Y_AXIS); yBox.add(yLabel); yBox.add(yUp); yBox.add(yDown); strut1 = yBox.createVerticalStrut(yUp.getPreferredSize().height); strut2 = yBox.createVerticalStrut(yUp.getPreferredSize().height); strut3 = yBox.createVerticalStrut(yUp.getPreferredSize().height); yBox.add(strut1); yBox.add(strut2); yBox.add(strut3); texByRef = new JRadioButton("by reference"); texByRef.addActionListener(this); texByRef.setSelected(true); texByCopy = new JRadioButton("by copy"); texByCopy.addActionListener(this); ButtonGroup texGroup = new ButtonGroup(); texGroup.add(texByRef); texGroup.add(texByCopy); JLabel texLabel = new JLabel("Texture:*"); javax.swing.Box texBox = new javax.swing.Box(BoxLayout.Y_AXIS); texBox.add(texLabel); texBox.add(texByRef); texBox.add(texByCopy); strut1 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); strut2 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); strut3 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); texBox.add(strut1); texBox.add(strut2); texBox.add(strut3); geomByRef = new JRadioButton("by reference"); geomByRef.addActionListener(this); geomByRef.setSelected(true); geomByCopy = new JRadioButton("by copy"); geomByCopy.addActionListener(this); ButtonGroup geomGroup = new ButtonGroup(); geomGroup.add(geomByRef); geomGroup.add(geomByCopy); JLabel geomLabel = new JLabel("Geometry:"); javax.swing.Box geomBox = new javax.swing.Box(BoxLayout.Y_AXIS); geomBox.add(geomLabel); geomBox.add(geomByRef); geomBox.add(geomByCopy); strut1 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); strut2 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); strut3 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); geomBox.add(strut1); geomBox.add(strut2); geomBox.add(strut3); img4ByteABGR = new JRadioButton("TYPE_4BYTE_ABGR"); img4ByteABGR.addActionListener(this); img4ByteABGR.setSelected(true); img3ByteBGR = new JRadioButton("TYPE_3BYTE_BGR"); img3ByteBGR.addActionListener(this); imgIntARGB = new JRadioButton("TYPE_INT_ARGB"); imgIntARGB.addActionListener(this); imgCustomRGBA = new JRadioButton("TYPE_CUSTOM RGBA"); imgCustomRGBA.addActionListener(this); imgCustomRGB = new JRadioButton("TYPE_CUSTOM RGB"); imgCustomRGB.addActionListener(this); ButtonGroup imgGroup = new ButtonGroup(); imgGroup.add(img4ByteABGR); imgGroup.add(img3ByteBGR); imgGroup.add(imgIntARGB); imgGroup.add(imgCustomRGBA); imgGroup.add(imgCustomRGB); JLabel imgLabel = new JLabel("Image Type:*"); javax.swing.Box imgBox = new javax.swing.Box(BoxLayout.Y_AXIS); imgBox.add(imgLabel); imgBox.add(img4ByteABGR); imgBox.add(img3ByteBGR); imgBox.add(imgIntARGB); imgBox.add(imgCustomRGBA); imgBox.add(imgCustomRGB); javax.swing.Box topBox = new javax.swing.Box(BoxLayout.X_AXIS); topBox.add(flipBox); topBox.add(texBox); topBox.add(geomBox); topBox.add(yBox); Component strut = topBox.createRigidArea(new Dimension(10, 10)); topBox.add(strut); topBox.add(imgBox); frameDelay = new JSlider(0, 50, 0); frameDelay.addChangeListener(this); frameDelay.setSnapToTicks(true); frameDelay.setPaintTicks(true); frameDelay.setPaintLabels(true); frameDelay.setMajorTickSpacing(10); frameDelay.setMinorTickSpacing(1); frameDelay.setValue(20); JLabel delayL = new JLabel("frame delay"); javax.swing.Box delayBox = new javax.swing.Box(BoxLayout.X_AXIS); delayBox.add(delayL); delayBox.add(frameDelay); animationB = new JButton(" stop animation "); animationB.addActionListener(this); JLabel texInfo1 = new JLabel("*To use ImageComponent by reference feature, use TYPE_4BYTE_ABGR on Solaris"); JLabel texInfo2 = new JLabel("and TYPE_3BYTE_BGR on Windows"); JPanel buttonP = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); buttonP.setLayout(gridbag); c.anchor = GridBagConstraints.CENTER; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(topBox, c); buttonP.add(topBox); gridbag.setConstraints(delayBox, c); buttonP.add(delayBox); gridbag.setConstraints(animationB, c); buttonP.add(animationB); gridbag.setConstraints(texInfo1, c); buttonP.add(texInfo1); gridbag.setConstraints(texInfo2, c); buttonP.add(texInfo2); return buttonP; }