List of usage examples for javax.swing JPanel getWidth
@BeanProperty(bound = false) public int getWidth()
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel plotPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); String[] labels0 = { "S2C0 ", "S2C1 ", "PCIe Reads " }; String[] labels1 = { "C2S0 ", "C2S1 ", "PCIe Writes " }; dma0chart = new DMABarChart("Transmit (S2C) Performance", panel1.getBackground(), labels0); dma1chart = new DMABarChart("Receive (C2S) Performance", panel1.getBackground(), labels1); panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); panel1.setSize(new Dimension(panel1.getWidth() - 100, panel1.getHeight() - 100)); panel1.add(dma0chart.getChart("")); panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS)); panel2.setSize(new Dimension(panel2.getWidth() - 100, panel2.getHeight() - 100)); panel2.add(dma1chart.getChart("")); panel.add(panel1);/* w w w. ja v a2s . c o m*/ panel.add(panel2); return panel; }
From source file:gestionelectrica.VentanaEjemploGraf.java
private void rellenar(JPanel jp) { // Create a simple XY chart XYSeries series = new XYSeries("EC"); series.add(1, 1);/*from www . j a va 2 s . c o m*/ series.add(1, 2); series.add(2, 1); series.add(3, 9); series.add(4, 10); series.add(7, 15); series.add(10, 6); // Add the series to your data set XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart("Energa comprada", // Title "hora", // x-axis Label "KWh", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); JFreeChart pieChart = ChartFactory.createXYLineChart("EJEMPLOOOO", "Category", "Score", createDataset(), PlotOrientation.VERTICAL, true, true, false); System.out.println(System.getProperty("user.home")); System.out.println(System.getProperty("java.io.tmpdir")); System.out.println(System.getProperties()); File f = new File(System.getProperty("java.io.tmpdir") + "\\chart.jpg"); try { ChartUtilities.saveChartAsJPEG(f, chart, jp.getWidth(), jp.getHeight()); } catch (IOException e) { System.err.println("Problem occurred creating chart."); System.err.println(e.getMessage()); } // Adding chart into a chart panel //ChartPanel chartPanel = new ChartPanel(pieChart); // settind default size //chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // add to contentPane //setContentPane(chartPanel); //jPanel1.add(chartPanel); ImageIcon ic = new ImageIcon(f.getAbsolutePath()); ImagePanel panel = new ImagePanel(ic.getImage(), jp.getWidth(), jp.getHeight()); jp.add(panel); /*jPanel1.repaint(); jPanel1.updateUI(); jPanel1.validate();*/ if (f.delete()) System.out.println("BORRADO CORRECTAMENTE"); else System.err.println("NO SE PUDO BORRAR"); }
From source file:parts.GraphicContent.java
public void setContent(JPanel panel) { String sprint[] = null;//from w w w .j av a 2 s .c o m int taskCount[] = null; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select COUNT(*) from sprint"; result = st.executeQuery(sql); result.next(); sprint = new String[result.getInt(1)]; } catch (Exception e) { e.printStackTrace(); } try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select * from sprint"; result = st.executeQuery(sql); int i = 0; while (result.next()) { sprint[i] = result.getString("alias"); i++; } } catch (Exception e) { e.printStackTrace(); } int sprintIDs[] = new int[sprint.length]; try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select * from sprint"; result = st.executeQuery(sql); int i = 0; while (result.next()) { sprintIDs[i] = result.getInt("idsprint"); i++; } } catch (Exception e) { e.printStackTrace(); } for (int i = 0; i < sprint.length; i++) { try { Statement st = scrum.SCRUM.conexao.createStatement(); String sql = "select COUNT(*) from sprint_tasks where idsprint = " + sprintIDs[i]; result = st.executeQuery(sql); while (result.next()) { dataset.addValue(result.getInt(1), "Tarefas", sprint[i]); } } catch (Exception e) { e.printStackTrace(); } } JFreeChart chart = null; chart = ChartFactory.createBarChart("Quantidade de tarefas por Sprint", "Sprint", "Tarefas", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartPanel cp = new ChartPanel(chart); cp.setBounds(0, 0, panel.getWidth(), panel.getHeight()); panel.removeAll(); cp.setVisible(true); panel.add(cp); panel.revalidate(); panel.repaint(); }
From source file:com.xilinx.virtex7.MainScreen.java
private JPanel plotPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); String[] labels0 = { "S2C0 ", "S2C1 ", "S2C2 ", "S2C3 ", "PCIe Reads " }; String[] labels1 = { "C2S0 ", "C2S1 ", "C2S2 ", "C2S3 ", "PCIe Writes " }; dma0chart = new DMABarChart("Transmit (S2C) Performance", panel1.getBackground(), labels0); dma1chart = new DMABarChart("Receive (C2S) Performance", panel1.getBackground(), labels1); panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); panel1.setSize(new Dimension(panel1.getWidth() - 100, panel1.getHeight() - 100)); panel1.add(dma0chart.getChart("")); panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS)); panel2.setSize(new Dimension(panel2.getWidth() - 100, panel2.getHeight() - 100)); panel2.add(dma1chart.getChart("")); panel.add(panel1);//from w w w . j ava 2s . c o m panel.add(panel2); return panel; }
From source file:com.xilinx.ultrascale.gui.MainScreen.java
public JPanel createPanelForGraph(JPanel panel) { // dimensions Dimension dmsns = new Dimension(panel.getWidth(), panel.getHeight()); JPanel dmaStatsPanel = new JPanel(); dmaStatsPanel.setLayout(new BoxLayout(dmaStatsPanel, BoxLayout.Y_AXIS)); dmaStatsPanel.setSize(dmsns);/*from ww w. j a va 2s. c o m*/ return dmaStatsPanel; }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
/** * Draw a chart in a panel. Good for precursors and daughters * @param parentPanel/*w w w . j a v a 2s.c o m*/ * @param dataset * @param domainMin * @param domainMax * @param supplier * @param wg */ protected void createChartInPanel(JPanel parentPanel, XYSeriesCollection dataset, Double domainMin, Double domainMax, DrawingSupplier supplier, whichGraph wg) { if (precursorChromatogramEmpty(transitionOnPlot) && wg == whichGraph.Precursor) { precursorContainerContainerPanel.setVisible(false); if (this.getWidth() >= 100 && this.getHeight() >= 100) this.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); pack(); return; } switch (wg) { case Precursor: clearPreviousChartJunk(oldPrecursorChart); oldPrecursorChart = null; break; case Daughter: clearPreviousChartJunk(oldProductChart); oldProductChart = null; break; } JFreeChart chart = ChartFactory.createXYLineChart(null, "seconds", null, dataset, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(new Color(220, 220, 220)); XYPlot xyp = (XYPlot) (chart.getPlot()); xyp.setBackgroundPaint(Color.WHITE); xyp.setDomainGridlinesVisible(true); xyp.setRangeGridlinesVisible(true); xyp.setDomainGridlinePaint(Color.LIGHT_GRAY); xyp.setRangeGridlinePaint(Color.LIGHT_GRAY); if (supplier != null) { xyp.setDrawingSupplier(supplier); } else { xyp.setDrawingSupplier(Utils.plainDrawingSupplier(Color.LIGHT_GRAY)); } xyp.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); CenterZoomNumberAxis axisDomain = new CenterZoomNumberAxis("seconds"); axisDomain.setAutoRangeIncludesZero(false); axisDomain.setRange(Math.max(0.0, domainMin), domainMax); axisDomain.addChangeListener(new domainAxisZoomCoordinator(axisDomain)); xyp.clearAnnotations(); xyp.setDomainAxis(axisDomain); xyp.getDomainAxis().setAutoRange(false); xyp.getRangeAxis().setAutoRange(false); XYLineAndShapeRenderer xylsr = (XYLineAndShapeRenderer) xyp.getRenderer(); xylsr.setLegendLine(Utils.legendThing(16, 6)); xylsr.setShapesFilled(true); xylsr.setBaseShapesFilled(true); PanelWithChart panelWithChart = new PanelWithChart(chart); ChartPanel cp = panelWithChart.getChartPanel(); cp.removeMouseListener(cp); cp.removeMouseMotionListener(cp); if (peaksTable != null) { MRMerMouseListener mml = new MRMerMouseListener(cp, (PeaksTableModel) peaksTable.getModel()); cp.addMouseListener(mml); cp.addMouseMotionListener(mml); } cp.setPreferredSize(new Dimension(parentPanel.getWidth(), parentPanel.getHeight() - 10)); cp.setDomainZoomable(true); cp.setRangeZoomable(false); cp.setPopupMenu(null); parentPanel.removeAll(); parentPanel.add(panelWithChart); switch (wg) { case Precursor: createChartInPanelPrecursorTasksOnly(xyp); oldPrecursorChart = xyp; break; case Daughter: createChartInPanelDaughterTasksOnly(xyp); oldProductChart = xyp; break; } parentPanel.updateUI(); listTransition.requestFocus(); }
From source file:com.xilinx.kintex7.MainScreen.java
private JPanel pciInfo() { JPanel pciSystemPanel = new JPanel(); pciSystemPanel.setLayout(new BoxLayout(pciSystemPanel, BoxLayout.Y_AXIS)); JPanel topPanel = new JPanel(new GridLayout(1, 2)); topPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("PCIe Settings"), BorderFactory.createRaisedBevelBorder())); JPanel sPanel = new JPanel(new FlowLayout()); sPanel.add(new JLabel("Link Speed: ")); Object[] speeds = { "2.5 Gbps", "5.0 Gbps" }; final PartialDisableComboBox lspeed = new PartialDisableComboBox(); lspeed.addItems(speeds);/*from w w w. ja va2 s .c om*/ lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed - 1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed - 1, false); sPanel.add(lspeed); JButton setSpeed = new JButton("Go"); setSpeed.setToolTipText("This enables directed PCIe link speed change"); setSpeed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (lspeed.isItemEnabled(lspeed.getSelectedIndex())) { int ret = di.setLinkSpeed(lspeed.getSelectedIndex() + 1); if (ret == 0) { //update pcie information di.get_PCIstate(); lspeed.setItemEnabled(0, true); lspeed.setItemEnabled(1, true); lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed - 1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed - 1, false); ptable.setData(di.getPCIInfo().getPCIData(), pcieColumnNames); ptable.fireTableDataChanged(); } else { updateLog("Unable to set Link Speed " + lspeed.getSelectedItem(), keyWord); } } } }); sPanel.add(setSpeed); topPanel.add(sPanel); JPanel sPanel1 = new JPanel(new FlowLayout()); sPanel1.add(new JLabel("Link Width: ")); Object[] widths = { "x1", "x2", "x4", "x8" }; final PartialDisableComboBox lwidths = new PartialDisableComboBox(); lwidths.addItems(widths); lwidths.setSelectedItem("x" + di.getPCIInfo().LinkWidth); lwidths.setItemEnabled(lwidths.getSelectedIndex(), false); sPanel1.add(lwidths); JButton setWidth = new JButton("Go"); setWidth.setToolTipText("This enables directed PCIe link width change"); setWidth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (lwidths.isItemEnabled(lwidths.getSelectedIndex())) { int ret = di.setLinkWidth(lwidths.getSelectedIndex() + 1); if (ret == 0) { //update pcie information // some times width change affect link speed so // enable the same in lspeedd also di.get_PCIstate(); lwidths.setItemEnabled(0, true); lwidths.setItemEnabled(1, true); lwidths.setItemEnabled(2, true); lwidths.setItemEnabled(3, true); lwidths.setSelectedItem("x" + di.getPCIInfo().LinkWidth); lwidths.setItemEnabled(lwidths.getSelectedIndex(), false); // some times width change affect link speed so // enable the same in lspeed also lspeed.setItemEnabled(0, true); lspeed.setItemEnabled(1, true); lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed - 1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed - 1, false); ptable.setData(di.getPCIInfo().getPCIData(), pcieColumnNames); ptable.fireTableDataChanged(); } else { di.get_PCIstate(); int upCap = di.getPCIInfo().LinkUpCap; if (upCap == 0) updateLog("Unable to set Link Width " + lwidths.getSelectedItem() + ". PCIe link not upconfigurable", keyWord); else updateLog("Unable to set Link Width " + lwidths.getSelectedItem(), keyWord); } } } }); sPanel1.add(setWidth); topPanel.add(sPanel1); pciSystemPanel.add(topPanel); JPanel panel = new JPanel(new GridLayout(1, 2)); JPanel pciPanel = new JPanel(new BorderLayout()); pciPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("PCIe Endpoint Status"), BorderFactory.createRaisedBevelBorder())); ptable = new MyTableModel(di.getPCIInfo().getPCIData(), pcieColumnNames); pcieTable = new JTable(ptable); try { pcieTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader pcieHeader = pcieTable.getTableHeader(); pcieHeader.setForeground(new Color(92, 25, 25)); pciPanel.add(pcieHeader, BorderLayout.PAGE_START); pciPanel.add(pcieTable, BorderLayout.CENTER); panel.add(pciPanel); JPanel hostPanel = new JPanel(new BorderLayout()); hostPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Host System's Initial Credits"), BorderFactory.createRaisedBevelBorder())); htable = new MyTableModel(di.getPCIInfo().getHostedData(), pcieColumnNames); hostTable = new JTable(htable); try { hostTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader hostHeader = hostTable.getTableHeader(); hostHeader.setForeground(new Color(92, 25, 25)); hostPanel.add(hostHeader, BorderLayout.PAGE_START); hostPanel.add(hostTable, BorderLayout.CENTER); panel.add(hostPanel); pciSystemPanel.add(panel); pciSystemPanel.add(dialChart(pciSystemPanel.getWidth())); return pciSystemPanel; }
From source file:com.xilinx.virtex7.MainScreen.java
private JPanel pciInfo() { JPanel pciSystemPanel = new JPanel(); pciSystemPanel.setLayout(new BoxLayout(pciSystemPanel, BoxLayout.Y_AXIS)); //pciSystemPanel.setLayout(new GridLayout(2, 1)); JPanel topPanel = new JPanel(new GridLayout(1, 2)); topPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("PCIe Settings"), BorderFactory.createRaisedBevelBorder())); /*JPanel sPanel = new JPanel(new FlowLayout()); sPanel.add(new JLabel("Link Speed: ")); Object[] speeds = {"2.5 Gbps","5.0 Gbps"}; final PartialDisableComboBox lspeed = new PartialDisableComboBox(); lspeed.addItems(speeds);// w ww .ja v a2 s . co m // hack for safe exit if (di.getPCIInfo().LinkSpeed != 0 && di.getPCIInfo().LinkSpeed-1 < speeds.length){ lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed-1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed-1, false); }else{ if (di.getPCIInfo().LinkSpeed == 4){ System.out.println(di.getPCIInfo().LinkSpeed-2); // lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed-2); // lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed-2, false); }else updateLog("Invalid Link Speed", keyWord); } sPanel.add(lspeed); JButton setSpeed = new JButton("Go"); setSpeed.setToolTipText("This enables directed PCIe link speed change"); setSpeed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (lspeed.isItemEnabled(lspeed.getSelectedIndex())) { int ret = 0; if (lspeed.getSelectedIndex() == 2) ret = di.setLinkSpeed(lspeed.getSelectedIndex()+2); else ret = di.setLinkSpeed(lspeed.getSelectedIndex()+1); if (ret == 0){ //update pcie information di.get_PCIstate(); lspeed.setItemEnabled(0, true); lspeed.setItemEnabled(1, true); lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed-1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed-1, false); ptable.setData(di.getPCIInfo().getPCIData(), pcieColumnNames); ptable.fireTableDataChanged(); } else{ updateLog("Unable to set Link Speed "+lspeed.getSelectedItem(), keyWord); } } } }); sPanel.add(setSpeed); // topPanel.add(sPanel); JPanel sPanel1 = new JPanel(new FlowLayout()); sPanel1.add(new JLabel("Link Width: ")); Object[] widths = {"x1","x2","x4","x8"}; final PartialDisableComboBox lwidths = new PartialDisableComboBox(); lwidths.addItems(widths); lwidths.setSelectedItem("x"+di.getPCIInfo().LinkWidth); lwidths.setItemEnabled(lwidths.getSelectedIndex(), false); sPanel1.add(lwidths); JButton setWidth = new JButton("Go"); setWidth.setToolTipText("This enables directed PCIe link width change"); setWidth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (lwidths.isItemEnabled(lwidths.getSelectedIndex())) { int ret = di.setLinkWidth(lwidths.getSelectedIndex()+1); if (ret == 0){ //update pcie information // some times width change affect link speed so // enable the same in lspeedd also di.get_PCIstate(); lwidths.setItemEnabled(0, true); lwidths.setItemEnabled(1, true); lwidths.setItemEnabled(2, true); lwidths.setItemEnabled(3, true); lwidths.setSelectedItem("x"+di.getPCIInfo().LinkWidth); lwidths.setItemEnabled(lwidths.getSelectedIndex(), false); // some times width change affect link speed so // enable the same in lspeed also lspeed.setItemEnabled(0, true); lspeed.setItemEnabled(1, true); lspeed.setSelectedIndex(di.getPCIInfo().LinkSpeed-1); lspeed.setItemEnabled(di.getPCIInfo().LinkSpeed-1, false); ptable.setData(di.getPCIInfo().getPCIData(), pcieColumnNames); ptable.fireTableDataChanged(); }else { di.get_PCIstate(); int upCap = di.getPCIInfo().LinkUpCap; if (upCap == 0) updateLog("Unable to set Link Width "+lwidths.getSelectedItem()+". PCIe link not upconfigurable", keyWord); else updateLog("Unable to set Link Width "+lwidths.getSelectedItem(), keyWord); } } } }); sPanel1.add(setWidth); // topPanel.add(sPanel1); */ // pciSystemPanel.add(topPanel); JPanel panel = new JPanel(new GridLayout(1, 2)); JPanel pciPanel = new JPanel(new BorderLayout()); pciPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("PCIe Endpoint Status"), BorderFactory.createRaisedBevelBorder())); ptable = new MyTableModel(di.getPCIInfo().getPCIData(), pcieColumnNames); pcieTable = new JTable(ptable); try { pcieTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader pcieHeader = pcieTable.getTableHeader(); pcieHeader.setForeground(new Color(92, 25, 25)); pciPanel.add(pcieHeader, BorderLayout.PAGE_START); pciPanel.add(pcieTable, BorderLayout.CENTER); panel.add(pciPanel); JPanel hostPanel = new JPanel(new BorderLayout()); hostPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Host System's Initial Credits"), BorderFactory.createRaisedBevelBorder())); htable = new MyTableModel(di.getPCIInfo().getHostedData(), pcieColumnNames); hostTable = new JTable(htable); try { hostTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer()); } catch (Exception e) { } JTableHeader hostHeader = hostTable.getTableHeader(); hostHeader.setForeground(new Color(92, 25, 25)); hostPanel.add(hostHeader, BorderLayout.PAGE_START); hostPanel.add(hostTable, BorderLayout.CENTER); panel.add(hostPanel); pciSystemPanel.add(panel); pciSystemPanel.add(dialChart(pciSystemPanel.getWidth())); return pciSystemPanel; }
From source file:ueg.watchdog.util.ImageUtils.java
/** * Method to get resized buffered image when user passes the relevant frame and video panel. * * @param frame/* ww w . ja v a 2 s . c om*/ * @param videoPanel * @return */ public static BufferedImage getResizedBufferedImage(Frame frame, JPanel videoPanel) { BufferedImage resizedImage = null; try { /* * We get notified about the frames that are being added. Then we pass each frame to BufferedImage. I have used * a library called Thumbnailator to achieve the resizing effect along with performance */ resizedImage = Thumbnails.of(frameConverter.getBufferedImage(frame)) .size(videoPanel.getWidth(), videoPanel.getHeight()).asBufferedImage(); } catch (IOException e) { logger.error("Unable to convert the image to a buffered image", e); } return resizedImage; }