List of usage examples for javax.swing JPanel setSize
public void setSize(Dimension d)
From source file:iad_zad3.gui.ChartWorker.java
private void updateVoronoi() { VoronoiPanel vPanel = new VoronoiPanel(); for (Pnt p : GUIHelper.getVoronoiPoints(clusteringAlgorithm)) { vPanel.addSite(p);/*from w ww . ja v a 2 s .co m*/ } JPanel tmpPanel = new JPanel(); tmpPanel.setSize(new Dimension(700, 700)); tmpPanel.setLayout(new BorderLayout()); voronoiPanel.add(tmpPanel, "Center"); tmpPanel.add(vPanel, "Center"); voronoiPanel.revalidate(); }
From source file:gui.images.CodebookVectorProfilePanel.java
/** * Sets the data to be shown.//w w w . j a va2 s .co 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:com.rapidminer.gui.plotter.PlotterPanel.java
@Override public Component getExportComponent() { JPanel outerPanel = new JPanel() { private static final long serialVersionUID = 7315234075649335574L; @Override/*from w ww . j a v a2s . c o m*/ public void paintComponent(Graphics g) { PlotterPanel.this.print(g); } }; outerPanel.setSize(getPlotterComponent().getSize()); return outerPanel; }
From source file:datavis.Gui.java
private void updateGraphs_lineGraph(DataList dataset, boolean load) { String sItem = "default"; if (load) {/*w w w . j av a2 s. c o m*/ sItem = "default"; } else { sItem = jComboBox3.getSelectedItem().toString(); } sItem = sItem.replaceAll("\\s+", ""); sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : ""); jPanel3.removeAll(); jPanel3.revalidate(); JFreeChart chart = dataset.getBarGraphChart(sItem); chart.removeLegend(); javax.swing.JPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(jPanel3.getSize()); jPanel3.add(chartPanel); jPanel3.repaint(); }
From source file:datavis.Gui.java
private void updateGraphs_barGraph(DataList dataset, boolean load) { String sItem = "default"; if (load) {//from w w w. j a v a 2s. c o m sItem = "default"; } else { sItem = jComboBox2.getSelectedItem().toString(); } sItem = sItem.replaceAll("\\s+", ""); sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : ""); jPanel2.removeAll(); jPanel2.revalidate(); JFreeChart chart = dataset.getLineGraphChart(sItem); chart.removeLegend(); javax.swing.JPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(jPanel2.getSize()); jPanel2.add(chartPanel); jPanel2.repaint(); }
From source file:datavis.Gui.java
private void updateGraphs_pieChart(DataList dataset, boolean load) { String sItem = "default"; //If you are initially loading the data.. if (load) {//ww w. j a v a 2 s . co m sItem = "default"; //Display the default chart } else { //otherwise, display the chart from the drop-down menu selection sItem = jComboBox1.getSelectedItem().toString(); } //modify the string to match what is needed //To select the proper graph sItem = sItem.replaceAll("\\s+", ""); sItem = Character.toLowerCase(sItem.charAt(0)) + (sItem.length() > 1 ? sItem.substring(1) : ""); //Reinit and Add chart to GUI jPanel1.removeAll(); jPanel1.revalidate(); JFreeChart chart = dataset.getPieChartChart(sItem); chart.removeLegend(); javax.swing.JPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(jPanel1.getSize()); jPanel1.add(chartPanel); jPanel1.repaint(); }
From source file:datavis.Gui.java
private void initGraphs(DataList dataset) { //Initialize the GUI with default, blank sample graphs //That serve as place holders for that actual content //Create Pie Chart PieChart samplePie = new PieChart("Sample Data"); samplePie.addData("Default Value", 1.0); JFreeChart chart = samplePie.getChartPanel(); //Add chart to GUI javax.swing.JPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(jPanel1.getSize()); jPanel1.add(chartPanel);//from ww w . j av a 2 s . co m jPanel1.getParent().validate(); //Create Line graph DefaultCategoryDataset sampleLine = new DefaultCategoryDataset(); sampleLine.setValue(1.0, "sample Data", "Sample Data"); JFreeChart chart2 = ChartFactory.createLineChart("Sample Data", "Sample", "Sample", sampleLine); //Add chart to GUI javax.swing.JPanel chartPanel2 = new ChartPanel(chart2); chartPanel2.setSize(jPanel2.getSize()); jPanel2.add(chartPanel2); jPanel2.getParent().validate(); //Create bar graph DefaultCategoryDataset sampleBar = new DefaultCategoryDataset(); sampleLine.setValue(1.0, "sample Data", "Sample Data"); JFreeChart chart3 = ChartFactory.createBarChart("Sample Data", "Sample", "Sample", sampleBar); //Add chart to GUI javax.swing.JPanel chartPanel3 = new ChartPanel(chart3); chartPanel3.setSize(jPanel3.getSize()); jPanel3.add(chartPanel3); jPanel3.getParent().validate(); //Set the author information to the info box jTextArea2.setText(displayDevelopers); }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
public static void showError(final Component parent, String description, final Throwable e) { String s = ""; if (e instanceof IliasHTTPSException) { s = "<br><br>Die SSL Verbindung konnte nicht aufgebaut werden." + "<br>Sie benutzen Java Version " + System.getProperty("java.version") + "." + "<br>Fr einige SSL Verbindungen bentigen Sie <b>Java 1.8 oder hher.</b>" + "<br>Sie knnen Java hier herunterladen: http://java.com" + "<br><br>Alternativ knnen Sie in den Einstellungen beim Serverpfad https:// durch http:// ersetzen." + "<br><b>Das wird aber NICHT empfohlen, da Ihr Loginname und Ihr Passwort ungeschtzt bertragen werden.</b>"; }/*from www. j a v a2s .c om*/ description = description + s; JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); panel.add(new JLabel("<html>" + description + "</html>")); JButton b = new JButton("Details"); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { final JTextArea textarea = new JTextArea(); val c = new CircularStream(); Thread t = new Thread(new Runnable() { @Override public void run() { e.printStackTrace(new PrintStream(c.getOutputStream())); IOUtils.closeQuietly(c.getOutputStream()); } }); t.start(); try { textarea.append(IOUtils.toString(c.getInputStream())); } catch (IOException e1) { e1.printStackTrace(); } try { t.join(); } catch (InterruptedException e1) { e1.printStackTrace(); } JPanel p = new JPanel(new BorderLayout()); p.add(new JLabel(e.getMessage()), BorderLayout.NORTH); JScrollPane scrollpane = new JScrollPane(textarea); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); p.add(scrollpane, BorderLayout.CENTER); p.setMaximumSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); p.setPreferredSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); p.setSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); JOptionPane.showMessageDialog(parent, p, "Fehlerdetails", JOptionPane.ERROR_MESSAGE); } }); panel.add(b); JOptionPane.showMessageDialog(parent, panel, "Fehler", JOptionPane.ERROR_MESSAGE); }
From source file:com.moss.greenshell.wizard.ProcessPanel.java
private void transitionAnimated(final JPanel oldView, final JPanel newView, final Runnable followupAction, SlidingPanel.Mode direction) {//from w w w . j ava 2 s . c om final Dimension dimension = view.getActionArea().getSize(); final SlidingPanel slidingPanel = new SlidingPanel(); int gapBetweenViews = 100; synchronized (view.getActionArea()) { view.getActionArea().removeAll(); view.getActionArea().add(slidingPanel); } slidingPanel.setSize(dimension); slidingPanel.setLocation(0, 0); slidingPanel.setLayout(null); slidingPanel.add(oldView); slidingPanel.add(newView); oldView.setSize(dimension); oldView.setLocation(0, 0); if (direction.equals(SlidingPanel.Mode.HORIZONTAL_LEFT)) { newView.setSize(dimension); newView.setLocation(dimension.width + gapBetweenViews, 0); } else if (direction.equals(SlidingPanel.Mode.HORIZONTAL_RIGHT)) { newView.setSize(dimension); newView.setLocation(0 - dimension.width - gapBetweenViews, 0); } else if (direction.equals(SlidingPanel.Mode.VERTICAL_UP)) { newView.setSize(dimension); newView.setLocation(0, dimension.width + gapBetweenViews); } else if (direction.equals(SlidingPanel.Mode.VERTICAL_DOWN)) { newView.setSize(dimension); newView.setLocation(0, 0 - dimension.width - gapBetweenViews); } view.getActionArea().invalidate(); view.validate(); view.repaint(); slidingPanel.setMode(direction); slidingPanel.setTranslateMax(dimension.width + gapBetweenViews); slidingPanel.slide(new ActionListener() { public void actionPerformed(ActionEvent e) { transitionStatic(oldView, newView, followupAction); } }); }
From source file:com.polivoto.vistas.Charts.java
private JPanel hacerTabla(Pregunta pregunta, List<Opcion> opciones, String perfil) { Tabla panel = new Tabla(); //Panel completo //scrollPanel.setBackground(Color.blue); //Ttulo pregunta JLabel tituloPregunta = new JLabel("\t" + pregunta.getTitulo() + " (" + perfil + ")"); tituloPregunta.setFont(new Font("Roboto", 1, 24)); tituloPregunta.setForeground(Color.black); tituloPregunta.setVerticalAlignment(JLabel.CENTER); JPanel panelHeader = panel.getjPanelHead(); panelHeader.add(tituloPregunta);//w ww . j a v a 2 s . c o m panelHeader.setOpaque(false); panelHeader.setPreferredSize(panelGrafica.getSize()); //Panel de la tabla JPanel tabla = new JPanel(new GridLayout(pregunta.obtenerCantidadDeOpciones() + 2, 3, 5, 5)); tabla.setBackground(Color.white); //Poner el titulo de cada columna for (int i = 0; i < 3; i++) { JPanel tilt = new JPanel(); tilt.setBackground(new Color(137, 36, 31)); JLabel label = new JLabel(i == 0 ? "Opcion" : i == 2 ? "Porcentaje" : "Cantidad"); label.setFont(new Font("Roboto", 1, 18)); label.setForeground(Color.white); tilt.add(label); tilt.setSize(new Dimension(0, 35)); tilt.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); tabla.add(tilt); } int sum = 0; for (Opcion opcion : opciones) { sum += opcion.getCantidad(); } for (Opcion opc : opciones) { JPanel p1 = new JPanel(new GridLayout(0, 1)); p1.setBackground(Color.white); p1.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JTextArea l1 = new JTextArea(opc.getNombre()); l1.setWrapStyleWord(true); l1.setLineWrap(true); l1.setFont(new Font("Roboto", 0, 18)); l1.setEditable(false); l1.setBorder(null); p1.setPreferredSize(l1.getSize()); p1.add(l1); tabla.add(p1); JPanel p2 = new JPanel(); p2.setBackground(Color.white); p2.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l2 = new JLabel("" + opc.getCantidad()); l2.setFont(new Font("Roboto", 0, 18)); p2.add(l2); tabla.add(p2); JPanel p3 = new JPanel(); p3.setBackground(Color.white); p3.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); double porcentaje = (opc.getCantidad() * 100.0) / sum; JLabel l3 = new JLabel(String.format("%.2f", porcentaje) + "%"); l3.setFont(new Font("Roboto", 0, 18)); p3.add(l3); tabla.add(p3); } JPanel p1 = new JPanel(); p1.setBackground(Color.white); p1.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l1 = new JLabel("Total"); l1.setHorizontalTextPosition(JLabel.LEFT); l1.setFont(new Font("Roboto", 1, 18)); p1.add(l1); tabla.add(p1); JPanel p2 = new JPanel(); p2.setBackground(Color.white); p2.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l2 = new JLabel("" + sum); l2.setFont(new Font("Roboto", 1, 18)); p2.add(l2); tabla.add(p2); JPanel p3 = new JPanel(); p3.setBackground(Color.white); p3.setBorder(new MatteBorder(1, 1, 1, 1, new Color(230, 230, 230))); JLabel l3 = new JLabel("100.00%"); l3.setFont(new Font("Roboto", 1, 18)); p3.add(l3); tabla.add(p3); panel.getjPanelContent().add(tabla, BorderLayout.CENTER); //Relleno JPanel x = new JPanel(new GridLayout()); x.setPreferredSize(new Dimension(100, 0)); x.setBackground(Color.white); panel.getjPanelContent().add(x, BorderLayout.LINE_START); JPanel y = new JPanel(new GridLayout()); y.setPreferredSize(new Dimension(100, 0)); y.setBackground(Color.white); panel.getjPanelContent().add(y, BorderLayout.LINE_END); JPanel z = new JPanel(new GridLayout()); z.setBackground(Color.white); z.setPreferredSize(new Dimension(0, 40)); panel.getjPanelContent().add(z, BorderLayout.PAGE_END); return panel; }