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:com.github.lucapino.sheetmaker.PreviewJFrame.java

public static void main(String[] args) {
    System.setProperty("awt.useSystemAAFontSettings", "on");
    System.setProperty("swing.aatext", "true");
    SwingUtilities.invokeLater(new Runnable() {

        @Override// www .j a  v  a 2s .c o m
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                File tmpFolder = new File("/tmp/images");
                tmpFolder.mkdir();

                String coverPath = tmpFolder.getAbsolutePath().replaceAll("\\\\", "/") + "/cover.jpg";
                String backdropPath = tmpFolder.getAbsolutePath().replaceAll("\\\\", "/") + "/backdrop.jpg";
                String fanart1Path = tmpFolder.getAbsolutePath().replaceAll("\\\\", "/") + "/fanart1.jpg";
                String fanart2Path = tmpFolder.getAbsolutePath().replaceAll("\\\\", "/") + "/fanart2.jpg";
                String fanart3Path = tmpFolder.getAbsolutePath().replaceAll("\\\\", "/") + "/fanart3.jpg";

                PreviewJFrame frame = new PreviewJFrame();
                logger.info("Creating parser...");
                InfoRetriever parser = new MediaInfoRetriever();
                MovieInfo movieInfo = parser.getMovieInfo("/media/tagliani/Elements/Film/JackRyan.mkv");
                logger.info("Retrieving movie file info...");
                logger.info("Creating dataretriever...");
                DataRetriever retriever = new DataRetrieverImpl();
                logger.info("Retrieving movie data...");
                Movie movie = retriever.retrieveMovieFromImdbID("tt1205537", "IT");
                logger.info("Retrieving backdrops and fanart...");
                List<Artwork> images = movie.getBackdrops();
                // background
                logger.info("Saving backdrop...");
                IOUtils.copyLarge(new URL(images.get(0).getImageURL()).openStream(),
                        new FileOutputStream(backdropPath));
                for (int i = 1; i < 4; i++) {
                    // fanart1
                    // fanart2
                    // fanart3
                    String imageURL = images.get(i).getImageURL();
                    logger.info("Saving fanart{}...", i);
                    IOUtils.copyLarge(new URL(imageURL).openStream(),
                            new FileOutputStream(tmpFolder.getAbsolutePath() + "/fanart" + i + ".jpg"));
                }
                // cover
                logger.info("Retrieving cover...");
                Artwork cover = movie.getPosters().get(0);
                String imageURL = cover.getImageURL();
                logger.info("Saving cover...");
                IOUtils.copyLarge(new URL(imageURL).openStream(), new FileOutputStream(coverPath));

                Map<String, String> tokenMap = TemplateFilter.createTokenMap(movie, movieInfo, null);

                logger.info("Creating renderer...");
                JavaTemplateRenderer renderer = new JavaTemplateRenderer();
                JPanel imagePanel = null;
                try {
                    logger.info("Rendering image...");
                    imagePanel = renderer.renderTemplate(
                            this.getClass().getResource("/templates/simplicity/template.xml"), tokenMap,
                            backdropPath, fanart1Path, fanart2Path, fanart3Path, coverPath);
                    logger.info("Adding image to frame...");
                    frame.add(imagePanel);

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
                imagePanel.setPreferredSize(new Dimension(imagePanel.getWidth(), imagePanel.getHeight()));
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                frame.setVisible(true);
                frame.pack();
                logger.info("Creating image for save...");
                BufferedImage imageTosave = ScreenImage.createImage(imagePanel);
                logger.info("Saving image...");
                ScreenImage.writeImage(imageTosave, "/tmp/images/final.png");
                logger.info("Image saved...");
            } catch (Exception ex) {
                logger.error("Error: ", ex);
            }
        }

    });

}

From source file:edu.sdsc.scigraph.services.jersey.writers.ImageWriter.java

