List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border, String title)
From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java
/** * Create a panel containing the proxy server details * * @return the panel/*w ww .j a va2 s . c o m*/ */ protected final JPanel getProxyServerPanel() { JPanel proxyServer = new HorizontalPanel(); proxyServer.add(getProxyHostPanel(), BorderLayout.CENTER); proxyServer.add(getProxyPortPanel(), BorderLayout.EAST); JPanel proxyLogin = new HorizontalPanel(); proxyLogin.add(getProxyUserPanel()); proxyLogin.add(getProxyPassPanel()); JPanel proxyServerPanel = new HorizontalPanel(); proxyServerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), UPMPConstant.upmp_proxy_server_title)); // $NON-NLS-1$ proxyServerPanel.add(proxyServer, BorderLayout.CENTER); proxyServerPanel.add(proxyLogin, BorderLayout.EAST); return proxyServerPanel; }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createCordinatePanel() { JPanel wrap = new JPanel(new BorderLayout()); JPanel coordinate = new JPanel(new GridLayout(3, 1)); coordinate.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); //Horizontal group JPanel horizontal = new JPanel(new BorderLayout()); horizontal//from w w w . ja va 2 s . co m .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Horizontal Axis")); JPanel inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Flip X Axis")); flipX = new JCheckBox(); flipX.setActionCommand(FLIP_X_AXIS_COMMAND); flipX.addActionListener(this); inner.add(flipX); inner.add(new JLabel()); horizontal.add(inner, BorderLayout.NORTH); //Vertical group JPanel vertical = new JPanel(new BorderLayout()); vertical.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Vertical Axis")); inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Flip Y Axis")); flipY = new JCheckBox(); flipY.setActionCommand(FLIP_Y_AXIS_COMMAND); flipY.addActionListener(this); inner.add(flipY); inner.add(new JLabel()); vertical.add(inner, BorderLayout.NORTH); //Color scale group JPanel colorScale = new JPanel(new BorderLayout()); colorScale.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Color Scale")); inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Show Color Scale")); showColorScale = new JCheckBox(); showColorScale.setActionCommand(SHOW_SCALE_COMMAND); showColorScale.addActionListener(this); inner.add(showColorScale); inner.add(new JLabel()); inner.add(new JLabel("Select Theme")); ColorScale[] scales = ColorScale.values(); colourScaleCombo = new JComboBox(scales); // colourScaleCombo.setMaximumRowCount(7); colourScaleCombo.setActionCommand(CHANGE_COLOUR_SCALE_COMMAND); colourScaleCombo.addActionListener(this); inner.add(colourScaleCombo); inner.add(new JLabel()); inner.add(new JLabel("Use Logarithmic Scale")); logarithmScale = new JCheckBox(); logarithmScale.setActionCommand(LOGARITHM_SCALE_COMMAND); logarithmScale.addActionListener(this); inner.add(logarithmScale); inner.add(new JLabel()); colorScale.add(inner, BorderLayout.NORTH); coordinate.add(horizontal); coordinate.add(vertical); coordinate.add(colorScale); wrap.setName("Coordinate"); wrap.add(coordinate, BorderLayout.NORTH); return wrap; }
From source file:com.mirth.connect.client.ui.alert.AlertChannelPane.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Channels")); setLayout(new MigLayout("insets 0", "[grow][grow]", "[][][grow]")); filterLabel = new JLabel("Filter: "); filterTextField = new JTextField(); filterTextField.addKeyListener(new KeyListener() { @Override/*from w ww . j a va 2 s . co m*/ public void keyTyped(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { updateFilter(filterTextField.getText()); } }); expandLabel = new JLabel("<html><u>Expand All</u></html>"); expandLabel.setForeground(Color.blue); expandLabel.setToolTipText("Expand all nodes below."); expandLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); expandLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { channelTreeTable.expandAll(); } }); collapseLabel = new JLabel("<html><u>Collapse All</u></html>"); collapseLabel.setForeground(Color.blue); collapseLabel.setToolTipText("Collapse all nodes below."); collapseLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); collapseLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { channelTreeTable.collapseAll(); } }); enableButton = new JButton("Enable"); enableButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleSelectedRows(true); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); disableButton = new JButton("Disable"); disableButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleSelectedRows(false); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); channelTreeTable = new MirthTreeTable(); channelScrollPane = new JScrollPane(channelTreeTable); add(filterLabel, "span 2, split"); add(filterTextField, "growx, span, wrap"); add(enableButton, "split 2, alignx left, width 50"); add(disableButton, "alignx left, width 50"); add(expandLabel, "split 2, alignx right"); add(collapseLabel, "alignx right, wrap"); add(channelScrollPane, "height 100:100:, width 100:100:, grow, span"); }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
private JPanel configureLeftBottomPanel() { this.focusPanel = new FocusPane(this); final JPanel focusPanelContainer = new JPanel(new BorderLayout()); final JToolBar navigationToolbar = new JToolBar(JToolBar.VERTICAL); navigationToolbar.setRollover(true); navigationToolbar.setFloatable(false); navigationToolbar.setOpaque(false);/*ww w. j av a 2 s .c o m*/ final JButton btn_pickNavigationUndo, btn_pickNavigationRedo; btn_pickNavigationUndo = new JButton(""); btn_pickNavigationUndo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoPick.png"))); btn_pickNavigationUndo.setToolTipText("Navigate back to the previous element picked"); btn_pickNavigationRedo = new JButton(""); btn_pickNavigationRedo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoPick.png"))); btn_pickNavigationRedo.setToolTipText("Navigate forward to the next element picked"); final ActionListener action = e -> { Pair<NetworkElement, Pair<Demand, Link>> backOrForward; do { backOrForward = (e.getSource() == btn_pickNavigationUndo) ? GUINetworkDesign.this.getVisualizationState().getPickNavigationBackElement() : GUINetworkDesign.this.getVisualizationState().getPickNavigationForwardElement(); if (backOrForward == null) break; final NetworkElement ne = backOrForward.getFirst(); // For network elements final Pair<Demand, Link> fr = backOrForward.getSecond(); // For forwarding rules if (ne != null) { if (ne.getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (ne.getNetPlan() == null) continue; break; } else if (fr != null) { if (fr.getFirst().getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (fr.getFirst().getNetPlan() == null) continue; if (fr.getSecond().getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (fr.getSecond().getNetPlan() == null) continue; break; } else break; // null,null => reset picked state } while (true); if (backOrForward != null) { if (backOrForward.getFirst() != null) GUINetworkDesign.this.getVisualizationState().pickElement(backOrForward.getFirst()); else if (backOrForward.getSecond() != null) GUINetworkDesign.this.getVisualizationState().pickForwardingRule(backOrForward.getSecond()); else GUINetworkDesign.this.getVisualizationState().resetPickedState(); GUINetworkDesign.this.updateVisualizationAfterPick(); } }; btn_pickNavigationUndo.addActionListener(action); btn_pickNavigationRedo.addActionListener(action); btn_pickNavigationRedo.setFocusable(false); btn_pickNavigationUndo.setFocusable(false); navigationToolbar.add(btn_pickNavigationUndo); navigationToolbar.add(btn_pickNavigationRedo); final JScrollPane scPane = new JScrollPane(focusPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scPane.getVerticalScrollBar().setUnitIncrement(20); scPane.getHorizontalScrollBar().setUnitIncrement(20); scPane.setBorder(BorderFactory.createEmptyBorder()); // Control the scroll scPane.getHorizontalScrollBar().addAdjustmentListener(e -> { // Repaints the panel each time the horizontal scroll bar is moves, in order to avoid ghosting. focusPanelContainer.revalidate(); focusPanelContainer.repaint(); }); focusPanelContainer.add(navigationToolbar, BorderLayout.WEST); focusPanelContainer.add(scPane, BorderLayout.CENTER); JPanel pane = new JPanel(new MigLayout("fill, insets 0 0 0 0")); pane.setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Focus panel")); pane.add(focusPanelContainer, "grow"); return pane; }
From source file:com.mirth.connect.client.ui.alert.AlertActionPane.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); setLayout(new MigLayout("insets 0, flowy", "[][grow][]", "grow")); actionTable = new MirthTable(); actionTable.setModel(new ActionTableModel()); actionScrollPane = new JScrollPane(actionTable); actionScrollPane.setBackground(UIConstants.BACKGROUND_COLOR); addActionButton = new MirthButton("Add"); addActionButton.addActionListener(new ActionListener() { @Override//from w w w. j a va2 s. c o m public void actionPerformed(ActionEvent e) { ((ActionTableModel) actionTable.getModel()).addRow(new AlertAction(DEFAULT_PROTOCOL, "")); if (actionTable.getRowCount() == 1) { actionTable.setRowSelectionInterval(0, 0); } removeActionButton.setEnabled(true); PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); removeActionButton = new MirthButton("Remove"); removeActionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (actionTable.getSelectedModelIndex() != -1) { if (actionTable.isEditing()) { actionTable.getCellEditor().stopCellEditing(); } ActionTableModel model = (ActionTableModel) actionTable.getModel(); int selectedModelIndex = actionTable.getSelectedModelIndex(); int newViewIndex = actionTable.convertRowIndexToView(selectedModelIndex); if (newViewIndex == (model.getRowCount() - 1)) { newViewIndex--; } // must set lastModelRow to -1 so that when setting the new // row selection below the old data won't try to be saved. // lastEmailRow = -1; model.removeRow(selectedModelIndex); if (actionTable.getModel().getRowCount() != 0) { actionTable.setRowSelectionInterval(newViewIndex, newViewIndex); } else { removeActionButton.setEnabled(false); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); actionPane = new JPanel(); actionPane.setBackground(UIConstants.BACKGROUND_COLOR); actionPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Actions")); actionPane.setLayout(new MigLayout("insets 0, flowy", "[grow][]", "grow")); actionPane.add(actionScrollPane, "grow, wrap"); actionPane.add(addActionButton, "aligny top, growx, split"); actionPane.add(removeActionButton, "growx"); subjectTextField = new MirthTextField(); subjectTextField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { actionGroup.setSubject(subjectTextField.getText()); } @Override public void removeUpdate(DocumentEvent e) { actionGroup.setSubject(subjectTextField.getText()); } @Override public void changedUpdate(DocumentEvent e) { } }); subjectPane = new JPanel(); subjectPane.setBackground(UIConstants.BACKGROUND_COLOR); subjectPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Subject (only used for email messages)")); subjectPane.setLayout(new BorderLayout()); subjectPane.add(subjectTextField); templateTextArea = new MirthTextArea(); templateTextArea.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { actionGroup.setTemplate(templateTextArea.getText()); } @Override public void removeUpdate(DocumentEvent e) { actionGroup.setTemplate(templateTextArea.getText()); } @Override public void changedUpdate(DocumentEvent e) { } }); templateScrollPane = new JScrollPane(templateTextArea); templateScrollPane.setBackground(UIConstants.BACKGROUND_COLOR); templatePane = new JPanel(); templatePane.setBackground(UIConstants.BACKGROUND_COLOR); templatePane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Template")); templatePane.setLayout(new BorderLayout()); templatePane.add(templateScrollPane); variableList = new MirthVariableList(); variableScrollPane = new JScrollPane(variableList); variableScrollPane.setBackground(UIConstants.BACKGROUND_COLOR); variablePane = new JPanel(); variablePane.setBackground(UIConstants.BACKGROUND_COLOR); variablePane .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Alert Variables")); variablePane.setLayout(new BorderLayout()); variablePane.add(variableScrollPane); add(actionPane, "width 280:280:280, growy, wrap"); add(subjectPane, "split, growx"); add(templatePane, "grow, wrap"); add(variablePane, "width 140:140:140, growy"); }
From source file:userinterface.graph.Histogram.java
/** * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram * to plot data on// w w w .j a v a 2 s.c o m * * @param defaultSeriesName * @param handler instance of {@link GUIGraphHandler} * @param minVal the min value in data cache * @param maxVal the max value in data cache * @return Either a new instance of a Histogram or an old one depending on what the user selects */ public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler, double minVal, double maxVal) { // make sure that the probabilities are valid if (maxVal > 1.0) maxVal = 1.0; if (minVal < 0.0) minVal = 0.0; // set properties for the dialog JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true); dialog.setLayout(new BorderLayout()); JPanel p1 = new JPanel(new FlowLayout()); p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Number of buckets")); JPanel p2 = new JPanel(new FlowLayout()); p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1)); buckets.setToolTipText("Select the number of buckets for this Histogram"); // provides the ability to select a new or an old histogram to plot the series on JTextField seriesName = new JTextField(defaultSeriesName); JRadioButton newSeries = new JRadioButton("New Histogram"); JRadioButton existing = new JRadioButton("Existing Histogram"); newSeries.setSelected(true); JPanel seriesSelectPanel = new JPanel(); seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS)); JPanel seriesTypeSelect = new JPanel(new FlowLayout()); JPanel seriesOptionsPanel = new JPanel(new FlowLayout()); seriesTypeSelect.add(newSeries); seriesTypeSelect.add(existing); JComboBox<String> seriesOptions = new JComboBox<>(); seriesOptionsPanel.add(seriesOptions); seriesSelectPanel.add(seriesTypeSelect); seriesSelectPanel.add(seriesOptionsPanel); seriesSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to")); // provides ability to select the min/max range of the plot JLabel minValsLabel = new JLabel("Min range:"); JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01)); minVals.setToolTipText("Does not allow value more than the min value in the probabilities"); JLabel maxValsLabel = new JLabel("Max range:"); JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01)); maxVals.setToolTipText("Does not allow value less than the max value in the probabilities"); JPanel minMaxPanel = new JPanel(); minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS)); JPanel leftValsPanel = new JPanel(new BorderLayout()); JPanel rightValsPanel = new JPanel(new BorderLayout()); minMaxPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range")); leftValsPanel.add(minValsLabel, BorderLayout.WEST); leftValsPanel.add(minVals, BorderLayout.CENTER); rightValsPanel.add(maxValsLabel, BorderLayout.WEST); rightValsPanel.add(maxVals, BorderLayout.CENTER); minMaxPanel.add(leftValsPanel); minMaxPanel.add(rightValsPanel); // fill the old histograms in the property dialog boolean found = false; for (int i = 0; i < handler.getNumModels(); i++) { if (handler.getModel(i) instanceof Histogram) { seriesOptions.addItem(handler.getGraphName(i)); found = true; } } existing.setEnabled(found); seriesOptions.setEnabled(false); // the bottom panel JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton ok = new JButton("Plot"); JButton cancel = new JButton("Cancel"); // bind keyboard keys to plot and cancel buttons to improve usability ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = -7324877661936685228L; @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ok"); cancel.getActionMap().put("ok", new AbstractAction() { private static final long serialVersionUID = 2642213543774356676L; @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); //Action listener for the new series radio button newSeries.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newSeries.isSelected()) { existing.setSelected(false); seriesOptions.setEnabled(false); buckets.setEnabled(true); buckets.setToolTipText("Select the number of buckets for this Histogram"); minVals.setEnabled(true); maxVals.setEnabled(true); } } }); //Action listener for the existing series radio button existing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existing.isSelected()) { newSeries.setSelected(false); seriesOptions.setEnabled(true); buckets.setEnabled(false); minVals.setEnabled(false); maxVals.setEnabled(false); buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram"); } } }); //Action listener for the plot button ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); if (newSeries.isSelected()) { hist = new Histogram(); hist.setNumOfBuckets((int) buckets.getValue()); hist.setIsNew(true); } else if (existing.isSelected()) { String HistName = (String) seriesOptions.getSelectedItem(); hist = (Histogram) handler.getModel(HistName); hist.setIsNew(false); } key = hist.addSeries(seriesName.getText()); if (minVals.isEnabled() && maxVals.isEnabled()) { hist.setMinProb((double) minVals.getValue()); hist.setMaxProb((double) maxVals.getValue()); } } }); //Action listener for the cancel button cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); hist = null; } }); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { hist = null; } }); p1.add(buckets, BorderLayout.CENTER); p2.add(seriesName, BorderLayout.CENTER); options.add(ok); options.add(cancel); // add everything to the main panel of the dialog JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(seriesSelectPanel); mainPanel.add(p1); mainPanel.add(p2); mainPanel.add(minMaxPanel); // add main panel to the dialog dialog.add(mainPanel, BorderLayout.CENTER); dialog.add(options, BorderLayout.SOUTH); // set dialog properties dialog.setSize(320, 290); dialog.setLocationRelativeTo(GUIPrism.getGUI()); dialog.setVisible(true); // return the user selected Histogram with the properties set return new Pair<Histogram, SeriesKey>(hist, key); }
From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java
private JPanel createCordinatePanel() { JPanel wrap = new JPanel(new BorderLayout()); JPanel coordinate = new JPanel(new GridLayout(2, 1)); coordinate.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); //Horizontal group JPanel horizontal = new JPanel(new BorderLayout()); horizontal/*from w w w. j ava 2s.c o m*/ .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Horizontal Axis")); JPanel inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Logarithm X Axis")); logarithmX = new JCheckBox(); logarithmX.setActionCommand(LOGARITHM_X_AXIS_COMMAND); logarithmX.addActionListener(this); inner.add(logarithmX); inner.add(new JLabel()); inner.add(new JLabel("Flip X Axis")); flipX = new JCheckBox(); flipX.setActionCommand(FLIP_X_AXIS_COMMAND); flipX.addActionListener(this); inner.add(flipX); inner.add(new JLabel()); inner.add(new JLabel("X Axis Margin Percentage")); horizontalMargin = new JTextField(); horizontalMargin.setActionCommand(X_AXIS_MARGIN_COMMAND); horizontalMargin.addActionListener(this); inner.add(horizontalMargin); inner.add(new JLabel()); horizontal.add(inner, BorderLayout.NORTH); //Vertical group JPanel vertical = new JPanel(new BorderLayout()); vertical.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Vertical Axis")); inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Logarithm Y Axis")); logarithmY = new JCheckBox(); logarithmY.setActionCommand(LOGARITHM_Y_AXIS_COMMAND); logarithmY.addActionListener(this); inner.add(logarithmY); inner.add(new JLabel()); inner.add(new JLabel("Flip Y Axis")); flipY = new JCheckBox(); flipY.setActionCommand(FLIP_Y_AXIS_COMMAND); flipY.addActionListener(this); inner.add(flipY); inner.add(new JLabel()); vertical.add(inner, BorderLayout.NORTH); coordinate.add(horizontal, BorderLayout.NORTH); coordinate.add(vertical); wrap.setName("Coordinate"); wrap.add(coordinate, BorderLayout.NORTH); return wrap; }
From source file:com.net2plan.gui.utils.topologyPane.TopologyPanel.java
/** * Default constructor.//from ww w .j ava2 s . c om * * @param callback Topology callback listening plugin events * @param defaultDesignDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/networkTopologies}) * @param defaultDemandDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/trafficMatrices}) * @param canvasType Canvas type (i.e. JUNG) * @param plugins List of plugins to be included (it may be null) */ public TopologyPanel(final IVisualizationCallback callback, File defaultDesignDirectory, File defaultDemandDirectory, Class<? extends ITopologyCanvas> canvasType, List<ITopologyCanvasPlugin> plugins) { File currentDir = SystemUtils.getCurrentDir(); this.callback = callback; this.defaultDesignDirectory = defaultDesignDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "networkTopologies") : defaultDesignDirectory; this.defaultDemandDirectory = defaultDemandDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "trafficMatrices") : defaultDemandDirectory; this.multilayerControlPanel = new MultiLayerControlPanel(callback); try { canvas = canvasType.getDeclaredConstructor(IVisualizationCallback.class, TopologyPanel.class) .newInstance(callback, this); } catch (Exception e) { throw new RuntimeException(e); } if (plugins != null) for (ITopologyCanvasPlugin plugin : plugins) addPlugin(plugin); setLayout(new BorderLayout()); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true); toolbar.setFloatable(false); toolbar.setOpaque(false); toolbar.setBorderPainted(false); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(toolbar, BorderLayout.NORTH); add(topPanel, BorderLayout.NORTH); JComponent canvasComponent = canvas.getCanvasComponent(); canvasPanel = new JPanel(new BorderLayout()); canvasComponent.setBorder(LineBorder.createBlackLineBorder()); JToolBar multiLayerToolbar = new JToolBar(JToolBar.VERTICAL); multiLayerToolbar.setRollover(true); multiLayerToolbar.setFloatable(false); multiLayerToolbar.setOpaque(false); canvasPanel.add(canvasComponent, BorderLayout.CENTER); canvasPanel.add(multiLayerToolbar, BorderLayout.WEST); add(canvasPanel, BorderLayout.CENTER); btn_load = new JButton(); btn_load.setToolTipText("Load a network design"); btn_loadDemand = new JButton(); btn_loadDemand.setToolTipText("Load a traffic demand set"); btn_save = new JButton(); btn_save.setToolTipText("Save current state to a file"); btn_zoomIn = new JButton(); btn_zoomIn.setToolTipText("Zoom in"); btn_zoomOut = new JButton(); btn_zoomOut.setToolTipText("Zoom out"); btn_zoomAll = new JButton(); btn_zoomAll.setToolTipText("Zoom all"); btn_takeSnapshot = new JButton(); btn_takeSnapshot.setToolTipText("Take a snapshot of the canvas"); btn_showNodeNames = new JToggleButton(); btn_showNodeNames.setToolTipText("Show/hide node names"); btn_showLinkIds = new JToggleButton(); btn_showLinkIds.setToolTipText( "Show/hide link utilization, measured as the ratio between the total traffic in the link (including that in protection segments) and total link capacity (including that reserved by protection segments)"); btn_showNonConnectedNodes = new JToggleButton(); btn_showNonConnectedNodes.setToolTipText("Show/hide non-connected nodes"); btn_increaseNodeSize = new JButton(); btn_increaseNodeSize.setToolTipText("Increase node size"); btn_decreaseNodeSize = new JButton(); btn_decreaseNodeSize.setToolTipText("Decrease node size"); btn_increaseFontSize = new JButton(); btn_increaseFontSize.setToolTipText("Increase font size"); btn_decreaseFontSize = new JButton(); btn_decreaseFontSize.setToolTipText("Decrease font size"); /* Multilayer buttons */ btn_increaseInterLayerDistance = new JButton(); btn_increaseInterLayerDistance .setToolTipText("Increase the distance between layers (when more than one layer is visible)"); btn_decreaseInterLayerDistance = new JButton(); btn_decreaseInterLayerDistance .setToolTipText("Decrease the distance between layers (when more than one layer is visible)"); btn_showLowerLayerInfo = new JToggleButton(); btn_showLowerLayerInfo .setToolTipText("Shows the links in lower layers that carry traffic of the picked element"); btn_showLowerLayerInfo.setSelected(getVisualizationState().isShowInCanvasLowerLayerPropagation()); btn_showUpperLayerInfo = new JToggleButton(); btn_showUpperLayerInfo.setToolTipText( "Shows the links in upper layers that carry traffic that appears in the picked element"); btn_showUpperLayerInfo.setSelected(getVisualizationState().isShowInCanvasUpperLayerPropagation()); btn_showThisLayerInfo = new JToggleButton(); btn_showThisLayerInfo.setToolTipText( "Shows the links in the same layer as the picked element, that carry traffic that appears in the picked element"); btn_showThisLayerInfo.setSelected(getVisualizationState().isShowInCanvasThisLayerPropagation()); btn_npChangeUndo = new JButton(); btn_npChangeUndo.setToolTipText( "Navigate back to the previous state of the network (last time the network design was changed)"); btn_npChangeRedo = new JButton(); btn_npChangeRedo.setToolTipText( "Navigate forward to the next state of the network (when network design was changed"); btn_osmMap = new JToggleButton(); btn_osmMap.setToolTipText( "Toggle between on/off the OSM support. An internet connection is required in order for this to work."); btn_tableControlWindow = new JButton(); btn_tableControlWindow.setToolTipText("Show the network topology control window."); // MultiLayer control window JPopupMenu multiLayerPopUp = new JPopupMenu(); multiLayerPopUp.add(multilayerControlPanel); JPopUpButton btn_multilayer = new JPopUpButton("", multiLayerPopUp); btn_reset = new JButton("Reset"); btn_reset.setToolTipText("Reset the user interface"); btn_reset.setMnemonic(KeyEvent.VK_R); btn_load.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDesign.png"))); btn_loadDemand.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDemand.png"))); btn_save.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/saveDesign.png"))); btn_showNodeNames .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNodeName.png"))); btn_showLinkIds .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLinkUtilization.png"))); btn_showNonConnectedNodes.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); //btn_whatIfActivated.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); btn_zoomIn.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomIn.png"))); btn_zoomOut.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomOut.png"))); btn_zoomAll.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomAll.png"))); btn_takeSnapshot.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/takeSnapshot.png"))); btn_increaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseNode.png"))); btn_decreaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseNode.png"))); btn_increaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseFont.png"))); btn_decreaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseFont.png"))); btn_increaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseLayerDistance.png"))); btn_decreaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseLayerDistance.png"))); btn_multilayer .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerControl.png"))); btn_showThisLayerInfo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerPropagation.png"))); btn_showUpperLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerUpperPropagation.png"))); btn_showLowerLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerLowerPropagation.png"))); btn_tableControlWindow .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showControl.png"))); btn_osmMap.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showOSM.png"))); btn_npChangeUndo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoButton.png"))); btn_npChangeRedo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoButton.png"))); btn_load.addActionListener(this); btn_loadDemand.addActionListener(this); btn_save.addActionListener(this); btn_showNodeNames.addActionListener(this); btn_showLinkIds.addActionListener(this); btn_showNonConnectedNodes.addActionListener(this); btn_zoomIn.addActionListener(this); btn_zoomOut.addActionListener(this); btn_zoomAll.addActionListener(this); btn_takeSnapshot.addActionListener(this); btn_reset.addActionListener(this); btn_increaseInterLayerDistance.addActionListener(this); btn_decreaseInterLayerDistance.addActionListener(this); btn_showLowerLayerInfo.addActionListener(this); btn_showUpperLayerInfo.addActionListener(this); btn_showThisLayerInfo.addActionListener(this); btn_increaseNodeSize.addActionListener(this); btn_decreaseNodeSize.addActionListener(this); btn_increaseFontSize.addActionListener(this); btn_decreaseFontSize.addActionListener(this); btn_npChangeUndo.addActionListener(this); btn_npChangeRedo.addActionListener(this); btn_osmMap.addActionListener(this); btn_tableControlWindow.addActionListener(this); toolbar.add(btn_load); toolbar.add(btn_loadDemand); toolbar.add(btn_save); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_zoomIn); toolbar.add(btn_zoomOut); toolbar.add(btn_zoomAll); toolbar.add(btn_takeSnapshot); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_showNodeNames); toolbar.add(btn_showLinkIds); toolbar.add(btn_showNonConnectedNodes); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_increaseNodeSize); toolbar.add(btn_decreaseNodeSize); toolbar.add(btn_increaseFontSize); toolbar.add(btn_decreaseFontSize); toolbar.add(new JToolBar.Separator()); toolbar.add(Box.createHorizontalGlue()); toolbar.add(btn_osmMap); toolbar.add(btn_tableControlWindow); toolbar.add(btn_reset); multiLayerToolbar.add(new JToolBar.Separator()); multiLayerToolbar.add(btn_multilayer); multiLayerToolbar.add(btn_increaseInterLayerDistance); multiLayerToolbar.add(btn_decreaseInterLayerDistance); multiLayerToolbar.add(btn_showLowerLayerInfo); multiLayerToolbar.add(btn_showUpperLayerInfo); multiLayerToolbar.add(btn_showThisLayerInfo); multiLayerToolbar.add(Box.createVerticalGlue()); multiLayerToolbar.add(btn_npChangeUndo); multiLayerToolbar.add(btn_npChangeRedo); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (e.getComponent().getSize().getHeight() != 0 && e.getComponent().getSize().getWidth() != 0) { canvas.zoomAll(); } } }); List<Component> children = SwingUtils.getAllComponents(this); for (Component component : children) if (component instanceof AbstractButton) component.setFocusable(false); if (ErrorHandling.isDebugEnabled()) { canvas.getCanvasComponent().addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { Point point = e.getPoint(); position.setText("view = " + point + ", NetPlan coord = " + canvas.getCanvasPointFromNetPlanPoint(point)); } }); position = new JLabel(); add(position, BorderLayout.SOUTH); } else { position = null; } new FileDrop(canvasComponent, new LineBorder(Color.BLACK), new FileDrop.Listener() { @Override public void filesDropped(File[] files) { for (File file : files) { try { if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p")) return; loadDesignFromFile(file); break; } catch (Throwable e) { break; } } } }); btn_showNodeNames.setSelected(getVisualizationState().isCanvasShowNodeNames()); btn_showLinkIds.setSelected(getVisualizationState().isCanvasShowLinkLabels()); btn_showNonConnectedNodes.setSelected(getVisualizationState().isCanvasShowNonConnectedNodes()); final ITopologyCanvasPlugin popupPlugin = new PopupMenuPlugin(callback, this.canvas); addPlugin(new PanGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK)); if (callback.getVisualizationState().isNetPlanEditable() && getCanvas() instanceof JUNGCanvas) addPlugin(new AddLinkGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)); addPlugin(popupPlugin); if (callback.getVisualizationState().isNetPlanEditable()) addPlugin(new MoveNodePlugin(callback, canvas, MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)); setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Network topology")); // setAllowLoadTrafficDemand(callback.allowLoadTrafficDemands()); }
From source file:it.staiger.jmeter.protocol.http.config.gui.DynamicFilePanel.java
/** * Create a panel containing the source files Mime-Type and relative path. * * @return a panel containing the source files parameters. */// w w w .ja v a 2s .co m private JPanel getImportInfo() { JPanel panel = new HorizontalPanel(); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Source:")); // $NON-NLS-1$ attachmentsCT = new JTextField(10); folder = new JTextField(10); folder.setToolTipText("leave Empty for relative path to ${base.dir}");// $NON-NLS-1$ browseFolder = new JButton("Browse"); // $NON-NLS-1$ browseFolder.setActionCommand(BROWSE_IMPORT_PATH); browseFolder.addActionListener(this); panel.add(StaigerUtils.getInputPanel("MIME Type:", attachmentsCT));// $NON-NLS-1$ panel.add(StaigerUtils.getInputPanel("set Path Relative to:", folder, browseFolder));// $NON-NLS-1$ return panel; }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Initializes the layout for the visible components in this menu. A * {@link GridBagLayout} is used./*from w w w. jav a 2 s.co m*/ */ private void initLayout() { GridBagLayout gbl = new GridBagLayout(); panelDirectory.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("Select directory"))); panelFiles.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("Select files"))); panelEntryTypesSelection.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("BibTeX entry creation"))); Insets basicInsets = new Insets(6, 6, 6, 6); Insets smallInsets = new Insets(3, 2, 3, 1); Insets noInsets = new Insets(0, 0, 0, 0); // x, y, w, h, wx,wy,ix,iy FindUnlinkedFilesDialog.addComponent(gbl, panelSearchArea, buttonScan, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, noInsets, 0, 1, 1, 1, 1, 1, 40, 10); FindUnlinkedFilesDialog.addComponent(gbl, panelSearchArea, labelSearchingDirectoryInfo, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, noInsets, 0, 2, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelSearchArea, progressBarSearching, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, noInsets, 0, 3, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, labelDirectoryDescription, null, GridBagConstraints.WEST, new Insets(6, 6, 0, 6), 0, 0, 3, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, textfieldDirectoryPath, GridBagConstraints.HORIZONTAL, null, basicInsets, 0, 1, 2, 1, 1, 1, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, buttonBrowse, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, basicInsets, 2, 1, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, labelFileTypesDescription, GridBagConstraints.NONE, GridBagConstraints.WEST, new Insets(18, 6, 18, 3), 0, 3, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, comboBoxFileTypeSelection, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, new Insets(18, 3, 18, 6), 1, 3, 1, 1, 1, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, panelSearchArea, GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, new Insets(18, 6, 18, 6), 2, 3, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelFiles, labelFilesDescription, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, new Insets(6, 6, 0, 6), 0, 0, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelFiles, scrollpaneTree, GridBagConstraints.BOTH, GridBagConstraints.CENTER, basicInsets, 0, 1, 1, 1, 1, 1, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelFiles, panelOptions, GridBagConstraints.NONE, GridBagConstraints.NORTHEAST, basicInsets, 1, 1, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionSelectAll, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, noInsets, 0, 0, 1, 1, 1, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionUnselectAll, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, noInsets, 0, 1, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionExpandAll, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, new Insets(6, 0, 0, 0), 0, 2, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionCollapseAll, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, noInsets, 0, 3, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelEntryTypesSelection, labelEntryTypeDescription, GridBagConstraints.NONE, GridBagConstraints.WEST, basicInsets, 0, 0, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelEntryTypesSelection, comboBoxEntryTypeSelection, GridBagConstraints.NONE, GridBagConstraints.WEST, basicInsets, 1, 0, 1, 1, 1, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelEntryTypesSelection, checkboxCreateKeywords, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, basicInsets, 0, 1, 2, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelImportArea, labelImportingInfo, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(6, 6, 0, 6), 0, 1, 1, 1, 1, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelImportArea, progressBarImporting, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 6, 6, 6), 0, 2, 1, 1, 1, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, panelButtons, panelImportArea, GridBagConstraints.NONE, GridBagConstraints.EAST, smallInsets, 1, 0, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelDirectory, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, basicInsets, 0, 0, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelFiles, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(12, 6, 2, 2), 0, 1, 1, 1, 1, 1, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelEntryTypesSelection, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHWEST, new Insets(12, 6, 2, 2), 0, 2, 1, 1, 0, 0, 0, 0); FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelButtons, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(10, 6, 10, 6), 0, 3, 1, 1, 0, 0, 0, 0); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addButton(buttonApply); bb.addButton(buttonClose); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panelImportArea.add(bb.getPanel(), GridBagConstraints.NONE); pack(); }