List of usage examples for javax.swing JPanel revalidate
public void revalidate()
From source file:com.polivoto.vistas.Charts.java
public void getHeader(JPanel header) { header.removeAll();/*from w ww . j a v a2 s. co m*/ GridBagConstraints gridBagConstraints; header.setLayout(new GridBagLayout()); header.setBackground(Color.white); header.setPreferredSize(new Dimension(0, 100)); JLabel titulo = new JLabel("<html> <b>Votacin: </b>" + votacion.getTitulo() + "</html>"); JLabel lugar = new JLabel("<html> <b>Lugar: </b>" + votacion.getLugar() + "</html>"); SimpleDateFormat sdf = new SimpleDateFormat("EEEE d' de 'MMMM' del 'yyyy, hh:mm:ss"); JLabel fechaInicio = new JLabel( "<html><b>Fecha de inicio: </b>" + sdf.format(new Date(votacion.getFechaInicio())) + "</html>"); JLabel fechaFin = new JLabel( "<html><b>Fecha de fin: </b>" + sdf.format(new Date(votacion.getFechaFin())) + "</html>"); titulo.setFont(fuenteNormal); titulo.setVerticalAlignment(JLabel.CENTER); lugar.setFont(fuenteNormal); lugar.setVerticalAlignment(JLabel.CENTER); fechaFin.setFont(fuenteNormal); fechaFin.setVerticalAlignment(JLabel.CENTER); fechaInicio.setFont(fuenteNormal); fechaInicio.setVerticalAlignment(JLabel.CENTER); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5); header.add(titulo, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15); header.add(fechaInicio, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5); header.add(lugar, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 3; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15); header.add(fechaFin, gridBagConstraints); header.repaint(); header.revalidate(); }
From source file:com.haulmont.cuba.desktop.sys.DesktopWindowManager.java
protected void showOptionDialog(final String title, final String message, @Nullable MessageType messageType, final Icon icon, boolean alwaysModal, final Action[] actions, String debugName) { final DialogWindow dialog = new DialogWindow(frame, title); if (App.getInstance().isTestMode()) { dialog.setName(debugName);/*from w w w . ja va 2 s . c om*/ } dialog.setModal(false); if (actions.length > 1) { dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); } int width = 500; SizeUnit unit = null; DialogParams dialogParams = getDialogParams(); if (messageType != null && messageType.getWidth() != null) { width = messageType.getWidth().intValue(); unit = messageType.getWidthUnit(); } else if (dialogParams.getWidth() != null) { width = dialogParams.getWidth().intValue(); unit = dialogParams.getWidthUnit(); } LC lc = new LC(); lc.insets("10"); MigLayout layout = new MigLayout(lc); final JPanel panel = new JPanel(layout); if (icon != null) { JLabel iconLabel = new JLabel(icon); panel.add(iconLabel, "aligny top"); } JLabel msgLabel = new JLabel(message); if (width != AUTO_SIZE_PX) { panel.add(msgLabel, "width 100%, wrap, growy 0"); } else { panel.add(msgLabel, "wrap"); } if (icon != null) { panel.add(new JLabel(" ")); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dialog.requestFocus(); } }); final JPanel buttonsPanel = createButtonsPanel(actions, dialog); panel.add(buttonsPanel, "alignx right"); if (width != AUTO_SIZE_PX) { if (unit != null && unit != SizeUnit.PIXELS) { throw new UnsupportedOperationException("Dialog size can be set only in pixels"); } dialog.setLayout(new MigLayout(new LC().insets("0").width(width + "px"))); dialog.setFixedWidth(width); dialog.add(panel, "width 100%, growy 0"); } else { dialog.add(panel); } assignDialogShortcuts(dialog, panel, actions); dialog.pack(); dialog.setResizable(false); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { panel.revalidate(); panel.repaint(); java.awt.Container container = panel.getTopLevelAncestor(); if (container instanceof JDialog) { JDialog dialog = (JDialog) container; dialog.pack(); } } }); dialog.setLocationRelativeTo(frame); boolean modal = true; if (!alwaysModal) { if (!hasModalWindow()) { if (messageType != null && messageType.getModal() != null) { modal = messageType.getModal(); } else if (dialogParams.getModal() != null) { modal = dialogParams.getModal(); } } } else { if (messageType != null && messageType.getModal() != null) { log.warn("MessageType.modal is not supported for showOptionDialog"); } } if (modal) { DialogWindow lastDialogWindow = getLastDialogWindow(); if (lastDialogWindow == null) { frame.deactivate(null); } else { lastDialogWindow.disableWindow(null); } } dialog.setVisible(true); }
From source file:com.game.ui.views.WeaponEditorPanel.java
@Override public void actionPerformed(ActionEvent ae) { if (ae.getActionCommand().equalsIgnoreCase("dropDown")) { JPanel panel = (JPanel) comboBox.getParent().getComponent(4); String name = comboBox.getSelectedItem().toString(); for (Item item : GameBean.weaponDetails) { if (item instanceof Weapon) { Weapon weapon = (Weapon) item; if (weapon.getName().equalsIgnoreCase(name)) { ((JTextField) panel.getComponent(2)).setText(name); ((JComboBox) panel.getComponent(4)).setSelectedItem(weapon.getWeaponType()); ((JTextField) panel.getComponent(6)).setText(Integer.toString(weapon.getAttackRange())); ((JTextField) panel.getComponent(8)).setText(Integer.toString(weapon.getAttackPts())); return; }/* w w w . ja va 2 s. c om*/ } } } else { JButton btn = (JButton) ae.getSource(); JPanel panel = (JPanel) btn.getParent(); String name = ((JTextField) panel.getComponent(2)).getText(); String weaponType = (String) (((JComboBox) panel.getComponent(4)).getSelectedItem()); String attackRnge = ((JTextField) panel.getComponent(6)).getText(); String attackPts = ((JTextField) panel.getComponent(8)).getText(); // JLabel message = ((JLabel) this.getComponent(5)); validationMess.setText(""); validationMess.setVisible(false); if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(weaponType) && StringUtils.isNotBlank(attackRnge) && StringUtils.isNotBlank(attackPts)) { validationMess.setVisible(false); Weapon weapon = new Weapon(); weapon.setName(name); ; weapon.setAttackRange(Integer.parseInt(attackRnge)); weapon.setAttackPts(Integer.parseInt(attackPts)); weapon.setWeaponType(weaponType); boolean weaponAlrdyPresent = false; int position = GameUtils.getPositionOfWeaponItem(name); if (GameBean.weaponDetails == null) { GameBean.weaponDetails = new ArrayList<Item>(); } if (position != -1) { GameBean.weaponDetails.remove(position); } GameBean.weaponDetails.add(weapon); try { GameUtils.writeItemsToXML(GameBean.weaponDetails, Configuration.PATH_FOR_WEAPONS); validationMess.setText("Saved Successfully.."); validationMess.setVisible(true); if (!weaponAlrdyPresent) { comboBox.removeActionListener(this); comboBox.addItem(name); comboBox.setSelectedItem(name); comboBox.addActionListener(this); } TileInformation tileInfo = GameBean.mapInfo.getPathMap().get(location); if (tileInfo == null) { tileInfo = new TileInformation(); } tileInfo.setWeapon(weapon); GameBean.mapInfo.getPathMap().put(location, tileInfo); chkBox.setSelected(true); this.revalidate(); return; } catch (Exception e) { System.out.println("WeaponEditorPanel : actionPerformed() : Some error occured " + e); } } else { validationMess.setText("Pls enter all the fields or pls choose a weapon from the drop down"); validationMess.setVisible(true); panel.revalidate(); } } }
From source file:com.sdk.connector.chart.CoherenceDomainRenderer.java
public CoherenceDomainRenderer(final String title, JPanel panel, String side) { sdf = Protocol.getInstance().getTimestampFormat(); serieFFT.setKey(side + " FFT Based"); serieLomb.setKey(side + " Lomb Based"); serieMemse.setKey(side + " AR Based"); dataset.addSeries(serieFFT);/*from www. j av a 2s .c o m*/ dataset.addSeries(serieLomb); dataset.addSeries(serieMemse); chart = ChartFactory.createTimeSeriesChart(title, java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("coherence.xlabel"), java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("coherence.ylabel"), dataset, true, true, false); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100); //chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.GREEN)); // chart.setBackgroundPaint(new Color(220,255,220,0)); //chart.setBackgroundImage(new javax.swing.ImageIcon(getClass().getResource("/com/sdk/connector/resources/background.png")).getImage()); chart.addSubtitle(rangeAnnotation); plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, sdf, new DecimalFormat("0.00"))); renderer.setSeriesOutlinePaint(0, Color.BLACK); if (side.startsWith( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) { renderer.setSeriesPaint(0, Color.BLUE); leftSide = true; } else { renderer.setSeriesPaint(0, Color.RED); leftSide = false; } renderer.setSeriesShape(0, new Ellipse2D.Double(-1.0, -1.0, 3.0, 3.0)); DateTickUnit dtUnit = new DateTickUnit(DateTickUnitType.MINUTE, 1, tickSDF); final DateAxis domainAxis = (DateAxis) plot.getDomainAxis(); domainAxis.setTickUnit(dtUnit); // ValueAxis axis = plot.getDomainAxis(); // axis = plot.getRangeAxis(); // ((NumberAxis) axis).setTickUnit(new NumberTickUnit(100)); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); // plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f)); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("message.wait")); plot.setRangePannable(true); plot.setDomainPannable(true); Color color1 = new Color(0, 0, 0, 24); Color color2 = new Color(255, 255, 255, 24); GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2); plot.setBackgroundPaint(gp); chartPanel = new ChartPanel(chart); panel.setLayout(new GridLayout(0, 1)); panel.add(chartPanel); panel.repaint(); panel.revalidate(); }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
private JPanel configureLeftBottomPanel() { this.focusPanel = new FocusPane(this); final JPanel focusPanelContainer = new JPanel(new BorderLayout()); final JToolBar navigationToolbar = new JToolBar(JToolBar.VERTICAL); navigationToolbar.setRollover(true); navigationToolbar.setFloatable(false); navigationToolbar.setOpaque(false);//w w w.j a v a2 s . c om final JButton btn_pickNavigationUndo, btn_pickNavigationRedo; btn_pickNavigationUndo = new JButton(""); btn_pickNavigationUndo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoPick.png"))); btn_pickNavigationUndo.setToolTipText("Navigate back to the previous element picked"); btn_pickNavigationRedo = new JButton(""); btn_pickNavigationRedo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoPick.png"))); btn_pickNavigationRedo.setToolTipText("Navigate forward to the next element picked"); final ActionListener action = e -> { Pair<NetworkElement, Pair<Demand, Link>> backOrForward; do { backOrForward = (e.getSource() == btn_pickNavigationUndo) ? GUINetworkDesign.this.getVisualizationState().getPickNavigationBackElement() : GUINetworkDesign.this.getVisualizationState().getPickNavigationForwardElement(); if (backOrForward == null) break; final NetworkElement ne = backOrForward.getFirst(); // For network elements final Pair<Demand, Link> fr = backOrForward.getSecond(); // For forwarding rules if (ne != null) { if (ne.getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (ne.getNetPlan() == null) continue; break; } else if (fr != null) { if (fr.getFirst().getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (fr.getFirst().getNetPlan() == null) continue; if (fr.getSecond().getNetPlan() != GUINetworkDesign.this.getDesign()) continue; if (fr.getSecond().getNetPlan() == null) continue; break; } else break; // null,null => reset picked state } while (true); if (backOrForward != null) { if (backOrForward.getFirst() != null) GUINetworkDesign.this.getVisualizationState().pickElement(backOrForward.getFirst()); else if (backOrForward.getSecond() != null) GUINetworkDesign.this.getVisualizationState().pickForwardingRule(backOrForward.getSecond()); else GUINetworkDesign.this.getVisualizationState().resetPickedState(); GUINetworkDesign.this.updateVisualizationAfterPick(); } }; btn_pickNavigationUndo.addActionListener(action); btn_pickNavigationRedo.addActionListener(action); btn_pickNavigationRedo.setFocusable(false); btn_pickNavigationUndo.setFocusable(false); navigationToolbar.add(btn_pickNavigationUndo); navigationToolbar.add(btn_pickNavigationRedo); final JScrollPane scPane = new JScrollPane(focusPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scPane.getVerticalScrollBar().setUnitIncrement(20); scPane.getHorizontalScrollBar().setUnitIncrement(20); scPane.setBorder(BorderFactory.createEmptyBorder()); // Control the scroll scPane.getHorizontalScrollBar().addAdjustmentListener(e -> { // Repaints the panel each time the horizontal scroll bar is moves, in order to avoid ghosting. focusPanelContainer.revalidate(); focusPanelContainer.repaint(); }); focusPanelContainer.add(navigationToolbar, BorderLayout.WEST); focusPanelContainer.add(scPane, BorderLayout.CENTER); JPanel pane = new JPanel(new MigLayout("fill, insets 0 0 0 0")); pane.setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Focus panel")); pane.add(focusPanelContainer, "grow"); return pane; }
From source file:com.sdk.connector.chart.TimeDomainRenderer.java
public TimeDomainRenderer(final String title, JPanel panel, String side, String type) { sdf = protocol.getTimestampFormat(); this.side = side + type; this.type = type; serie.setKey(side);// w ww . j a v a 2 s .c o m dataset.addSeries(serie); String legendX = ""; if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("RR"))) { legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle") .getString("timeRR.ylabel"); } else { legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle") .getString("timeBC.ylabel"); } chart = ChartFactory.createTimeSeriesChart(title, java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("time.xlabel"), legendX, dataset, true, true, false); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100); //chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.GREEN)); // chart.setBackgroundPaint(new Color(220,255,220,0)); //chart.setBackgroundImage(new javax.swing.ImageIcon(getClass().getResource("/com/sdk/connector/resources/background.png")).getImage()); chart.addSubtitle(rangeAnnotation); plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, sdf, new DecimalFormat("0.00"))); renderer.setSeriesOutlinePaint(0, Color.BLACK); if (side.startsWith( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) { renderer.setSeriesPaint(0, Color.BLUE); } else { renderer.setSeriesPaint(0, Color.RED); } renderer.setSeriesShape(0, new Ellipse2D.Double(-1.0, -1.0, 3.0, 3.0)); if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("BC"))) { renderer.setSeriesShape(0, new Rectangle2D.Double(-1.0, -1.0, 3.0, 3.0)); } DateTickUnit dtUnit = new DateTickUnit(DateTickUnitType.MINUTE, 1, tickSDF); final DateAxis domainAxis = (DateAxis) plot.getDomainAxis(); domainAxis.setTickUnit(dtUnit); // ValueAxis axis = plot.getDomainAxis(); // axis = plot.getRangeAxis(); // ((NumberAxis) axis).setTickUnit(new NumberTickUnit(100)); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); // plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f)); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("CALIBRATING...")); plot.setRangePannable(true); plot.setDomainPannable(true); Color color1 = new Color(0, 0, 0, 24); Color color2 = new Color(255, 255, 255, 24); GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2); plot.setBackgroundPaint(gp); chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(this); panel.setLayout(new GridLayout(0, 1)); panel.add(chartPanel); panel.repaint(); panel.revalidate(); }
From source file:com.polivoto.vistas.Charts.java
private void crearBarChart(Pregunta pregunta) { JPanel panel = new JPanel(new BorderLayout()); panel.setBackground(Color.white); panelGrafica.add(panel);/* w w w .j a v a2s. c om*/ DefaultCategoryDataset data = new DefaultCategoryDataset(); // Fuente de Datos //Calcular el nmero N de perfiles. Si N=1, no discriminar por pestanas. //Si son N perfiles (N>2), hacer N+1 pestanas (la ltima representa la //suma de los resultados sin segregacin. int n = pregunta.obtenerCantidadDePerfiles(); System.out.println(" n " + n); if (n > 1) { for (int i = 0; i < n; i++) { List<Opcion> opciones = pregunta.obtenerResultadoPorPerfil(i).getOpciones(); for (Opcion opc : opciones) { data.setValue(opc.getCantidad(), opc.getNombre(), pregunta.obtenerResultadoPorPerfil(i).getPerfil()); } } } for (int i = 0; i < pregunta.obtenerCantidadDeOpciones(); i++) { Opcion opc = pregunta.obtenerOpcion(i); data.setValue(opc.getCantidad(), opc.getNombre(), "Todos"); } // Creando el Grafico JFreeChart chart = ChartFactory.createBarChart("\n" + pregunta.getTitulo() + "\n", "Perfil", "Total de votos", data, PlotOrientation.VERTICAL, true, // include legend true, // tooltips? false // URLs? ); //chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Roboto", 0, 28)); //chart.addSubtitle(new TextTitle("Titulo jajaja")); //chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.white)); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setOutlineVisible(false); ChartPanel barChart = new ChartPanel(chart); barChart.setBounds(panel.getVisibleRect()); //barChart.setPreferredSize(panelGrafica.getSize()); //barChart.setBounds(panel.getVisibleRect()); //Colores de Barras Paint[] colors = { new Color(124, 181, 236), new Color(244, 91, 91), new Color(144, 237, 125), new Color(67, 67, 72), new Color(247, 163, 92), new Color(128, 133, 233), new Color(241, 92, 128), new Color(228, 211, 84), new Color(43, 144, 143), new Color(145, 232, 225) }; ((org.jfree.chart.renderer.category.BarRenderer) plot.getRenderer()) .setBarPainter(new StandardBarPainter()); // Quita Efecto luz BarRenderer renderer = new BarRenderer(colors); renderer.setColor(plot, data); //Numeros sobre barras CategoryItemRenderer renderizar; renderizar = plot.getRenderer(); renderizar.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderizar.setBaseItemLabelsVisible(true); renderizar.setItemLabelFont(new Font("Roboto", 0, 18)); //Valores eje Y ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setLabelFont(new Font("Roboto", 0, 17)); rangeAxis.setTickLabelFont(new Font("Roboto", 0, 17)); //Diseo categorias org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLabelFont(new Font("Roboto", 0, 17)); domainAxis.setTickLabelFont(new Font("Roboto", 0, 17)); /*domainAxis.setTickLabelPaint(new Color(160, 163, 165)); domainAxis.setCategoryLabelPositionOffset(4); domainAxis.setLowerMargin(0); domainAxis.setUpperMargin(0); domainAxis.setCategoryMargin(0.2); */ //Leyendas LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.BOTTOM); Font nwfont = new Font("Roboto", 0, 18); legend.setItemFont(nwfont); legend.setBorder(0, 0, 0, 0); legend.setBackgroundPaint(Color.WHITE); legend.setItemLabelPadding(new RectangleInsets(8, 8, 8, 15)); /* plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{1} {0}")); plot.setLegendItemShape(new Rectangle(25, 25)); */ // Pintar panel.removeAll(); panel.add(barChart); panel.repaint(); panel.revalidate(); panelGrafica.repaint(); panelGrafica.revalidate(); }
From source file:com.sdk.connector.chart.FrequencyDomainRenderer.java
/** * Creates a new demo application./*w w w. j a va 2 s. c o m*/ * * @param title the frame title. */ public FrequencyDomainRenderer(String title, JPanel panel, String side, String type) { this.side = side; this.type = type; serie.setKey(side); dataset.addSeries(serie); JFreeChart chart = ChartFactory.createXYAreaChart(title, java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("frequency.xlabel"), java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("frequency.ylabel2"), dataset, PlotOrientation.VERTICAL, true, true, false); // TextTitle t1 = new TextTitle( "Espectro de Frequncia Estimado (PSD)", new Font("SansSerif", Font.BOLD, 14) ); // //TextTitle t2 = new TextTitle( "valores atualizados a cada potncia de 2", new Font("SansSerif", Font.PLAIN, 11) ); // chart.addSubtitle(t1); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100); //chart.addSubtitle(t2); plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLUE); plot.setRangeGridlinePaint(Color.CYAN); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); //plot.setRangePannable(true); plot.setForegroundAlpha(0.65f); //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer = plot.getRenderer(); renderer.setSeriesOutlinePaint(0, Color.BLACK); if (side.startsWith( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) { renderer.setSeriesPaint(0, Color.BLUE); } else { renderer.setSeriesPaint(0, Color.RED); } // renderer.setSeriesLinesVisible(0, true); // renderer.setSeriesShapesVisible(0, false); // renderer.setSeriesLinesVisible(1, true); // renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.setForegroundAlpha(0.5f); Color color1 = new Color(0, 0, 0, 24); Color color2 = new Color(255, 255, 255, 24); GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2); plot.setBackgroundPaint(gp); final ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickMarkPaint(Color.black); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); NumberAxis numDomainAxis = (NumberAxis) plot.getDomainAxis(); numDomainAxis.setAutoRangeIncludesZero(true); // // final NumberAxis rangeAxis = new LogarithmicAxis("Log(y)"); // // plot.setRangeAxis(rangeAxis); final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setTickMarkPaint(Color.black); numRangeAxis = (NumberAxis) plot.getRangeAxis(); numRangeAxis.setAutoRangeIncludesZero(true); vlfTarget.setLabel("VLF"); vlfTarget.setLabelFont(new Font("SansSerif", Font.ITALIC, 9)); vlfTarget.setLabelAnchor(RectangleAnchor.CENTER); vlfTarget.setLabelTextAnchor(TextAnchor.CENTER); vlfTarget.setPaint(new Color(0, 100, 255, 128)); // plot.addRangeMarker(target, Layer.BACKGROUND); plot.addDomainMarker(vlfTarget, Layer.BACKGROUND); lfTarget.setLabel("LF"); lfTarget.setLabelFont(new Font("SansSerif", Font.ITALIC, 9)); lfTarget.setLabelAnchor(RectangleAnchor.CENTER); lfTarget.setLabelTextAnchor(TextAnchor.CENTER); lfTarget.setPaint(new Color(255, 255, 0, 128)); // plot.addRangeMarker(target, Layer.BACKGROUND); plot.addDomainMarker(lfTarget, Layer.BACKGROUND); hfTarget.setLabel("HF"); hfTarget.setLabelFont(new Font("SansSerif", Font.ITALIC, 9)); hfTarget.setLabelAnchor(RectangleAnchor.CENTER); hfTarget.setLabelTextAnchor(TextAnchor.CENTER); hfTarget.setPaint(new Color(255, 0, 255, 128)); // plot.addRangeMarker(target, Layer.BACKGROUND); plot.addDomainMarker(hfTarget, Layer.BACKGROUND); plot.setNoDataMessage( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("message.wait")); chartPanel = new ChartPanel(chart); panel.setLayout(new GridLayout(0, 1)); panel.add(chartPanel); panel.repaint(); panel.revalidate(); }
From source file:model.DrawTopologyDiagram.java
@Override public void init() { //create a graph Graph<VertexTopology, Number> ig = Graphs.<VertexTopology, Number>synchronizedDirectedGraph( new DirectedSparseMultigraph<VertexTopology, Number>()); ObservableGraph<VertexTopology, Number> og = new ObservableGraph<VertexTopology, Number>(ig); og.addGraphEventListener(new GraphEventListener<VertexTopology, Number>() { public void handleGraphEvent(GraphEvent<VertexTopology, Number> evt) { System.err.println("got " + evt); }// w ww . j ava2 s .c o m }); this.g = og; //layouts //create a graphdraw // layout = new FRLayout2<String,Number>(g); // layout = new SpringLayout<String,Number>(g); // ((FRLayout)layout).setMaxIterations(200); layout = new KKLayout<VertexTopology, Number>(g); vv = new VisualizationViewer<VertexTopology, Number>(layout, new Dimension(600, 600)); createGraph(); Container content = getContentPane(); JPanel totalCasesPanel = new JPanel(); final JPanel scaleGrids = new JPanel(new GridLayout(0, 2)); scaleGrids.add(new JLabel(" Test Cases ")); scaleGrids.add(new JLabel(" ")); totalCasesPanel.add(scaleGrids); JPanel filteredCasesPanel = new JPanel(); final JPanel filteredGrids = new JPanel(new GridLayout(0, 2)); filteredGrids.add(new JLabel(" Filtered Cases ")); filteredGrids.add(new JLabel(" ")); filteredCasesPanel.add(filteredGrids); JRootPane rp = this.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); content.setLayout(new BorderLayout()); content.setBackground(java.awt.Color.lightGray); content.setFont(new Font("Serif", Font.PLAIN, 12)); vv.getModel().getRelaxer().setSleepTime(500); vv.setGraphMouse(new DefaultModalGraphMouse<VertexTopology, Number>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.setForeground(Color.white); FontMetrics fm = vv.getFontMetrics(vv.getFont()); int width = fm.stringWidth(g.toString()); Transformer<VertexTopology, Shape> vertexSize = new Transformer<VertexTopology, Shape>() { public Shape transform(VertexTopology i) { Ellipse2D circle = new Ellipse2D.Double(-20, -20, 40, 40); // in this case, the vertex is twice as large return circle; } }; vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller() { @Override public String transform(Object v) { return ((VertexTopology) v).getScreenName(); } }); vv.getRenderContext().setVertexShapeTransformer(vertexSize); //Get picked states final PickedState<VertexTopology> pickedState = vv.getPickedVertexState(); pickedState.addItemListener(new ItemListener() { ArrayList<TestCase> outputTestCase = new ArrayList<TestCase>(); final Map<String, JButton> createdBtns = new HashMap<String, JButton>(); Map<String, Integer> deviceSelected = new HashMap<String, Integer>(); // not useful ArrayList<String> endPointList = new ArrayList<String>(); @Override public void itemStateChanged(ItemEvent e) { // TODO Auto-generated method stub Object subject = e.getItem(); if (e.getStateChange() != 1) { scaleGrids.removeAll(); filteredGrids.removeAll(); endPointList.remove(getScreenName(subject)); outputTestCase.clear(); filteredGrids.repaint(); filteredGrids.add(new JLabel(" Filtered Cases ")); filteredGrids.add(new JLabel(" ")); scaleGrids.repaint(); scaleGrids.add(new JLabel(" Test Cases ")); scaleGrids.add(new JLabel(" ")); deviceSelected.clear(); } if (e.getStateChange() == 1) { for (TestCase testCase : outputTestCase) { scaleGrids.removeAll(); scaleGrids.add(new JLabel(" Test Cases ")); scaleGrids.add(new JLabel(" ")); filteredGrids.removeAll(); filteredGrids.add(new JLabel(" Filtered Cases ")); filteredGrids.add(new JLabel(" ")); } if (subject instanceof VertexTopology) { final VertexTopology edgePicked = (VertexTopology) subject; if (pickedState.isPicked(edgePicked)) { for (TestCase testCase : edgePicked.getTestCaseList()) { if (!outputTestCase.contains(testCase)) outputTestCase.add(testCase); System.out.println("The size for reference is " + testCase.inputReferenceMap.size() + testCase.getName()); System.out.println("The size for target is " + testCase.inputTargetMap.size() + testCase.getName()); } if (deviceSelected.get(edgePicked.getScreenName()) != null) deviceSelected.put(edgePicked.getScreenName(), deviceSelected.get(edgePicked.getScreenName()) + 1); else deviceSelected.put(edgePicked.getScreenName(), 1); endPointList.add(edgePicked.getScreenName()); } } } for (TestCase testCase : outputTestCase) { JButton btnCase = new JButton(testCase.getName()); scaleGrids.add(btnCase); if (testCase.getInputDeviceList().size() <= endPointList.size()) if (testCaseSelected(testCase, endPointList)) { JButton btnCaseFiltered = new JButton(testCase.getName()); filteredGrids.add(btnCaseFiltered); } ; } scaleGrids.revalidate(); scaleGrids.setVisible(true); } }); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); content.setPreferredSize(new Dimension(1400, 900)); content.add(vv); switchLayout = new JButton("Switch to SpringLayout"); // switchLayout.addActionListener(new ActionListener() { // // @SuppressWarnings("unchecked") // public void actionPerformed(ActionEvent ae) { // Dimension d = new Dimension(600,600); // if (switchLayout.getText().indexOf("Spring") > 0) { // switchLayout.setText("Switch to FRLayout"); // layout = new SpringLayout<String,Number>(g, // new ConstantTransformer(EDGE_LENGTH)); // layout.setSize(d); // vv.getModel().setGraphLayout(layout, d); // } else { // switchLayout.setText("Switch to SpringLayout"); // layout = new FRLayout<String,Number>(g, d); // vv.getModel().setGraphLayout(layout, d); // } // } // }); JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, totalCasesPanel, filteredCasesPanel); jSplitPane.setResizeWeight(.5d); content.add(switchLayout, BorderLayout.SOUTH); content.add(jSplitPane, BorderLayout.EAST); }
From source file:lol.search.RankedStatsPage.java
private JScrollPane championSelectPanel() { JPanel mainPanel = new JPanel(new FlowLayout()); //mainPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); mainPanel.setBackground(backgroundColor); for (int i = 0; i < this.objChampRankedList.size(); i++) { int position = counter; ImageIcon champImageIcon = this.OBJ_RANKED_STATS_BY_ID.getChampionIconOf(this.champKeyList.get(i)); JButton champButton = new JButton(); champButton.setIcon(champImageIcon); if (i == 0) { champButton.setIcon(this.profileIcon); champButton.setToolTipText("Overall Stats"); }//from ww w. j a v a 2 s .com champButton.setPreferredSize(new Dimension(55, 55)); champButton.setBackground(Color.BLACK); champButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //button pressed background.setIcon(OBJ_GAME_STATIC_DATA.getBackgroundImageIcon(champKeyList.get(position))); loadArtLabel.setIcon(OBJ_GAME_STATIC_DATA.initLoadingArt(champKeyList.get(position))); nameHeader.setText(OBJ_ALL_CHAMPS_BY_ID.getChampNameFromId(champIdList.get(position))); titleHeader.setText(" " + OBJ_ALL_CHAMPS_BY_ID.getChampTitleFromId(champIdList.get(position))); String sessionsWon = ""; String sessionsLost = ""; String winPercentString = ""; try { int won = objChampRankedList.get(position).getJSONObject("stats") .getInt("totalSessionsWon"); sessionsWon = Integer.toString(won); int lost = objChampRankedList.get(position).getJSONObject("stats") .getInt("totalSessionsLost"); sessionsLost = Integer.toString(lost); winPercentString = getWinPercentage(won, lost); totalGamesInt = won + lost; avgKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalChampionKills") / (double) totalGamesInt)); avgAssistsLabelValue .setText(new DecimalFormat("##.##").format((double) objChampRankedList.get(position) .getJSONObject("stats").getInt("totalAssists") / (double) totalGamesInt)); avgDeathsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalDeathsPerSession") / (double) totalGamesInt)); avgMinionKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalMinionKills") / (double) totalGamesInt)); avgDoubleKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalDoubleKills") / (double) totalGamesInt)); avgTripleKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalTripleKills") / (double) totalGamesInt)); avgQuadKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalQuadraKills") / (double) totalGamesInt)); avgPentaKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalPentaKills") / (double) totalGamesInt)); totalKillsLabelValue.setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalChampionKills"))); totalDeathsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalDeathsPerSession"))); totalAssistsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalAssists"))); totalMinionsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalMinionKills"))); totalDoubleKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalDoubleKills"))); totalTripleKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalTripleKills"))); totalQuadKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalQuadraKills"))); totalPentaKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalPentaKills"))); } catch (JSONException ex) { Logger.getLogger(RankedStatsPage.class.getName()).log(Level.SEVERE, null, ex); } totalWins.setText(sessionsWon); totalLosses.setText(sessionsLost); winPercent.setText(winPercentString + "%"); totalGamesPlayed.setText(String.valueOf(totalGamesInt)); masterFrame.revalidate(); masterFrame.repaint(); } }); champButton.setToolTipText(OBJ_ALL_CHAMPS_BY_ID.getChampNameFromId(champIdList.get(position))); champButtons.add(champButton); //champButton.setBorder(BorderFactory.createLineBorder(Color.BLACK)); counter++; } for (int i = 0; i < champButtons.size(); i++) { mainPanel.add(champButtons.get(i)); mainPanel.revalidate(); } JScrollPane scrollPane = new JScrollPane(mainPanel); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(1200, 85)); scrollPane.setBackground(new Color(0, 0, 0, 100)); scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); scrollPane.getHorizontalScrollBar().setUI(new BasicScrollBarUI() { @Override protected void configureScrollBarColors() { this.thumbColor = new Color(124, 124, 124, 255); this.trackColor = Color.BLACK; } }); return scrollPane; }