private static BufferedImage renderImage(JPanel panel) {
    JFrame frame = new JFrame();
    frame.setUndecorated(true);//from ww w .ja v a 2  s. c  o m
    frame.getContentPane().add(panel);
    frame.pack();
    BufferedImage bi = new BufferedImage(panel.getWidth(), panel.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D graphics = bi.createGraphics();
    panel.print(graphics);
    graphics.dispose();
    frame.dispose();
    return bi;
}

From source file:eu.cassandra.csn.gui.CSN.java

/**
 * //from  www .  j a v  a 2 s  .com
 * @param graph
 * @return
 */
public static JPanel setUpView() {
    JPanel csnPanel = new JPanel();
    vv.getGraphLayout().setSize(new Dimension(csnPanel.getWidth(), csnPanel.getHeight()));
    setUpVV();
    GraphZoomScrollPane graphZoomScrollPane = new GraphZoomScrollPane(vv);
    JPanel thisPanel = new JPanel(new BorderLayout());
    thisPanel.add(graphZoomScrollPane, BorderLayout.CENTER);

    slider.setBackground(Color.WHITE);
    slider.setPreferredSize(new Dimension(210, 50));
    slider.setPaintTicks(true);
    slider.setMaximum(100);
    slider.setMinimum(0);
    slider.setValue(0);
    slider.setMajorTickSpacing(50);
    slider.setPaintLabels(true);
    slider.setPaintTicks(true);
    slider.setBorder(BorderFactory.createLineBorder(Color.black));
    slider.setEnabled(false);
    sliderLabel.setEnabled(false);
    slider.addMouseListener(new MouseListener() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (sliderLabel.getText().contains("oltage"))
                ClusterGraph.clusterAndRecolor(ClusterGraph.VoltageClusterer, slider.getValue());
            else if (sliderLabel.getText().contains("etweenness"))
                ClusterGraph.clusterAndRecolor(ClusterGraph.BetweennessClusterer, slider.getValue());
        }

        public void mouseClicked(MouseEvent arg0) {
        }

        public void mouseEntered(MouseEvent arg0) {
        }

        public void mouseExited(MouseEvent arg0) {
        }

        public void mousePressed(MouseEvent arg0) {
        }
    });
    JPanel p = new JPanel(new BorderLayout());
    p.add(sliderLabel, BorderLayout.PAGE_START);
    p.add(slider, BorderLayout.CENTER);

    sliderEdge.setBackground(Color.WHITE);
    sliderEdge.setPreferredSize(new Dimension(210, 50));
    sliderEdge.setPaintTicks(true);
    sliderEdge.setValue(0);
    sliderEdge.setMajorTickSpacing(5);
    sliderEdge.setPaintLabels(true);
    sliderEdge.setPaintTicks(true);
    sliderEdge.setBorder(BorderFactory.createLineBorder(Color.black));
    sliderEdge.setEnabled(false);
    sliderLabelEdge.setEnabled(false);
    sliderEdge.addMouseListener(new MouseListener() {
        @Override
        public void mouseReleased(MouseEvent e) {
            double v = Double
                    .parseDouble(((JLabel) sliderEdge.getLabelTable().get(sliderEdge.getValue())).getText());
            CSNGraph.addEdgesBasedOnKL(v);
        }

        public void mouseClicked(MouseEvent arg0) {
        }

        public void mouseEntered(MouseEvent arg0) {
        }

        public void mouseExited(MouseEvent arg0) {
        }

        public void mousePressed(MouseEvent arg0) {
        }
    });
    JPanel pEdge = new JPanel(new BorderLayout());
    pEdge.add(sliderLabelEdge, BorderLayout.PAGE_START);
    pEdge.add(sliderEdge, BorderLayout.CENTER);

    JPanel p2 = new JPanel(new BorderLayout());
    p2.add(pEdge, BorderLayout.PAGE_START);
    p2.add(p, BorderLayout.PAGE_END);

    thisPanel.add(p2, BorderLayout.PAGE_END);

    return thisPanel;
}

