List of usage examples for javax.swing JButton setIcon
@BeanProperty(visualUpdate = true, description = "The button's default icon") public void setIcon(Icon defaultIcon)
From source file:org.zaproxy.zap.extension.tlsdebug.TlsDebugPanel.java
@SuppressWarnings("deprecation") private void initialize() { this.setIcon(TLSDEBUG_ICON); this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, // TODO Remove warn suppression and use View.getMenuShortcutKeyStroke with // newer ZAP (or use getMenuShortcutKeyMaskEx() with Java 10+) Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.ALT_DOWN_MASK, false)); this.setLayout(new BorderLayout()); JPanel panelContent = new JPanel(new GridBagLayout()); this.add(panelContent, BorderLayout.NORTH); panelContent.setBackground(Color.white); panelContent.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); panelContent.add(new JLabel(Constant.messages.getString("tlsdebug.label.url")), LayoutHelper.getGBC(0, 0, 1, 0.0D, new Insets(5, 5, 5, 5))); JPanel urlSelectPanel = new JPanel(new GridBagLayout()); JButton selectButton = new JButton(Constant.messages.getString("all.button.select")); selectButton.setIcon( DisplayUtils.getScaledIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")))); // Globe // icon// w ww . j av a 2 s . c o m selectButton.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent e) { NodeSelectDialog nsd = new NodeSelectDialog(View.getSingleton().getMainFrame()); SiteNode node = null; try { node = Model.getSingleton().getSession().getSiteTree() .findNode(new URI(getUrlField().getText(), false)); } catch (Exception e2) { // Ignore } node = nsd.showDialog(node); if (node != null && node.getHistoryReference() != null) { try { getUrlField().setText(node.getHistoryReference().getURI().toString()); } catch (Exception e1) { // Ignore } } } }); urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 1.0D)); urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D)); panelContent.add(urlSelectPanel, LayoutHelper.getGBC(1, 0, 3, 0.25D)); panelContent.add(this.getCheckButton(), LayoutHelper.getGBC(0, 1, 1, 0.0D)); JPanel outputPanel = new JPanel(new BorderLayout()); outputPanel.add(new JLabel(Constant.messages.getString("tlsdebug.label.console")), BorderLayout.NORTH); JScrollPane jScrollPane = new JScrollPane(); jScrollPane.add(getOutputArea(), LayoutHelper.getGBC(0, 0, 4, 1.D, 1.0D)); // Padding // at // bottom jScrollPane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 11)); jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); jScrollPane.setViewportView(getOutputArea()); outputPanel.add(jScrollPane, BorderLayout.CENTER); this.add(outputPanel, BorderLayout.CENTER); }
From source file:Proiect.uploadFTP.java
public void actionFTP() { adressf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { InetAddress thisIp;//from ww w .j a v a 2 s. c om try { thisIp = InetAddress.getLocalHost(); titleFTP.setText("Connection: " + thisIp.getHostAddress() + " -> " + adressf.getText()); } catch (UnknownHostException e1) { e1.printStackTrace(); } } }); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveState(); uploadFTP.dispose(); tree.dispose(); } }); connect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FTPClient client = new FTPClient(); FileInputStream fis = null; String pass = String.valueOf(passf.getPassword()); try { if (filename == null) { status.setText("File does not exist!"); } else { // Server address client.connect(adressf.getText()); // Login credentials client.login(userf.getText(), pass); if (client.isConnected()) { status.setText("Succesfull transfer!"); // File type client.setFileType(FTP.BINARY_FILE_TYPE); // File location File file = new File(filepath); fis = new FileInputStream(file); // Change the folder on the server client.changeWorkingDirectory(folderf.getText()); // Save the file on the server client.storeFile(filename, fis); } else { status.setText("Transfer failed!"); } } client.logout(); } catch (IOException e1) { Encrypter.printException(e1); } finally { try { if (fis != null) { fis.close(); } client.disconnect(); } catch (IOException e1) { Encrypter.printException(e1); } } } }); browsef.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int retval = chooserf.showOpenDialog(chooserf); if (retval == JFileChooser.APPROVE_OPTION) { status.setText(""); filename = chooserf.getSelectedFile().getName().toString(); filepath = chooserf.getSelectedFile().getPath(); filenf.setText(chooserf.getSelectedFile().getName().toString()); } } }); adv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.setSize(220, uploadFTP.getHeight()); tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY()); tree.setResizable(false); tree.setIconImage(Toolkit.getDefaultToolkit() .getImage(getClass().getClassLoader().getResource("assets/ico.png"))); tree.setUndecorated(true); tree.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2)); tree.setVisible(true); tree.setLayout(new BorderLayout()); JLabel labeltree = new JLabel("Server documents"); labeltree.setOpaque(true); labeltree.setBackground(Encrypter.color_light); labeltree.setBorder(BorderFactory.createMatteBorder(8, 10, 10, 0, Encrypter.color_light)); labeltree.setForeground(Encrypter.color_blue); labeltree.setFont(Encrypter.font16); JButton refresh = new JButton(""); ImageIcon refresh_icon = getImageIcon("assets/icons/refresh.png"); refresh.setIcon(refresh_icon); refresh.setBackground(Encrypter.color_light); refresh.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); refresh.setForeground(Encrypter.color_black); refresh.setFont(Encrypter.font16); refresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final FTPClient client = new FTPClient(); DefaultMutableTreeNode top = new DefaultMutableTreeNode(adressf.getText()); DefaultMutableTreeNode files = null; DefaultMutableTreeNode leaf = null; final JTree tree_view = new JTree(top); tree_view.setForeground(Encrypter.color_black); tree_view.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); tree_view.putClientProperty("JTree.lineStyle", "None"); tree_view.setBackground(Encrypter.color_light); JScrollPane scrolltree = new JScrollPane(tree_view); scrolltree.setBackground(Encrypter.color_light); scrolltree.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0)); UIManager.put("Tree.textBackground", Encrypter.color_light); UIManager.put("Tree.selectionBackground", Encrypter.color_blue); UIManager.put("Tree.selectionBorderColor", Encrypter.color_blue); tree_view.updateUI(); final String pass = String.valueOf(passf.getPassword()); try { client.connect(adressf.getText()); client.login(userf.getText(), pass); client.enterLocalPassiveMode(); if (client.isConnected()) { try { FTPFile[] ftpFiles = client.listFiles(); for (FTPFile ftpFile : ftpFiles) { files = new DefaultMutableTreeNode(ftpFile.getName()); top.add(files); if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) { FTPFile[] ftpFiles1 = client.listFiles(ftpFile.getName()); for (FTPFile ftpFile1 : ftpFiles1) { leaf = new DefaultMutableTreeNode(ftpFile1.getName()); files.add(leaf); } } } } catch (IOException e1) { Encrypter.printException(e1); } client.disconnect(); } else { status.setText("Failed connection!"); } } catch (IOException e1) { Encrypter.printException(e1); } finally { try { client.disconnect(); } catch (IOException e1) { Encrypter.printException(e1); } } tree.add(labeltree, BorderLayout.NORTH); tree.add(scrolltree, BorderLayout.CENTER); tree.add(refresh, BorderLayout.SOUTH); uploadFTP.addComponentListener(new ComponentListener() { public void componentMoved(ComponentEvent e) { tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY()); } public void componentShown(ComponentEvent e) { } public void componentResized(ComponentEvent e) { } public void componentHidden(ComponentEvent e) { } }); uploadFTP.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { tree.toFront(); } public void windowOpened(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } public void windowClosing(WindowEvent e) { } public void windowClosed(WindowEvent e) { } }); refresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.dispose(); tree.setVisible(true); } }); } }); }
From source file:savant.view.swing.BookmarkSheet.java
public BookmarkSheet(Container c) { // set the layout of the data sheet c.setLayout(new BorderLayout()); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); /**/* www . j av a 2 s . co m*/ * Create a toolbar. */ JMenuBar toolbar = new JMenuBar(); toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); c.add(toolbar, BorderLayout.NORTH); JButton previousButton = new JButton(); previousButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UP)); previousButton.setToolTipText("Go to previous bookmark [ Ctrl+( ]"); previousButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); previousButton.putClientProperty("JButton.segmentPosition", "first"); previousButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToPreviousBookmark(); } }); toolbar.add(previousButton); JButton nextButton = new JButton(); nextButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.DOWN)); nextButton.setToolTipText("Go to next bookmark [ Ctrl+) ]"); nextButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); nextButton.putClientProperty("JButton.segmentPosition", "last"); nextButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToNextBookmark(); } }); toolbar.add(nextButton); JButton goButton = new JButton("Go"); goButton.setToolTipText("Go to selected bookmark"); goButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); goButton.putClientProperty("JButton.segmentPosition", "only"); goButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToSelectedBookmark(); } }); toolbar.add(goButton); toolbar.add(Box.createGlue()); addButton = new JButton(); addButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_ADD)); addButton.setToolTipText("Add bookmark for current range"); addButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); addButton.putClientProperty("JButton.segmentPosition", "first"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); fc.addCurrentRangeToBookmarks(); } }); toolbar.add(addButton); JButton deleteButton = new JButton(); deleteButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.BKMK_RM)); deleteButton.setToolTipText("Delete selected bookmarks"); deleteButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); deleteButton.putClientProperty("JButton.segmentPosition", "last"); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BookmarkController fc = BookmarkController.getInstance(); int[] selectedRows = table.getSelectedRows(); Arrays.sort(selectedRows); boolean delete = false; if (selectedRows.length > 0 && confirmDelete) { Object[] options = { "Yes", "No", "Yes, don't ask again" }; JLabel message = new JLabel( "Are you sure you want to delete " + selectedRows.length + " item(s)?"); message.setPreferredSize(new Dimension(300, 20)); int confirmDeleteDialog = JOptionPane.showOptionDialog(DialogUtils.getMainWindow(), message, "Confirm Delete", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (confirmDeleteDialog == 0) { delete = true; } else if (confirmDeleteDialog == 2) { delete = true; confirmDelete = false; } } else if (selectedRows.length > 0 && !confirmDelete) { delete = true; } if (delete) { for (int i = selectedRows.length - 1; i >= 0; i--) { fc.removeBookmark(selectedRows[i]); } } } }); toolbar.add(deleteButton); toolbar.add(Box.createGlue()); JButton loadButton = new JButton(); loadButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.OPEN)); loadButton.setToolTipText("Load bookmarks from file"); loadButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); loadButton.putClientProperty("JButton.segmentPosition", "first"); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadBookmarks(table); } }); toolbar.add(loadButton); JButton saveButton = new JButton(); saveButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SAVE)); saveButton.setToolTipText("Save bookmarks to file"); saveButton.putClientProperty("JButton.buttonType", "segmentedRoundRect"); saveButton.putClientProperty("JButton.segmentPosition", "last"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveBookmarks(table); } }); toolbar.add(saveButton); // create a table (the most important component) table = new JTable(new BookmarksTableModel()); table.setAutoCreateRowSorter(true); table.setFillsViewportHeight(true); table.setShowGrid(true); table.setGridColor(Color.gray); //table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); // add the table and its header to the subpanel c.add(table.getTableHeader()); add(table); final JScrollPane sp = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setWheelScrollingEnabled(false); sp.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { sp.getVerticalScrollBar().setValue(sp.getVerticalScrollBar().getValue() + e.getUnitsToScroll() * 2); } }); c.add(sp); // add glue to fill the remaining space add(Box.createGlue()); }
From source file:savant.view.swing.NavigationBar.java
NavigationBar() { this.setOpaque(false); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); String buttonStyle = "segmentedCapsule"; String shortcutMod = MiscUtils.MAC ? "Cmd" : "Ctrl"; add(getRigidPadding());/*from w w w .j a v a 2 s . co m*/ JButton loadGenomeButton = (JButton) add(new JButton("")); loadGenomeButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.GENOME)); loadGenomeButton.setToolTipText("Load or change genome"); loadGenomeButton.setFocusable(false); loadGenomeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Savant.getInstance().showOpenGenomeDialog(); } }); loadGenomeButton.putClientProperty("JButton.buttonType", buttonStyle); loadGenomeButton.putClientProperty("JButton.segmentPosition", "first"); loadGenomeButton.setPreferredSize(ICON_SIZE); loadGenomeButton.setMinimumSize(ICON_SIZE); loadGenomeButton.setMaximumSize(ICON_SIZE); JButton loadTrackButton = (JButton) add(new JButton("")); loadTrackButton.setFocusable(false); loadTrackButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK)); loadTrackButton.setToolTipText("Load a track"); loadTrackButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Savant.getInstance().openTrack(); } }); loadTrackButton.putClientProperty("JButton.buttonType", buttonStyle); loadTrackButton.putClientProperty("JButton.segmentPosition", "last"); loadTrackButton.setPreferredSize(ICON_SIZE); loadTrackButton.setMinimumSize(ICON_SIZE); loadTrackButton.setMaximumSize(ICON_SIZE); if (!Savant.getInstance().isStandalone()) { add(loadGenomeButton); add(loadTrackButton); add(getRigidPadding()); add(getRigidPadding()); } else { loadGenomeButton.setVisible(false); loadTrackButton.setVisible(false); } JLabel rangeText = new JLabel("Location "); add(rangeText); String[] a = { " ", " ", " ", " ", " ", " ", " ", " ", " ", " " }; locationField = new JComboBox(a); locationField.setEditable(true); locationField.setRenderer(new ReferenceListRenderer()); // When the item is chosen from the menu, navigate to the given feature/reference. locationField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (!currentlyPopulating) { if (ae.getActionCommand().equals("comboBoxChanged")) { // Assumes that combo-box items created by populateCombo() are of the form "GENE (chrX:1-1000)". String itemText = locationField.getSelectedItem().toString(); int lastBracketPos = itemText.lastIndexOf('('); if (lastBracketPos > 0) { itemText = itemText.substring(lastBracketPos + 1, itemText.length() - 1); } setRangeFromText(itemText); } } } }); // When the combo-box is popped open, we may want to repopulate the menu. locationField.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent pme) { String text = (String) locationField.getEditor().getItem(); if (!text.equals(lastPoppedUp)) { try { // Building the menu could take a while. setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); populateCombo(); } finally { setCursor(Cursor.getDefaultCursor()); } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) { } @Override public void popupMenuCanceled(PopupMenuEvent pme) { } }); // Add our special keystroke-handling to the JComboBox' text-field. // We have to turn off default tab-handling so that tab can pop up our list. Component textField = locationField.getEditor().getEditorComponent(); textField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET); textField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_TAB) { locationField.showPopup(); } else if (evt.getModifiers() == KeyEvent.SHIFT_MASK) { switch (evt.getKeyCode()) { case KeyEvent.VK_LEFT: locationController.shiftRangeLeft(); evt.consume(); break; case KeyEvent.VK_RIGHT: locationController.shiftRangeRight(); evt.consume(); break; case KeyEvent.VK_UP: locationController.zoomIn(); evt.consume(); break; case KeyEvent.VK_DOWN: locationController.zoomOut(); evt.consume(); break; case KeyEvent.VK_HOME: locationController.shiftRangeFarLeft(); evt.consume(); break; case KeyEvent.VK_END: locationController.shiftRangeFarRight(); evt.consume(); break; } } } }); add(locationField); locationField.setToolTipText("Current display range"); locationField.setPreferredSize(LOCATION_SIZE); locationField.setMaximumSize(LOCATION_SIZE); locationField.setMinimumSize(LOCATION_SIZE); add(getRigidPadding()); JButton goButton = (JButton) add(new JButton(" Go ")); goButton.putClientProperty("JButton.buttonType", buttonStyle); goButton.putClientProperty("JButton.segmentPosition", "only"); goButton.setToolTipText("Go to specified range (Enter)"); goButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRangeFromText(locationField.getEditor().getItem().toString()); } }); add(getRigidPadding()); JLabel l = new JLabel("Length: "); add(l); lengthLabel = (JLabel) add(new JLabel()); lengthLabel.setToolTipText("Length of the current range"); lengthLabel.setPreferredSize(LENGTH_SIZE); lengthLabel.setMaximumSize(LENGTH_SIZE); lengthLabel.setMinimumSize(LENGTH_SIZE); add(Box.createGlue()); double screenwidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth(); JButton afterGo = null; //if (screenwidth > 800) { final JButton undoButton = (JButton) add(new JButton("")); afterGo = undoButton; undoButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.UNDO)); undoButton.setToolTipText("Undo range change (" + shortcutMod + "+Z)"); undoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.undoLocationChange(); } }); undoButton.putClientProperty("JButton.buttonType", buttonStyle); undoButton.putClientProperty("JButton.segmentPosition", "first"); undoButton.setPreferredSize(ICON_SIZE); undoButton.setMinimumSize(ICON_SIZE); undoButton.setMaximumSize(ICON_SIZE); final JButton redo = (JButton) add(new JButton("")); redo.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.REDO)); redo.setToolTipText("Redo range change (" + shortcutMod + "+Y)"); redo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.redoLocationChange(); } }); redo.putClientProperty("JButton.buttonType", buttonStyle); redo.putClientProperty("JButton.segmentPosition", "last"); redo.setPreferredSize(ICON_SIZE); redo.setMinimumSize(ICON_SIZE); redo.setMaximumSize(ICON_SIZE); //} add(getRigidPadding()); add(getRigidPadding()); final JButton zoomInButton = (JButton) add(new JButton()); if (afterGo == null) { afterGo = zoomInButton; } zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.putClientProperty("JButton.buttonType", buttonStyle); zoomInButton.putClientProperty("JButton.segmentPosition", "first"); zoomInButton.setPreferredSize(ICON_SIZE); zoomInButton.setMinimumSize(ICON_SIZE); zoomInButton.setMaximumSize(ICON_SIZE); zoomInButton.setToolTipText("Zoom in (Shift+Up)"); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.zoomIn(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"), new NameValuePair("navigation-direction", "in"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton zoomOut = (JButton) add(new JButton("")); zoomOut.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOut.setToolTipText("Zoom out (Shift+Down)"); zoomOut.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.zoomOut(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "zoomed"), new NameValuePair("navigation-direction", "out"), new NameValuePair("navigation-modality", "navbar") }); } }); zoomOut.putClientProperty("JButton.buttonType", buttonStyle); zoomOut.putClientProperty("JButton.segmentPosition", "last"); zoomOut.setPreferredSize(ICON_SIZE); zoomOut.setMinimumSize(ICON_SIZE); zoomOut.setMaximumSize(ICON_SIZE); add(getRigidPadding()); add(getRigidPadding()); final JButton shiftFarLeft = (JButton) add(new JButton()); shiftFarLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARLEFT)); shiftFarLeft.putClientProperty("JButton.buttonType", buttonStyle); shiftFarLeft.putClientProperty("JButton.segmentPosition", "first"); shiftFarLeft.setToolTipText("Move to the beginning of the genome (Shift+Home)"); shiftFarLeft.setPreferredSize(ICON_SIZE); shiftFarLeft.setMinimumSize(ICON_SIZE); shiftFarLeft.setMaximumSize(ICON_SIZE); shiftFarLeft.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeFarLeft(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "left"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftLeft = (JButton) add(new JButton()); shiftLeft.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_LEFT)); shiftLeft.putClientProperty("JButton.buttonType", buttonStyle); shiftLeft.putClientProperty("JButton.segmentPosition", "middle"); shiftLeft.setToolTipText("Move left (Shift+Left)"); shiftLeft.setPreferredSize(ICON_SIZE); shiftLeft.setMinimumSize(ICON_SIZE); shiftLeft.setMaximumSize(ICON_SIZE); shiftLeft.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeLeft(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "left"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftRight = (JButton) add(new JButton()); shiftRight.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_RIGHT)); shiftRight.putClientProperty("JButton.buttonType", buttonStyle); shiftRight.putClientProperty("JButton.segmentPosition", "middle"); shiftRight.setToolTipText("Move right (Shift+Right)"); shiftRight.setPreferredSize(ICON_SIZE); shiftRight.setMinimumSize(ICON_SIZE); shiftRight.setMaximumSize(ICON_SIZE); shiftRight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeRight(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "right"), new NameValuePair("navigation-modality", "navbar") }); } }); final JButton shiftFarRight = (JButton) add(new JButton()); shiftFarRight .setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.SHIFT_FARRIGHT)); shiftFarRight.putClientProperty("JButton.buttonType", buttonStyle); shiftFarRight.putClientProperty("JButton.segmentPosition", "last"); shiftFarRight.setToolTipText("Move to the end of the genome (Shift+End)"); shiftFarRight.setPreferredSize(ICON_SIZE); shiftFarRight.setMinimumSize(ICON_SIZE); shiftFarRight.setMaximumSize(ICON_SIZE); shiftFarRight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { locationController.shiftRangeFarRight(); AnalyticsAgent.log(new NameValuePair[] { new NameValuePair("navigation-event", "panned"), new NameValuePair("navigation-direction", "right"), new NameValuePair("navigation-modality", "navbar") }); } }); add(getRigidPadding()); locationController.addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { updateLocation(event.getReference(), (Range) event.getRange()); } }); // When the genome changes, we may need to invalidate our menu. GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { lastPoppedUp = "INVALID"; } }); this.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent ce) { int width = ce.getComponent().getWidth(); undoButton.setVisible(true); redo.setVisible(true); zoomInButton.setVisible(true); zoomOut.setVisible(true); shiftFarLeft.setVisible(true); shiftLeft.setVisible(true); shiftRight.setVisible(true); shiftFarRight.setVisible(true); // hide some components if the window isn't wide enough if (width < 1200) { undoButton.setVisible(false); redo.setVisible(false); } if (width < 1000) { shiftFarLeft.setVisible(false); shiftFarRight.setVisible(false); shiftRight.putClientProperty("JButton.segmentPosition", "last"); shiftLeft.putClientProperty("JButton.segmentPosition", "first"); } else { shiftRight.putClientProperty("JButton.segmentPosition", "middle"); shiftLeft.putClientProperty("JButton.segmentPosition", "middle"); } } public void componentMoved(ComponentEvent ce) { } @Override public void componentShown(ComponentEvent ce) { } @Override public void componentHidden(ComponentEvent ce) { } }); }
From source file:savant.view.variation.swing.VariationModule.java
public VariationModule(VariationController vc) { super(new GridBagLayout()); controller = vc;//from w ww. j a v a 2s. com // Toolbar shared by all panels. JToolBar tools = new JToolBar(); tools.setFloatable(false); rangeField = new JTextField(); rangeField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String text = rangeField.getText(); try { Bookmark bm = new Bookmark(text, controller.getReference(), controller.getVisibleRange()); controller.setLocation(bm.getReference(), (Range) bm.getRange()); } catch (ParseException x) { DialogUtils.displayMessage(String.format("Unable to parse \"%s\" as a location.", text)); } } }); tools.add(rangeField); tools.addSeparator(); JButton zoomInButton = new JButton(); zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.setBorderPainted(false); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomIn(); } }); tools.add(zoomInButton); JButton zoomOutButton = new JButton(); zoomOutButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOutButton.setBorderPainted(false); zoomOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomOut(); } }); tools.add(zoomOutButton); tools.addSeparator(); JButton controlsButton = new JButton("Controls"); controlsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (controller.getTracks().length > 0) { new CaseControlDialog(controller).setVisible(true); frequencyPlot.repaint(); } else { Toolkit.getDefaultToolkit().beep(); } } }); tools.add(controlsButton); tabs = new JTabbedPane(); table = new RecordTable(new VariantTableModel(null)); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { controller.navigateToRecord(controller.getData().get(table.getSelectedRow())); } } }); tabs.addTab("Table", new JScrollPane(table)); map = new VariantMap(controller); map.addMouseWheelListener(wheelListener); LocationController.getInstance().addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { map.repaint(); } }); JPanel mapPanel = populatePanel(map); tabs.addTab("Map", mapPanel); frequencyPlot = new AlleleFrequencyPlot(controller); frequencyPlot.addMouseWheelListener(wheelListener); JPanel frequencyPanel = populatePanel(frequencyPlot); tabs.addTab("Allele Frequency", frequencyPanel); JPanel ldPanel = new JPanel(); ldPanel.setLayout(new GridBagLayout()); ActionListener redrawForcer = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ldPlot.repaint(); } }; JRadioButton dPrimeButton = new JRadioButton("D\u2032", true); dPrimeButton.setActionCommand("true"); dPrimeButton.addActionListener(redrawForcer); JRadioButton rSquaredButton = new JRadioButton("r\u00B2", false); rSquaredButton.setActionCommand("false"); rSquaredButton.addActionListener(redrawForcer); methodGroup = new ButtonGroup(); JPanel methodPanel = new JPanel(); methodPanel.setBorder(BorderFactory.createTitledBorder("Calculation Method")); methodPanel.add(dPrimeButton); methodGroup.add(dPrimeButton); methodPanel.add(rSquaredButton); methodGroup.add(rSquaredButton); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.weighty = 0.0; ldPanel.add(methodPanel, gbc); ldPlot = new LDPlot(controller); JPanel lowerLDPanel = populatePanel(ldPlot); gbc.weighty = 1.0; ldPanel.add(lowerLDPanel, gbc); tabs.addTab("LD Plot", ldPanel); gbc.weighty = 0.0; add(tools, gbc); // Create the informative cards, but don't use them. messageLabel = new JLabel(); messageLabel.setFont(MESSAGE_FONT); messagePanel = populatePanel(messageLabel); progressPanel = new ProgressPanel(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { controller.cancelDataRequests(); } }); showCard(tabs, null); }
From source file:se.llbit.chunky.renderer.ui.RenderControls.java
private JPanel buildGeneralPane() { JLabel canvasSizeLbl = new JLabel("Canvas size:"); JLabel canvasSizeAdvisory = new JLabel("Note: Actual image size may not be the same as the window size!"); canvasSizeCB.setEditable(true);/*from w w w. ja v a 2 s . com*/ canvasSizeCB.addItem("400x400"); canvasSizeCB.addItem("1024x768"); canvasSizeCB.addItem("960x540"); canvasSizeCB.addItem("1920x1080"); canvasSizeCB.addActionListener(canvasSizeListener); final JTextField canvasSizeEditor = (JTextField) canvasSizeCB.getEditor().getEditorComponent(); canvasSizeEditor.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { } @Override public void focusGained(FocusEvent e) { canvasSizeEditor.selectAll(); } }); updateCanvasSizeField(); loadSceneBtn.setText("Load Scene"); loadSceneBtn.setIcon(Icon.load.imageIcon()); loadSceneBtn.addActionListener(loadSceneListener); JButton loadSelectedChunksBtn = new JButton("Load Selected Chunks"); loadSelectedChunksBtn.setToolTipText("Load the chunks that are currently selected in the map view"); loadSelectedChunksBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sceneMan.loadChunks(chunky.getWorld(), chunky.getSelectedChunks()); } }); JButton reloadChunksBtn = new JButton("Reload Chunks"); reloadChunksBtn.setIcon(Icon.reload.imageIcon()); reloadChunksBtn.setToolTipText("Reload all chunks in the scene"); reloadChunksBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sceneMan.reloadChunks(); } }); openSceneDirBtn.setText("Open Scene Directory"); openSceneDirBtn.setToolTipText("Open the directory where Chunky stores scene descriptions and renders"); openSceneDirBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(context.getSceneDirectory()); } } catch (IOException e) { Log.warn("Failed to open scene directory", e); } } }); openSceneDirBtn.setVisible(Desktop.isDesktopSupported()); loadSceneBtn.setToolTipText("This replaces the current scene!"); JButton setCanvasSizeBtn = new JButton("Apply"); setCanvasSizeBtn.setToolTipText("Set the canvas size to the value in the field"); setCanvasSizeBtn.addActionListener(canvasSizeListener); JButton halveCanvasSizeBtn = new JButton("Halve"); halveCanvasSizeBtn.setToolTipText("Halve the canvas width and height"); halveCanvasSizeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int width = renderMan.scene().canvasWidth() / 2; int height = renderMan.scene().canvasHeight() / 2; setCanvasSize(width, height); } }); JButton doubleCanvasSizeBtn = new JButton("Double"); doubleCanvasSizeBtn.setToolTipText("Double the canvas width and height"); doubleCanvasSizeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int width = renderMan.scene().canvasWidth() * 2; int height = renderMan.scene().canvasHeight() * 2; setCanvasSize(width, height); } }); JButton makeDefaultBtn = new JButton("Make Default"); makeDefaultBtn.setToolTipText("Make the current canvas size the default"); makeDefaultBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { PersistentSettings.set3DCanvasSize(renderMan.scene().canvasWidth(), renderMan.scene().canvasHeight()); } }); JSeparator sep1 = new JSeparator(); JSeparator sep2 = new JSeparator(); biomeColorsCB.setText("enable biome colors"); updateBiomeColorsCB(); saveDumpsCB.setText("save dump once every "); saveDumpsCB.addActionListener(saveDumpsListener); updateSaveDumpsCheckBox(); String[] frequencyStrings = new String[dumpFrequencies.length]; for (int i = 0; i < dumpFrequencies.length; ++i) { frequencyStrings[i] = Integer.toString(dumpFrequencies[i]); } dumpFrequencyCB.setModel(new DefaultComboBoxModel(frequencyStrings)); dumpFrequencyCB.setEditable(true); dumpFrequencyCB.addActionListener(dumpFrequencyListener); updateDumpFrequencyField(); saveSnapshotsCB.addActionListener(saveSnapshotListener); updateSaveSnapshotCheckBox(); yCutoff.update(); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(loadSceneBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(openSceneDirBtn)) .addGroup(layout.createSequentialGroup().addComponent(loadSelectedChunksBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(reloadChunksBtn)) .addComponent(sep1) .addGroup(layout.createSequentialGroup().addComponent(canvasSizeLbl) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(setCanvasSizeBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(makeDefaultBtn)) .addGroup(layout.createSequentialGroup().addComponent(halveCanvasSizeBtn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(doubleCanvasSizeBtn)) .addComponent(canvasSizeAdvisory).addComponent(sep2).addComponent(biomeColorsCB) .addGroup(layout.createSequentialGroup().addComponent(saveDumpsCB) .addComponent(dumpFrequencyCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(dumpFrequencyLbl).addGap(0, 0, Short.MAX_VALUE)) .addComponent(saveSnapshotsCB).addGroup(yCutoff.horizontalGroup(layout))) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup().addComponent(loadSceneBtn).addComponent(openSceneDirBtn)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout .createParallelGroup().addComponent(loadSelectedChunksBtn).addComponent(reloadChunksBtn)) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent( sep1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(canvasSizeLbl) .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(setCanvasSizeBtn).addComponent(makeDefaultBtn)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup().addComponent(halveCanvasSizeBtn) .addComponent(doubleCanvasSizeBtn)) .addPreferredGap(ComponentPlacement.RELATED).addComponent(canvasSizeAdvisory) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(sep2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(biomeColorsCB) .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(saveDumpsCB) .addComponent(dumpFrequencyCB).addComponent(dumpFrequencyLbl)) .addComponent(saveSnapshotsCB).addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(yCutoff.verticalGroup(layout)).addContainerGap()); return panel; }
From source file:se.llbit.chunky.renderer.ui.RenderControls.java
private JPanel buildSkyPane() { JLabel skyModeLbl = new JLabel("Sky Mode:"); skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values())); skyModeCB.addActionListener(skyModeListener); updateSkyMode();// w ww . j a v a 2 s . c o m JLabel skymapRotationLbl = new JLabel("Skymap rotation:"); skymapRotationSlider.setMinimum(1); skymapRotationSlider.setMaximum(100); skymapRotationSlider.addChangeListener(skyRotationListener); skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:"); lightProbeRotationSlider.setMinimum(1); lightProbeRotationSlider.setMaximum(100); lightProbeRotationSlider.addChangeListener(skyRotationListener); lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel skyboxRotationLbl = new JLabel("Skybox rotation:"); skyboxRotationSlider.setMinimum(1); skyboxRotationSlider.setMaximum(100); skyboxRotationSlider.addChangeListener(skyRotationListener); skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); updateSkyRotation(); skyHorizonOffset.update(); cloudSize.update(); cloudXOffset.update(); cloudYOffset.update(); cloudZOffset.update(); JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):"); ButtonGroup verticalResolution = new ButtonGroup(); v90Btn.setSelected(true); v180Btn.setSelected(false); verticalResolution.add(v90Btn); verticalResolution.add(v180Btn); v90Btn.addActionListener(v90Listener); v180Btn.addActionListener(v180Listener); updateVerticalResolution(); simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings")); GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel); simulatedSkyPanel.setLayout(simulatedSkyLayout); simulatedSkyLayout.setAutoCreateContainerGaps(true); simulatedSkyLayout.setAutoCreateGaps(true); simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup() .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout))); simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup() .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout))); skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings")); GroupLayout skymapLayout = new GroupLayout(skymapPanel); skymapPanel.setLayout(skymapLayout); skymapLayout.setAutoCreateContainerGaps(true); skymapLayout.setAutoCreateGaps(true); skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn) .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl) .addComponent(skymapRotationSlider)) .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn))); skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl) .addComponent(v90Btn).addComponent(v180Btn)) .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup() .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider))); loadSkymapBtn.setText("Load Skymap"); loadSkymapBtn.setToolTipText("Use a panoramic skymap"); loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan)); lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings")); GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel); lightProbePanel.setLayout(lightProbeLayout); lightProbeLayout.setAutoCreateContainerGaps(true); lightProbeLayout.setAutoCreateGaps(true); lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn) .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl) .addComponent(lightProbeRotationSlider))); lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn) .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup() .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider))); loadLightProbeBtn.setText("Load Spherical Skymap"); loadLightProbeBtn.setToolTipText("Select the spherical skymap to use"); loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan)); skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient")); gradientEditor = new GradientEditor(); gradientEditor.addGradientListener(gradientListener); updateSkyGradient(); skyGradientPanel.add(gradientEditor); GroupLayout skyboxLayout = new GroupLayout(skyboxPanel); skyboxPanel.setLayout(skyboxLayout); skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox")); JLabel skyboxLbl = new JLabel("Load skybox textures:"); JButton loadUpTexture = new JButton("Up"); loadUpTexture.setToolTipText("Load up texture"); loadUpTexture.setIcon(Icon.skyboxUp.imageIcon()); loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP)); JButton loadDownTexture = new JButton("Down"); loadDownTexture.setToolTipText("Load down texture"); loadDownTexture.setIcon(Icon.skyboxDown.imageIcon()); loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN)); JButton loadFrontTexture = new JButton("Front"); loadFrontTexture.setToolTipText("Load front (north) texture"); loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon()); loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT)); JButton loadBackTexture = new JButton("Back"); loadBackTexture.setToolTipText("Load back (south) texture"); loadBackTexture.setIcon(Icon.skyboxBack.imageIcon()); loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK)); JButton loadRightTexture = new JButton("Right"); loadRightTexture.setToolTipText("Load right (east) texture"); loadRightTexture.setIcon(Icon.skyboxRight.imageIcon()); loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT)); JButton loadLeftTexture = new JButton("Left"); loadLeftTexture.setToolTipText("Load left (west) texture"); loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon()); loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT)); skyboxLayout.setAutoCreateContainerGaps(true); skyboxLayout.setAutoCreateGaps(true); skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup() .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadFrontTexture).addComponent(loadRightTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture) .addComponent(loadBackTexture).addComponent(loadLeftTexture))) .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadDownTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture) .addComponent(loadBackTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture) .addComponent(loadLeftTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); atmosphereEnabled.setText("enable atmosphere"); atmosphereEnabled.addActionListener(atmosphereListener); updateAtmosphereCheckBox(); transparentSky.setText("transparent sky"); transparentSky.addActionListener(transparentSkyListener); updateTransparentSky(); volumetricFogEnabled.setText("enable volumetric fog"); volumetricFogEnabled.addActionListener(volumetricFogListener); updateVolumetricFogCheckBox(); cloudsEnabled.setText("enable clouds"); cloudsEnabled.addActionListener(cloudsEnabledListener); updateCloudsEnabledCheckBox(); JPanel panel = new JPanel(); GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel) .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(atmosphereEnabled) .addComponent(transparentSky).addComponent(volumetricFogEnabled).addComponent(cloudsEnabled) .addGroup(cloudSize.horizontalGroup(layout)).addGroup(cloudXOffset.horizontalGroup(layout)) .addGroup(cloudYOffset.horizontalGroup(layout)).addGroup(cloudZOffset.horizontalGroup(layout))) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl) .addComponent(skyModeCB)) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel) .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel) .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(atmosphereEnabled).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(volumetricFogEnabled).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudZOffset.verticalGroup(layout)).addContainerGap()); return panel; }
From source file:se.llbit.chunky.renderer.ui.tabs.SkyTab.java
public SkyTab(RenderControls renderControls) { super(renderControls); JLabel skyModeLbl = new JLabel("Sky Mode:"); skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values())); skyModeCB.addActionListener(skyModeListener); // Need to hide these to not warp the Swing layout: simulatedSkyPanel.setVisible(false); skymapPanel.setVisible(false);/*from ww w . j a v a 2s .c o m*/ lightProbePanel.setVisible(false); skyGradientPanel.setVisible(false); skyboxPanel.setVisible(false); JLabel skymapRotationLbl = new JLabel("Skymap rotation:"); skymapRotationSlider.setMinimum(1); skymapRotationSlider.setMaximum(100); skymapRotationSlider.addChangeListener(skyRotationListener); skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:"); lightProbeRotationSlider.setMinimum(1); lightProbeRotationSlider.setMaximum(100); lightProbeRotationSlider.addChangeListener(skyRotationListener); lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel skyboxRotationLbl = new JLabel("Skybox rotation:"); skyboxRotationSlider.setMinimum(1); skyboxRotationSlider.setMaximum(100); skyboxRotationSlider.addChangeListener(skyRotationListener); skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap"); JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):"); ButtonGroup verticalResolution = new ButtonGroup(); v90Btn.setSelected(true); v180Btn.setSelected(false); verticalResolution.add(v90Btn); verticalResolution.add(v180Btn); v90Btn.addActionListener(v90Listener); v180Btn.addActionListener(v180Listener); simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings")); GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel); simulatedSkyPanel.setLayout(simulatedSkyLayout); simulatedSkyLayout.setAutoCreateContainerGaps(true); simulatedSkyLayout.setAutoCreateGaps(true); simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup() .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout))); simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup() .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout))); skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings")); GroupLayout skymapLayout = new GroupLayout(skymapPanel); skymapPanel.setLayout(skymapLayout); skymapLayout.setAutoCreateContainerGaps(true); skymapLayout.setAutoCreateGaps(true); skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn) .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl) .addComponent(skymapRotationSlider)) .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn) .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn))); skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl) .addComponent(v90Btn).addComponent(v180Btn)) .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup() .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider))); loadSkymapBtn.setText("Load Skymap"); loadSkymapBtn.setToolTipText("Use a panoramic skymap"); loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan)); lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings")); GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel); lightProbePanel.setLayout(lightProbeLayout); lightProbeLayout.setAutoCreateContainerGaps(true); lightProbeLayout.setAutoCreateGaps(true); lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn) .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl) .addComponent(lightProbeRotationSlider))); lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn) .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup() .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider))); loadLightProbeBtn.setText("Load Spherical Skymap"); loadLightProbeBtn.setToolTipText("Select the spherical skymap to use"); loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan)); skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient")); gradientEditor = new GradientEditor(); gradientEditor.addGradientListener(gradientListener); skyGradientPanel.add(gradientEditor); GroupLayout skyboxLayout = new GroupLayout(skyboxPanel); skyboxPanel.setLayout(skyboxLayout); skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox")); JLabel skyboxLbl = new JLabel("Load skybox textures:"); JButton loadUpTexture = new JButton("Up"); loadUpTexture.setToolTipText("Load up texture"); loadUpTexture.setIcon(Icon.skyboxUp.imageIcon()); loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP)); JButton loadDownTexture = new JButton("Down"); loadDownTexture.setToolTipText("Load down texture"); loadDownTexture.setIcon(Icon.skyboxDown.imageIcon()); loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN)); JButton loadFrontTexture = new JButton("Front"); loadFrontTexture.setToolTipText("Load front (north) texture"); loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon()); loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT)); JButton loadBackTexture = new JButton("Back"); loadBackTexture.setToolTipText("Load back (south) texture"); loadBackTexture.setIcon(Icon.skyboxBack.imageIcon()); loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK)); JButton loadRightTexture = new JButton("Right"); loadRightTexture.setToolTipText("Load right (east) texture"); loadRightTexture.setIcon(Icon.skyboxRight.imageIcon()); loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT)); JButton loadLeftTexture = new JButton("Left"); loadLeftTexture.setToolTipText("Load left (west) texture"); loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon()); loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT)); skyboxLayout.setAutoCreateContainerGaps(true); skyboxLayout.setAutoCreateGaps(true); skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup() .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadFrontTexture).addComponent(loadRightTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture) .addComponent(loadBackTexture).addComponent(loadLeftTexture))) .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture) .addComponent(loadDownTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture) .addComponent(loadBackTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture) .addComponent(loadLeftTexture)) .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl) .addComponent(skyboxRotationSlider))); transparentSky.setText("transparent sky"); transparentSky.setToolTipText("Disables rendering the skybox"); transparentSky.addActionListener(transparentSkyListener); JLabel fogColorLbl = new JLabel( "<html>Hint: set fog density > 0.1 for thick fog,<br>set it < 0.1 for haze/atmosphere effect"); fogColorBtn.setIcon(Icon.colors.imageIcon()); fogColorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ColorPicker picker = new ColorPicker(fogColorBtn, renderMan.scene().getFogColor()); picker.addColorListener(new ColorListener() { @Override public void onColorPicked(Vector3d color) { renderMan.scene().setFogColor(color); } }); } }); cloudsEnabled.setText("enable clouds"); cloudsEnabled.addActionListener(cloudsEnabledListener); GroupLayout layout = new GroupLayout(this); setLayout(layout); layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup() .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl) .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel) .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(transparentSky) .addComponent(cloudsEnabled).addGroup(cloudSize.horizontalGroup(layout)) .addGroup(cloudXOffset.horizontalGroup(layout)).addGroup(cloudYOffset.horizontalGroup(layout)) .addGroup(cloudZOffset.horizontalGroup(layout)).addGroup(fogDensity.horizontalGroup(layout)) .addGroup(layout.createSequentialGroup().addComponent(fogColorBtn) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(fogColorLbl))) .addContainerGap()); layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl) .addComponent(skyModeCB)) .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel) .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel) .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(cloudZOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(fogDensity.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup().addComponent(fogColorBtn).addComponent(fogColorLbl)) .addContainerGap()); }
From source file:se.nawroth.asciidoc.browser.AsciidocBrowserApplication.java
public AsciidocBrowserApplication(final String[] args) { super("Asciidoc Browser"); setIconImage(Icons.APPLICATION.image()); setSize(1200, 1024);/*from w ww . ja v a 2 s . c o m*/ addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { actionExit(); } }); JPanel buttonPanel = new JPanel(); backButton = new JButton(""); backButton.setIcon(Icons.BACK.icon()); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actionBack(); } }); buttonPanel.setLayout(new MigLayout("", "[1px][][][][]", "[1px]")); JButton btnOptionsbutton = new JButton(""); btnOptionsbutton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { settingsDialog.setVisible(true); } }); btnOptionsbutton.setIcon(Icons.OPTIONS.icon()); buttonPanel.add(btnOptionsbutton, "flowx,cell 0 0"); backButton.setEnabled(false); buttonPanel.add(backButton, "cell 0 0,grow"); forwardButton = new JButton(""); forwardButton.setIcon(Icons.FORWARD.icon()); forwardButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actionForward(); } }); forwardButton.setEnabled(false); buttonPanel.add(forwardButton, "cell 0 0,grow"); getContentPane().setLayout(new MigLayout("", "[793.00px,grow]", "[44px][930px]")); getContentPane().add(buttonPanel, "cell 0 0,growx,aligny top"); locationTextField = new JTextField(65); locationTextField.setText(""); locationTextField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB) { actionGo(); refreshDocumentTree(); } } }); locationTextField.setTransferHandler( new TextFieldTransferHandler(locationTextField.getTransferHandler(), new Runnable() { @Override public void run() { locationTextField.setText(""); } }, new Runnable() { @Override public void run() { actionGo(); refreshDocumentTree(); } })); homebutton = new JButton(""); homebutton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { locationTextField.setText(Settings.getHome()); actionGo(); refreshDocumentTree(); } }); refreshButton = new JButton(""); refreshButton.setToolTipText("Refresh"); refreshButton.setEnabled(false); refreshButton.setIcon(Icons.REFRESH.icon()); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { actionGo(); refreshPreview(); } }); buttonPanel.add(refreshButton, "cell 1 0"); homebutton.setIcon(Icons.HOME.icon()); buttonPanel.add(homebutton, "cell 2 0"); buttonPanel.add(locationTextField, "cell 3 0,grow"); treeSourceSplitPane = new JSplitPane(); treeSourceSplitPane.setResizeWeight(0.3); getContentPane().add(treeSourceSplitPane, "cell 0 1,grow"); treeScrollPane = new JScrollPane(); treeScrollPane.setMinimumSize(new Dimension(200, 200)); treeSourceSplitPane.setLeftComponent(treeScrollPane); documentTree = new DocumentTree(documentModel); documentTree.setCellRenderer(new TooltipsTreeCellRenderer()); ToolTipManager.sharedInstance().registerComponent(documentTree); ToolTipManager.sharedInstance().setInitialDelay(INITIAL_TOOLTIP_DELAY); ToolTipManager.sharedInstance().setReshowDelay(0); documentTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(final TreeSelectionEvent tse) { TreePath newLeadSelectionPath = tse.getNewLeadSelectionPath(); if (newLeadSelectionPath != null && !newLeadSelectionPath.equals(currentSelectionPath)) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) newLeadSelectionPath .getLastPathComponent(); FileWrapper file = (FileWrapper) node.getUserObject(); showFile(file, true); refreshPreview(); } } }); treeScrollPane.setViewportView(documentTree); sourceEditorPane = new JEditorPane(); sourceEditorPane.setContentType("text/html"); sourceEditorPane.setEditable(false); sourceEditorPane.addHyperlinkListener(new HandleHyperlinkUpdate()); JScrollPane fileScrollPane = new JScrollPane(sourceEditorPane); fileScrollPane.setMinimumSize(new Dimension(600, 600)); documentTabbedPane = new JTabbedPane(SwingConstants.BOTTOM); documentTabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent ce) { refreshPreview(); } }); sourceLogSplitPane = new JSplitPane(); sourceLogSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); treeSourceSplitPane.setRightComponent(sourceLogSplitPane); sourceLogSplitPane.setTopComponent(documentTabbedPane); documentTabbedPane.add(fileScrollPane); documentTabbedPane.setTitleAt(0, "Source"); browserPane = new BrowserPane(); previewScrollPane = new JScrollPane(browserPane); documentTabbedPane.addTab("Preview", null, previewScrollPane, null); console = new JConsole(); System.setErr(console.getErr()); System.setOut(console.getOut()); sourceLogSplitPane.setBottomComponent(console); executor = new AsciidocExecutor(); }
From source file:snepsui.Interface.DrawNetwork.java
/** * Initializes the components in the DrawNetwork panel *//*from www. j ava 2 s .com*/ private void initGUI() { nodesList = new LinkedList<Node>(); molNodes = new Hashtable<String, CaseFrame>(); builtMolNodes = new Hashtable<String, Node>(); this.setPreferredSize(new Dimension(815, 600)); graph = new DirectedOrderedSparseMultigraph<String, String>(); this.layout = new StaticLayout<String, String>(graph, new Dimension(700, 450)); shape = new Transformer<String, Integer>() { public Integer transform(String vertex) { int stringLength = 0; if (molNodes.containsKey(vertex)) { stringLength = 3; } else { for (Node node : nodesList) { if (vertex.equals(node.getIdentifier())) { stringLength = node.getIdentifier().length(); } } } return stringLength; } }; vertexPaint = new Transformer<String, Paint>() { public Paint transform(String vertex) { if (molNodes.containsKey(vertex)) { if (builtMolNodes.containsKey(vertex)) { Node node = builtMolNodes.get(vertex); if (node.getClass().getSimpleName().equals("PatternNode")) { return Color.blue; } else if (node.getClass().getSimpleName().equals("ClosedNode")) { return Color.yellow; } } else return Color.white; } else { for (Node node : nodesList) { if (node.getIdentifier().equals(vertex)) { if (node.getClass().getSimpleName().equals("BaseNode")) { return Color.green; } else if (node.getClass().getSimpleName().equals("VariableNode")) { return Color.gray; } else if (node.getClass().getSimpleName().equals("PatternNode")) { return Color.blue; } else if (node.getClass().getSimpleName().equals("ClosedNode")) { return Color.yellow; } else { return Color.magenta; } } } } return Color.white; } }; edgeLabel = new Transformer<String, String>() { public String transform(String edge) { String result = ""; if (edge.isEmpty()) graph.removeEdge(""); vv.repaint(); try { result = edge.substring(0, edge.indexOf(":")); } catch (StringIndexOutOfBoundsException e) { } return result; } }; VertexShapeSizeAspect<String> vssa = new VertexShapeSizeAspect<String>(graph, shape); vv = new VisualizationViewer<String, String>(layout, new Dimension(700, 470)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<String, String>getInstance( LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>()))); vv.getRenderContext().setEdgeLabelTransformer(MapTransformer.<String, String>getInstance( LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>()))); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vv.getRenderContext().setVertexShapeTransformer(vssa); vv.getRenderContext() .setEdgeLabelClosenessTransformer(new ConstantDirectionalEdgeValueTransformer(0.5, 0.5)); vv.getRenderContext().setEdgeLabelTransformer(edgeLabel); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { point = e.getPoint(); } public void mouseReleased(MouseEvent e) { vv.repaint(); } }); vssa.setScaling(true); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); this.add(panel); Factory<String> vertexFactory = new VertexFactory(); Factory<String> edgeFactory = new EdgeFactory(); final EditingModalGraphMouse<String, String> graphMouse = new EditingModalGraphMouse<String, String>( vv.getRenderContext(), vertexFactory, edgeFactory); graphMouse.add(new CustomEditingPopupGraphMousePlugin<String>(vertexFactory, edgeFactory)); graphMouse.remove(graphMouse.getPopupEditingPlugin()); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.EDITING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); String path = "src/snepsui/Interface/resources/icons/"; JButton plus = new JButton(); plus.setIcon(new ImageIcon(path + "zoom_in.png")); plus.setSize(18, 18); plus.setFocusPainted(false); plus.setBorderPainted(false); plus.setContentAreaFilled(false); plus.setMargin(new Insets(0, 0, 0, 0)); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton(); minus.setIcon(new ImageIcon(path + "zoom_out.png")); minus.setSize(18, 18); minus.setFocusPainted(false); minus.setBorderPainted(false); minus.setContentAreaFilled(false); minus.setMargin(new Insets(0, 0, 0, 0)); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 2)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JButton colors = new JButton(new ImageIcon(path + "colors.png")); colors.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(getRootPane(), new NodeColors()); } }); JButton infoButton = new JButton(new ImageIcon(path + "info.png")); infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions, "Instructions", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/snepsui/Interface/resources/icons/info.png")); } }); JButton resetbutton = new JButton(new ImageIcon(path + "refresh.png")); resetbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ImageIcon icon = new ImageIcon("src/snepsui/Interface/resources/icons/info.png"); int result = JOptionPane.showConfirmDialog(vv, "Are you sure you want to reset the drawing area?", "Reset", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon); if (result == JOptionPane.YES_OPTION) { builtMolNodes.clear(); molNodes.clear(); nodesList.clear(); LinkedList<String> vertexList = new LinkedList<String>(); Collection<String> vertices = graph.getVertices(); for (String vertex : vertices) { vertexList.add(vertex); } for (String item : vertexList) { graph.removeVertex(item); } vv.repaint(); } } }); JLabel caseframeLabel = new JLabel("Case Frames"); DefaultComboBoxModel caseframeComboBoxModel = new DefaultComboBoxModel( new String[] { "define-caseframe", "undefine-caseframe" }); caseframeComboBox = new JComboBox(); caseframeComboBox.setModel(caseframeComboBoxModel); caseframeComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addCaseFrameCommands(e); } }); JLabel relationsLabel = new JLabel("Relations"); DefaultComboBoxModel relationsComboBoxModel = new DefaultComboBoxModel( new String[] { "define", "undefine" }); relationsComboBox = new JComboBox(); relationsComboBox.setModel(relationsComboBoxModel); relationsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addRelationCommands(e); } }); JPanel options = new JPanel(new GridLayout(3, 1)); options.add(infoButton); options.add(resetbutton); options.add(colors); this.add(options, BorderLayout.EAST); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(relationsLabel); controls.add(relationsComboBox); controls.add(caseframeLabel); controls.add(caseframeComboBox); JComboBox modeBox = graphMouse.getModeComboBox(); controls.add(modeBox); this.add(controls, BorderLayout.SOUTH); }