Example usage for javax.swing JPanel getHeight

List of usage examples for javax.swing JPanel getHeight

Introduction

In this page you can find the example usage for javax.swing JPanel getHeight.

Prototype

@BeanProperty(bound = false)
public int getHeight() 

Source Link

Document

Returns the current height of this component.

Usage

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);/* w  w  w  .j  a v  a2s .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;/* w w w .  j  a  v  a  2s  .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   www  .  j  a  v  a2 s . 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);/*  ww  w.j a  v  a2s.  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/*from  w  w  w .  ja va  2  s .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:ueg.watchdog.util.ImageUtils.java

/**
 * Method to get resized buffered image when user passes the relevant frame and video panel.
 *
 * @param frame/*from ww  w  . j  av a  2s.co m*/
 * @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;
}