From source file:logica_controladores.controlador_estadistica.java

public static void grafica_reorden(JPanel panel_grafica_orden, Inventario inventario, JLabel lbLinea) {
    XYSeries serie_2 = null;/*from w  ww.jav  a 2  s  . c o m*/
    XYDataset datos;
    JFreeChart linea;

    serie_2 = new XYSeries("graficas relacion gastos-reorden");

    for (int i = 0; i < inventario.getGastos().size(); i++) {
        serie_2.add(inventario.getGastos().get(i).getReorden(), inventario.getGastos().get(i).getGastos());
    }
    datos = new XYSeriesCollection(serie_2);
    linea = ChartFactory.createXYLineChart("grafica representativa de reordenes por corrida", "punto de orden",
            "gastos", datos, PlotOrientation.VERTICAL, true, true, true);
    BufferedImage graficoLinea = linea.createBufferedImage(panel_grafica_orden.getWidth(),
            panel_grafica_orden.getHeight());
    lbLinea.setSize(panel_grafica_orden.getSize());
    lbLinea.setIcon(new ImageIcon(graficoLinea));
    panel_grafica_orden.updateUI();
}

From source file:probe.com.model.util.vaadintoimageutil.Convertor.java

public String converLayout(Layout vaadinComponent) {
    vaadinLevelMap.clear();/*from ww  w  .  j  av  a2 s  . c  o m*/
    jpanelLevelMap.clear();
    //        HashSet<Layout> rootset = new HashSet<Layout>();
    //        rootset.add(vaadinComponent);
    //        String classType = vaadinComponent.getClass().getName();
    //        vaadinLevelMap.put(0, rootset);
    //        if (classType.equalsIgnoreCase(Vertical_Layout)) {
    //            System.out.println("componentType " + vaadinComponent.getClass().getName() + "   -" + vaadinComponent.getStyleName() + "-");
    //            HashSet<JPanel> jPaneltset = new HashSet<JPanel>();
    //            JPanel comp = convertVerticalLayout((VerticalLayout) vaadinComponent);
    //            jPaneltset.add(comp);
    //            jpanelLevelMap.put(0, jPaneltset);
    //        }
    //        if (vaadinComponent.getComponentCount() > 0) {
    fillVaadinMap(0, vaadinComponent);
    //        }
    for (int k : jpanelLevelMap.keySet()) {
        for (JPanel parent : jpanelLevelMap.get(k)) {
            if (jpanelLevelMap.get(k + 1) != null) {
                for (JPanel child : jpanelLevelMap.get(k + 1)) {
                    insert(parent, child);
                }
            }

        }

        System.out.println(k + "  " + jpanelLevelMap.get(k).size());
    }

    JPanel root = jpanelLevelMap.get(0).iterator().next();
    String imgUrl = toImage(root.getWidth(), root.getHeight(), root);

    return imgUrl;
}

From source file:userinterface.graph.GUIImageExportDialog.java

/** Creates new form GUIConstantsPicker */
public GUIImageExportDialog(GUIPrism parent, JPanel graph, int defaultImageType) {
    super(parent, "Provide rendering information", true);

    this.exportWidth = graph.getWidth();
    this.exportHeight = graph.getHeight();

    initComponents();/*from   w  ww  .  java  2 s  .c o m*/

    this.getRootPane().setDefaultButton(okayButton);

    this.cancelled = false;

    this.warningLabel.setIcon(GUIPrism.getIconFromImage("smallError.png"));
    this.warningLabel.setVisible(false);

    this.widthInputField.getDocument().addDocumentListener(this);
    this.heightInputField.getDocument().addDocumentListener(this);

    this.widthInputField.setText("" + exportWidth);
    this.heightInputField.setText("" + exportHeight);

    this.imageTypeInputField.setSelectedIndex(defaultImageType);

    this.alphaInputField.setSelected(false);
    this.alphaInputField.setEnabled(defaultImageType == PNG);
    this.alphaInputLabel.setEnabled(defaultImageType == PNG);

    super.setBounds(new Rectangle(550, 300));
    setResizable(true);
    setLocationRelativeTo(getParent()); // centre

    this.setVisible(true);
}

