List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color, int thickness)
From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java
private JPanel createServerPanel(final Server server, final JList list, final int index, final boolean isSelected) { final JXPanel p = new JXPanel(); p.setLayout(new GridBagLayout()); final Color background = Colors.alpha(getBackgroundColor(list, index, isSelected), 0.4f); p.setBackground(background);//from w w w . j a v a2 s .c om Color color1 = Colors.White.color(0.5f); Color color2 = Colors.Gray.color(0.95f); final Point2D start = new Point2D.Float(0, 0); Point2D stop = new Point2D.Float(150, 500); if (server != null && !server.sshWillFail() && server.getServerStatistics() != null) { final ServerStatisticsManager manager = server.getServerStatistics(); final Datastream.WarnLevel warnlevel = manager.getHighestWarnLevel(); if (warnlevel == Datastream.WarnLevel.HIGH) { color1 = Colors.Red.alpha(0.2f); color2 = Colors.Red.alpha(0.8f); stop = new Point2D.Float(500, 2); } else if (warnlevel == Datastream.WarnLevel.MEDIUM) { color1 = Colors.Orange.alpha(0.3f); color2 = Colors.Orange.alpha(0.8f); stop = new Point2D.Float(500, 2); } else if (warnlevel == Datastream.WarnLevel.LOW) { color1 = Colors.Orange.alpha(0.2f); color2 = Colors.Orange.alpha(0.4f); stop = new Point2D.Float(500, 2); } } final LinearGradientPaint gradientPaint = new LinearGradientPaint(start, stop, new float[] { 0.0f, 1.0f }, new Color[] { color1, color2 }); final MattePainter mattePainter = new MattePainter(gradientPaint, true); p.setBackgroundPainter(mattePainter); if (isSelected) { p.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(UIManager.getColor("List.background"), 2), BorderFactory.createBevelBorder(BevelBorder.LOWERED))); } else { p.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(UIManager.getColor("List.background"), 2), BorderFactory.createEtchedBorder())); } return p; }
From source file:edu.ku.brc.af.ui.db.ViewBasedDisplayDialog.java
@Override public void createUI() { setBackground(viewBasedPanel.getBackground()); JScrollPane scrollPane = UIHelper.createScrollPane(viewBasedPanel, true); scrollPane.setBorder(BorderFactory.createLineBorder(getBackground(), 8)); contentPanel = scrollPane;// w w w . j a v a 2s . com super.createUI(); viewBasedPanel.setOkCancelBtns(okBtn, cancelBtn); Integer width = (Integer) UIManager.get("ScrollBar.width"); if (width == null) { width = (new JScrollBar()).getPreferredSize().width; } Dimension dim1 = getPreferredSize(); dim1.height += width * 2; if (!UIHelper.isMacOS()) { dim1.width += width; } setSize(dim1); }
From source file:forge.gui.CardDetailPanel.java
private void updateBorder(final CardStateView card, final boolean canShow) { // color info if (card == null) { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); scrArea.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); return;/*from ww w .j av a2s. com*/ } final Color color = fromDetailColor(CardDetailUtil.getBorderColor(card, canShow)); setBorder(BorderFactory.createLineBorder(color, 2)); scrArea.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, color)); }
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private JPanel setUpFieldListPanel() { JPanel inputPanel = new JPanel(); // Panel Layout GridBagLayout gbl = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); con.weightx = 0;/*from w w w. ja va2 s. c o m*/ con.insets = new Insets(5, 5, 0, 5); con.fill = GridBagConstraints.HORIZONTAL; inputPanel.setLayout(gbl); // Border TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2), Localization.lang("Work options")); inputPanel.setBorder(titledBorder1); inputPanel.setMinimumSize(new Dimension(10, 10)); JScrollPane fieldScroller = new JScrollPane(fieldList); fieldScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); // insert buttons insertButton.addActionListener(event -> insertTextForTag(override.isSelected())); // Radio buttons append.setToolTipText(Localization.lang("Append the selected text to BibTeX field")); append.setMnemonic(KeyEvent.VK_A); append.setSelected(true); override.setToolTipText(Localization.lang("Override the BibTeX field by the selected text")); override.setMnemonic(KeyEvent.VK_O); override.setSelected(false); //Group the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(append); group.add(override); JPanel radioPanel = new JPanel(new GridLayout(0, 1)); radioPanel.add(append); radioPanel.add(override); // insert sub components JLabel label1 = new JLabel(Localization.lang("Available BibTeX fields")); con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(label1, con); inputPanel.add(label1); con.gridwidth = GridBagConstraints.REMAINDER; con.gridheight = 8; con.weighty = 1; con.fill = GridBagConstraints.BOTH; gbl.setConstraints(fieldScroller, con); inputPanel.add(fieldScroller); con.fill = GridBagConstraints.HORIZONTAL; con.weighty = 0; con.gridwidth = 2; gbl.setConstraints(radioPanel, con); inputPanel.add(radioPanel); con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(insertButton, con); inputPanel.add(insertButton); return inputPanel; }
From source file:com.haulmont.cuba.desktop.theme.impl.DesktopThemeLoaderImpl.java
private Border loadBorder(Element element) { String type = element.attributeValue("type"); if ("empty".equals(type)) { String value = element.attributeValue("margins"); String[] values = value.split(" "); if (values.length != 4) { log.error("Border margins value should be like '0 0 0 0': " + value); return null; }/*w w w . ja va2s . com*/ try { int top = Integer.parseInt(values[0]); int right = Integer.parseInt(values[1]); int bottom = Integer.parseInt(values[2]); int left = Integer.parseInt(values[3]); return BorderFactory.createEmptyBorder(top, left, bottom, right); } catch (NumberFormatException e) { log.error("Border margins value should be like '0 0 0 0': " + value); } } else if ("line".equals(type)) { String color = element.attributeValue("color"); String width = element.attributeValue("width"); Color borderColor = loadColorValue(color); if (borderColor == null) { log.error("Invalid line border color"); return null; } if (width != null) { return BorderFactory.createLineBorder(borderColor, Integer.parseInt(width)); } else { return BorderFactory.createLineBorder(borderColor); } } else if ("compound".equals(type)) { if (element.elements().size() < 2) { log.error("Compound border should have two child borders"); return null; } final Element child1 = (Element) element.elements().get(0); final Element child2 = (Element) element.elements().get(1); if (!BORDER_TAG.equals(child1.getName()) || !BORDER_TAG.equals(child2.getName())) { log.error("Compound border should have two child borders"); return null; } Border outsideBorder = loadBorder(child1); Border insideBorder = loadBorder(child2); if (outsideBorder == null || insideBorder == null) { return null; } return BorderFactory.createCompoundBorder(outsideBorder, insideBorder); } else { log.error("Unknown border type: " + type); } return null; }
From source file:gate.gui.docview.AnnotationStack.java
/** * Draw the annotation stack in a JPanel with a GridBagLayout. *//*from w ww . j a v a2s . c om*/ public void drawStack() { // clear the panel removeAll(); boolean textTooLong = text.length() > maxTextLength; int upperBound = text.length() - (maxTextLength / 2); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; /********************** * First row of text * *********************/ gbc.gridwidth = 1; gbc.insets = new java.awt.Insets(10, 10, 10, 10); JLabel labelTitle = new JLabel("Context"); labelTitle.setOpaque(true); labelTitle.setBackground(Color.WHITE); labelTitle.setBorder(new CompoundBorder( new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); labelTitle.setToolTipText("Expression and its context."); add(labelTitle, gbc); gbc.insets = new java.awt.Insets(10, 0, 10, 0); int expressionStart = contextBeforeSize; int expressionEnd = text.length() - contextAfterSize; // for each character for (int charNum = 0; charNum < text.length(); charNum++) { gbc.gridx = charNum + 1; if (textTooLong) { if (charNum == maxTextLength / 2) { // add ellipsis dots in case of a too long text displayed add(new JLabel("..."), gbc); // skip the middle part of the text if too long charNum = upperBound + 1; continue; } else if (charNum > upperBound) { gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } } // set the text and color of the feature value JLabel label = new JLabel(text.substring(charNum, charNum + 1)); if (charNum >= expressionStart && charNum < expressionEnd) { // this part is matched by the pattern, color it label.setBackground(new Color(240, 201, 184)); } else { // this part is the context, no color label.setBackground(Color.WHITE); } label.setOpaque(true); // get the word from which belongs the current character charNum int start = text.lastIndexOf(" ", charNum); int end = text.indexOf(" ", charNum); String word = text.substring((start == -1) ? 0 : start, (end == -1) ? text.length() : end); // add a mouse listener that modify the query label.addMouseListener(textMouseListener.createListener(word)); add(label, gbc); } /************************************ * Subsequent rows with annotations * ************************************/ // for each row to display for (StackRow stackRow : stackRows) { String type = stackRow.getType(); String feature = stackRow.getFeature(); if (feature == null) { feature = ""; } String shortcut = stackRow.getShortcut(); if (shortcut == null) { shortcut = ""; } gbc.gridy++; gbc.gridx = 0; gbc.gridwidth = 1; gbc.insets = new Insets(0, 0, 3, 0); // add the header of the row JLabel annotationTypeAndFeature = new JLabel(); String typeAndFeature = type + (feature.equals("") ? "" : ".") + feature; annotationTypeAndFeature.setText(!shortcut.equals("") ? shortcut : stackRow.getSet() != null ? stackRow.getSet() + "#" + typeAndFeature : typeAndFeature); annotationTypeAndFeature.setOpaque(true); annotationTypeAndFeature.setBackground(Color.WHITE); annotationTypeAndFeature .setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); if (feature.equals("")) { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type)); } else { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type, feature)); } gbc.insets = new java.awt.Insets(0, 10, 3, 10); add(annotationTypeAndFeature, gbc); gbc.insets = new java.awt.Insets(0, 0, 3, 0); // add all annotations for this row HashMap<Integer, TreeSet<Integer>> gridSet = new HashMap<Integer, TreeSet<Integer>>(); int gridyMax = gbc.gridy; for (StackAnnotation ann : stackRow.getAnnotations()) { gbc.gridx = ann.getStartNode().getOffset().intValue() - expressionStartOffset + contextBeforeSize + 1; gbc.gridwidth = ann.getEndNode().getOffset().intValue() - ann.getStartNode().getOffset().intValue(); if (gbc.gridx == 0) { // column 0 is already the row header gbc.gridwidth -= 1; gbc.gridx = 1; } else if (gbc.gridx < 0) { // annotation starts before displayed text gbc.gridwidth += gbc.gridx - 1; gbc.gridx = 1; } if (gbc.gridx + gbc.gridwidth > text.length()) { // annotation ends after displayed text gbc.gridwidth = text.length() - gbc.gridx + 1; } if (textTooLong) { if (gbc.gridx > (upperBound + 1)) { // x starts after the hidden middle part gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } else if (gbc.gridx > (maxTextLength / 2)) { // x starts in the hidden middle part if (gbc.gridx + gbc.gridwidth <= (upperBound + 3)) { // x ends in the hidden middle part continue; // skip the middle part of the text } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - gbc.gridx + 2; gbc.gridx = (maxTextLength / 2) + 2; } } else { // x starts before the hidden middle part if (gbc.gridx + gbc.gridwidth < (maxTextLength / 2)) { // x ends before the hidden middle part // do nothing } else if (gbc.gridx + gbc.gridwidth < upperBound) { // x ends in the hidden middle part gbc.gridwidth = (maxTextLength / 2) - gbc.gridx + 1; } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - (maxTextLength / 2) + 1; } } } if (gbc.gridwidth == 0) { gbc.gridwidth = 1; } JLabel label = new JLabel(); Object object = ann.getFeatures().get(feature); String value = (object == null) ? " " : Strings.toString(object); if (value.length() > maxFeatureValueLength) { // show the full text in the tooltip label.setToolTipText((value.length() > 500) ? "<html><textarea rows=\"30\" cols=\"40\" readonly=\"readonly\">" + value.replaceAll("(.{50,60})\\b", "$1\n") + "</textarea></html>" : ((value.length() > 100) ? "<html><table width=\"500\" border=\"0\" cellspacing=\"0\">" + "<tr><td>" + value.replaceAll("\n", "<br>") + "</td></tr></table></html>" : value)); if (stackRow.getCrop() == CROP_START) { value = "..." + value.substring(value.length() - maxFeatureValueLength - 1); } else if (stackRow.getCrop() == CROP_END) { value = value.substring(0, maxFeatureValueLength - 2) + "..."; } else {// cut in the middle value = value.substring(0, maxFeatureValueLength / 2) + "..." + value.substring(value.length() - (maxFeatureValueLength / 2)); } } label.setText(value); label.setBackground(AnnotationSetsView.getColor(stackRow.getSet(), ann.getType())); label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); label.setOpaque(true); label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, String.valueOf(ann.getId()))); // show the feature values in the tooltip if (!ann.getFeatures().isEmpty()) { String width = (Strings.toString(ann.getFeatures()).length() > 100) ? "500" : "100%"; String toolTip = "<html><table width=\"" + width + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">"; Color color = (Color) UIManager.get("ToolTip.background"); float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); color = Color.getHSBColor(hsb[0], hsb[1], Math.max(0f, hsb[2] - hsb[2] * 0.075f)); // darken the color String hexColor = Integer.toHexString(color.getRed()) + Integer.toHexString(color.getGreen()) + Integer.toHexString(color.getBlue()); boolean odd = false; // alternate background color every other row List<Object> features = new ArrayList<Object>(ann.getFeatures().keySet()); //sort the features into alphabetical order Collections.sort(features, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { return o1.toString().compareToIgnoreCase(o2.toString()); } }); for (Object key : features) { String fv = Strings.toString(ann.getFeatures().get(key)); toolTip += "<tr align=\"left\"" + (odd ? " bgcolor=\"#" + hexColor + "\"" : "") + "><td><strong>" + key + "</strong></td><td>" + ((fv.length() > 500) ? "<textarea rows=\"20\" cols=\"40\" cellspacing=\"0\">" + StringEscapeUtils .escapeHtml(fv.replaceAll("(.{50,60})\\b", "$1\n")) + "</textarea>" : StringEscapeUtils.escapeHtml(fv).replaceAll("\n", "<br>")) + "</td></tr>"; odd = !odd; } label.setToolTipText(toolTip + "</table></html>"); } else { label.setToolTipText("No features."); } if (!feature.equals("")) { label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, feature, Strings.toString(ann.getFeatures().get(feature)), String.valueOf(ann.getId()))); } // find the first empty row span for this annotation int oldGridy = gbc.gridy; for (int y = oldGridy; y <= (gridyMax + 1); y++) { // for each cell of this row where spans the annotation boolean xSpanIsEmpty = true; for (int x = gbc.gridx; (x < (gbc.gridx + gbc.gridwidth)) && xSpanIsEmpty; x++) { xSpanIsEmpty = !(gridSet.containsKey(x) && gridSet.get(x).contains(y)); } if (xSpanIsEmpty) { gbc.gridy = y; break; } } // save the column x and row y of the current value TreeSet<Integer> ts; for (int x = gbc.gridx; x < (gbc.gridx + gbc.gridwidth); x++) { ts = gridSet.get(x); if (ts == null) { ts = new TreeSet<Integer>(); } ts.add(gbc.gridy); gridSet.put(x, ts); } add(label, gbc); gridyMax = Math.max(gridyMax, gbc.gridy); gbc.gridy = oldGridy; } // add a button at the end of the row gbc.gridwidth = 1; if (stackRow.getLastColumnButton() != null) { // last cell of the row gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.insets = new Insets(0, 10, 3, 0); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; add(stackRow.getLastColumnButton(), gbc); gbc.insets = new Insets(0, 0, 3, 0); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; } // set the new gridy to the maximum row we put a value gbc.gridy = gridyMax; } if (lastRowButton != null) { // add a configuration button on the last row gbc.insets = new java.awt.Insets(0, 10, 0, 10); gbc.gridx = 0; gbc.gridy++; add(lastRowButton, gbc); } // add an empty cell that takes all remaining space to // align the visible cells at the top-left corner gbc.gridy++; gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; gbc.weightx = 1; gbc.weighty = 1; add(new JLabel(""), gbc); validate(); updateUI(); }
From source file:Proiect.uploadFTP.java
public void actionFTP() { adressf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { InetAddress thisIp;//from w ww .ja va 2s .c o m 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:network.view.relacoesEntidadesUI.GraphViewEntity.java
@SuppressWarnings("deprecation") public GraphViewEntity(Grafo g) { try {/* ww w . j a va 2 s . c o m*/ //this.grafo = g; graph = getGraph(g); } catch (Exception e) { graph = TestGraphs.getOneComponentGraph(); } vv = paintGraph(graph, g); frame = new JFrame("Relao entre Entidades"); Container content = frame.getContentPane(); panel = new JPanel(new BorderLayout()); panel.add(vv); content.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setIconImage(SwingResourceManager.getImage(GraphViewEntity.class, "/br/atech/smartsearch/view/images/logo-small.JPG")); dialog = new JDialog(frame); content = dialog.getContentPane(); // create the BirdsEyeView for zoom/pan final edu.uci.ics.jung.visualization.BirdsEyeVisualizationViewer bird = new edu.uci.ics.jung.visualization.BirdsEyeVisualizationViewer( vv, 0.25f, 0.25f); JButton reset = new JButton("Sem Zoom"); // 'reset' unzooms the graph via the Lens reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { bird.resetLens(); } }); final ScalingControl scaler = new ViewScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 0.9f, vv.getCenter()); } }); JButton help = new JButton("Ajuda"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String zoomHelp = "<html><center>Arraste o retngulo azul para deslocar a imagem<p>" + "Arraste um lado do retngulo para ajustar o zoom</center></html>"; JOptionPane.showMessageDialog(dialog, zoomHelp); } }); JPanel controls = new JPanel(new GridLayout(2, 2)); controls.add(plus); controls.add(minus); controls.add(reset); controls.add(help); content.add(bird); content.add(controls, BorderLayout.SOUTH); JButton zoomer = new JButton("Mostrar tela de zoom"); zoomer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.pack(); int w = dialog.getWidth() + 5; int h = dialog.getHeight() + 5; // 35; dialog.setLocation((int) (frame.getLocationOnScreen().getX() + frame.getWidth() - w), (int) frame.getLocationOnScreen().getY() + frame.getHeight() - h); //dialog.show(); dialog.setVisible(true); //bird.initLens(); } }); // [mcrb] Popup menu (Agrupar/Remover/Remover Selecao) popup = new JPopupMenu(); menuItem = new JMenuItem("Agrupar Nodos"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //TODO } }); popup.add(menuItem); menuItem = new JMenuItem("Remover Nodo"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myVertexDisplayPredicate.filter(true); clicksFiltro.add(selecionado); pr.setVertexPaintFunction(new MyVertexPaintFunction()); vv.repaint(); } }); popup.add(menuItem); menuItem = new JMenuItem("Remover Seleo"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clicks = new ArrayList<Vertex>(); pr.setVertexPaintFunction(new MyVertexPaintFunction()); // para evitar que o 'ultimo selecionado permaneca em destaque: selecionado = null; vv.repaint(); } }); popup.add(menuItem); labelFiltroArestas = new JLabel("Apresentar arestas com tamanho maior que "); textFieldFiltroArestas = new JTextField(2); buttonFiltroArestas = new JButton("Filtrar"); buttonEliminarFiltroArestas = new JButton("Remover Filtros"); buttonEliminarFiltroArestas.setEnabled(false); buttonFiltroArestas.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object objValue = textFieldFiltroArestas.getText(); try { new Integer((String) objValue).intValue(); } catch (NumberFormatException ex) { objValue = "0"; textFieldFiltroArestas.setText(""); } espessurasSelecionadas.add(objValue); myEdgeDisplayPredicate.filter(true, espessurasSelecionadas.toArray()); buttonEliminarFiltroArestas.setEnabled(true); vv.repaint(); } }); buttonEliminarFiltroArestas.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textFieldFiltroArestas.setText(""); espessurasSelecionadas = new ArrayList<Object>(); myEdgeDisplayPredicate.filter(false, espessurasSelecionadas.toArray()); vv.repaint(); } }); JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); // [inicio] acrescimo dos botoes de zoom JButton mais = new JButton(); mais.setToolTipText("Ampliar"); mais.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); mais.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton menos = new JButton(); menos.setToolTipText("Reduzir"); menos.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); menos.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); // [fim] acrescimo dos botoes de zoom final Color[] cores = { Color.BLACK, Color.BLUE, Color.CYAN, Color.DARK_GRAY, Color.GRAY, Color.GREEN, Color.MAGENTA, Color.ORANGE, Color.RED }; JButton agrupamento = new JButton("Agrupar"); agrupamento.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clusterAndRecolor(new SubLayoutDecorator(new FRLayout(graph)), 1, cores, true); vv.validate(); vv.repaint(); } }); p.add(mais); p.add(menos); p.add(zoomer); p.add(labelFiltroArestas); p.add(textFieldFiltroArestas); p.add(buttonFiltroArestas); p.add(buttonEliminarFiltroArestas); p.add(agrupamento); frame.getContentPane().add(p, BorderLayout.NORTH); frame.setSize(900, 600); frame.setVisible(true); }
From source file:wigraph.ShortestPathRelation.java
/** * *///w w w . j a v a 2 s . co m private JPanel setUpControls() { JPanel jp = new JPanel(); jp.setBackground(Color.WHITE); jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS)); jp.setBorder(BorderFactory.createLineBorder(Color.black, 3)); // jp_ss - word wist 1 (ss) horizontal panel JPanel jp_wl1 = new JPanel(); jp_wl1.setLayout(new BoxLayout(jp_wl1, BoxLayout.X_AXIS)); JLabel word1_label = new JLabel("List of words 1 separated by comma");//, Label.RIGHT) word_set1 = new JTextField(20); word1_label.setDisplayedMnemonic('W'); word_set1.setFocusAccelerator('W'); word_set1.setText(INITIAL_WORD_SET1); jp_wl1.add(word1_label); jp_wl1.add(word_set1); // jp_ss - word wist 1 (ss) horizontal panel JPanel jp_wl2 = new JPanel(); jp_wl2.setLayout(new BoxLayout(jp_wl2, BoxLayout.X_AXIS)); JLabel word2_label = new JLabel("List of words 2");//, Label.RIGHT) word_set2 = new JTextField(20); word2_label.setDisplayedMnemonic('o'); word_set2.setFocusAccelerator('o'); word_set2.setText(INITIAL_WORD_SET2); jp_wl2.add(word2_label); jp_wl2.add(word_set2); jp_wl2.add(Box.createRigidArea(new Dimension(5, 0))); jp_wl2.add(search_path_btn); jp.add(jp_wl1); jp.add(jp_wl2); result_len = new JTextField(20); jp.add(result_len); jp.add(new JLabel("Select a pair of vertices for which a shortest path will be displayed")); JPanel jp2 = new JPanel(); jp2.add(new JLabel("vertex from", SwingConstants.LEFT)); jp2.add(getSelectionBox(true)); jp2.setBackground(Color.white); JPanel jp3 = new JPanel(); jp3.add(new JLabel("vertex to", SwingConstants.LEFT)); jp3.add(getSelectionBox(false)); jp3.setBackground(Color.white); jp.add(jp2); jp.add(jp3); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); jp.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); jp.add(modeBox); return jp; }
From source file:app.RunApp.java
/** * Initializes Chi and Phi tables//from www. j av a2 s .c o m */ private void initChiPhiJTable() { fixedTableChiPhi.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jTableChiPhi.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fixedTableChiPhi.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableChiPhi.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fixedTableCoocurrences.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jTableCoocurrences.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fixedTableCoocurrences.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableCoocurrences.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); fixedTableHeatmap.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jTableHeatmap.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); fixedTableHeatmap.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableHeatmap.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); chiLabel = new JLabel("Chi coefficients", SwingConstants.CENTER); chiLabel.setBounds(25, 420, 120, 20); chiLabel.setBackground(Color.white); chiLabel.setForeground(Color.black); chiLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); chiLabel.setOpaque(true); chiLabel.setToolTipText("White cells corresponds to chi coefficients"); panelChiPhi.add(chiLabel); phiLabel = new JLabel("Phi coefficients", SwingConstants.CENTER); phiLabel.setBounds(165, 420, 120, 20); phiLabel.setBackground(Color.lightGray); phiLabel.setForeground(Color.black); phiLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); phiLabel.setOpaque(true); phiLabel.setToolTipText("Light gray cells corresponds to phi coefficients"); panelChiPhi.add(phiLabel); jLabelChiFiText.setVisible(false); }