List of usage examples for javax.swing DefaultListCellRenderer DefaultListCellRenderer
public DefaultListCellRenderer()
From source file:op.care.prescription.DlgOnDemand.java
private ListCellRenderer getRenderer() { return new ListCellRenderer() { @Override//from w w w . java2 s.c o m public java.awt.Component getListCellRendererComponent(JList jList, Object o, int i, boolean isSelected, boolean cellHasFocus) { String text; if (o == null) { text = "<i>" + SYSTools.xx("nursingrecords.prescription.dlgOnDemand.noOutcomeCheck") + "</i>"; } else if (o instanceof BigDecimal) { if (o.equals(new BigDecimal("0.5"))) { text = "½ " + SYSTools.xx("misc.msg.Hour"); } else if (o.equals(BigDecimal.ONE)) { text = "1 " + SYSTools.xx("misc.msg.Hour"); } else { text = o.toString() + " " + SYSTools.xx("misc.msg.Hours"); } } else { text = o.toString(); } return new DefaultListCellRenderer().getListCellRendererComponent(jList, SYSTools.toHTMLForScreen(text), i, isSelected, cellHasFocus); } }; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Nursing() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***//w w w .j a v a 2s . c o m * __ __ _ * \ \ / /__ _ _ _ __ __| |___ * \ \ /\ / / _ \| | | | '_ \ / _` / __| * \ V V / (_) | |_| | | | | (_| \__ \ * \_/\_/ \___/ \__,_|_| |_|\__,_|___/ * */ JPanel pnlWounds = new JPanel(new BorderLayout()); final JButton btnWounds = GUITools.createHyperlinkButton("opde.controlling.nursing.wounds", null, null); int woundsMonthsBack; try { woundsMonthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::woundsMonthsBack")); } catch (NumberFormatException nfe) { woundsMonthsBack = 7; } final JTextField txtWoundsMonthsBack = GUITools.createIntegerTextField(1, 12, woundsMonthsBack); txtWoundsMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnWounds.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::woundsMonthsBack", txtWoundsMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print( getWounds(Integer.parseInt(txtWoundsMonthsBack.getText()), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlWounds.add(btnWounds, BorderLayout.WEST); pnlWounds.add(txtWoundsMonthsBack, BorderLayout.EAST); pnlContent.add(pnlWounds); /*** * ____ _ _ _____ _ * / ___| ___ ___(_) __ _| | |_ _(_)_ __ ___ ___ ___ * \___ \ / _ \ / __| |/ _` | | | | | | '_ ` _ \ / _ \/ __| * ___) | (_) | (__| | (_| | | | | | | | | | | | __/\__ \ * |____/ \___/ \___|_|\__,_|_| |_| |_|_| |_| |_|\___||___/ * */ JPanel pblSocialTimes = new JPanel(new BorderLayout()); final JButton btnSocialTimes = GUITools.createHyperlinkButton("opde.controlling.nursing.social", null, null); final JComboBox cmbSocialTimes = new JComboBox( SYSCalendar.createMonthList(new LocalDate().minusYears(1), new LocalDate())); btnSocialTimes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { LocalDate month = (LocalDate) cmbSocialTimes.getSelectedItem(); SYSFilesTools.print(NReportTools.getTimes4SocialReports(month, progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); cmbSocialTimes.setRenderer(new ListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return new DefaultListCellRenderer().getListCellRendererComponent(list, monthFormatter.format(((LocalDate) value).toDate()), index, isSelected, cellHasFocus); } }); cmbSocialTimes.setSelectedIndex(cmbSocialTimes.getItemCount() - 2); pblSocialTimes.add(btnSocialTimes, BorderLayout.WEST); pblSocialTimes.add(cmbSocialTimes, BorderLayout.EAST); pnlContent.add(pblSocialTimes); return pnlContent; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Nutrition() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***//from w ww. j a va2 s . c om * _ _ _ _ _ _ * | (_) __ _ _ _(_) __| | | |__ __ _| | __ _ _ __ ___ ___ * | | |/ _` | | | | |/ _` | | '_ \ / _` | |/ _` | '_ \ / __/ _ \ * | | | (_| | |_| | | (_| | | |_) | (_| | | (_| | | | | (_| __/ * |_|_|\__, |\__,_|_|\__,_| |_.__/ \__,_|_|\__,_|_| |_|\___\___| * |_| */ JPanel pnlLiquidBalance = new JPanel(new BorderLayout()); final JButton btnLiquidBalance = GUITools.createHyperlinkButton("opde.controlling.nutrition.liquidbalance", null, null); final JComboBox cmbLiquidBalanceMonth = new JComboBox( SYSCalendar.createMonthList(new LocalDate().minusYears(1), new LocalDate())); btnLiquidBalance.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { LocalDate month = (LocalDate) cmbLiquidBalanceMonth.getSelectedItem(); SYSFilesTools.print(ResValueTools.getLiquidBalance(month, progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); cmbLiquidBalanceMonth.setRenderer(new ListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return new DefaultListCellRenderer().getListCellRendererComponent(list, monthFormatter.format(((LocalDate) value).toDate()), index, isSelected, cellHasFocus); } }); cmbLiquidBalanceMonth.setSelectedIndex(cmbLiquidBalanceMonth.getItemCount() - 2); pnlLiquidBalance.add(btnLiquidBalance, BorderLayout.WEST); pnlLiquidBalance.add(cmbLiquidBalanceMonth, BorderLayout.EAST); pnlContent.add(pnlLiquidBalance); /*** * _ _ _ _ _ _ _ _ * __ _____(_) __ _| |__ | |_ ___| |_ __ _| |_(_)___| |_(_) ___ ___ * \ \ /\ / / _ \ |/ _` | '_ \| __| / __| __/ _` | __| / __| __| |/ __/ __| * \ V V / __/ | (_| | | | | |_ \__ \ || (_| | |_| \__ \ |_| | (__\__ \ * \_/\_/ \___|_|\__, |_| |_|\__| |___/\__\__,_|\__|_|___/\__|_|\___|___/ * |___/ */ JPanel pnlWeight = new JPanel(new BorderLayout()); final JButton btnWeightStats = GUITools.createHyperlinkButton("opde.controlling.nutrition.weightstats", null, null); int wsMonthsBack; try { wsMonthsBack = Integer.parseInt(OPDE.getProps().getProperty("opde.controlling::wsMonthsBack")); } catch (NumberFormatException nfe) { wsMonthsBack = 7; } final JTextField txtWSMonthsBack = GUITools.createIntegerTextField(1, 24, wsMonthsBack); txtWSMonthsBack.setToolTipText(SYSTools.xx("misc.msg.monthsback")); btnWeightStats.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { SYSPropsTools.storeProp("opde.controlling::wsMonthsBack", txtWSMonthsBack.getText(), OPDE.getLogin().getUser()); SYSFilesTools.print(ResValueTools.getWeightStats( Integer.parseInt(txtWSMonthsBack.getText()), progressClosure), false); return null; } @Override protected void done() { OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlWeight.add(btnWeightStats, BorderLayout.WEST); pnlWeight.add(txtWSMonthsBack, BorderLayout.EAST); pnlContent.add(pnlWeight); return pnlContent; }
From source file:op.tools.SYSCalendar.java
public static ListCellRenderer getTimeRenderer() { return new ListCellRenderer() { DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT); @Override// www . ja v a 2 s. c om public Component getListCellRendererComponent(JList jList, Object o, int i, boolean isSelected, boolean cellHasFocus) { String text; if (o == null) { text = SYSTools.xx("misc.commands.>>noselection<<"); } else if (o instanceof Date) { Date date = (Date) o; text = timeFormat.format(date) + " " + SYSTools.xx("misc.msg.Time.short"); } else { text = o.toString(); } return new DefaultListCellRenderer().getListCellRendererComponent(jList, text, i, isSelected, cellHasFocus); } }; }
From source file:op.tools.SYSTools.java
public static ListCellRenderer getDefaultRenderer() { return new ListCellRenderer() { @Override// ww w .ja v a 2 s.c om public Component getListCellRendererComponent(JList jList, Object o, int i, boolean isSelected, boolean cellHasFocus) { String text; if (o == null) { text = SYSTools.xx("misc.commands.>>noselection<<"); } else { text = o.toString(); } return new DefaultListCellRenderer().getListCellRendererComponent(jList, text, i, isSelected, cellHasFocus); } }; }
From source file:org.encog.workbench.tabs.visualize.bayesian.BayesianStructureTab.java
public BayesianStructureTab(BayesianNetwork method) { super(null);/* www. ja va2 s .co m*/ // Graph<V, E> where V is the type of the vertices // and E is the type of the edges this.graph = buildGraph(method); Layout<DrawnEvent, DrawnEventConnection> layout = new KKLayout(graph); vv = new VisualizationViewer<DrawnEvent, DrawnEventConnection>(layout); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<DrawnEvent>()); vv.getRenderer().getVertexLabelRenderer().setPositioner(new InsidePositioner()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.N); vv.setVertexToolTipTransformer(new Transformer<DrawnEvent, String>() { public String transform(DrawnEvent edge) { return edge.getToolTip(); } }); Transformer<DrawnEvent, Paint> vertexPaint = new Transformer<DrawnEvent, Paint>() { public Paint transform(DrawnEvent neuron) { return Color.white; } }; final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); this.setLayout(new BorderLayout()); add(panel, BorderLayout.CENTER); final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); final ScalingControl scaler = new CrossoverScalingControl(); Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); // use a renderer to shorten the layout name presentation jcb.setRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new LayoutChooser(jcb, vv)); jcb.setSelectedItem(FRLayout.class); 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, 1 / 1.1f, vv.getCenter()); } }); JButton reset = new JButton("reset"); reset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity(); vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).setToIdentity(); } }); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(((DefaultModalGraphMouse<Integer, Number>) vv.getGraphMouse()).getModeListener()); JPanel controls = new JPanel(); controls.setLayout(new FlowLayout(FlowLayout.LEFT)); controls.add(plus); controls.add(minus); controls.add(reset); controls.add(modeBox); controls.add(jcb); Border border = BorderFactory.createEtchedBorder(); controls.setBorder(border); add(controls, BorderLayout.NORTH); }
From source file:org.graphwalker.GUI.App.java
@SuppressWarnings("serial") private void addButtons(JToolBar toolBar) { loadButton = makeNavigationButton("open", LOAD, "Load a model (graphml file)", "Load", true); toolBar.add(loadButton);/* ww w . j a v a 2 s . c om*/ reloadButton = makeNavigationButton("reload", RELOAD, "Reload/Restart already loaded Model", "Reload", false); toolBar.add(reloadButton); firstButton = makeNavigationButton("first", FIRST, "Start at the beginning", "First", false); toolBar.add(firstButton); backButton = makeNavigationButton("back", BACK, "Backs a step", "Back", false); toolBar.add(backButton); runButton = makeNavigationButton("run", RUN, "Starts the execution/Take a step forward in the log", "Run", false); toolBar.add(runButton); pauseButton = makeNavigationButton("pause", PAUSE, "Pauses the execution", "Pause", false); toolBar.add(pauseButton); nextButton = makeNavigationButton("next", NEXT, "Walk a step in the model/Go to the end of log", "Next", false); toolBar.add(nextButton); soapButton = makeNavigationCheckBoxButton("soap", SOAP, "Run MBT in SOAP(Web Services) mode", "Soap"); soapButton.setSelected(Util.readSoapGuiStartupState()); toolBar.add(soapButton); centerOnVertexButton = makeNavigationCheckBoxButton("centerOnVertex", CENTERONVERTEX, "Center the layout on the current vertex", "Center on current vertex"); toolBar.add(centerOnVertexButton); @SuppressWarnings("rawtypes") Class[] combos = getCombos(); final JComboBox jcb = new JComboBox(combos); // use a renderer to shorten the layout name presentation jcb.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new LayoutChooser(jcb, getVv())); jcb.setSelectedItem(StaticLayout.class); toolBar.add(jcb); }
From source file:org.javaswift.cloudie.CloudiePanel.java
private void createLists() { containersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); containersList.setCellRenderer(new DefaultListCellRenderer() { @Override/* w ww .ja va2 s .c o m*/ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); lbl.setBorder(LR_PADDING); Container c = (Container) value; lbl.setText(c.getName()); lbl.setToolTipText(lbl.getText()); return lbl; } }); containersList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { enableDisableContainerMenu(); updateStatusPanelForContainer(); } }); // storedObjectsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); storedObjectsList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); lbl.setBorder(LR_PADDING); StoredObject so = (StoredObject) value; lbl.setText(so.getName()); lbl.setToolTipText(lbl.getText()); return lbl; } }); storedObjectsList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { enableDisableStoredObjectMenu(); updateStatusPanelForStoredObject(); } }); }
From source file:org.mathIT.gui.GraphViewer.java
/** * This method is called from within the constructor to initialize the frame. *//* ww w . ja va2 s .co m*/ @SuppressWarnings({ "unchecked", "rawtypes" }) private void initComponents() { layout = new KKLayout<>(this.graph); //layout = new FRLayout<>(this.graph); //layout = new CircleLayout<>(this.graph); // Dimension preferredSize = new Dimension(840, 585); // old! Dimension preferredSize = new Dimension(900, 585); final VisualizationModel<V, E> visualizationModel = new DefaultVisualizationModel<>(layout, preferredSize); canvas = new GraphCanvas<>(this, visualizationModel, preferredSize); final PredicatedParallelEdgeIndexFunction<V, E> eif = PredicatedParallelEdgeIndexFunction.getInstance(); final Set<E> exclusions = new HashSet<>(); eif.setPredicate(new Predicate<E>() { @Override public boolean evaluate(E e) { return exclusions.contains(e); } }); /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(GraphViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } canvas.setBackground(Color.white); // --- Vertex configuration: --- //canvas.getRenderContext().setVertexShapeTransformer(new GraphViewer.ClusterVertexShapeFunction()); // ---- Vertex color: ---- canvas.getRenderer() .setVertexRenderer(new edu.uci.ics.jung.visualization.renderers.GradientVertexRenderer<>( Color.yellow, Color.yellow, // colors in normal state Color.white, Color.red, // colors in picked state canvas.getPickedVertexState(), false)); //canvas.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<V>(canvas.getPickedVertexState(), Color.red, Color.yellow)); pickActivated(); // --- Vertex labels: ----- canvas.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<>()); canvas.getRenderer().getVertexLabelRenderer() .setPositioner(new BasicVertexLabelRenderer.InsidePositioner()); canvas.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); // add a listener for ToolTips canvas.setVertexToolTipTransformer(new ToStringLabeller<V>() { /* (non-Javadoc) * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object) */ @Override public String transform(V v) { if (v instanceof Graph) { return ((Graph<V>) v).getVertices().toString(); } //return super.transform((V) v); return v.toString(); } }); // add a listener for ToolTips canvas.setEdgeToolTipTransformer(new ToStringLabeller<E>() { /* (non-Javadoc) * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object) */ @Override public String transform(E e) { return e.toString(); } }); // --- Edge Labels: --- canvas.getRenderContext().setParallelEdgeIndexFunction(eif); canvas.getRenderContext().getEdgeLabelRenderer(); /** * the regular graph mouse for the normal view */ final DefaultModalGraphMouse<V, E> graphMouse = new DefaultModalGraphMouse<>(); canvas.setGraphMouse(graphMouse); // --- Control Panel: --------------- content = getContentPane(); gzsp = new GraphZoomScrollPane(canvas); content.add(gzsp); modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); //graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Selection Mode")); modePanel.setLayout(new java.awt.GridLayout(3, 1)); modePanel.add(modeBox); if (invokerGraph instanceof NetworkOfActivatables) { JButton next = new JButton("Next Activation Step"); next.addActionListener((ActionEvent e) -> { nextActivationStep(); }); modePanel.add(next); JButton runAll = new JButton("Run Entire Activation"); runAll.addActionListener((ActionEvent e) -> { runActivation(); }); modePanel.add(runAll); } scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener((ActionEvent e) -> { scaler.scale(canvas, 1.1f, canvas.getCenter()); }); JButton minus = new JButton("-"); minus.addActionListener((ActionEvent e) -> { scaler.scale(canvas, 1 / 1.1f, canvas.getCenter()); }); buttonPanel = new JPanel(); buttonPanel.setLayout(new java.awt.GridLayout(4, 1)); print = new JButton("Print"); print.addActionListener((ActionEvent e) -> { canvas.startPrinterJob(); }); buttonPanel.add(print); help = new JButton("Help"); help.addActionListener((ActionEvent e) -> { JOptionPane.showMessageDialog((JComponent) e.getSource(), instructions, "Help", JOptionPane.PLAIN_MESSAGE); }); buttonPanel.add(help); load = new JButton("Load CSV File"); load.addActionListener((ActionEvent e) -> { //content.setCursor(new Cursor(Cursor.WAIT_CURSOR)); // funktioniert nicht... if (invokerGraph instanceof SocialNetwork) { SocialNetwork g = SocialNetwork.createNetworkFromCSVFile(); if (g != null) { this.setVisible(false); //invokerGraph.shutDisplay(); visualize(g); } } else if (invokerGraph instanceof WeightedGraph) { WeightedGraph<SimpleVertex> g = WeightedGraph.createWeightedGraphFromCSVFile(); if (g != null) { this.setVisible(false); //invokerGraph.shutDisplay(); visualize(g); } } else { org.mathIT.graphs.Graph<SimpleVertex> g = org.mathIT.graphs.Graph.createGraphFromCSVFile(); if (g != null) { this.setVisible(false); //invokerGraph.shutDisplay(); visualize(g); } } // content.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); // funktioniert nicht... }); buttonPanel.add(load); save = new JButton("Save as CSV"); save.addActionListener((ActionEvent e) -> { if (invokerGraph instanceof SocialNetwork) { for (V v : graph.getVertices()) { Activatable a = (Activatable) v; if (canvas.getPickedVertexState().isPicked(v)) { ((NetworkOfActivatables<Activatable>) invokerGraph).setActive(true); a.setActive(true); //} else { // a.setActive(false); } } ((SocialNetwork) invokerGraph).saveAsCSV(); } else if (invokerGraph instanceof WeightedGraph) { ((WeightedGraph<V>) invokerGraph).saveAsCSV(); } else { invokerGraph.saveAsCSV(); } }); buttonPanel.add(save); Class<? extends Layout<?, ?>>[] combos = getCombos(); jcb = new JComboBox<>(combos); // use a renderer to shorten the layout name presentation jcb.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String valueString = value.toString(); valueString = valueString.substring(valueString.lastIndexOf('.') + 1); return super.getListCellRendererComponent(list, valueString, index, isSelected, cellHasFocus); } }); jcb.addActionListener(new GraphViewer.LayoutChooser(jcb, canvas)); //jcb.setSelectedItem(KKLayout.class); //jcb.setSelectedItem(FRLayout.class); //jcb.setSelectedItem(CircleLayout.class); jcb.setSelectedItem(layout.getClass()); layoutChoice = new JPanel(); layoutChoice.setBorder(BorderFactory.createTitledBorder("Graph Layout")); layoutChoice.setLayout(new java.awt.GridLayout(2, 1)); layoutChoice.add(jcb); // Edge labels: edgePanel = new JPanel(); edgeLabels = new javax.swing.JCheckBox("Edge Labels"); edgePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING)); edgeLabels.addActionListener((java.awt.event.ActionEvent evt) -> { writeEdgeLabels(); }); edgePanel.add(edgeLabels); edgePanel.add(edgeLabels); layoutChoice.add(edgePanel); clusterControls = new JPanel(new GridLayout(3, 1)); if (invokerGraph instanceof org.mathIT.graphs.Graph) { clusterControls.setBorder(BorderFactory.createTitledBorder("Clusters")); JButton detect = new JButton("Detect (Greedy)"); detect.addActionListener((ActionEvent e) -> { detectClusters(); }); clusterControls.add(detect); JButton detectExactly = new JButton("Detect (Brute force)"); detectExactly.addActionListener((ActionEvent e) -> { detectClustersExactly(); }); clusterControls.add(detectExactly); JButton influencers = new JButton("Network Relevance"); influencers.addActionListener((ActionEvent e) -> { displayRelevanceClusters(); }); clusterControls.add(influencers); } matrixControls = new JPanel(new GridLayout(3, 1)); if (invokerGraph instanceof org.mathIT.graphs.Graph) { matrixControls.setBorder(BorderFactory.createTitledBorder("Matrices")); JButton adjacency = new JButton("Adjacency"); adjacency.addActionListener((ActionEvent e) -> { org.mathIT.algebra.Matrix A = new org.mathIT.algebra.Matrix(invokerGraph.getAdjacency()); new org.mathIT.gui.MatrixAlgebra("Adjacency matrix", A); }); matrixControls.add(adjacency); JButton computeHashimoto = new JButton("Hashimoto"); computeHashimoto.addActionListener((ActionEvent e) -> { org.mathIT.algebra.Matrix B = new org.mathIT.algebra.Matrix(invokerGraph.computeHashimoto()); new org.mathIT.gui.MatrixAlgebra("Hashimoto matrix", B); }); matrixControls.add(computeHashimoto); } // --- Build up Control Panel: ---- controls = new JPanel(); //controls.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER)); zoomControls = new JPanel(new GridLayout(2, 1)); zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom")); zoomControls.add(plus); zoomControls.add(minus); controls.add(zoomControls); controls.add(layoutChoice); controls.add(modePanel); if (invokerGraph instanceof org.mathIT.graphs.Graph) { controls.add(clusterControls); controls.add(matrixControls); } controls.add(buttonPanel); content.add(controls, BorderLayout.SOUTH); // Frame Properties: setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setLocationRelativeTo(null); //layout.setSize(canvas.getSize()); //scaler.scale(canvas, 1.f, canvas.getCenter()); setVisible(true); }
From source file:org.nuclos.client.common.NuclosCollectController.java
protected void setupSearchToolBar() { final Action actSaveFilter = new CommonAbstractAction( getSpringLocaleDelegate().getMessage("NuclosCollectController.9", "Filter speichern"), Icons.getInstance().getIconSave16(), getSpringLocaleDelegate().getMessage( "NuclosCollectController.5", "Eingestelltes Suchkriterium als Filter speichern")) { @Override/* w w w . j av a 2s . c o m*/ public void actionPerformed(ActionEvent ev) { cmdSaveFilter(); } }; final Action actRemoveFilter = new CommonAbstractAction( getSpringLocaleDelegate().getMessage("NuclosCollectController.8", "Filter l\u00f6schen"), Icons.getInstance().getIconDelete16(), getSpringLocaleDelegate() .getMessage("NuclosCollectController.2", "Ausgew\u00e4hlten Filter l\u00f6schen")) { @Override public void actionPerformed(ActionEvent ev) { cmdRemoveFilter(); } }; //result.add(Box.createHorizontalStrut(5)); CenteringPanel cpSearchFilter = new CenteringPanel(getSearchPanel().cmbbxSearchFilter) { @Override public Dimension getMinimumSize() { return this.getCenteredComponent().getMinimumSize(); } @Override public Dimension getMaximumSize() { return this.getCenteredComponent().getPreferredSize(); } }; cpSearchFilter.setOpaque(false); ColoredLabel bl = new ColoredLabel(cpSearchFilter, getSpringLocaleDelegate().getMessage("CollectController.Search.Filter", "Filter")); bl.setName("blChooseFilter"); this.getSearchPanel().addToolBarComponent(bl); //result.add(cpSearchFilter); //result.add(Box.createHorizontalStrut(2)); this.getSearchPanel().addPopupExtraSeparator(); JMenuItem btnSaveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actSaveFilter)); JMenuItem btnRemoveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actRemoveFilter)); //final JButton btnSaveFilter = result.add(actSaveFilter); //final JButton btnRemoveFilter = result.add(actRemoveFilter); // disable the remove filter action initially: actRemoveFilter.setEnabled(false); btnSaveFilter.setName("btnSaveFilter"); btnRemoveFilter.setName("btnRemoveFilter"); getSearchPanel().cmbbxSearchFilter.setName("cmbbxSearchFilter"); getSearchPanel().cmbbxSearchFilter.setToolTipText(getSpringLocaleDelegate() .getMessage("NuclosCollectController.15", "W\u00e4hlen Sie hier einen Suchfilter aus")); getSearchPanel().cmbbxSearchFilter.addActionListener(this.alSearchFilter); // set tool tips dynamically: getSearchPanel().cmbbxSearchFilter.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList lst, Object oValue, int index, boolean bSelected, boolean bCellHasFocus) { final JComponent result = (JComponent) super.getListCellRendererComponent(lst, oValue, index, bSelected, bCellHasFocus); String sToolTip = null; if (oValue != null) { final SearchFilter filter = (SearchFilter) oValue; if (result instanceof JLabel && !StringUtils.isNullOrEmpty(filter.getLabelResourceId())) { ((JLabel) result).setText(getSpringLocaleDelegate() .getTextFallback(filter.getLabelResourceId(), filter.getName())); } if (!StringUtils.isNullOrEmpty(filter.getDescriptionResourceId())) { sToolTip = getSpringLocaleDelegate().getTextFallback(filter.getDescriptionResourceId(), filter.getDescriptionResourceId()); } else { sToolTip = filter.getDescription(); } if (filter.getOwner() != null && !(filter.getOwner().equals(Main.getInstance().getMainController().getUserName()))) { sToolTip = sToolTip + " (" + filter.getOwner() + ")"; } result.setToolTipText(sToolTip); } return result; } }); // set the tool tip for the combobox also, as the tool tip for the renderer seems to be // taken in dropped down items only: getSearchPanel().cmbbxSearchFilter.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent ev) { final boolean bSelected = (ev.getStateChange() == ItemEvent.SELECTED); boolean bRegularFilterSelected = bSelected; String sToolTip = null; if (bSelected) { final SearchFilter filter = (SearchFilter) ev.getItem(); assert filter != null; sToolTip = filter.getDescription(); LOG.debug("Filter selected: " + filter.getName()); bRegularFilterSelected = !filter.isDefaultFilter(); } getSearchPanel().cmbbxSearchFilter.setToolTipText(sToolTip); // enable/disable remove filter action - the empty filter cannot be removed: actRemoveFilter.setEnabled(bRegularFilterSelected); } }); //return result; }