From source file:se.backede.jeconomix.forms.budget.BudgetOutcomePanel.java

private void setChart(JPanel panel, BudgetOutcomeModel model, CategoryTypeEnum category) {
    JFreeChart barChart = ChartFactory.createBarChart(category.name() + " budget vs outcome", "", "",
            createDataset(model), PlotOrientation.HORIZONTAL, true, true, false);

    barChart.setTitle(new org.jfree.chart.title.TextTitle(
            WordUtils.capitalizeFully(category.name()) + " budget vs outcome",
            new java.awt.Font("Courier New", java.awt.Font.PLAIN, 12)));

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(panel.getWidth(), panel.getHeight()));
    panel.setLayout(new BorderLayout());
    panel.add(chartPanel, BorderLayout.NORTH);
}

From source file:gui.images.CodebookVectorProfilePanel.java

/**
 * Sets the data to be shown.//from w  ww .  j  ava2 s .c  o m
 *
 * @param occurrenceProfile Double array that is the neighbor occurrence
 * profile of this visual word.
 * @param codebookIndex Integer that is the index of this visual word.
 * @param classColors Color[] of class colors.
 * @param classNames String[] of class names.
 */
public void setResults(double[] occurrenceProfile, int codebookIndex, Color[] classColors,
        String[] classNames) {
    int numClasses = Math.min(classNames.length, occurrenceProfile.length);
    this.codebookIndex = codebookIndex;
    this.occurrenceProfile = occurrenceProfile;
    DefaultPieDataset pieData = new DefaultPieDataset();
    for (int cIndex = 0; cIndex < numClasses; cIndex++) {
        pieData.setValue(classNames[cIndex], occurrenceProfile[cIndex]);
    }
    JFreeChart chart = ChartFactory.createPieChart3D("codebook vect " + codebookIndex, pieData, true, true,
            false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    PieRenderer prend = new PieRenderer(classColors);
    prend.setColor(plot, pieData);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(140, 140));
    chartPanel.setVisible(true);
    chartPanel.revalidate();
    chartPanel.repaint();
    JPanel jp = new JPanel();
    jp.setPreferredSize(new Dimension(140, 140));
    jp.setMinimumSize(new Dimension(140, 140));
    jp.setMaximumSize(new Dimension(140, 140));
    jp.setSize(new Dimension(140, 140));
    jp.setLayout(new FlowLayout());
    jp.add(chartPanel);
    jp.setVisible(true);
    jp.validate();
    jp.repaint();

    JFrame frame = new JFrame();
    frame.setBackground(Color.WHITE);
    frame.setUndecorated(true);
    frame.getContentPane().add(jp);
    frame.pack();
    BufferedImage bi = new BufferedImage(jp.getWidth(), jp.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D graphics = bi.createGraphics();
    jp.print(graphics);
    graphics.dispose();
    frame.dispose();
    imPanel.removeAll();
    imPanel.setImage(bi);
    imPanel.setVisible(true);
    imPanel.revalidate();
    imPanel.repaint();
}

From source file:edu.harvard.mcz.imagecapture.ImageDisplayFrame.java

public void addWest(JPanel panel) {
    //      JScrollPane scroll = new JScrollPane(panel);
    //      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    //      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    //      jContentPane.add(scroll,BorderLayout.WEST);
    jContentPane.add(panel, BorderLayout.WEST);
    panel.setPreferredSize(new Dimension(594, panel.getHeight()));
    //      scroll.setPreferredSize(new Dimension(594,panel.getHeight()));
    this.pack();//  ww w . ja va  2  s.  c  o m
}

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);//from   w w  w  . j ava2  s.  c  o  m
    panel.add(panel2);
    return panel;
}