List of usage examples for javax.swing JPanel repaint
public void repaint()
From source file:app.RunApp.java
/** * Create heatmap graph/*from w w w. jav a 2s. c o m*/ * * @param jpanel Panel * @param coefficients Coefficients * @param list List * @param oldHeatmap Old heatmap * @return Heatmap */ private HeatMap createHeatmapGraph(JPanel jpanel, double[][] coefficients, ArrayList<AttributesPair> list, HeatMap oldHeatmap) { Color[] colors = new Color[256]; for (int i = 0; i < colors.length; i++) { colors[i] = new Color(i, i, i); } HeatMap heatMap = null; double[][] newCoefs = coefficients.clone(); for (int i = 0; i < newCoefs.length; i++) { for (int j = 0; j < newCoefs.length; j++) { if (newCoefs[i][j] < 0) { newCoefs[i][j] = 0; } } } if ((list != null) && (list.size() > 0)) { HashSet<Integer> selected = new HashSet<>(); for (int i = 0; i < list.size(); i++) { selected.add(list.get(i).getAttribute1Index()); selected.add(list.get(i).getAttribute2Index()); } newCoefs = new double[selected.size()][selected.size()]; List sortedSelected = new ArrayList(selected); Collections.sort(sortedSelected); for (int i = 0; i < sortedSelected.size(); i++) { for (int j = 0; j < sortedSelected.size(); j++) { newCoefs[i][j] = coefficients[(int) sortedSelected.get(i)][(int) sortedSelected.get(j)]; } } } heatMap = new HeatMap(newCoefs, false, colors); if (oldHeatmap != null) { jpanel.remove(oldHeatmap); } jpanel.setLayout(new BorderLayout()); jpanel.setPreferredSize(new Dimension(550, 425)); jpanel.add(heatMap, BorderLayout.CENTER); jpanel.validate(); jpanel.repaint(); return heatMap; }
From source file:at.becast.youploader.gui.FrmMain.java
public void initMainTab() { cmbCategory = new JComboBox<Categories>(); cmbCategory.setModel(new DefaultComboBoxModel<Categories>(Categories.values())); SideBar sideBar = new SideBar(SideBar.SideBarMode.TOP_LEVEL, true, 300, true); ss1 = new SidebarSection(sideBar, LANG.getString("frmMain.Sidebar.Settings"), new EditPanel(this), new ImageIcon(getClass().getResource("/pencil.png"))); ss2 = new SidebarSection(sideBar, LANG.getString("frmMain.Sidebar.Playlists"), new PlaylistPanel(this), new ImageIcon(getClass().getResource("/layers.png"))); ss3 = new SidebarSection(sideBar, LANG.getString("frmMain.Sidebar.Monetisation"), new MonetPanel(), new ImageIcon(getClass().getResource("/money.png"))); sideBar.addSection(ss1, false);//from w w w. ja va 2 s. c o m sideBar.addSection(ss2); sideBar.addSection(ss3); JPanel mainTab = new JPanel(); JPanel panel = new JPanel(); GroupLayout mainTabLayout = new GroupLayout(mainTab); mainTabLayout.setHorizontalGroup(mainTabLayout.createParallelGroup(Alignment.TRAILING) .addGroup(mainTabLayout.createSequentialGroup() .addComponent(panel, GroupLayout.DEFAULT_SIZE, 465, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(sideBar, GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE))); mainTabLayout.setVerticalGroup(mainTabLayout.createParallelGroup(Alignment.LEADING) .addComponent(panel, GroupLayout.DEFAULT_SIZE, 492, Short.MAX_VALUE) .addGroup(mainTabLayout.createSequentialGroup() .addComponent(sideBar, GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE).addContainerGap())); panel.setLayout(new FormLayout( new ColumnSpec[] { ColumnSpec.decode("2px"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20px:grow"), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("23px"), ColumnSpec.decode("33px"), FormSpecs.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("61px"), FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("24px"), ColumnSpec.decode("28px"), ColumnSpec.decode("40px"), ColumnSpec.decode("36px"), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("28px"), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("58px"), }, new RowSpec[] { RowSpec.decode("2px"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("14px"), RowSpec.decode("25px"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("14px"), RowSpec.decode("25px"), FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("14px"), RowSpec.decode("25px"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, RowSpec.decode("64dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, RowSpec.decode("max(64dlu;default)"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, RowSpec.decode("25px"), FormSpecs.PARAGRAPH_GAP_ROWSPEC, RowSpec.decode("24px"), RowSpec.decode("23px"), })); lbltitlelenght = new JLabel("(0/100)"); panel.add(lbltitlelenght, "14, 6, 3, 1, right, top"); txtTitle = new JTextField(); contextMenu.add(txtTitle); panel.add(txtTitle, "3, 7, 14, 1, fill, fill"); txtTitle.setColumns(10); txtTitle.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { calcNotifies(); } }); JLabel lblCategory = new JLabel(LANG.getString("frmMain.Category")); panel.add(lblCategory, "3, 9, 4, 1, left, bottom"); panel.add(cmbCategory, "3, 10, 14, 1, fill, fill"); JLabel lblDescription = new JLabel(LANG.getString("frmMain.Description")); panel.add(lblDescription, "3, 12, 4, 1, left, bottom"); lblDesclenght = new JLabel("(0/5000)"); panel.add(lblDesclenght, "14, 12, 3, 1, right, bottom"); JScrollPane DescriptionScrollPane = new JScrollPane(); panel.add(DescriptionScrollPane, "3, 13, 14, 1, fill, fill"); txtDescription = new JTextArea(); contextMenu.add(txtDescription); txtDescription.setFont(new Font("SansSerif", Font.PLAIN, 13)); DescriptionScrollPane.setViewportView(txtDescription); txtDescription.setWrapStyleWord(true); txtDescription.setLineWrap(true); txtDescription.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { calcNotifies(); } }); JLabel lblTags = new JLabel(LANG.getString("frmMain.Tags")); panel.add(lblTags, "3, 15, 4, 1, left, bottom"); lblTagslenght = new JLabel("(0/500)"); panel.add(lblTagslenght, "14, 15, 3, 1, right, top"); JScrollPane TagScrollPane = new JScrollPane(); panel.add(TagScrollPane, "3, 16, 14, 1, fill, fill"); txtTags = new JTextArea(); contextMenu.add(txtTags); txtTags.setFont(new Font("SansSerif", Font.PLAIN, 13)); TagScrollPane.setViewportView(txtTags); txtTags.setWrapStyleWord(true); txtTags.setLineWrap(true); txtTags.setBorder(BorderFactory.createEtchedBorder()); txtTags.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { calcNotifies(); } }); JLabel lblAccount = new JLabel(LANG.getString("frmMain.Account")); panel.add(lblAccount, "3, 18, 4, 1, left, bottom"); cmbAccount = new JComboBox<AccountType>(); panel.add(getCmbAccount(), "3, 19, 14, 1, fill, fill"); cmbAccount.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { changeUser(); } }); btnAddToQueue = new JButton(LANG.getString("frmMain.addtoQueue")); btnAddToQueue.setEnabled(false); panel.add(btnAddToQueue, "3, 21, 6, 1, fill, fill"); btnAddToQueue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { queueButton(); } }); JLabel lblSelectVideo = new JLabel(); panel.add(lblSelectVideo, "3, 3, 4, 1, left, bottom"); lblSelectVideo.setText(LANG.getString("frmMain.selectVideoFile")); cmbFile = new JComboBox<String>(); cmbFile.setDropTarget(new DropTarget() { private static final long serialVersionUID = 8809983794742040683L; public synchronized void drop(DropTargetDropEvent evt) { try { evt.acceptDrop(DnDConstants.ACTION_COPY); @SuppressWarnings("unchecked") List<File> droppedFiles = (List<File>) evt.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); for (File file : droppedFiles) { cmbFile.removeAllItems(); cmbFile.addItem(file.getAbsolutePath()); } } catch (Exception ex) { LOG.error("Error dropping video file", ex); } } }); panel.add(cmbFile, "3, 4, 14, 1, fill, fill"); JButton btnSelectMovie = new JButton(); btnSelectMovie.setToolTipText("Select Video File"); panel.add(btnSelectMovie, "18, 4, center, top"); btnSelectMovie.setIcon(new ImageIcon(getClass().getResource("/film_add.png"))); JLabel lblTitle = new JLabel(LANG.getString("frmMain.Title")); panel.add(lblTitle, "3, 6, 4, 1, left, bottom"); JButton btnReset = new JButton(LANG.getString("frmMain.Reset")); btnReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetEdit(); } }); panel.add(btnReset, "11, 21, 6, 1, fill, fill"); btnSelectMovie.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { EditPanel edit = (EditPanel) ss1.contentPane; NativeJFileChooser chooser; if (edit.getTxtStartDir() != null && !edit.getTxtStartDir().equals("")) { chooser = new NativeJFileChooser(edit.getTxtStartDir().getText().trim()); } else { chooser = new NativeJFileChooser(); } int returnVal = chooser.showOpenDialog((Component) self); if (returnVal == JFileChooser.APPROVE_OPTION) { cmbFile.removeAllItems(); cmbFile.addItem(chooser.getSelectedFile().getAbsolutePath().toString()); } } }); mainTab.setLayout(mainTabLayout); mainTab.revalidate(); mainTab.repaint(); TabbedPane.addTab(LANG.getString("frmMain.Tabs.VideoSettings"), mainTab); }
From source file:app.RunApp.java
/** * Create Chart// ww w .j ava2 s . c o m * * @param jpanel Panel * @param type Chart type * @param titleX Title for X axis * @param titleY Title for Y axis * @param showXAxis Indicates if shows X axis * @param chartTitle Chart title * @return ChartPanel with the generated chart */ private ChartPanel createJChart(JPanel jpanel, String type, String titleX, String titleY, boolean showXAxis, String chartTitle) { DefaultCategoryDataset myData = new DefaultCategoryDataset(); JFreeChart chart1; CategoryPlot plot1; LineAndShapeRenderer lineandshaperenderer; //hide horizontal axis switch (type) { case "bar": chart1 = ChartFactory.createBarChart(chartTitle, titleY, titleX, myData, PlotOrientation.VERTICAL, false, true, false); plot1 = chart1.getCategoryPlot(); //Custom tooltips BarRenderer renderer = (BarRenderer) plot1.getRenderer(); switch (chartTitle.toLowerCase()) { case "label frequency": renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0} = {2}", NumberFormat.getInstance())); break; case "labelset frequency": renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0} = {2}", NumberFormat.getInstance())); break; case "labels histogram": renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator( "Instances with {1} labels = {2}", NumberFormat.getInstance())); break; case "ir inter class": renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0} = {2}", NumberFormat.getInstance())); break; case "ir intra class": renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0} = {2}", NumberFormat.getInstance())); break; case "ir per labelset": renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("ID: {0} = {2}", NumberFormat.getInstance())); break; default: renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); break; } plot1.setBackgroundAlpha(0); plot1.setRangeGridlinePaint(Color.black); break; case "line_2_axis": chart1 = ChartFactory.createLineChart(" ", titleX, titleY, myData, PlotOrientation.VERTICAL, false, true, false); plot1 = chart1.getCategoryPlot(); plot1.setRangeGridlinePaint(Color.black); //show little rectangles lineandshaperenderer = (LineAndShapeRenderer) plot1.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); CategoryAxis domainAxis = plot1.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); ValueAxis axis2 = new NumberAxis("# Labels"); plot1.setRangeAxis(1, axis2); plot1.mapDatasetToRangeAxis(1, 1); LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); plot1.setRenderer(1, renderer2); break; default: //type == "line") chart1 = ChartFactory.createLineChart(" ", titleX, titleY, myData, PlotOrientation.VERTICAL, false, true, false); plot1 = chart1.getCategoryPlot(); plot1.setRangeGridlinePaint(Color.black); //show little rectangles lineandshaperenderer = (LineAndShapeRenderer) plot1.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); break; } //Hide X axis plot1.getDomainAxis().setTickLabelsVisible(showXAxis); ChartPanel cp1 = new ChartPanel(chart1); cp1.setSize(new Dimension(450, 300)); cp1.setBounds(260, 100, 450, 300); cp1.setPreferredSize(new Dimension(450, 300)); cp1.repaint(); jpanel.setBounds(260, 100, 450, 300); jpanel.setLayout(new BorderLayout()); jpanel.add(cp1, BorderLayout.CENTER); jpanel.repaint(); jpanel.validate(); return cp1; }
From source file:app.RunApp.java
/** * Create JGraphX chart//from w w w .j a va 2 s. c om * * @param jpanel Panel * @param list List * @param labelNames Names of labels * @param oldGraph Old graph * @return */ private mxGraphComponent createJGraphX(JPanel jpanel, ArrayList<AttributesPair> list, String[] labelNames, mxGraphComponent oldGraph) { mxGraph graph = new mxGraph(); Object parent = graph.getDefaultParent(); graph.getModel().beginUpdate(); graph.setLabelsClipped(true); Random rand = new Random(); Object[] corners = new Object[labelNames.length]; ImbalancedFeature current; double freq; int min = 0; int max = 1; int numIntervals = 10; int strength; try { //create vertices for (int i = 0; i < labelNames.length; i++) { current = DataInfoUtils.getLabelByLabelname(labelNames[i], labelsFreqSorted); freq = current.getAppearances() / (dataset.getNumInstances() * 1.0); strength = ChartUtils.getBorderStrength(min, max, numIntervals, freq); switch (strength) { case 1: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 6, 20); break; case 2: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "ROUNDED;strokeWidth=2"); break; case 3: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "ROUNDED;strokeWidth=3"); break; case 4: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "ROUNDED;strokeWidth=4"); break; case 5: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=5"); break; case 6: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=6"); break; case 7: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=7"); break; case 8: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=8"); break; case 9: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=9"); break; default: corners[i] = graph.insertVertex(parent, null, labelNames[i], rand.nextInt(430), rand.nextInt(280), labelNames[i].length() * 5, 20, "strokeWidth=10"); break; } } ArrayList<String> otherList; //create edges if (!list.isEmpty()) { AttributesPair temp; for (int i = 0; i < labelNames.length; i++) { otherList = ChartUtils.getVertices(labelNames[i], list); for (String actual : otherList) { int index = DataInfoUtils.getLabelIndex(labelNames, actual); temp = AttributePairsUtils.searchAndGet(labelNames[i], actual, list); freq = temp.getAppearances() / (dataset.getNumInstances() * 1.0); strength = ChartUtils.getBorderStrength(min, max, numIntervals, freq); switch (strength) { case 1: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=1"); break; case 2: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=2"); break; case 3: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=3"); break; case 4: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=4"); break; case 5: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=5"); break; case 6: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=6"); break; case 7: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=7"); break; case 8: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=8"); break; case 9: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=9"); break; default: graph.insertEdge(parent, null, "", corners[i], corners[index], "startArrow=none;endArrow=none;strokeWidth=3"); break; } } } } } finally { graph.getModel().endUpdate(); } if (oldGraph != null) { jpanel.remove(oldGraph); } graph.setCellsEditable(false); graph.setAllowDanglingEdges(false); mxGraphComponent graphComponent = new mxGraphComponent(graph); graphComponent.getGraph().getModel().endUpdate(); jpanel.setLayout(new BorderLayout()); jpanel.setPreferredSize(new Dimension(550, 425)); jpanel.add(graphComponent, BorderLayout.CENTER); jpanel.validate(); jpanel.repaint(); return graphComponent; }
From source file:nl.detoren.ijsco.ui.Mainscreen.java
public JPanel createDeelnemersPanel() { JPanel panel = new JPanel(false); panel.setBackground(Color.BLACK); //panel.setLayout(new GridLayout(1, 0)); panel.setLayout(new BorderLayout()); JPanel innerPanel = new JPanel(); JLabel lbAanwezig = new JLabel("Deelnemers: "); innerPanel.add(lbAanwezig, BorderLayout.NORTH); tfAanwezig = new JLabel(Integer.toString(status.deelnemers.aantalAanwezig()), 10); innerPanel.add(tfAanwezig, BorderLayout.NORTH); //innerPanel.setLayout(new GridLayout(1, 0)); innerPanel.add(new JLabel("Naam:"), BorderLayout.NORTH); JTextField deelnemer = new JTextField(15); ArrayList<String> words = new ArrayList<>(); if (status.OSBOSpelers != null) { for (Speler s : status.OSBOSpelers.values()) { words.add(s.getNaam().trim()); words.add(Integer.toString(s.getKnsbnummer())); }/*from w ww . j a v a 2 s.co m*/ } @SuppressWarnings("unused") Suggesties suggesties = new Suggesties(deelnemer, this, words, 2); innerPanel.add(deelnemer, BorderLayout.NORTH); deelnemer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); JButton btVoegToe = new JButton("Voeg toe"); btVoegToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); innerPanel.add(btVoegToe); panel.add(innerPanel); // panel_deelnemers.add(new JLabel("Deelnemers IJSCO toernooi")); deelnemersModel = new DeelnemersModel(panel, status.deelnemers); JTable deelnemersTabel = new JTable(deelnemersModel) { private static final long serialVersionUID = -8293073016982337108L; @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); DeelnemersModel model = (DeelnemersModel) getModel(); // Tooltip if (c instanceof JComponent) { ((JComponent) c) .setToolTipText(model.getToolTip(convertRowIndexToModel(row), column).toString()); } // Alternate row color if (!isRowSelected(row)) { c.setBackground(row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY); } // Highlight overruled entries if (status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam() || status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam()) { c.setForeground(Color.BLUE); } else { c.setForeground(Color.BLACK); } return c; } }; deelnemersTabel.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { status.groepen = null; status.schemas = null; status.schema = null; groepenText.setText(""); schemaModel.setSchemas(null); schemaModel.fireTableDataChanged(); if (status.deelnemers != null && tfAanwezig != null) { tfAanwezig.setText(Integer.toString(status.deelnemers.aantalAanwezig())); } panel.repaint(); } }); deelnemersTabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { logger.log(Level.INFO, "MouseEvent on table fired, type : " + e.toString()); logger.log(Level.INFO, "Popup trigger? : " + e.isPopupTrigger()); if (e.isPopupTrigger()) { int row = deelnemersTabel.rowAtPoint(e.getPoint()); JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Bewerk speler"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Bewerk Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); BewerkSpelerDialoog rd = new BewerkSpelerDialoog(new JFrame(), "Bewerk Speler", s, deelnemersModel); rd.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { System.out.println("closing..."); } }); rd.setVisible(true); } }); popup.add(menuItem); menuItem = new JMenuItem("Verwijder Speler"); popup.add(menuItem); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Verwijder Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); status.deelnemers.remove(s); deelnemersModel.fireTableDataChanged(); } }); popup.show(e.getComponent(), e.getX(), e.getY()); } } }); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(deelnemersTabel); innerPanel.add(scrollPane, BorderLayout.CENTER); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(deelnemersModel); deelnemersTabel.setRowSorter(sorter); innerPanel.add(new JLabel("Filter op : ")); JTextField tfFilter = new JTextField(10); tfFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(tfFilter); JButton btPasToe = new JButton("Apply"); btPasToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(btPasToe); JButton btWis = new JButton("Wis"); btWis.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { tfFilter.setText(""); logger.log(Level.INFO, "Wis filter"); sorter.setRowFilter(null); } }); innerPanel.add(btWis); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(0), 30); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(1), 55); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(2), 170); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(3), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(4), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(5), 30); Utils.fixedComponentSize(scrollPane, 400, 580); return panel; }
From source file:org.apereo.learninganalytics.snapp.ClusteringDemo.java
private void setUpView(Graph<Integer, Number> grp, Map<Integer, String> name) { /*/*from ww w . jav a2 s .c om*/ Factory<Number> vertexFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; Factory<Number> edgeFactory = new Factory<Number>() { int n = 0; public Number create() { return n++; } }; PajekNetReader<Graph<Number, Number>, Number,Number> pnr = new PajekNetReader<Graph<Number, Number>, Number,Number>(vertexFactory, edgeFactory); final Graph<Number,Number> graph = new SparseMultigraph<Number, Number>(); pnr.load(br, graph); */ //Create a simple layout frame //specify the Fruchterman-Rheingold layout algorithm this.usernames = name; final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>( new FRLayout<Integer, Number>(grp)); layout.setSize(new Dimension(500, 500)); vv = new VisualizationViewer<Integer, Number>(layout); vv.setBackground(Color.white); //Tell the renderer to use our own customized color rendering vv.getRenderContext() .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints)); vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() { public Paint transform(Integer v) { if (vv.getPickedVertexState().isPicked(v)) { return Color.cyan; } else { return Color.BLACK; } } }); vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints)); vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() { protected final Stroke THIN = new BasicStroke(1); protected final Stroke THICK = new BasicStroke(2); public Stroke transform(Number e) { Paint c = edgePaints.get(e); if (c == Color.LIGHT_GRAY) return THIN; else return THICK; } }); vv.getRenderContext().setVertexLabelTransformer( // this chains together Transformers so that the html tags // are prepended to the toString method output new ChainedTransformer<Integer, String>( new Transformer[] { new ToStringLabeller<String>(), new Transformer<String, String>() { public String transform(String input) { return usernames.get(Integer.parseInt(input)); } } })); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); /* //add restart button JButton scramble = new JButton("Restart"); scramble.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Layout layout = vv.getGraphLayout(); layout.initialize(); Relaxer relaxer = vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop(); relaxer.prerelax(); relaxer.relax(); } } }); */ DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); vv.setGraphMouse(gm); final JToggleButton groupVertices = new JToggleButton("Group Clusters"); //Create slider to adjust the number of edges to remove when clustering final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL); edgeBetweennessSlider.setBackground(Color.WHITE); edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50)); edgeBetweennessSlider.setPaintTicks(true); edgeBetweennessSlider.setMaximum(grp.getEdgeCount()); edgeBetweennessSlider.setMinimum(0); edgeBetweennessSlider.setValue(0); edgeBetweennessSlider.setMajorTickSpacing(10); edgeBetweennessSlider.setPaintLabels(true); edgeBetweennessSlider.setPaintTicks(true); // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black)); //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):")); //I also want the slider value to appear final JPanel eastControls = new JPanel(); eastControls.setOpaque(true); eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS)); eastControls.add(Box.createVerticalGlue()); eastControls.add(edgeBetweennessSlider); final String COMMANDSTRING = "Edges removed for clusters: "; final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue(); final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize); eastControls.setBorder(sliderBorder); //eastControls.add(eastSize); eastControls.add(Box.createVerticalGlue()); groupVertices.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors, e.getStateChange() == ItemEvent.SELECTED); vv.repaint(); } }); clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected()); edgeBetweennessSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int numEdgesToRemove = source.getValue(); clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected()); sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue()); eastControls.repaint(); vv.validate(); vv.repaint(); } } }); // Add a restart button so the graph can be redrawn to fit the size of the frame JFrame jf = new JFrame("SNAPP: Find Clusters"); //jf.getContentPane().add(); //Container content = getContentPane(); //content.add(new GraphZoomScrollPane(vv)); jf.getContentPane().add(new GraphZoomScrollPane(vv)); JPanel south = new JPanel(); JPanel grid = new JPanel(new GridLayout(2, 1)); //grid.add(scramble); grid.add(groupVertices); south.add(grid); south.add(eastControls); JPanel p = new JPanel(); p.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); p.add(gm.getModeComboBox()); south.add(p); //content.add(south, BorderLayout.SOUTH); jf.getContentPane().add(south, BorderLayout.SOUTH); //jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }
From source file:org.asciidoc.intellij.editor.AsciiDocPreviewEditor.java
@Contract("_, null, null -> fail") @NotNull// w w w . j a v a 2 s .c o m private static AsciiDocHtmlPanel detachOldPanelAndCreateAndAttachNewOne(Document document, Path imagesDir, @NotNull JPanel panelWrapper, @Nullable AsciiDocHtmlPanel oldPanel, @Nullable AsciiDocHtmlPanelProvider newPanelProvider) { ApplicationManager.getApplication().assertIsDispatchThread(); if (oldPanel == null && newPanelProvider == null) { throw new IllegalArgumentException("Either create new one or leave the old"); } if (newPanelProvider == null) { return oldPanel; } if (oldPanel != null) { panelWrapper.remove(oldPanel.getComponent()); Disposer.dispose(oldPanel); } final AsciiDocHtmlPanel newPanel = newPanelProvider.createHtmlPanel(document, imagesDir); if (oldPanel != null) { newPanel.setEditor(oldPanel.getEditor()); } panelWrapper.add(newPanel.getComponent(), BorderLayout.CENTER); panelWrapper.repaint(); return newPanel; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
private JPanel creerJournalMoisPanel(final Date date, long debit, long credit, final Journal jrnl) { final JPanel panelMoisCompte = new JPanel(); panelMoisCompte.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;/*from w w w.j av a 2s . c o m*/ c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; panelMoisCompte.setBorder(BorderFactory.createTitledBorder(dateFormat.format(date))); // Date du mois panelMoisCompte.add(new JLabel(dateFormat.format(date)), c); // Totaux du mois c.gridx++; panelMoisCompte.add(new JLabel(" dbit : " + GestionDevise.currencyToString(debit)), c); c.gridx++; panelMoisCompte.add(new JLabel(" crdit : " + GestionDevise.currencyToString(credit)), c); // Bouton dtails JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.LEFT); c.weightx = 0; c.gridx++; panelMoisCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private ListPanelEcritures listEcriture; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { final SQLElement element = Configuration.getInstance().getDirectory().getElement("ECRITURE"); final SQLTable ecrTable = element.getTable(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); Date inf = cal.getTime(); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Date sup = cal.getTime(); System.out.println("Inf : " + inf + " Sup : " + sup); Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", jrnl.getId()); Where w2 = new Where(ecrTable.getField("DATE"), inf, sup); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecrTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } this.listEcriture = new ListPanelEcritures(element, w.and(w2)); this.listEcriture.setModificationVisible(false); this.listEcriture.setAjoutVisible(false); this.listEcriture.setSuppressionVisible(false); this.listEcriture.getListe().setSQLEditable(false); Dimension d; // Taille limite 200 maximum if (this.listEcriture.getListe().getPreferredSize().height > 200) { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, 200); } else { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, this.listEcriture.getListe().getPreferredSize().height + 30); } this.listEcriture.getListe().setPreferredSize(d); // c.gridy = 2; c.gridx = 0; c.gridy = 1; c.gridwidth = 4; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; this.listEcriture.getListe().setSQLEditable(false); panelMoisCompte.add(this.listEcriture, c); this.listEcriture.getListe().getJTable().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { SQLRow row = base.getTable("ECRITURE") .getRow(listEcriture.getListe().getSelectedId()); MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT")); } }); menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } } }); } else { panelMoisCompte.remove(this.listEcriture); System.out.println("Hide ListEcriture"); panelMoisCompte.repaint(); panelMoisCompte.revalidate(); } this.isShow = !this.isShow; SwingUtilities.getRoot(panelMoisCompte).repaint(); } }); return panelMoisCompte; }
From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java
private JPanel creerComptePanel(final Compte compte) { final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = GridBagConstraints.RELATIVE; c.gridy = 0;//from ww w. j a va 2 s. co m c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; // Intitul du compte final JPanel panelCompte = new JPanel(); panelCompte.setOpaque(false); panelCompte.setLayout(new GridBagLayout()); panelCompte.setBorder(BorderFactory.createTitledBorder(compte.getNumero() + " " + compte.getNom())); // Bouton Dtails +/- du compte JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.RIGHT); // Total du Compte JLabel labelCompteDebit = new JLabel( "Total Debit : " + GestionDevise.currencyToString(compte.getTotalDebit())); JLabel labelCompteCredit = new JLabel( " Credit : " + GestionDevise.currencyToString(compte.getTotalCredit())); // labelCompte.setFont(new Font(labelCompte.getFont().getFontName(), Font.BOLD, 12)); labelCompteDebit.setHorizontalAlignment(SwingUtilities.LEFT); labelCompteCredit.setHorizontalAlignment(SwingUtilities.LEFT); JLabel labelTmp = new JLabel(compte.getNumero() + " " + compte.getNom()); labelTmp.setHorizontalAlignment(SwingUtilities.LEFT); panelCompte.add(labelTmp, c); panelCompte.add(labelCompteDebit, c); panelCompte.add(labelCompteCredit, c); c.weightx = 1; c.anchor = GridBagConstraints.NORTHEAST; panelCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private JScrollPane scroll = null; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { // if (this.scroll == null) { System.err.println(compte); JTable tableCpt = createJTableCompte(compte); this.scroll = new JScrollPane(tableCpt); // calcul de la taille du JScrollPane Dimension d; System.err.println(tableCpt); if (tableCpt.getPreferredSize().height > 200) { d = new Dimension(this.scroll.getPreferredSize().width, 200); } else { d = new Dimension(this.scroll.getPreferredSize().width, tableCpt.getPreferredSize().height + 30); } this.scroll.setPreferredSize(d); c.gridy++; c.gridwidth = 4; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; panelCompte.add(this.scroll, c); /* * } else { this.scroll.setVisible(true); } */ } else { // if (this.scroll != null) { panelCompte.remove(this.scroll); System.out.println("Hide scrollPane"); // this.scroll.setVisible(false); // this.scroll.repaint(); panelCompte.repaint(); panelCompte.revalidate(); // } } this.isShow = !this.isShow; SwingUtilities.getRoot(panelCompte).repaint(); } }); return panelCompte; }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private void refreshReferencePanel(JPanel p) throws SQLException, RemoteException { try {//from w w w. j a v a 2 s. c o m Reference[] references = MedSavantClient.ReferenceManager.getReferences(LoginController.getSessionID()); Annotation[] annotations = MedSavantClient.AnnotationManagerAdapter .getAnnotations(LoginController.getSessionID()); p.removeAll(); checkListItems.clear(); for (Reference r : references) { CheckListItem cli = new CheckListItem(r, annotations); checkListItems.add(cli); p.add(cli); } // By default, select the last check-box. It's either the one they just added, or hg19. if (checkListItems.size() > 0) { checkListItems.get(checkListItems.size() - 1).setSelected(true); } p.add(Box.createVerticalGlue()); p.updateUI(); p.repaint(); } catch (SessionExpiredException ex) { MedSavantExceptionHandler.handleSessionExpiredException(ex); return; } }