List of usage examples for javax.swing DefaultListCellRenderer DefaultListCellRenderer
public DefaultListCellRenderer()
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
private void UpdategraphComponents(Forest<String, Integer> graph) throws IOException { jLayeredPane1.removeAll();//from w ww . j a v a 2 s .c o m /* List<String> heads = new ArrayList<>(); List<String> subgrph = new ArrayList<>(); ArgBuildManager manag = new ArgBuildManager(); Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = manag.getGraphJung(); */ Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = graph; System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount()); //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); ObservableGraph g = new ObservableGraph(graphGUI); //Layout layout = new BalloonLayout(forest); Layout layout = new BalloonLayout(graphGUI); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene2 = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout); mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene2.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene2.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene2.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene2.getLookup()); Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene2.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // this.repaint(); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene2.relayout(true); scene2.validate(); } }); }
From source file:com.raddle.tools.MergeMain.java
private void setCellRenderer(JList list) { list.setCellRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @Override/*from www. j av a2 s.c om*/ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { PropertyLine line = (PropertyLine) value; boolean isInSelected = false; for (int selectedIndex : list.getSelectedIndices()) { if (index == selectedIndex) { isInSelected = true; } } if (!isInSelected) { if (CompareResult.extra == line.getCompareResult()) { c.setBackground(new Color(0xFFC48E)); } else if (CompareResult.different == line.getCompareResult()) { c.setBackground(new Color(0xBBBBFF)); } } if (line.getState() != null) { if (LineState.added == line.getState()) { c.setForeground(new Color(0xCC0033)); } else if (LineState.updated == line.getState()) { c.setForeground(new Color(0x0066CC)); } else if (LineState.deleted == line.getState()) { if (line.getOriginalValue() == null) { c.setForeground(new Color(0xAAAAAA)); } else { c.setForeground(new Color(0x666666)); } Map<Attribute, Object> map = new HashMap<Attribute, Object>(); map.put(TextAttribute.FONT, c.getFont()); map.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); c.setFont(Font.getFont(map)); } } } return c; } }); }
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
private void UpdategraphComponents2(Forest<String, Integer> graph) throws IOException { jLayeredPane5.removeAll();//from www . j a va 2s .co m /* List<String> heads = new ArrayList<>(); List<String> subgrph = new ArrayList<>(); ArgBuildManager manag = new ArgBuildManager(); Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = manag.getGraphJung(); */ Forest<String, Integer> graphGUI = new DelegateForest<>(); graphGUI = graph; System.out.println("\t \t NUM UF VERT:" + graphGUI.getVertexCount()); //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); ObservableGraph g = new ObservableGraph(graphGUI); //Layout layout = new BalloonLayout(forest); Layout layout = new BalloonLayout(graphGUI); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene2 = new SceneImpl(g, layout); jLayeredPane5.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane5.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout); mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene2.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene2.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene2.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new ListenerWindow.MinSizePanel(scene2.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene2.getLookup()); Lookup.Result<String> selectedNodes = scene2.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene2.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane6.setLayout(new BorderLayout()); jLayeredPane6.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // this.repaint(); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene2.relayout(true); scene2.validate(); } }); }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JList buildJList(final Dimension dimension, final Object[] items, final JList list, final boolean sort) { if (items == null) { return null; }/* w ww.j av a2 s. co m*/ list.setModel(new DefaultListModel() { @Override public void addElement(Object obj) { boolean inserted = false; if (sort) { for (int i = 0; i < this.getSize() && !inserted; i++) { try { final String comparator = ((obj == null) ? "" : obj.toString()); if (this.get(i).toString().compareTo(comparator) > 0) { this.add(i, obj); inserted = true; } } catch (Throwable t) { log.error("Error al ordenar a " + obj + " y no lo incluimos", t); inserted = true; } } } if (!inserted) { super.addElement(obj); } } }); log.trace("Lista con " + items.length + " objetos"); for (Object obj : items) { ((DefaultListModel) list.getModel()).addElement(obj); } list.setCellRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = -987995602141400182L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel c = new JLabel(); c.setText(value.toString()); if (isSelected) { c.setOpaque(true); c.setBackground(Color.YELLOW); } return c; } }); list.setMinimumSize(dimension); list.setFixedCellHeight(22); return list; }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Initialises the combobox that contains the available file types which * bibtex entries can be created of.//from ww w . jav a 2s. c o m */ private void createFileTypesCombobox() { List<FileFilter> fileFilterList = creatorManager.getFileFilterList(); Vector<FileFilter> vector = new Vector<>(); for (FileFilter fileFilter : fileFilterList) { vector.add(fileFilter); } comboBoxFileTypeSelection = new JComboBox<>(vector); comboBoxFileTypeSelection.setRenderer(new DefaultListCellRenderer() { /* (non-Javadoc) * @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) */ @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof EntryFromFileCreator) { EntryFromFileCreator creator = (EntryFromFileCreator) value; if (creator.getExternalFileType() != null) { label.setIcon(creator.getExternalFileType().getIcon()); } } return label; } }); }
From source file:com.declarativa.interprolog.gui.Ini2.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); Layout layout = new BalloonLayout(forest); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);/*from www. ja v a 2s . c o m*/ mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); } }); }
From source file:com.declarativa.interprolog.gui.Ini3.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); Layout layout = new BalloonLayout(forest); //Layout layout = new TreeLayout(forest, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);/* w ww . j a v a 2 s.co m*/ mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane3.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); } }); }
From source file:org.forester.archaeopteryx.ControlPanel.java
private void addSequenceRelationBlock() { final JLabel spacer = new JLabel(""); spacer.setSize(1, 1);/*from w ww . jav a2 s .c om*/ add(spacer); final JLabel mainLabel = new JLabel("Sequence relations to display"); final JLabel typeLabel = customizeLabel(new JLabel("(type) "), getConfiguration()); typeLabel.setFont(ControlPanel.js_font.deriveFont(7)); getSequenceRelationTypeBox().setFocusable(false); _sequence_relation_type_box.setFont(ControlPanel.js_font); if (!_configuration.isUseNativeUI()) { _sequence_relation_type_box.setBackground(Constants.BUTTON_BACKGROUND_COLOR_DEFAULT); _sequence_relation_type_box.setForeground(Constants.BUTTON_TEXT_COLOR_DEFAULT); } _sequence_relation_type_box.setRenderer(new ListCellRenderer() { @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { final Component component = new DefaultListCellRenderer().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if ((value != null) && (value instanceof SequenceRelation.SEQUENCE_RELATION_TYPE)) { ((DefaultListCellRenderer) component).setText(SequenceRelation .getPrintableNameByType((SequenceRelation.SEQUENCE_RELATION_TYPE) value)); } return component; } }); final GridBagLayout gbl = new GridBagLayout(); _sequence_relation_type_box.setMinimumSize(new Dimension(115, 17)); _sequence_relation_type_box.setPreferredSize(new Dimension(115, 20)); final JPanel horizGrid = new JPanel(gbl); horizGrid.setBackground(getBackground()); horizGrid.add(typeLabel); horizGrid.add(_sequence_relation_type_box); add(customizeLabel(mainLabel, getConfiguration())); add(horizGrid); add(getSequenceRelationBox()); if (_configuration.doDisplayOption(Configuration.show_relation_confidence)) { addCheckbox(Configuration.show_relation_confidence, _configuration.getDisplayTitle(Configuration.show_relation_confidence)); setCheckbox(Configuration.show_relation_confidence, _configuration.doCheckOption(Configuration.show_relation_confidence)); } }
From source file:com.biosis.biosislite.vistas.dialogos.DlgEmpleadoCRUD.java
private void iniciar() { FormularioUtil.activarComponente(this.dcFechaInicio, true); FormularioUtil.activarComponente(this.dcFechaNacimiento, true); FormularioUtil.activarComponente(this.dcFechaInicio, true); cboTipoDocumento.setModel(new DefaultComboBoxModel(tdc.buscarTodos().toArray())); cboTipoDocumento.setRenderer(new DefaultListCellRenderer() { @Override//from w ww . j a v a 2 s .c o m public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof TipoDocumento) { value = ((TipoDocumento) value).getNombre(); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. } }); // cboOficina.setModel(new DefaultComboBoxModel(dc.buscarTodos().toArray())); // cboOficina.setRenderer(new DefaultListCellRenderer() { // // @Override // public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // if (value instanceof Departamento) { // value = ((Departamento) value).getNombre(); // } // return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. // } // // }); cboNivelEducativo.setModel(new DefaultComboBoxModel(nec.buscarTodos().toArray())); cboNivelEducativo.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { value = value instanceof NivelEducativo ? ((NivelEducativo) value).getDescripcion() : value; return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. } }); cboTipoVia.setModel(new DefaultComboBoxModel(tvc.buscarTodos().toArray())); cboTipoVia.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { value = value instanceof TipoVia ? ((TipoVia) value).getAbreviatura() : value; return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. } }); cboTipoZona.setModel(new DefaultComboBoxModel(tzc.buscarTodos().toArray())); cboTipoZona.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { value = value instanceof TipoZona ? ((TipoZona) value).getAbreviatura() : value; return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. } }); cboTipoContrato.setModel(new DefaultComboBoxModel(tcc.buscarTodos().toArray())); cboTipoContrato.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { value = value instanceof TipoContrato ? ((TipoContrato) value).getDescripcion() : value; return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. } }); cboRegimenLaboral.setModel(new DefaultComboBoxModel(rlc.buscarTodos().toArray())); cboRegimenLaboral.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { value = value instanceof RegimenLaboral ? ((RegimenLaboral) value).getNombre() : value; return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. } }); // cboSituacionEmpleado.setModel(new DefaultComboBoxModel(stc.buscarTodos().toArray())); // cboSituacionEmpleado.setRenderer(new DefaultListCellRenderer() { // @Override // public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // value = value instanceof SituacionTrabajador ? ((SituacionTrabajador) value).getDescripcion() : value; // return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. // } // }); cboGerencia.setModel(new DefaultComboBoxModel(gc.buscarTodos().toArray())); if (this.accion == Controlador.MODIFICAR) { mostrarDatos(this.empleado); } }
From source file:edu.harvard.i2b2.query.ui.GroupPanel.java
/** * This method is called from within the constructor to initialize the form. *//*ww w.j a va 2s .c om*/ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jClearButton = new javax.swing.JButton(); jConstrainButton = new javax.swing.JButton(); jExcludeButton = new javax.swing.JButton(); jOccurrenceButton = new javax.swing.JButton(); jNameLabel = new javax.swing.JLabel(); jHintLabel = new javax.swing.JLabel(); jTimingComboBox = new javax.swing.JComboBox(); // jAnyvisitToggleButton = new javax.swing.JToggleButton(); // jSamevisitToggleButton = new javax.swing.JToggleButton(); setLayout(null); QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData(); tmpData.name("working ......"); tmpData.tooltip("A root node"); tmpData.visualAttribute("FAO"); top = new DefaultMutableTreeNode(tmpData); // top = new DefaultMutableTreeNode("Root Node"); treeModel = new DefaultTreeModel(top); // treeModel.addTreeModelListener(new MyTreeModelListener()); jTree1 = new JTree(treeModel); jTree1.setDragEnabled(true); jTree1.setEditable(true); // jTree1.getSelectionModel().setSelectionMode // (TreeSelectionModel.SINGLE_TREE_SELECTION); // jTree1.setShowsRootHandles(true); // JScrollPane treeView = new JScrollPane(jTree1); jTree1.setRootVisible(false); jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setCellRenderer(new MyRenderer()); ToolTipManager.sharedInstance().registerComponent(jTree1); setBorder(javax.swing.BorderFactory.createEtchedBorder()); add(jScrollPane1); // jScrollPane1.setBounds(0, 40, 180, 200); jClearButton.setFont(new java.awt.Font("Tahoma", 1, 10)); jClearButton.setText("X"); jClearButton.setToolTipText("Clear all items from panel"); jClearButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jClearButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); jClearButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } jClearButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jClearButtonActionPerformed(evt); } }); add(jClearButton); jClearButton.setBounds(160, 0, 18, 20); jConstrainButton.setText("Dates"); jConstrainButton.setToolTipText("Constrain group by dates"); jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); // jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10,-20)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); // jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } jConstrainButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jConstrainButtonActionPerformed(evt); } }); add(jConstrainButton); jConstrainButton.setBounds(0, 20, 40, 21); jOccurrenceButton.setText("Occurs > 0x"); jOccurrenceButton.setToolTipText("Set occurrence times"); jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10)); } jOccurrenceButton.setIconTextGap(0); jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jOccurrenceButtonActionPerformed(evt); } }); jOccurrenceButton.setBounds(40, 20, 90, 21); add(jOccurrenceButton); // jExcludeButton.setMnemonic('E'); jExcludeButton.setText("Exclude"); jExcludeButton.setToolTipText("Exclude all items in group"); jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); } jExcludeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jExcludeButtonActionPerformed(evt); } }); add(jExcludeButton); jExcludeButton.setBounds(130, 20, 48, 21); jNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jNameLabel.setText("Group 1"); jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jNameLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); add(jNameLabel); jNameLabel.setBounds(0, 0, 160, 20); jNameLabel.setTransferHandler(new GroupLabelTextHandler()); jNameLabel.addMouseListener(new DragMouseAdapter()); jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { jNameLabelMouseMoved(evt); // System.out.println("mouse x: "+evt.getX()+" y: "+evt. // getY()); // System.out.println("name label x: "+jNameLabel.getX()+ // " width: "+ // jNameLabel.getWidth()+" y: " // +jNameLabel.getY()+" height "+jNameLabel.getHeight()); } }); jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jNameLabelMouseExited(evt); } }); /* * jAnyvisitToggleButton.setText("Any Visit"); * add(jAnyvisitToggleButton); jAnyvisitToggleButton.setBounds(0, 40, * 89, 20); * * jSamevisitToggleButton.setText("Same Visit"); * add(jSamevisitToggleButton); jSamevisitToggleButton.setBounds(90, 40, * 88, 20); * * ButtonGroup group = new ButtonGroup(); * group.add(jAnyvisitToggleButton); group.add(jSamevisitToggleButton); * jAnyvisitToggleButton.setSelected(true); */ jTree1.addTreeExpansionListener(this); jTree1.setTransferHandler(new TextHandler()); add(jScrollPane1); jScrollPane1.setViewportView(jTree1); // jTree1.setToolTipText( // "Double click on a folder to view the items inside"); // jScrollPane1.getViewport().setToolTipText( // "Double click on a folder to view the items inside"); jScrollPane1.setBounds(0, 60, 180, 120); // jScrollPane1.setBounds(0, 60, 190, 270); // jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new // java.awt.Color(0, 0, 0))); // jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() // { // public void mouseMoved(java.awt.event.MouseEvent evt) { // jScrollPane1MouseMoved(evt); // } // @Override // public void mouseDragged(MouseEvent e) { // jScrollPane1MouseMoved(e); // } // }); // jTree1.addMouseListener(new java.awt.event.MouseAdapter() { // public void mouseExited(java.awt.event.MouseEvent evt) { // jScrollPane1MouseExited(evt); // } // @Override // public void mouseEntered(MouseEvent e) { // jScrollPane1MouseEntered(e); // } // }); jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jHintLabel.setText( "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group"); // jHintLabel.getFont(); jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9)); // jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER); // jHintLabel.setBackground(Color.WHITE); // jHintLabel.setForeground(Color.WHITE); add(jHintLabel); jHintLabel.setBounds(0, 120, 180, 30); jTimingComboBox.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Treat Independently", "Occurs in Same Encounter", "Items instance will be same" })); jTimingComboBox.setAlignmentX(5.0F); ListCellRenderer renderer = new DefaultListCellRenderer(); ((JLabel) renderer).setHorizontalAlignment(SwingConstants.CENTER); jTimingComboBox.setRenderer(renderer); // jTimingComboBox.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); add(jTimingComboBox); jTimingComboBox.setBounds(1, 40, 177, 20); jTimingComboBox.setEnabled(false); }