public void buildPopulationBox() { rebuilding = true; populationBox.removeAll(); peopleList = new ArrayList<Object>(); famList = new ArrayList<Family>(); peopleList.addAll(ctxt.individualCensus); String plur = (peopleList.size() == 1 ? "" : "s"); populationBox.setLayout(new BoxLayout(populationBox, BoxLayout.PAGE_AXIS)); populationBox.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Current Population")); populationBox.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(8, 0))); indivLabel = new JLabel("Contains " + peopleList.size() + " Individual" + plur); indivLabel.setAlignmentX(0.5f); populationBox.add(indivLabel); if (peopleList.size() > 0) { JPanel indivBtnBox = new JPanel(); indivBtnBox.setLayout(new BoxLayout(indivBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] indMenu = genIndMenu(peopleList); indPick = new JComboBox(indMenu); indPick.addActionListener(listener); indPick.setActionCommand("view/edit person"); indPick.setMinimumSize(sizer2); indPick.setMaximumSize(sizer2); indPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Person")); indivBtnBox.add(indPick); populationBox.add(indivBtnBox); } // end of if-any-people-exist famList.addAll(ctxt.familyCensus); // end of filtering deleted records plur = (famList.size() == 1 ? "y" : "ies"); famLabel = new JLabel("Contains " + famList.size() + " Famil" + plur); famLabel.setAlignmentX(0.5f); populationBox.add(Box.createRigidArea(new Dimension(0, 4))); populationBox.add(famLabel); if (famList.size() > 0) { JPanel famBtnBox = new JPanel(); famBtnBox.setLayout(new BoxLayout(famBtnBox, BoxLayout.LINE_AXIS)); Dimension sizer2 = new Dimension(350, 50); String[] famMenu = genFamMenu(famList); famPick = new JComboBox(famMenu); famPick.addActionListener(listener); famPick.setActionCommand("view/edit family"); famPick.setMinimumSize(sizer2); famPick.setMaximumSize(sizer2); famPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit Family")); famBtnBox.add(famPick); populationBox.add(famBtnBox); } // end of if-any-families-exist rebuilding = false; } // end of method buildPopulationBox
public HeaderPanel(String heading) { super(); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.setBackground(background); JLabel panelLabel = new JLabel(" " + heading, SwingConstants.LEFT); Font labelFont = new Font("Dialog", Font.BOLD, 18); panelLabel.setFont(labelFont); this.add(panelLabel); this.add(Box.createHorizontalGlue()); refresh = new JButton("Refresh"); refresh.addActionListener(this); this.add(refresh); this.add(Box.createHorizontalStrut(5)); root = new JComboBox(); Dimension d = root.getPreferredSize(); d.width = 90; root.setPreferredSize(d); root.setMaximumSize(d); File[] roots = directoryPane.getRoots(); for (int i = 0; i < roots.length; i++) root.addItem(roots[i].getAbsolutePath()); this.add(root); root.setSelectedIndex(directoryPane.getCurrentRootIndex()); root.addActionListener(this); this.add(Box.createHorizontalStrut(17)); }
public ReferencePropertyWidget(boolean containedByListReferenceGUI) { this.containedByListReferenceGUI = containedByListReferenceGUI; // get Options m_comboBox = new JComboBox(); m_comboBox.setEditable(false); m_comboBox.setPreferredSize(new Dimension(300, 20)); // m_comboBox.setMinimumSize(new Dimension(260, 20)); m_comboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 20)); KeyStroke controlT = KeyStroke.getKeyStroke("control SPACE"); getTextField().getInputMap().put(controlT, controlT); getTextField().getActionMap().put(controlT, new CodeCompleteAction()); ToolTipManager.sharedInstance().registerComponent(m_comboBox); }
@Inject public ProblemSelectionPanel(qcevolutionbackend be) { this.setLayout(new BorderLayout()); backend = be; Set<String> probs = backend.getProbmanager().getAvailableProblems(); String[] options = new String[probs.size() + 1]; options[0] = "Please Select Problem"; int index = 1; Iterator<String> iter = probs.iterator(); while (iter.hasNext()) { options[index++] = iter.next(); } selection_model = new DefaultComboBoxModel(options); description = new JTextPane(); description.setEditable(false); description_scroller = new JScrollPane(description); description_scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); description_scroller.setPreferredSize(new Dimension(250, 155)); description_scroller.setMinimumSize(new Dimension(10, 10)); if (backend.getCurrentse() != null) { String key = backend.getQproblem().getName(); selection_model.setSelectedItem(key); description.setText(backend.getProbmanager().getSearchEngineDesc(key)); } Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); selection = new JComboBox(selection_model); selection.addActionListener(this); selection.setPreferredSize(new Dimension((int) (screenSize.width * MainPanel.right_perc), 30)); selection.setMaximumSize(new Dimension((int) (screenSize.width * MainPanel.right_perc), 30)); be.addObserver(this); be.getProbmanager().addObserver(this); if (null != backend.getCurrentse()) { backend.getCurrentse().addObserver(this); } this.add(selection, BorderLayout.NORTH); this.add(description_scroller, BorderLayout.CENTER); }
private StaticPanel createStaticComboBoxPanel( PrimitiveForm primitiveForm, DOTProperty property, String labelText, Object[] items) { JLabel label = new JLabel(labelText); JComboBox comboBox = new JComboBox(items); comboBox.setMaximumSize(new Dimension(300, 25)); comboBox.setEnabled(_dotDefinitionDialogFrame.isEditable()); StaticPanel thePanel = new StaticPanel(primitiveForm, property); thePanel.setMaximumSize(new Dimension(300, 25)); thePanel.setLayout(new SpringLayout()); thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK)); thePanel.add(label); thePanel.add(comboBox); SpringUtilities.makeCompactGrid(thePanel, 2, 5, 5); thePanel.setValue(comboBox); thePanel.addListener(comboBox); return thePanel; }
private JPanel createLeftPanel() { JPanel left = new JPanel(); left.setLayout(new BoxLayout(left, BoxLayout.X_AXIS)); imagesCombo = new JComboBox(); imagesCombo.addItem("Thresholded"); imagesCombo.addItem("Filtered"); imagesCombo.addActionListener(this); imagesCombo.setSelectedIndex(1); imagesCombo.setMaximumSize(imagesCombo.getPreferredSize()); selectThresh = new SelectHistogramThresholdPanel(20, true); selectThresh.setListener(this); left.add(imagesCombo); left.add(selectThresh); left.add(Box.createHorizontalGlue()); return left; }
/* * Create and set up a new CoreqPanel that is the correct size. Do not allow the user to modify any * of the characteristics of the panel; the panel will be the same for any course. */ public CoreqPanel() { this.setMinimumSize(new Dimension(800, 25)); this.setMaximumSize(new Dimension(2600, 26)); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); coreqField = new JTextField(); coreqField.setMinimumSize(new Dimension(300, 20)); coreqField.setMaximumSize(new Dimension(2000, 21)); coreqType = new JComboBox(); coreqType.addItem("Credits"); coreqType.addItem("Course"); coreqType.addItem("Requirement"); coreqType.setMinimumSize(new Dimension(100, 20)); coreqType.setMaximumSize(new Dimension(100, 21)); JLabel coreqName = new JLabel("Name of Corequisite: "); this.add(coreqName); this.add(coreqField); this.add(Box.createRigidArea(new Dimension(10, 0))); this.add(coreqType); this.add(Box.createGlue()); }
void jbInit() throws Exception { border1 = BorderFactory.createEmptyBorder(10, 10, 5, 5); panel1.setLayout(borderLayout1); jPanel1.setLayout(borderLayout2); jScrollPane1.getViewport().setBackground(Color.white); jPanel2.setLayout(gridBagLayout1); jLabel1.setText("Profile Name : "); nameTextField.setMinimumSize(new Dimension(4, 18)); nameTextField.setPreferredSize(new Dimension(63, 18)); jLabel2.setText("Profile Type : "); openButton.setMaximumSize(new Dimension(73, 24)); openButton.setMinimumSize(new Dimension(73, 24)); openButton.setPreferredSize(new Dimension(73, 24)); openButton.setText("Open"); openButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { openButton_actionPerformed(e); } }); cancelButton.setMaximumSize(new Dimension(73, 24)); cancelButton.setMinimumSize(new Dimension(73, 24)); cancelButton.setPreferredSize(new Dimension(73, 24)); cancelButton.setMargin(new Insets(0, 5, 0, 5)); cancelButton.setText("Cancel"); cancelButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton_actionPerformed(e); } }); profileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); profileList.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { profileList_mouseClicked(e); } }); jPanel2.setBorder(border1); typeComboBox.setMaximumSize(new Dimension(32767, 18)); typeComboBox.setMinimumSize(new Dimension(122, 18)); typeComboBox.setPreferredSize(new Dimension(176, 18)); getContentPane().add(panel1); panel1.add(jPanel1, BorderLayout.CENTER); jPanel1.add(jScrollPane1, BorderLayout.CENTER); panel1.add(jPanel2, BorderLayout.SOUTH); jPanel2.add( jLabel1, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 7, 0), 0, 0)); jPanel2.add( nameTextField, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 11, 7, 0), 0, 0)); jPanel2.add( jLabel2, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 17, 0), 0, 0)); jScrollPane1.getViewport().add(profileList, null); jPanel2.add( openButton, new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 2, 10), 0, 0)); jPanel2.add( cancelButton, new GridBagConstraints( 3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 9, 10), 0, 0)); jPanel2.add( typeComboBox, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 11, 17, 0), 0, 0)); }
public LingDisplay(final Ling.StoredGraphs storedGraphs) { this.storedGraphs = storedGraphs; if (storedGraphs.getNumGraphs() == 0) { workbench = new GraphWorkbench(); } else { workbench = new GraphWorkbench(storedGraphs.getGraph(0)); } subsetIndices = getStableIndices(storedGraphs); final SpinnerNumberModel model = new SpinnerNumberModel(subsetIndices.size() == 0 ? 0 : 1, 0, subsetIndices.size(), 1); model.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { int index = model.getNumber().intValue(); workbench.setGraph(storedGraphs.getGraph(subsetIndices.get(index - 1))); } }); spinner = new JSpinner(); subsetCombo = new JComboBox(new String[] {"Show Stable", "Show Unstable", "Show All"}); subsetCombo.setSelectedItem("Show Stable"); spinner.setModel(model); totalLabel = new JLabel(" of " + subsetIndices.size()); subsetCombo.setMaximumSize(subsetCombo.getPreferredSize()); subsetCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { resetDisplay(); } }); spinner.setPreferredSize(new Dimension(50, 20)); spinner.setMaximumSize(spinner.getPreferredSize()); Box b = Box.createVerticalBox(); Box b1 = Box.createHorizontalBox(); // b1.add(Box.createHorizontalGlue()); // b1.add(Box.createHorizontalStrut(10)); b1.add(subsetCombo); b1.add(Box.createHorizontalGlue()); b1.add(new JLabel("DAG ")); b1.add(spinner); b1.add(totalLabel); b.add(b1); Box b2 = Box.createHorizontalBox(); JPanel graphPanel = new JPanel(); graphPanel.setLayout(new BorderLayout()); JScrollPane jScrollPane = new JScrollPane(workbench); // jScrollPane.setPreferredSize(new Dimension(400, 400)); graphPanel.add(jScrollPane); // graphPanel.setBorder(new TitledBorder("DAG")); b2.add(graphPanel); b.add(b2); setLayout(new BorderLayout()); // add(menuBar(), BorderLayout.NORTH); add(b, BorderLayout.CENTER); }
public GUI() { // Frame frame = new JFrame("HardwareSwap Notifier"); // Panels panel = new JPanel(); group1 = new JPanel(); group2 = new JPanel(); group3 = new JPanel(); group4 = new JPanel(); group5 = new JPanel(); group6 = new JPanel(); group7 = new JPanel(); group8 = new JPanel(); // Menu Bar menus = new JMenuBar(); fileMenu = new JMenu("File"); clearCurrent = new JMenuItem("Clear"); quitItem = new JMenuItem("Quit"); load = new JMenuItem("Load"); saveCurrent = new JMenuItem("Save All"); clearSaved = new JMenuItem("Clear Saved"); removeItem = new JMenuItem("Remove Item"); removePhone = new JMenuItem("Remove Phone"); saveCurrent = new JMenuItem("Save Current"); helpMenu = new JMenu("Help"); help = new JMenuItem("How To Use"); about = new JMenuItem("About"); // Buttons add1 = new JButton("Add"); add2 = new JButton("Add"); start = new JButton("Start"); stop = new JButton("Stop"); save1 = new JButton("Add/Save"); save2 = new JButton("Add/Save"); show = new JButton("Display Data"); add1.setFocusPainted(false); add2.setFocusPainted(false); start.setFocusPainted(false); stop.setFocusPainted(false); save1.setFocusPainted(false); save2.setFocusPainted(false); show.setFocusPainted(false); stop.setEnabled(false); // CheckBox remove = new JCheckBox("Remove items when found"); remove.setFocusable(false); // Listener ButtonListener listener = new ButtonListener(); add1.addActionListener(listener); add2.addActionListener(listener); start.addActionListener(listener); stop.addActionListener(listener); load.addActionListener(listener); save1.addActionListener(listener); save2.addActionListener(listener); saveCurrent.addActionListener(listener); show.addActionListener(listener); quitItem.addActionListener(listener); clearCurrent.addActionListener(listener); clearSaved.addActionListener(listener); saveCurrent.addActionListener(listener); help.addActionListener(listener); about.addActionListener(listener); removePhone.addActionListener(listener); removeItem.addActionListener(listener); remove.addActionListener(listener); // Carrier Selection options = new String[10]; options[0] = "AT&T"; options[1] = "Boost Mobile"; options[2] = "Cellular One"; options[3] = "Nextel"; options[4] = "T-Mobile"; options[5] = "Tracfone"; options[6] = "US Cellular"; options[7] = "Sprint"; options[8] = "Verizon"; options[9] = "Virgin Mobile"; carriers = new JComboBox<String>(options); // Text Fields searchName = new JTextField(15); item = new JTextField(15); phone = new JTextField(15); interval2 = new JTextField(15); results = new JTextArea(10, 20); JScrollPane scrollPane = new JScrollPane(results); results.setEditable(false); // Interval intOptions = new SpinnerNumberModel(5, 1, 60, 1); interval = new JSpinner(intOptions); JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField(); tf.setHorizontalAlignment(JFormattedTextField.LEFT); // Background panelBackground = new Color(237, 237, 237); panel.setBackground(panelBackground); searchName.setBackground(panelBackground); item.setBackground(panelBackground); phone.setBackground(panelBackground); interval.setBackground(panelBackground); // Panel Layouts panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS)); group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS)); group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS)); group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS)); group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS)); group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS)); group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS)); group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS)); // Borders searchName.setBorder( BorderFactory.createTitledBorder( null, "Search Name", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); item.setBorder( BorderFactory.createTitledBorder( null, "Item", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); phone.setBorder( BorderFactory.createTitledBorder( null, "Cell Phone", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); group5.setBorder( BorderFactory.createTitledBorder( null, "Check Interval (mins)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); // Sizes panel.setPreferredSize(new Dimension(200, 0)); searchName.setMaximumSize(new Dimension(190, 50)); item.setMaximumSize(new Dimension(190, 50)); phone.setMaximumSize(new Dimension(185, 50)); carriers.setMaximumSize(new Dimension(175, 20)); group5.setPreferredSize(new Dimension(190, 47)); group5.setMaximumSize(new Dimension(190, 47)); add1.setMaximumSize(new Dimension(90, 20)); save1.setMaximumSize(new Dimension(90, 20)); add2.setMaximumSize(new Dimension(90, 20)); save2.setMaximumSize(new Dimension(90, 20)); start.setMaximumSize(new Dimension(90, 20)); stop.setMaximumSize(new Dimension(90, 20)); show.setMaximumSize(new Dimension(120, 20)); // Add file menu items fileMenu.add(clearCurrent); fileMenu.add(clearSaved); fileMenu.add(load); fileMenu.add(removeItem); fileMenu.add(removePhone); fileMenu.add(saveCurrent); fileMenu.add(quitItem); // Add help menu items helpMenu.add(help); helpMenu.add(about); // Add to menu bar menus.add(fileMenu); menus.add(helpMenu); // Add items to panel group1.add(searchName); group1.add(item); group2.add(add1); group2.add(Box.createHorizontalStrut(10)); group2.add(save1); group6.add(remove); group3.add(phone); group3.add(Box.createVerticalStrut(10)); group3.add(carriers); group4.add(add2); group4.add(Box.createHorizontalStrut(10)); group4.add(save2); group5.add(interval); group7.add(show); group8.add(start); group8.add(Box.createHorizontalStrut(10)); group8.add(stop); panel.add(Box.createVerticalStrut(10)); panel.add(group1); panel.add(Box.createVerticalStrut(10)); panel.add(group2); panel.add(Box.createVerticalStrut(40)); panel.add(group3); panel.add(Box.createVerticalStrut(10)); panel.add(group4); panel.add(Box.createVerticalStrut(40)); panel.add(group5); panel.add(Box.createVerticalStrut(30)); panel.add(group6); panel.add(Box.createVerticalStrut(40)); panel.add(group7); panel.add(Box.createVerticalStrut(10)); panel.add(group8); panel.add(Box.createVerticalStrut(10)); // Setup frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(menus); frame.add(scrollPane); frame.add(BorderLayout.EAST, panel); frame.pack(); frame.setSize(new Dimension(670, 620)); frame.setVisible(true); }
public DetectPolygonControlPanel(DetectBlackPolygonApp owner) { this.owner = owner; imageView = new JComboBox(); imageView.addItem("Input"); imageView.addItem("Binary"); imageView.addItem("Black"); imageView.addActionListener(this); imageView.setMaximumSize(imageView.getPreferredSize()); selectZoom = new JSpinner(new SpinnerNumberModel(1, 0.1, 50, 1)); selectZoom.addChangeListener(this); selectZoom.setMaximumSize(selectZoom.getPreferredSize()); showCorners = new JCheckBox("Corners"); showCorners.addActionListener(this); showCorners.setSelected(bShowCorners); showLines = new JCheckBox("Lines"); showLines.setSelected(bShowLines); showLines.addActionListener(this); showContour = new JCheckBox("Contour"); showContour.addActionListener(this); showContour.setSelected(bShowContour); threshold = new ThresholdControlPanel(owner); refineChoice = new JComboBox(); for (PolygonRefineType n : PolygonRefineType.values()) { refineChoice.addItem(n.name()); } refineChoice.setSelectedIndex(refineType.ordinal()); refineChoice.addActionListener(this); refineChoice.setMaximumSize(refineChoice.getPreferredSize()); spinnerMinContourSize = new JSpinner(new SpinnerNumberModel(config.minContourImageWidthFraction, 0.0, 0.2, 0.01)); configureSpinnerFloat(spinnerMinContourSize); spinnerMinSides = new JSpinner(new SpinnerNumberModel(minSides, 3, 20, 1)); spinnerMinSides.setMaximumSize(spinnerMinSides.getPreferredSize()); spinnerMinSides.addChangeListener(this); spinnerMaxSides = new JSpinner(new SpinnerNumberModel(maxSides, 3, 20, 1)); spinnerMaxSides.setMaximumSize(spinnerMaxSides.getPreferredSize()); spinnerMaxSides.addChangeListener(this); spinnerMinEdge = new JSpinner(new SpinnerNumberModel(config.minimumEdgeIntensity, 0.0, 255.0, 1.0)); spinnerMinEdge.setMaximumSize(spinnerMinEdge.getPreferredSize()); spinnerMinEdge.addChangeListener(this); spinnerContourSplit = new JSpinner(new SpinnerNumberModel(config.contour2Poly_splitFraction, 0.0, 1.0, 0.01)); configureSpinnerFloat(spinnerContourSplit); spinnerContourMinSplit = new JSpinner( new SpinnerNumberModel(config.contour2Poly_minimumSideFraction, 0.0, 1.0, 0.001)); configureSpinnerFloat(spinnerContourMinSplit); spinnerContourSplit.addChangeListener(this); spinnerContourIterations = new JSpinner(new SpinnerNumberModel(config.contour2Poly_iterations, 1, 200, 1)); spinnerContourIterations.setMaximumSize(spinnerContourIterations.getPreferredSize()); spinnerContourIterations.addChangeListener(this); spinnerSplitPenalty = new JSpinner(new SpinnerNumberModel(config.splitPenalty, 0.0, 100.0, 1.0)); configureSpinnerFloat(spinnerSplitPenalty); setConvex = new JCheckBox("Convex"); setConvex.addActionListener(this); setConvex.setSelected(config.convex); setBorder = new JCheckBox("Image Border"); setBorder.addActionListener(this); setBorder.setSelected(config.canTouchBorder); spinnerLineSamples = new JSpinner(new SpinnerNumberModel(configLine.lineSamples, 5, 100, 1)); spinnerLineSamples.setMaximumSize(spinnerLineSamples.getPreferredSize()); spinnerLineSamples.addChangeListener(this); spinnerCornerOffset = new JSpinner(new SpinnerNumberModel(configLine.cornerOffset, 0, 10, 1)); spinnerCornerOffset.setMaximumSize(spinnerCornerOffset.getPreferredSize()); spinnerCornerOffset.addChangeListener(this); spinnerSampleRadius = new JSpinner(new SpinnerNumberModel(configLine.sampleRadius, 0, 10, 1)); spinnerSampleRadius.setMaximumSize(spinnerCornerOffset.getPreferredSize()); spinnerSampleRadius.addChangeListener(this); spinnerRefineMaxIterations = new JSpinner(new SpinnerNumberModel(configLine.maxIterations, 0, 200, 1)); spinnerRefineMaxIterations.setMaximumSize(spinnerRefineMaxIterations.getPreferredSize()); spinnerRefineMaxIterations.addChangeListener(this); spinnerConvergeTol = new JSpinner(new SpinnerNumberModel(configLine.convergeTolPixels, 0.0, 2.0, 0.005)); configureSpinnerFloat(spinnerConvergeTol); spinnerMaxCornerChange = new JSpinner(new SpinnerNumberModel(configLine.maxCornerChangePixel, 0.0, 50.0, 1.0)); configureSpinnerFloat(spinnerMaxCornerChange); addLabeled(imageView, "View: ", this); addLabeled(selectZoom, "Zoom", this); addAlignLeft(showCorners, this); addAlignLeft(showLines, this); addAlignLeft(showContour, this); add(threshold); addLabeled(spinnerMinContourSize, "Min Contour Size: ", this); addLabeled(spinnerMinSides, "Minimum Sides: ", this); addLabeled(spinnerMaxSides, "Maximum Sides: ", this); addLabeled(spinnerMinEdge, "Edge Intensity: ", this); addAlignLeft(setConvex, this); addAlignLeft(setBorder, this); addCenterLabel("Contour", this); addLabeled(spinnerContourSplit, "Split Fraction: ", this); addLabeled(spinnerContourMinSplit, "Min Split: ", this); addLabeled(spinnerContourIterations, "Max Iterations: ", this); addLabeled(spinnerSplitPenalty, "Split Penalty: ", this); addCenterLabel("Refinement", this); addLabeled(refineChoice, "Refine: ", this); addLabeled(spinnerLineSamples, "Line Samples: ", this); addLabeled(spinnerCornerOffset, "Corner Offset: ", this); addLabeled(spinnerSampleRadius, "Sample Radius: ", this); addLabeled(spinnerRefineMaxIterations, "Iterations: ", this); addLabeled(spinnerConvergeTol, "Converge Tol Pixels: ", this); addLabeled(spinnerMaxCornerChange, "Max Corner Change: ", this); addVerticalGlue(this); }
/** * Конструктор * * @param mediator Посредник родитьельского окна */ public ButtonToolBar(final IGuiMediator mediator) { this.mediator = mediator; try { locale = ((WBDrawing) mediator).getLocalizer(); } catch (Exception e) { logger.debug(e.getMessage(), e); } mouseMenu = new JPopupMenu(); imagePanel = new JPanel(); imagePanel.setLayout(new GridLayout(4, 2)); mouseMenu.add(imagePanel); imagePanel.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { System.out.println("Focus Gained"); } public void focusLost(FocusEvent e) { mouseMenu.setVisible(false); System.out.println("Focus Lost"); } }); URL url = ClassLoader.getSystemResource("img/open.gif"); Icon iconOpen = new ImageIcon(url); JButton btnOpen = new JButton(iconOpen); btnOpen.setToolTipText(locale.getString("btntoolbar.open")); url = ClassLoader.getSystemResource("img/save.gif"); Icon iconSave = new ImageIcon(url); JButton btnSave = new JButton(iconSave); btnSave.setToolTipText(locale.getString("btntoolbar.save")); url = ClassLoader.getSystemResource("img/undo.gif"); Icon iconUndo = new ImageIcon(url); btnUndo = new JButton(iconUndo); btnUndo.setToolTipText(locale.getString("btntoolbar.undo")); url = ClassLoader.getSystemResource("img/redo.gif"); Icon iconRedo = new ImageIcon(url); btnRedo = new JButton(iconRedo); btnRedo.setToolTipText(locale.getString("btntoolbar.redo")); url = ClassLoader.getSystemResource("img/draw.gif"); Icon iconDraw = new ImageIcon(url); btnDraw = new JToggleButton(iconDraw, true); btnDraw.setToolTipText(locale.getString("btntoolbar.draw")); url = ClassLoader.getSystemResource("img/pen.gif"); Icon iconPen = new ImageIcon(url); btnPen = new JToggleButton(iconPen); btnPen.setToolTipText(locale.getString("btntoolbar.pen")); url = ClassLoader.getSystemResource("img/calibrate.gif"); Icon iconCalibrate = new ImageIcon(url); btnCalibrate = new JToggleButton(iconCalibrate); btnCalibrate.setToolTipText(locale.getString("btntoolbar.calibration")); url = ClassLoader.getSystemResource("img/gridMove.gif"); Icon iconGridMove = new ImageIcon(url); JToggleButton btnGrigMove = new JToggleButton(iconGridMove); url = ClassLoader.getSystemResource("img/hand.gif"); Icon iconHand = new ImageIcon(url); JToggleButton btnHand = new JToggleButton(iconHand); btnHand.setToolTipText(locale.getString("btntoolbar.hand")); url = ClassLoader.getSystemResource("img/selTool.gif"); Icon iconSelTool = new ImageIcon(url); JToggleButton btnSelTool = new JToggleButton(iconSelTool); url = ClassLoader.getSystemResource("img/spline.gif"); Icon iconQuadTool = new ImageIcon(url); btnSpline = new JToggleButton(iconQuadTool); btnSpline.setToolTipText(locale.getString("btntoolbar.spline")); btnTools = new JToggleButton("T"); btnTextTool = new JToggleButton("A"); url = ClassLoader.getSystemResource("img/ruler.gif"); Icon iconRulerTool = new ImageIcon(url); btnRulerTool = new JToggleButton(iconRulerTool); url = ClassLoader.getSystemResource("img/sendFile.gif"); Icon iconSendFile = new ImageIcon(url); JToggleButton btnFileTransmit = new JToggleButton(iconSendFile); btnFileTransmit.setToolTipText(locale.getString("btntoolbar.fileTransmit")); url = ClassLoader.getSystemResource("img/nodesEdit.gif"); Icon iconNodesEdit = new ImageIcon(url); JToggleButton btnNodesEdit = new JToggleButton(iconNodesEdit); btnNodesEdit.setToolTipText(locale.getString("btntoolbar.nodeEdit")); JButton btnTest = new JButton(locale.getString("btntoolbar.button.Test")); btnTest.setEnabled(false); url = ClassLoader.getSystemResource("img/send.gif"); Icon iconSend = new ImageIcon(url); JButton btnSendArq = new JButton(iconSend); btnSendArq.setToolTipText(locale.getString("btntoolbar.send")); url = ClassLoader.getSystemResource("img/clear.gif"); Icon iconClear = new ImageIcon(url); JButton btnClearTab = new JButton(iconClear); btnClearTab.setToolTipText(locale.getString("btntoolbar.clear")); JButton btnRequestModel = new JButton(locale.getString("btntoolbar.button.RequestModel")); btnRequestModel.setEnabled(false); JComboBox cmbTools = new JComboBox(); cmbTools.addItem("Thick Line"); cmbTools.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = btnTools.getModel().isSelected(); if (selected) { mode = getToolsMode(); guiChanged(); } } }); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(btnDraw); buttonGroup.add(btnPen); buttonGroup.add(btnCalibrate); buttonGroup.add(btnGrigMove); buttonGroup.add(btnHand); buttonGroup.add(btnSelTool); buttonGroup.add(btnSpline); buttonGroup.add(btnTextTool); buttonGroup.add(btnRulerTool); buttonGroup.add(btnNodesEdit); // buttonGroup.add( btnTools ); btnDraw.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_DRAWING; } guiChanged(); } }); btnPen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_PEN; } guiChanged(); } }); btnCalibrate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_CALIBRATING; } guiChanged(); } }); btnGrigMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_GRID_MOVING; } guiChanged(); } }); btnHand.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_HAND_MAP; } guiChanged(); } }); btnSelTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_SELECT_TOOL; } guiChanged(); } }); btnSpline.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_QUAD_TOOL; } guiChanged(); } }); btnTextTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_TEXT_TOOL; } guiChanged(); } }); btnRulerTool.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_RULER_TOOL; } guiChanged(); } }); btnNodesEdit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (selected) { mode = Mode.MODE_NODES_EDIT; } guiChanged(); } }); btnTools.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mode = getToolsMode(); guiChanged(); } }); btnOpen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnOpenPressed(); } }); btnSave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSavePressed(); } }); btnUndo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnUndoPressed(); } }); btnRedo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnRedoPressed(); } }); btnTest.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnTestPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendModelPressed(); } }); btnSendArq.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnSendArqModelPressed(); } }); btnClearTab.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnClearTabPressed(); } }); btnRequestModel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); btnFileTransmit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { mediator.btnFileTransmitPressed(); } }); add(btnOpen); add(btnSave); // add( btnUndo ); // add( btnRedo ); addSeparator(); // add(lblMode); actionButton = new JToggleButton(btnDraw.getIcon()); actionButton.setToolTipText(btnDraw.getToolTipText()); actionButton.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { mouseMenu.show(e.getComponent(), e.getX(), e.getY()); } }); addButton(btnDraw); addButton(btnPen); addButton(btnCalibrate); // add( btnGrigMove ); addButton(btnHand); // add(btnSelTool); addButton(btnSpline); addButton(btnNodesEdit); // add( btnTextTool ); addButton(btnRulerTool); // addSeparator(); // add(cmbTools); add(actionButton); cmbScale = new JComboBox(); cmbScale.setEditable(true); cmbScale.addItem("1:1000"); cmbScale.addItem("1:2000"); cmbScale.addItem("1:5000"); cmbScale.addItem("1:10000"); cmbScale.addItem("1:25000"); cmbScale.addItem("1:50000"); cmbScale.addItem("1:100000"); cmbScale.setSelectedIndex(3); cmbScale.setToolTipText(locale.getString("btntoolbar.scale")); cmbScale.setPreferredSize(cmbScale.getMinimumSize()); cmbScale.setMaximumSize(cmbScale.getMinimumSize()); cmbScale.addItemListener(new ZoomListener()); addSeparator(); chbVisibleGrid = new JCheckBox(); chbVisibleGrid.setSelected(true); chbVisibleGrid.setToolTipText(locale.getString("btntoolbar.grid")); // addSeparator(); chbVisibleGrid.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { guiChanged(); } }); add(btnFileTransmit); add(btnSendArq); add(btnClearTab); add(chbVisibleGrid); add(cmbScale); // addSeparator(); // add( lblControl ); // add( btnSend ); // add( btnRequestModel ); // add( btnTest ); }
/** Builds the panel. */ public void setup() { DataModelList dataModelList = null; for (Object parentModel : parentModels) { if (parentModel instanceof DataWrapper) { DataWrapper dataWrapper = (DataWrapper) parentModel; dataModelList = dataWrapper.getDataModelList(); } } if (dataModelList == null) { throw new NullPointerException("Null data model list."); } for (DataModel model : dataModelList) { if (!(model instanceof DataSet)) { JOptionPane.showMessageDialog( JOptionUtils.centeringComp(), "For the shift search, all of the data in the data box must be in the form of data sets."); return; } } final List<DataSet> dataSets = new ArrayList<DataSet>(); for (Object aDataModelList : dataModelList) { dataSets.add((DataSet) aDataModelList); } SpinnerModel maxVarsModel = new SpinnerNumberModel( Preferences.userRoot().getInt("shiftSearchMaxNumShifts", 3), 1, 50, 1); JSpinner maxVarsSpinner = new JSpinner(maxVarsModel); maxVarsSpinner.setMaximumSize(maxVarsSpinner.getPreferredSize()); maxVarsSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel(); int value = (Integer) model.getValue(); Preferences.userRoot().putInt("shiftSearchMaxNumShifts", value); } }); SpinnerModel maxShiftModel = new SpinnerNumberModel(Preferences.userRoot().getInt("shiftSearchMaxShift", 2), 1, 50, 1); JSpinner maxShiftSpinner = new JSpinner(maxShiftModel); maxShiftSpinner.setMaximumSize(maxShiftSpinner.getPreferredSize()); maxShiftSpinner.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); SpinnerNumberModel model = (SpinnerNumberModel) spinner.getModel(); int value = (Integer) model.getValue(); Preferences.userRoot().putInt("shiftSearchMaxShift", value); } }); JButton searchButton = new JButton("Search"); final JButton stopButton = new JButton("Stop"); final JTextArea textArea = new JTextArea(); JScrollPane textScroll = new JScrollPane(textArea); textScroll.setPreferredSize(new Dimension(500, 200)); searchButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { final Thread thread = new Thread() { public void run() { textArea.setText(""); doShiftSearch(dataSets, textArea); } }; thread.start(); } }); stopButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (search != null) { search.stop(); } } }); JComboBox directionBox = new JComboBox(new String[] {"forward", "backward"}); directionBox.setSelectedItem(params.isForwardSearch() ? "forward" : "backward"); directionBox.setMaximumSize(directionBox.getPreferredSize()); directionBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JComboBox source = (JComboBox) actionEvent.getSource(); String selected = (String) source.getSelectedItem(); params.setForwardSearch("forward".equals(selected)); } }); Box b1 = Box.createVerticalBox(); Box b2 = Box.createHorizontalBox(); b2.add(new JLabel("Maximum number of variables in shift set is: ")); b2.add(maxVarsSpinner); b2.add(Box.createHorizontalGlue()); b1.add(b2); Box b3 = Box.createHorizontalBox(); b3.add(new JLabel("Maximum ")); b3.add(directionBox); b3.add(new JLabel(" shift: ")); b3.add(maxShiftSpinner); b3.add(Box.createHorizontalGlue()); b1.add(b3); Box b4 = Box.createHorizontalBox(); b4.add(new JLabel("Output:")); b4.add(Box.createHorizontalGlue()); b1.add(b4); Box b5 = Box.createHorizontalBox(); b5.add(textScroll); b1.add(b5); Box b6 = Box.createHorizontalBox(); b6.add(searchButton); b6.add(stopButton); b1.add(b6); final Box a1 = Box.createVerticalBox(); Box a2 = Box.createHorizontalBox(); a2.add(new JLabel("Specify the shift (positive or negative) for each variable:")); a2.add(Box.createHorizontalGlue()); a1.add(a2); a1.add(Box.createVerticalStrut(20)); setUpA1(dataSets, a1); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Shift", new JScrollPane(a1)); tabbedPane.addTab("Search", new JScrollPane(b1)); add(tabbedPane, BorderLayout.CENTER); tabbedPane.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { System.out.println("a1 shown"); a1.removeAll(); setUpA1(dataSets, a1); } }); }
public SceneLayoutApp() { super(); new Pair(); final JFrame frame = new JFrame("Scene Layout"); final JPanel panel = new JPanel(new BorderLayout()); frame.setContentPane(panel); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setMaximumSize(screenSize); frame.setSize(screenSize); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JMenuBar mb = new JMenuBar(); frame.setJMenuBar(mb); final JMenu jMenu = new JMenu("File"); mb.add(jMenu); mb.add(new JMenu("Edit")); mb.add(new JMenu("Help")); JMenu menu = new JMenu("Look and Feel"); // // Get all the available look and feel that we are going to use for // creating the JMenuItem and assign the action listener to handle // the selection of menu item to change the look and feel. // UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lookAndFeelInfos.length; i++) { final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i]; JMenuItem item = new JMenuItem(lookAndFeelInfo.getName()); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { // // Set the look and feel for the frame and update the UI // to use a new selected look and feel. // UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); SwingUtilities.updateComponentTreeUI(frame); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } } }); menu.add(item); } mb.add(menu); jMenu.add(new JMenuItem(new scene.action.QuitAction())); panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER); final JToolBar bar = new JToolBar(); panel.add(bar, BorderLayout.NORTH); final JComboBox comboNewWindow = new JComboBox( new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"}); comboNewWindow.addActionListener(new CreateSceneWindowAction()); comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window")); bar.add(comboNewWindow); bar.add( new AbstractAction("Progress Bars") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new ProgressBarAnimator(); } }); bar.add( new AbstractAction("Sliders") { /** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { new SliderBarAnimator(); } }); final JCheckBox permaViz = new JCheckBox(); permaViz.setText("Show the dump window"); permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); dumpWindow = new JInternalFrame("perma dump window"); dumpWindow.setContentPane(new JScrollPane(permText)); permaViz.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dumpWindow.setVisible(permaViz.isSelected()); } }); comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize()); permaViz.setSelected(false); bar.add(new CreateWebViewV1Action()); bar.add(new CreateWebViewV2Action()); bar.add(permaViz); desktopPane.add(dumpWindow); dumpWindow.setSize(400, 400); dumpWindow.setResizable(true); dumpWindow.setClosable(false); dumpWindow.setIconifiable(false); final JMenuBar m = new JMenuBar(); final JMenu cmenu = new JMenu("Create"); m.add(cmenu); final JMenuItem menuItem = new JMenuItem( new AbstractAction("new") { @Override public void actionPerformed(ActionEvent e) { Runnable runnable = new Runnable() { public void run() { Object[] in = (Object[]) XSTREAM.fromXML(permText.getText()); final JInternalFrame ff = new JInternalFrame(); final ScenePanel c = new ScenePanel(); ff.setContentPane(c); desktopPane.add(ff); final Dimension d = (Dimension) in[0]; c.setMaximumSize(d); c.setPreferredSize(d); ff.setSize(d.width + 50, d.height + 50); ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]); c.invalidate(); c.repaint(); ff.pack(); ff.setClosable(true); ff.setMaximizable(false); ff.setIconifiable(false); ff.setResizable(false); ff.show(); } }; SwingUtilities.invokeLater(runnable); } }); cmenu.add(menuItem); // JMenuBar menuBar = new JMenuBar(); // getContentPane().add(menuBar); dumpWindow.setJMenuBar(m); frame.setVisible(true); }
public ContextEditor(Context cntxt) { super("Edit User Context: " + localFileName(cntxt)); ctxt = cntxt; windowNum = ctxt.languageName + " Context Editor"; setDefaultCloseOperation(DISPOSE_ON_CLOSE); listener = new CEListener(this); JPanel nameBox = new JPanel(); nameBox.setLayout(new BoxLayout(nameBox, BoxLayout.LINE_AXIS)); name = new JTextField(ctxt.languageName, 28); name.setMaximumSize(new Dimension(225, 22)); name.addFocusListener( new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { nameFocusLost(evt); } }); JLabel nameLabel = new JLabel("Language Name: "); nameBox.add(nameLabel); nameBox.add(name); JPanel folderBox = new JPanel(); folderBox.setLayout(new BoxLayout(folderBox, BoxLayout.LINE_AXIS)); folder = new JTextField(ctxt.editDirectory); folder.setMaximumSize(new Dimension(225, 22)); // folder.addActionListener(listener); // folder.setActionCommand("folder edit"); folder.addFocusListener( new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { folderFocusLost(evt); } }); JLabel folderLabel = new JLabel("SILK file folder: "); folderBox.add(folderLabel); folderBox.add(folder); JPanel nameFolderBox = new JPanel(); nameFolderBox.setLayout(new BoxLayout(nameFolderBox, BoxLayout.PAGE_AXIS)); nameBox.setAlignmentX(0.5f); nameFolderBox.add(nameBox); nameFolderBox.add(Box.createRigidArea(new Dimension(0, 4))); nameFolderBox.add(folderBox); nameFolderBox.setAlignmentX(0.5f); buildPopulationBox(); JPanel btnBoxUDPs = new JPanel(), subBoxUDP = new JPanel(); btnBoxUDPs.setLayout(new BoxLayout(btnBoxUDPs, BoxLayout.PAGE_AXIS)); subBoxUDP.setLayout(new BoxLayout(subBoxUDP, BoxLayout.LINE_AXIS)); int numUDPs = 0; if (ctxt.userDefinedProperties != null) { numUDPs = ctxt.userDefinedProperties.size(); } String plur = "ies"; if (numUDPs == 1) { plur = "y"; } JLabel udpLabel = new JLabel("Has " + numUDPs + " User-Defined Propert" + plur); subBoxUDP.add(udpLabel); JButton addUDP = new JButton("Add UDP"); addUDP.setActionCommand("add UDP"); addUDP.addActionListener(listener); subBoxUDP.add(addUDP); btnBoxUDPs.add(subBoxUDP); if (numUDPs > 0) { Dimension sizer = new Dimension(250, 50); String[] udpMenu = genUDPMenu(); UDPick = new JComboBox(udpMenu); UDPick.addActionListener(listener); UDPick.setActionCommand("view/edit UDP"); UDPick.setMinimumSize(sizer); UDPick.setMaximumSize(sizer); UDPick.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "View/Edit UDPs")); btnBoxUDPs.add(UDPick); } // end of if-any-UDPs-exist JPanel domThs = new JPanel(); domThs.setLayout(new BoxLayout(domThs, BoxLayout.PAGE_AXIS)); domThs.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Kinship System Domain Theories")); domThs.setAlignmentX(0.5f); JPanel dtRefBtnBox = new JPanel(); dtRefBtnBox.setLayout(new BoxLayout(dtRefBtnBox, BoxLayout.LINE_AXIS)); dtRefBtnBox.setAlignmentX(0.0f); JLabel dtRefLabel = new JLabel("Terms of Reference "); dtRefBtnBox.add(dtRefLabel); if (ctxt.domTheoryRefExists()) { JButton dtRefEdit = new JButton("Edit Theory"); dtRefEdit.setActionCommand("edit dtRef"); dtRefEdit.addActionListener(listener); dtRefBtnBox.add(dtRefEdit); // JButton dtRefDelete = new JButton("Delete Theory"); // dtRefDelete.setActionCommand("dtRef delete"); // dtRefDelete.addActionListener(listener); // dtRefBtnBox.add(dtRefDelete); } // end of if-dt-exists else { // if does not exist JLabel dtRefNone = new JLabel("< None >"); dtRefBtnBox.add(dtRefNone); // JButton dtRefAdd = new JButton("Add Theory"); // dtRefAdd.setActionCommand("dtRef add"); // dtRefAdd.addActionListener(listener); // dtRefBtnBox.add(dtRefAdd); } // end of does-not-exist domThs.add(dtRefBtnBox); JPanel dtAddrBtnBox = new JPanel(); dtAddrBtnBox.setLayout(new BoxLayout(dtAddrBtnBox, BoxLayout.LINE_AXIS)); dtAddrBtnBox.setAlignmentX(0.0f); JLabel dtAddrLabel = new JLabel("Terms of Address "); dtAddrBtnBox.add(dtAddrLabel); if (ctxt.domTheoryAdrExists()) { JButton dtAddrEdit = new JButton("Edit Theory"); dtAddrEdit.setActionCommand("edit dtAddr"); dtAddrEdit.addActionListener(listener); dtAddrBtnBox.add(dtAddrEdit); // JButton dtAddrViewList = new JButton("Delete Theory"); // dtAddrViewList.setActionCommand("dtAddr delete"); // dtAddrViewList.addActionListener(listener); // dtAddrBtnBox.add(dtAddrViewList); } // end of if-dt-exists else { // if does not exist JLabel dtAddrNone = new JLabel("< None >"); dtAddrBtnBox.add(dtAddrNone); // JButton dtAddrAdd = new JButton("Add Theory"); // dtAddrAdd.setActionCommand("dtAddr add"); // dtAddrAdd.addActionListener(listener); // dtAddrBtnBox.add(dtAddrAdd); } // end of does-not-exist domThs.add(dtAddrBtnBox); // End of the left hand portion // Right hand portion follows. it is narrower. JPanel polyBox = new JPanel(); polyBox.setLayout(new BoxLayout(polyBox, BoxLayout.PAGE_AXIS)); polyBox.setAlignmentX(0.5f); JLabel polyLabelA = new JLabel("Polygamy"); JLabel polyLabelB = new JLabel("Permitted?"); JRadioButton yesPoly = new JRadioButton("Yes"); yesPoly.setActionCommand("polygamy yes"); yesPoly.addActionListener(listener); JRadioButton noPoly = new JRadioButton("No"); noPoly.setActionCommand("polygamy no"); noPoly.addActionListener(listener); if (cntxt.polygamyPermit) { yesPoly.setSelected(true); } else { noPoly.setSelected(true); } ButtonGroup polyBtns = new ButtonGroup(); polyBtns.add(yesPoly); polyBtns.add(noPoly); polyBox.add(polyLabelA); polyBox.add(polyLabelB); polyBox.add(yesPoly); polyBox.add(noPoly); JPanel matrixBox = new JPanel(); matrixBox.setLayout(new BoxLayout(matrixBox, BoxLayout.PAGE_AXIS)); matrixBox.setAlignmentX(0.5f); JLabel matrixLabelA = new JLabel("Kin Term Matrix"); JLabel matrixLabelC = new JLabel(ctxt.indSerNumGen + " rows"); JLabel matrixLabelD = new JLabel(ctxt.ktm.numberOfKinTerms() + " terms"); matrixLabelA.setAlignmentX(0.5f); matrixLabelC.setAlignmentX(0.5f); matrixLabelD.setAlignmentX(0.5f); JButton matrixEditBtn = new JButton("Edit Matrix"); matrixEditBtn.setEnabled(false); matrixEditBtn.setActionCommand("edit matrix"); matrixEditBtn.addActionListener(listener); matrixEditBtn.setAlignmentX(0.5f); matrixBox.add(matrixLabelA); matrixBox.add(matrixLabelC); matrixBox.add(matrixLabelD); matrixBox.add(matrixEditBtn); JPanel distinctBox = new JPanel(); distinctBox.setLayout(new BoxLayout(distinctBox, BoxLayout.PAGE_AXIS)); distinctBox.setAlignmentX(0.5f); JLabel distinctLabelA = new JLabel("Distinct Terms"); JLabel distinctLabelB = new JLabel("of Address"); distinctLabelA.setAlignmentX(0.5f); distinctLabelB.setAlignmentX(0.5f); JRadioButton yesDistinct = new JRadioButton("Yes"); yesDistinct.setActionCommand("distinct yes"); yesDistinct.addActionListener(listener); JRadioButton noDistinct = new JRadioButton("No"); noDistinct.setActionCommand("distinct no"); noDistinct.addActionListener(listener); yesDistinct.setAlignmentX(0.5f); noDistinct.setAlignmentX(0.5f); if (ctxt.distinctAdrTerms) { yesDistinct.setSelected(true); } else { noDistinct.setSelected(true); } ButtonGroup distinctBtns = new ButtonGroup(); distinctBtns.add(yesDistinct); distinctBtns.add(noDistinct); distinctBox.add(distinctLabelA); distinctBox.add(distinctLabelB); distinctBox.add(yesDistinct); distinctBox.add(noDistinct); /* * NOTE: It should be possible to put all these elements directly into * the ContentPane. But that doesn't work; the layout is truly ugly and * stuff gets stacked on top of other stuff. What works is to put * everything into a JPanel with BoxLayout. Then put the JPanel into * ContentPane. */ JPanel leftCol = new JPanel(); leftCol.setLayout(new BoxLayout(leftCol, BoxLayout.PAGE_AXIS)); leftCol.add(nameFolderBox); leftCol.add(Box.createRigidArea(new Dimension(0, 4))); leftCol.add(populationBox); leftCol.add(Box.createRigidArea(new Dimension(0, 8))); leftCol.add(btnBoxUDPs); leftCol.add(Box.createRigidArea(new Dimension(0, 8))); leftCol.add(domThs); leftCol.add(new JLabel(" ")); JPanel rightCol = new JPanel(); rightCol.setLayout(new BoxLayout(rightCol, BoxLayout.PAGE_AXIS)); rightCol.setBorder( BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue), "Options")); rightCol.add(Box.createRigidArea(new Dimension(0, 20))); rightCol.add(polyBox); rightCol.add(Box.createRigidArea(new Dimension(0, 20))); rightCol.add(matrixBox); int high = (numUDPs > 0 ? 120 : 20); rightCol.add(Box.createRigidArea(new Dimension(0, high))); rightCol.add(distinctBox); JPanel commentBox = new JPanel(); commentBox.setLayout(new BoxLayout(commentBox, BoxLayout.PAGE_AXIS)); commentBox.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.blue), "Notes on this culture:")); JScrollPane commentsPane = new JScrollPane(); comments = new JTextArea(); comments.setColumns(20); comments.setEditable(true); comments.setRows(3); comments.setText(PersonPanel.restoreLineBreaks(ctxt.comments)); comments.getDocument().addDocumentListener(new CommentListener()); commentsPane.setViewportView(comments); commentBox.add(commentsPane); JPanel guts = new JPanel(); // Holds the guts of this window guts.setLayout(new BoxLayout(guts, BoxLayout.LINE_AXIS)); guts.add(leftCol); guts.add(Box.createRigidArea(new Dimension(10, 4))); guts.add(rightCol); JPanel wholeThing = new JPanel(); wholeThing.setLayout(new BoxLayout(wholeThing, BoxLayout.PAGE_AXIS)); wholeThing.add(Box.createRigidArea(new Dimension(0, 4))); wholeThing.add(guts); wholeThing.add(Box.createRigidArea(new Dimension(0, 8))); wholeThing.add(commentBox); wholeThing.add(Box.createRigidArea(new Dimension(0, 4))); getContentPane().add(wholeThing); addInternalFrameListener(this); setSize(600, 620); setVisible(true); } // end of ContextEditor constructor
@Analyzer( name = "Event Data Attribute Visualizer", names = {"Log"}) public JComponent analyze(LogReader log) { /* * this plugin takes a log, shows a list of available data-attributes * and a list of cases After selecting a data-attribute (and possibly a * case) a graph is made of the value of the data-attribute against * either time or against the sequence of events. * * input: log with data attributes gui-input: select a data-attribute, * choose time or event-sequence, and possibly a case * * internally : if not caseselected -> scatterplot of values against * time/event-number else show graph for value against time/event-number * * createGraph : check number / string */ mylog = log; mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); chartPanel = new JPanel(); chartPanel.setLayout(new BoxLayout(chartPanel, BoxLayout.PAGE_AXIS)); optionsPanel = new JPanel(); optionsPanel.setLayout(new SpringLayout()); JLabel attributelabel = new JLabel("Select attributes to use"); attributeslist = new JList(getAttributes()); attributeslist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); attributeslist.setLayoutOrientation(JList.VERTICAL); optionsPanel.add(attributelabel); optionsPanel.add(attributeslist); JLabel xlabel = new JLabel("Chart type"); String[] xvalues = new String[4]; xvalues[0] = " Attribute values against event sequence"; xvalues[1] = "Attribute values against timestamps"; xvalues[2] = "Average attribute values against event sequence"; xvalues[3] = "Average attribute values against timestamps"; xbox = new JComboBox(xvalues); xbox.setMaximumSize(xbox.preferredSize()); xbox.setSelectedIndex(1); xbox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); if (cb.getSelectedIndex() == 3) { BSpinner.setVisible(true); } else { BSpinner.setVisible(false); } }; }); optionsPanel.add(xlabel); optionsPanel.add(xbox); JLabel timelabel = new JLabel("show time by "); String[] timevalues = new String[4]; timevalues[0] = "second"; timevalues[1] = "minute"; timevalues[2] = "hour"; timevalues[3] = "day"; timebox = new JComboBox(timevalues); timebox.setMaximumSize(timebox.preferredSize()); timebox.setSelectedIndex(1); optionsPanel.add(timelabel); optionsPanel.add(timebox); SpinnerModel Bmodel = new SpinnerNumberModel(10, 2, 1000000, 1); BSpinner = new JSpinner(Bmodel); JLabel BLabel = new JLabel("Select histogram barsize"); JLabel B2Label = new JLabel("used for average against timestamps"); BSpinner.setMaximumSize(BSpinner.preferredSize()); BSpinner.setVisible(false); optionsPanel.add(BLabel); optionsPanel.add(B2Label); optionsPanel.add(BSpinner); JButton updatebutton = new JButton("update"); updatebutton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] sels = attributeslist.getSelectedValues(); String[] els = new String[sels.length]; for (int i = 0; i < sels.length; i++) { els[i] = sels[i].toString(); } long timesize = 1000; switch (timebox.getSelectedIndex()) { case 0: timesize = 1000; break; case 1: timesize = 1000 * 60; break; case 2: timesize = 1000 * 60 * 60; break; case 3: timesize = 1000 * 60 * 60 * 24; break; } String xname = null; JFreeChart mychart = null; if (xbox.getSelectedIndex() == 0) { data = getDataAttributes(els, false, timesize); xname = "Event sequence"; mychart = ChartFactory.createScatterPlot( "Scatterplot of all values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); } else if (xbox.getSelectedIndex() == 1) { data = getDataAttributes(els, true, timesize); xname = "Time(" + timebox.getSelectedItem() + ") since beginning of the process"; mychart = ChartFactory.createScatterPlot( "Scatterplot of all values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); } else if (xbox.getSelectedIndex() == 2) { xname = "Event sequence"; data = getHistrogrammedDataAttributes(els, 1, 1); mychart = ChartFactory.createXYLineChart( "Average values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); mychart.setBackgroundPaint(Color.white); XYPlot plot = mychart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); DeviationRenderer renderer = new DeviationRenderer(true, true); renderer.setSeriesStroke( 0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); renderer.setSeriesStroke(3, new BasicStroke(2.0f)); renderer.setSeriesFillPaint(0, Color.red); renderer.setSeriesFillPaint(1, Color.blue); renderer.setSeriesFillPaint(2, Color.green); renderer.setSeriesFillPaint(3, Color.orange); plot.setRenderer(renderer); // change the auto tick unit selection to integer units // only... NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); // yAxis.setAutoRangeIncludesZero(false); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } else { xname = "Time(" + timebox.getSelectedItem() + "s) since beginning of the process"; data = getHistrogrammedDataAttributes( els, ((Integer) BSpinner.getValue()) * timesize, timesize); mychart = ChartFactory.createXYLineChart( "Average values", xname, "attribute value", data, PlotOrientation.VERTICAL, true, true, false); mychart.setBackgroundPaint(Color.white); XYPlot plot = mychart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); DeviationRenderer renderer = new DeviationRenderer(true, true); renderer.setSeriesStroke( 0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); renderer.setSeriesStroke(3, new BasicStroke(2.0f)); renderer.setSeriesFillPaint(0, Color.red); renderer.setSeriesFillPaint(1, Color.blue); renderer.setSeriesFillPaint(2, Color.green); renderer.setSeriesFillPaint(3, Color.orange); plot.setRenderer(renderer); // change the auto tick unit selection to integer units // only... NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); // yAxis.setAutoRangeIncludesZero(false); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } ChartPanel mychartpanel = new ChartPanel(mychart); mychartpanel.setBackground(Color.white); chartPanel.removeAll(); chartPanel.add(mychartpanel); chartPanel.updateUI(); }; }); optionsPanel.add(updatebutton); JSplitPane splitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, optionsPanel, chartPanel); SpringUtils.makeCompactGrid( optionsPanel, 10, 1, // rows, cols 6, 2, // initX, initY 6, 2); // xPad, yPad mainPanel.add(splitPanel, BorderLayout.CENTER); return mainPanel; }