List of usage examples for org.jfree.chart ChartPanel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:org.nbheaven.sqe.codedefects.history.controlcenter.panels.SQEHistoryPanel.java
/** Creates new form SQEHistoryPanel */ public SQEHistoryPanel() { historyChart = org.jfree.chart.ChartFactory.createStackedXYAreaChart(null, "Snapshot", "CodeDefects", perProjectDataSet, PlotOrientation.VERTICAL, false, true, false); historyChart.setBackgroundPaint(Color.WHITE); historyChart.getXYPlot().setRangeGridlinePaint(Color.BLACK); historyChart.getXYPlot().setDomainGridlinePaint(Color.BLACK); historyChart.getXYPlot().setBackgroundPaint(Color.WHITE); XYPlot plot = historyChart.getXYPlot(); plot.setForegroundAlpha(0.7f);/*from w w w . j a va 2 s . co m*/ // plot.getRenderer(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LogarithmicAxis rangeAxis = new LogarithmicAxis("CodeDefects"); rangeAxis.setStrictValuesFlag(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(rangeAxis); StackedXYAreaRenderer2 categoryItemRenderer = new StackedXYAreaRenderer2(); //3D(); categoryItemRenderer.setSeriesPaint(0, Color.RED); categoryItemRenderer.setSeriesPaint(1, Color.ORANGE); categoryItemRenderer.setSeriesPaint(2, Color.YELLOW); plot.setRenderer(categoryItemRenderer); ChartPanel historyChartPanel = new ChartPanel(historyChart); historyChartPanel.setBorder(null); historyChartPanel.setPreferredSize(new Dimension(150, 200)); historyChartPanel.setBackground(Color.WHITE); initComponents(); historyView.setLayout(new BorderLayout()); historyView.add(historyChartPanel, BorderLayout.CENTER); JPanel selectorPanel = new JPanel(); selectorPanel.setOpaque(false); GroupLayout layout = new GroupLayout(selectorPanel); selectorPanel.setLayout(layout); // Turn on automatically adding gaps between components layout.setAutocreateGaps(true); // Turn on automatically creating gaps between components that touch // the edge of the container and the container. layout.setAutocreateContainerGaps(true); ParallelGroup horizontalParallelGroup = layout.createParallelGroup(GroupLayout.LEADING); SequentialGroup verticalSequentialGroup = layout.createSequentialGroup(); layout.setHorizontalGroup(layout.createSequentialGroup().add(horizontalParallelGroup)); layout.setVerticalGroup(verticalSequentialGroup); clearHistoryButton = new JButton(); clearHistoryButton.setEnabled(false); clearHistoryButton.setIcon(ImageUtilities .image2Icon(ImageUtilities.loadImage("org/nbheaven/sqe/codedefects/history/resources/trash.png"))); clearHistoryButton.setOpaque(false); clearHistoryButton.setFocusPainted(false); clearHistoryButton.setToolTipText( NbBundle.getBundle("org/nbheaven/sqe/codedefects/history/controlcenter/panels/Bundle") .getString("HINT_clear_button")); horizontalParallelGroup.add(clearHistoryButton); verticalSequentialGroup.add(clearHistoryButton); clearHistoryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (null != activeHistory) { activeHistory.clear(); } } }); Component createVerticalStrut = Box.createVerticalStrut(10); horizontalParallelGroup.add(createVerticalStrut); verticalSequentialGroup.add(createVerticalStrut); for (final QualityProvider provider : SQEUtilities.getProviders()) { final JToggleButton providerButton = new JToggleButton(); providerButton.setIcon(provider.getIcon()); providerButton.setOpaque(false); providerButton.setFocusPainted(false); horizontalParallelGroup.add(providerButton); verticalSequentialGroup.add(providerButton); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { if (providerButton.isSelected()) { addSelectedProvider(provider); } else { removeSelectedProvider(provider); } updateView(); } }; providerButton.addActionListener(listener); addSelectedProvider(provider); providerButton.setSelected(true); } historyView.add(selectorPanel, BorderLayout.EAST); }
From source file:org.broad.igv.peaks.PeakTrackMenu.java
void openTimeSeriesPlot(TrackClickEvent trackClickEvent) { if (trackClickEvent == null) return;//from w w w .j a v a2 s .c om ReferenceFrame referenceFrame = trackClickEvent.getFrame(); if (referenceFrame == null) return; String chr = referenceFrame.getChrName(); double position = trackClickEvent.getChromosomePosition(); XYSeriesCollection data = new XYSeriesCollection(); List<Color> colors = new ArrayList(); for (SoftReference<PeakTrack> ref : PeakTrack.instances) { PeakTrack track = ref.get(); if (track != null) { Peak peak = track.getFilteredPeakNearest(chr, position); if (peak != null) { XYSeries series = new XYSeries(track.getName()); float[] scores = peak.getTimeScores(); if (scores.length == 4) { float t0 = scores[0] + 10; series.add(0, (scores[0] + 10) / t0); series.add(30, (scores[1] + 10) / t0); series.add(60, (scores[2] + 10) / t0); series.add(120, (scores[3] + 10) / t0); } data.addSeries(series); Color c = track.getName().contains("Pol") ? Color.black : track.getColor(); colors.add(c); } } } final JFreeChart chart = ChartFactory.createXYLineChart("", "Time", "Score", data, PlotOrientation.VERTICAL, true, true, false); NumberAxis axis = (NumberAxis) chart.getXYPlot().getDomainAxis(0); axis.setTickUnit(new NumberTickUnit(30)); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(400, 400)); chartPanel.setSize(new java.awt.Dimension(400, 400)); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); for (int i = 0; i < colors.size(); i++) { renderer.setSeriesPaint(i, colors.get(i)); } chartPanel.setBackground(Color.white); chart.getXYPlot().setBackgroundPaint(Color.white); chart.getXYPlot().setRangeGridlinePaint(Color.black); PeakTimePlotFrame frame = new PeakTimePlotFrame(chartPanel); frame.setVisible(true); }
From source file:srvclientmonitor.frmMain.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed JPanel panel = new JPanel(); getContentPane().add(panel);//from w w w .j a v a 2s.co m DefaultCategoryDataset data = new DefaultCategoryDataset(); //DefaultPieDataset data = new DefaultPieDataset(); //Para el Grafico PIE data.addValue(20, "OSP", "HOY"); data.addValue(99, "ETL", "HOY"); data.addValue(25, "LOR", "HOY"); data.addValue(12, "MOV", "HOY"); // Creando el Grafico //JFreeChart chart = ChartFactory.createPieChart( //JFreeChart chart = ChartFactory.createBarChart("Ejemplo Rapido de Grafico en un ChartFrame", "Mes", "Valor", data); JFreeChart chart = ChartFactory.createBarChart("", "", "", data, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.BLACK); chart.setTitle(""); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangePannable(true); plot.setRangeGridlinesVisible(false); plot.setBackgroundAlpha(1); plot.setBackgroundPaint(Color.BLACK); plot.setForegroundAlpha(1); plot.setDomainCrosshairPaint(Color.WHITE); plot.setNoDataMessagePaint(Color.WHITE); plot.setOutlinePaint(Color.WHITE); plot.setRangeCrosshairPaint(Color.WHITE); plot.setRangeMinorGridlinePaint(Color.WHITE); plot.setRangeZeroBaselinePaint(Color.WHITE); // Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green); // plot.setBackgroundPaint(p); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelPaint(Color.WHITE); rangeAxis.setAxisLinePaint(Color.WHITE); rangeAxis.setTickLabelPaint(Color.WHITE); rangeAxis.setVerticalTickLabels(true); //ChartUtilities.applyCurrentTheme(chart); // Crear el Panel del Grafico con ChartPanel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setSize(300, 150); chartPanel.setBackground(Color.BLACK); chartPanel.setOpaque(false); chartPanel.setDomainZoomable(true); this.jPanel1.setSize(300, 200); this.jPanel1.setBackground(Color.DARK_GRAY); this.jPanel1.add(chartPanel); }
From source file:lu.lippmann.cdb.lab.mds.UniversalMDS.java
public JXPanel buildMDSViewFromDataSet(Instances ds, MDSTypeEnum type) throws Exception { final XYSeriesCollection dataset = new XYSeriesCollection(); final JFreeChart chart = ChartFactory.createScatterPlot("", // title "X", "Y", // axis labels dataset, // dataset PlotOrientation.VERTICAL, true, // legend? yes true, // tooltips? yes false // URLs? no );//from w ww . j a v a 2 s . co m final XYPlot xyPlot = (XYPlot) chart.getPlot(); chart.setTitle(type.name() + " MDS"); Attribute clsAttribute = null; int nbClass = 1; if (ds.classIndex() != -1) { clsAttribute = ds.classAttribute(); nbClass = clsAttribute.numValues(); } final List<XYSeries> lseries = new ArrayList<XYSeries>(); if (nbClass <= 1) { lseries.add(new XYSeries("Serie #1", false)); } else { for (int i = 0; i < nbClass; i++) { lseries.add(new XYSeries(clsAttribute.value(i), false)); } } dataset.removeAllSeries(); /** * Initialize filtered series */ final List<Instances> filteredInstances = new ArrayList<Instances>(); for (int i = 0; i < lseries.size(); i++) { filteredInstances.add(new Instances(ds, 0)); } for (int i = 0; i < ds.numInstances(); i++) { final Instance oInst = ds.instance(i); int indexOfSerie = 0; if (oInst.classIndex() != -1) { indexOfSerie = (int) oInst.value(oInst.classAttribute()); } lseries.get(indexOfSerie).add(coordinates[i][0], coordinates[i][1]); filteredInstances.get(indexOfSerie).add(oInst); } final List<Paint> colors = new ArrayList<Paint>(); for (final XYSeries series : lseries) { dataset.addSeries(series); } final XYToolTipGenerator gen = new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { return InstanceFormatter.htmlFormat(filteredInstances.get(series).instance(item), true); } }; final Shape shape = new Ellipse2D.Float(0f, 0f, 5f, 5f); ((XYLineAndShapeRenderer) xyPlot.getRenderer()).setUseOutlinePaint(true); for (int p = 0; p < nbClass; p++) { xyPlot.getRenderer().setSeriesToolTipGenerator(p, gen); ((XYLineAndShapeRenderer) xyPlot.getRenderer()).setLegendShape(p, shape); xyPlot.getRenderer().setSeriesOutlinePaint(p, Color.BLACK); } for (int ii = 0; ii < nbClass; ii++) { colors.add(xyPlot.getRenderer().getItemPaint(ii, 0)); } final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(1200, 900)); chartPanel.setBorder(new TitledBorder("MDS Projection")); chartPanel.setBackground(Color.WHITE); final JXPanel allPanel = new JXPanel(); allPanel.setLayout(new BorderLayout()); allPanel.add(chartPanel, BorderLayout.CENTER); return allPanel; }
From source file:userinterface.CyberSecurity.CyberSecurityJPanel.java
private void btnLogsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogsActionPerformed Organization organization = (Organization) organizationComboBox.getSelectedItem(); UserAccountDirectory userAccountDirectory = organization.getUserAccountDirectory(); if (null == userAccountDirectory) { JOptionPane.showMessageDialog(this, organization.getName() + " does not have employees to view details!", "No employees found", JOptionPane.WARNING_MESSAGE); return;// w w w .j ava 2 s. c om } int selectedRowIndex = employeeTable.getSelectedRow(); if (selectedRowIndex == -1) { // no row selected JOptionPane.showMessageDialog(this, "Please select employee to view details.", "No employee selected!", JOptionPane.WARNING_MESSAGE); return; } String employeeId = getEmployeeIDFromTable(selectedRowIndex); UserAccount userAccount = findUserAccountByID(employeeId, userAccountDirectory); if (null == userAccount) { JOptionPane.showMessageDialog(this, "Employee details not found!", "Not found", JOptionPane.WARNING_MESSAGE); return; } LoginDetails latestLoginDetails = userAccount.getLatestLoginDetails(); if (null == latestLoginDetails) { JOptionPane.showMessageDialog(this, "No logs to display charts", "Charts cannot be displayed", JOptionPane.ERROR_MESSAGE); return; } ChartPanel chart = ChartFactory.createChart(userAccount); chart.setBackground(Color.WHITE); chartContainer.removeAll(); chartContainer.add(chart, BorderLayout.CENTER); chart.setSize(chartContainer.getSize()); chartContainer.setBackground(Color.WHITE); chartContainer.add(chart); chart.setVisible(true); chartContainer.repaint(); }
From source file:UI.SecurityDashboard.java
private void performMetric9() { GZDecompression m9 = new GZDecompression(); String[][] counts = m9.getMetric9(); Font titleFont = new Font("Calibri", Font.BOLD, 27); JLabel logAuditTitleLabel = new JLabel(" Log Audit"); logAuditTitleLabel.setFont(titleFont); AreaChart areaChart = new AreaChart(m9.getLogCount(), m9.getSuccessCount(), m9.getFailCount()); ChartPanel thisChart = areaChart.drawAreaChart(); thisChart.setBackground(Color.white); thisChart.addChartMouseListener(new ChartMouseListener() { @Override/*from ww w . jav a2s . c o m*/ public void chartMouseClicked(ChartMouseEvent cme) { dashboardTabs.setSelectedIndex(9); } @Override public void chartMouseMoved(ChartMouseEvent cme) { } }); Metric9Panel.setBackground(Color.WHITE); Metric9Panel.setLayout(new BorderLayout()); Metric9Panel.add(logAuditTitleLabel, BorderLayout.NORTH); Metric9Panel.add(thisChart, BorderLayout.CENTER); Metric9Panel.setEnabled(false); String[] columns = { "Log Failure" }; JTable table = new JTable(counts, columns); table.setShowHorizontalLines(true); table.setRowHeight(40); table.setEnabled(false); JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); AuditPanel.setLayout(new BorderLayout()); JTextArea header = new JTextArea( "\nThrough the analysis of security logs, this page will show an audit of the attack attempts and " + "security breaches. The logs provide critical information related to system events that can be used to track suspicicous " + "activities.\n"); header.setLineWrap(true); header.setWrapStyleWord(true); header.setEditable(false); AuditPanel.add(header, BorderLayout.NORTH); AuditPanel.add(tableScrollPane, BorderLayout.CENTER); }
From source file:techtonic.Techtonic.java
private void btnSetPropertiesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetPropertiesActionPerformed XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, foreColor); renderer.setSeriesShapesVisible(0, false); plot.setRenderer(renderer);// w ww .j a v a 2s.co m ChartPanel cp = new ChartPanel(chart); System.out.println("opacity: " + cp.isOpaque()); cp.setBackground(bgColor); setFreeChart(chart); setDisplayArea(cp); }
From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java
/** * Updates the charts.//from w ww .j a va 2s . c o m */ @SuppressWarnings({ "unchecked", "rawtypes" }) private void updateCharts() { for (int i = 0; i < listOfChartPanels.size(); i++) { JPanel panel = listOfChartPanels.get(i); panel.removeAll(); final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) { private static final long serialVersionUID = -6953213567063104487L; @Override public Dimension getPreferredSize() { return DIMENSION_CHART_PANEL_ENLARGED; } }; chartPanel.setPopupMenu(null); chartPanel.setBackground(COLOR_TRANSPARENT); chartPanel.setOpaque(false); chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter); panel.add(chartPanel, BorderLayout.CENTER); JPanel openChartPanel = new JPanel(new GridBagLayout()); openChartPanel.setOpaque(false); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 1.0; gbc.weighty = 1.0; JButton openChartButton = new JButton(OPEN_CHART_ACTION); openChartButton.setOpaque(false); openChartButton.setContentAreaFilled(false); openChartButton.setBorderPainted(false); openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter); openChartButton.setHorizontalAlignment(SwingConstants.LEFT); openChartButton.setHorizontalTextPosition(SwingConstants.LEFT); openChartButton.setIcon(null); Font font = openChartButton.getFont(); Map attributes = font.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f)); openChartPanel.add(openChartButton, gbc); panel.add(openChartPanel, BorderLayout.SOUTH); panel.revalidate(); panel.repaint(); } }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_//from w w w . j av a 2 s . c om * * @param g _more_ * @param comp _more_ */ public void paintDashboardAfter(Graphics g, JComponent comp) { Graphics2D g2 = (Graphics2D) g; AffineTransform oldTransform = g2.getTransform(); Rectangle b = dashboardLbl.getBounds(); int w = dashboardImage.getWidth(null); int h = dashboardImage.getHeight(null); Point ul = new Point(b.width / 2 - w / 2, b.height - h); int ptsIdx = 0; try { pipPanel.setPreferredSize(new Dimension(dialPts[ptsIdx][2], dialPts[ptsIdx][3])); pipFrame.setSize(dialPts[ptsIdx][2], dialPts[ptsIdx][3]); pipPanel.doLayout(); pipPanel.validate(); pipFrame.pack(); pipPanel.resetDrawBounds(); pipPanel.redraw(); } catch (Exception ignore) { } JLabel locLbl = null; if (lastLocation != null) { try { locLbl = new JLabel("<html><table width=100%><tr><td align=right> Lat:</td></td>" + getIdv().getDisplayConventions().formatLatLon(getLat(lastLocation)) + "</td></tr>" + "<tr><td align=right> Lon:</td></td>" + getIdv().getDisplayConventions().formatLatLon(getLon(lastLocation)) + "</td></tr>" + "<tr><td align=right> Alt:</td></td>" + getIdv().getDisplayConventions().formatDistance(getAlt(lastLocation)) + "</table>"); } catch (Exception ignore) { } } if (locLbl == null) { locLbl = new JLabel( "<html><table width=100%><tr><td align=right> Lat:</td></td>N/A </td></tr><tr><td align=right> Lon:</td></td>N/A </td></tr><tr><td align=right> Alt:</td></td>N/A </table>"); } locLbl.setOpaque(true); locLbl.setBackground(Color.white); DefaultValueDataset headingDataset = new DefaultValueDataset(new Double(currentHeading)); CompassPlot plot = new CompassPlot(headingDataset); plot.setSeriesNeedle(0); plot.setSeriesPaint(0, Color.red); plot.setSeriesOutlinePaint(0, Color.red); JFreeChart chart = new JFreeChart("", plot); ChartPanel compassPanel = new ChartPanel(chart); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundImageAlpha(0.0f); chart.setBackgroundPaint(new Color(255, 255, 255, 0)); compassPanel.setBackground(new Color(255, 255, 255, 0)); compassPanel.setPreferredSize(dialDimension); // compassPanel.setSize(new Dimension(100,100)); g2.setTransform(oldTransform); pipRect = drawDial(g2, pipPanel, ptsIdx++, ul); JFrame dummyFrame = new JFrame(""); dummyFrame.setContentPane(compassPanel); dummyFrame.pack(); g2.setTransform(oldTransform); drawDial(g2, compassPanel, ptsIdx++, ul); g2.setTransform(oldTransform); dummyFrame.setContentPane(locLbl); dummyFrame.pack(); drawDial(g2, locLbl, ptsIdx++, ul); if (showReadout) { for (JComponent dial : dials) { dummyFrame.setContentPane(dial); dummyFrame.pack(); g2.setTransform(oldTransform); drawDial(g2, dial, ptsIdx++, ul); } } g2.setTransform(oldTransform); }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_//from ww w. j ava 2 s . c om * * @param pt1 _more_ * * @throws Exception _more_ */ protected void processReadout(FlythroughPoint pt1) throws Exception { Font font = new Font("Dialog", Font.BOLD, 22); dials = new ArrayList<JComponent>(); if ((readoutLabel == null) || (pt1 == null)) { return; } List<ReadoutInfo> samples = new ArrayList<ReadoutInfo>(); readoutLabel.setText(readout.getReadout(pt1.getEarthLocation(), showReadout, true, samples)); if (!showReadout) { return; } List comps = new ArrayList(); for (FlythroughDecorator decorator : decorators) { decorator.handleReadout(pt1, samples); } for (ReadoutInfo info : samples) { Real r = info.getReal(); if (r == null) { continue; } Unit unit = info.getUnit(); if (unit == null) { unit = r.getUnit(); } String name = ucar.visad.Util.cleanTypeName(r.getType()); String unitSuffix = ""; if (unit != null) { unitSuffix = " [" + unit + "]"; } double v = r.getValue(unit); if (v == v) { v = Misc.parseNumber(Misc.format(v)); } JLabel label = new JLabel(name.replace("_", " ")); label.setFont(font); DefaultValueDataset dataset = new DefaultValueDataset(new Double(v)); MeterPlot plot = new MeterPlot(dataset); if (info.getRange() != null) { Range range = info.getRange(); plot.setRange(new org.jfree.data.Range(range.getMin(), range.getMax())); } if (unit != null) { plot.setUnits(unit.toString()); } else { plot.setUnits(""); } plot.setDialBackgroundPaint(Color.white); plot.setTickLabelsVisible(true); plot.setValueFont(font); plot.setTickLabelFont(font); plot.setTickLabelPaint(Color.darkGray); plot.setTickPaint(Color.black); plot.setValuePaint(Color.black); JFreeChart chart = new JFreeChart("", plot); TextTitle title = new TextTitle(" " + label.getText() + " ", font); title.setBackgroundPaint(Color.gray); title.setPaint(Color.white); chart.setTitle(title); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(dialDimension); chartPanel.setSize(new Dimension(150, 150)); plot.setBackgroundPaint(new Color(255, 255, 255, 0)); plot.setBackgroundImageAlpha(0.0f); chart.setBackgroundPaint(new Color(255, 255, 255, 0)); chartPanel.setBackground(new Color(255, 255, 255, 0)); comps.add(chartPanel); dials.add(chartPanel); } readoutDisplay.removeAll(); updateDashboard(); }