List of usage examples for java.awt Color gray
Color gray
To view the source code for java.awt Color gray.
Click Source Link
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.PlateHeatMapController.java
/** * Plot the z-scores: simple scatterplot *//*from w w w . j a va 2s. co m*/ private void plotZScores() { XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); Map<Well, Double> map = computeZScoresForMap(); List<PlateCondition> plateConditionList = trackCoordinatesController.getPlateConditionList(); for (int i = 0; i < plateConditionList.size(); i++) { // current condition PlateCondition condition = plateConditionList.get(i); XYSeries series = new XYSeries(i + "-" + condition); for (int j = 0; j < condition.getSingleCellAnalyzedWells().size(); j++) { // current well Well well = condition.getSingleCellAnalyzedWells().get(j); series.add(i + 1, map.get(well)); } xySeriesCollection.addSeries(series); } JFreeChart jfreechart = ChartFactory.createScatterPlot("z*-score", "condition number", "z*-score", xySeriesCollection, PlotOrientation.VERTICAL, false, true, false); JFreeChartUtils.setupXYPlot(jfreechart.getXYPlot()); jfreechart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // line for the median speed ValueMarker marker = new ValueMarker(0); marker.setPaint(Color.GRAY); Stroke dashedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 1.0f, 3.0f }, 0.0f); marker.setStroke(dashedStroke); jfreechart.getXYPlot().addRangeMarker(marker); marker = new ValueMarker(3); marker.setPaint(Color.GRAY); marker.setStroke(dashedStroke); jfreechart.getXYPlot().addRangeMarker(marker); marker = new ValueMarker(-3); marker.setPaint(Color.GRAY); marker.setStroke(dashedStroke); jfreechart.getXYPlot().addRangeMarker(marker); XYItemRenderer renderer = jfreechart.getXYPlot().getRenderer(); for (int i = 0; i < xySeriesCollection.getSeriesCount(); i++) { // plot lines according to conditions indexes int colorIndex = i % GuiUtils.getAvailableColors().length; Color color = GuiUtils.getAvailableColors()[colorIndex]; color = new Color(color.getRed(), color.getGreen(), color.getBlue(), 127); renderer.setSeriesPaint(i, color); renderer.setSeriesShape(i, new Ellipse2D.Double(0, 0, 10, 10)); } zScoreChartPanel.setChart(jfreechart); }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addWeather() { int nyr = utils.getNYR(); XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }/*w w w. jav a 2 s . com*/ } XYSeries rainSeries = new XYSeries("RAIN"); double[][] RAIN = utils.getRain(); for (int i = 0; i < 10/*RAIN.length*/; i++) { for (int j = 0; j < 10/*RAIN[0].length*/; j++) { rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); dataset.addSeries(rainSeries); JFreeChart chart = ChartFactory.createXYLineChart("Weather Data", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Weather", panel); }
From source file:playground.dgrether.events.handlers.DgGeoFilteredLegHistogram.java
private JFreeChart getGraphic(final ModeData modeData, final String modeName) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries departuresSerie = new XYSeries("departures", false, true); final XYSeries arrivalsSerie = new XYSeries("arrivals", false, true); final XYSeries onRouteSerie = new XYSeries("en route", false, true); int onRoute = 0; for (int i = 0; i < modeData.countsDep.length; i++) { onRoute = onRoute + modeData.countsDep[i] - modeData.countsArr[i] - modeData.countsStuck[i]; double hour = i * this.binSizeSeconds / 60.0 / 60.0; departuresSerie.add(hour, modeData.countsDep[i]); arrivalsSerie.add(hour, modeData.countsArr[i]); onRouteSerie.add(hour, onRoute); }/* w ww . j a v a 2s . com*/ xyData.addSeries(departuresSerie); xyData.addSeries(arrivalsSerie); xyData.addSeries(onRouteSerie); final JFreeChart chart = ChartFactory.createXYStepChart( "Leg Histogram, " + modeName + ", it." + this.iteration, "time", "# vehicles", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); return chart; }
From source file:net.fenyo.gnetwatch.GUI.GenericSrcComponent.java
/** * Paints the chart.// ww w . ja v a2 s. c o m * @param now current time. * @return void. */ // AWT thread // AWT thread << sync_value_per_vinterval << events public void paintChart(final long now) { backing_g.setClip(axis_margin_left + 1, axis_margin_top, dimension.width - axis_margin_left - axis_margin_right - 1, dimension.height - axis_margin_top - axis_margin_bottom); synchronized (events) { final int npoints = events.size(); final int point_x[] = new int[npoints]; final int point_y[] = new int[npoints]; final int point_y1[] = new int[npoints]; final int point_y2[] = new int[npoints]; final int point_y3[] = new int[npoints]; final int point_y4[] = new int[npoints]; final int point_y5[] = new int[npoints]; final int point_y6[] = new int[npoints]; final int point_y7[] = new int[npoints]; final int point_y8[] = new int[npoints]; final int point_y9[] = new int[npoints]; final int point_y10[] = new int[npoints]; final long time_to_display = now - now % _getDelayPerInterval(); final int pixels_offset = (pixels_per_interval * (int) (now % _getDelayPerInterval())) / (int) _getDelayPerInterval(); final int last_interval_pos = dimension.width - axis_margin_right - pixels_offset; for (int i = 0; i < events.size(); i++) { final EventGenericSrc event = (EventGenericSrc) events.get(i); final long xpos = ((long) last_interval_pos) + (((long) pixels_per_interval) * (event.getDate().getTime() - time_to_display)) / _getDelayPerInterval(); if (xpos < -1000) point_x[i] = -1000; else if (xpos > 1000 + dimension.width) point_x[i] = 1000 + dimension.width; else point_x[i] = (int) xpos; // cast to double to avoid overflow on int that lead to wrong results point_y[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getIntValue() / value_per_vinterval); point_y1[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue1() / value_per_vinterval); point_y2[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue2() / value_per_vinterval); point_y3[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue3() / value_per_vinterval); point_y4[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue4() / value_per_vinterval); point_y5[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue5() / value_per_vinterval); point_y6[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue6() / value_per_vinterval); point_y7[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue7() / value_per_vinterval); point_y8[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue8() / value_per_vinterval); point_y9[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue9() / value_per_vinterval); point_y10[i] = (int) (dimension.height - axis_margin_bottom - pixels_per_vinterval * (double) event.getValue10() / value_per_vinterval); } backing_g.setColor(Color.GREEN); backing_g.drawPolyline(point_x, point_y, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y[i] - 2, 4, 4); backing_g.setColor(Color.WHITE); backing_g.drawPolyline(point_x, point_y1, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y1[i] - 2, 4, 4); backing_g.setColor(Color.BLUE); backing_g.drawPolyline(point_x, point_y2, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y2[i] - 2, 4, 4); backing_g.setColor(Color.GRAY); backing_g.drawPolyline(point_x, point_y3, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y3[i] - 2, 4, 4); backing_g.setColor(Color.YELLOW); backing_g.drawPolyline(point_x, point_y4, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y4[i] - 2, 4, 4); backing_g.setColor(Color.ORANGE); backing_g.drawPolyline(point_x, point_y5, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y5[i] - 2, 4, 4); backing_g.setColor(Color.CYAN); backing_g.drawPolyline(point_x, point_y6, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y6[i] - 2, 4, 4); backing_g.setColor(Color.MAGENTA); backing_g.drawPolyline(point_x, point_y7, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y7[i] - 2, 4, 4); backing_g.setColor(Color.LIGHT_GRAY); backing_g.drawPolyline(point_x, point_y8, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y8[i] - 2, 4, 4); backing_g.setColor(Color.PINK); backing_g.drawPolyline(point_x, point_y9, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y9[i] - 2, 4, 4); backing_g.setColor(Color.RED); backing_g.drawPolyline(point_x, point_y10, events.size()); for (int i = 0; i < events.size(); i++) backing_g.drawRect(point_x[i] - 2, point_y10[i] - 2, 4, 4); int cnt = 1; int cnt2 = 1; if (events.size() > 0) for (final String str : ((EventGenericSrc) events.get(0)).getUnits().split(";")) { if (str.length() > 0) { switch (cnt) { case 1: backing_g.setColor(Color.WHITE); break; case 2: backing_g.setColor(Color.BLUE); break; case 3: backing_g.setColor(Color.GRAY); break; case 4: backing_g.setColor(Color.YELLOW); break; case 5: backing_g.setColor(Color.ORANGE); break; case 6: backing_g.setColor(Color.CYAN); break; case 7: backing_g.setColor(Color.MAGENTA); break; case 8: backing_g.setColor(Color.LIGHT_GRAY); break; case 9: backing_g.setColor(Color.PINK); break; case 10: backing_g.setColor(Color.RED); break; } backing_g.fillRect(dimension.width - axis_margin_right - 150, 50 - 5 + 13 * cnt2, 20, 3); backing_g.setColor(Color.WHITE); backing_g.drawString(str, dimension.width - axis_margin_right - 150 + 22, 50 + 13 * cnt2); cnt2++; } cnt++; } backing_g.setClip(null); } }
From source file:visualizer.datamining.dataanalysis.CreateLineGraph.java
private JFreeChart createChart(XYDataset xydataset, String title, String xtitle, String ytitle) { JFreeChart chart = ChartFactory.createXYLineChart(title, xtitle, ytitle, xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE, Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW }, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setDrawOutlines(true); return chart; }
From source file:flexflux.analyses.result.PP2DResult.java
public void plot() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // one chart by group Map<Integer, Integer> correspGroup = new HashMap<Integer, Integer>(); XYSeriesCollection dataset = new XYSeriesCollection(); int index = 0; XYSeries series = new XYSeries(""); for (double point : fluxValues) { series.add(point, resultValues.get(point)); correspGroup.put(index, pointIndex.get(point)); index++;/*from www . jav a 2 s . co m*/ } dataset.addSeries(series); if (!expValues.isEmpty()) { XYSeries expSeries = new XYSeries("Experimental values"); if (!expValues.isEmpty()) { for (Double d : expValues.keySet()) { for (Double d2 : expValues.get(d)) { expSeries.add(d, d2); } } } dataset.addSeries(expSeries); } final JFreeChart chart = ChartFactory.createXYLineChart("", // chart // title reacName, // domain axis label objName, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); XYLineAndShapeRenderer renderer = new MyRenderer(true, false, correspGroup); plot.setRenderer(0, renderer); if (!expValues.isEmpty()) { renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesPaint(1, Color.BLUE); } ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); JPanel fvaPanel = new JPanel(); fvaPanel.setLayout(new BoxLayout(fvaPanel, BoxLayout.PAGE_AXIS)); for (int i = 1; i <= groupIndex.size(); i++) { Color color = COLORLIST[i % COLORLIST.length]; JPanel groupPanel = new JPanel(); groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.PAGE_AXIS)); List<BioEntity> newEssentialReactions = comparator.getNewEssentialEntities().get(i); List<BioEntity> noLongerEssentialReactions = comparator.getNoLongerEssentialEntities().get(i); JPanel colorPanel = new JPanel(); colorPanel.setBackground(color); groupPanel.add(colorPanel); groupPanel.add(new JLabel( "Phenotypic phase " + i + ", " + newEssentialReactions.size() + " new essential reactions")); fvaPanel.add(groupPanel); if (newEssentialReactions.size() > 0) { fvaPanel.add(new JScrollPane(comparator.getNewEssentialEntitiesPanel().get(i))); } fvaPanel.add(new JLabel("Phenotypic phase " + i + ", " + noLongerEssentialReactions.size() + " no longer essential reactions")); if (noLongerEssentialReactions.size() > 0) { fvaPanel.add(fvaPanel.add(new JScrollPane(comparator.getNoLongerEssentialEntitiesPanel().get(i)))); } } JScrollPane fvaScrollPane = new JScrollPane(fvaPanel); JFrame frame = new JFrame("Phenotypic phase analysis results"); if (expValues.size() > 0) { frame.setTitle("Pareto analysis two dimensions results"); } if (groupIndex.size() > 0) { JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, fvaScrollPane); frame.setContentPane(splitPane); frame.setSize(600, 1000); } else { frame.setContentPane(panel); frame.setSize(600, 600); } panel.setPreferredSize(new Dimension(600, 600)); panel.setMinimumSize(new Dimension(600, 600)); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java
private void initComponents() { scrollPane = new javax.swing.JScrollPane(); scrollPane.getHorizontalScrollBar().setUnitIncrement(5); scrollPane.getVerticalScrollBar().setUnitIncrement(5); pnlInScroll = new javax.swing.JPanel(); pnlPage = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); pnlLinks = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jPanel6 = new javax.swing.JPanel(); jPanel7 = new javax.swing.JPanel(); jPanel8 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel9 = new javax.swing.JPanel(); lblPage = new PageRenderer(); setMinimumSize(new java.awt.Dimension(450, 150)); setPreferredSize(new java.awt.Dimension(450, 150)); setLayout(new java.awt.BorderLayout()); addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent evt) { pnlMainComponentResized(evt); }/*from w ww .ja v a 2s . co m*/ }); //scrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); //scrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); pnlInScroll.setLayout(new java.awt.GridBagLayout()); pnlPage.setLayout(new java.awt.BorderLayout()); pnlPage.setMinimumSize(new java.awt.Dimension(100, 100)); pnlPage.setPreferredSize(new java.awt.Dimension(100, 100)); jPanel4.setLayout(new java.awt.GridBagLayout()); jPanel4.setMinimumSize(new java.awt.Dimension(100, 120)); jPanel4.setPreferredSize(new java.awt.Dimension(100, 120)); pnlLinks.setLayout(null); pnlLinks.setMinimumSize(new java.awt.Dimension(5, 5)); pnlLinks.setPreferredSize(new java.awt.Dimension(5, 5)); pnlLinks.setOpaque(false); pnlLinks.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { pnlLinksMousePressed(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { pnlLinksMouseReleased(evt); } }); pnlLinks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseDragged(java.awt.event.MouseEvent evt) { pnlLinksMouseDragged(evt); } }); GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; jPanel4.add(pnlLinks, gridBagConstraints); jPanel5.setBackground(java.awt.Color.gray); jPanel5.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel5.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; jPanel4.add(jPanel5, gridBagConstraints); jPanel6.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel6.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; jPanel4.add(jPanel6, gridBagConstraints); jPanel7.setBackground(java.awt.Color.gray); jPanel7.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel7.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel4.add(jPanel7, gridBagConstraints); jPanel8.setBackground(java.awt.Color.gray); jPanel8.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel8.setPreferredSize(new java.awt.Dimension(5, 5)); jLabel1.setText("jLabel1"); jPanel8.add(jLabel1); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; jPanel4.add(jPanel8, gridBagConstraints); jPanel9.setMinimumSize(new java.awt.Dimension(5, 5)); jPanel9.setPreferredSize(new java.awt.Dimension(5, 5)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; jPanel4.add(jPanel9, gridBagConstraints); lblPage.setBackground(java.awt.Color.white); lblPage.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0))); lblPage.setOpaque(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jPanel4.add(lblPage, gridBagConstraints); pnlPage.add(jPanel4, java.awt.BorderLayout.CENTER); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); pnlInScroll.add(pnlPage, gridBagConstraints); scrollPane.setViewportView(pnlInScroll); add(scrollPane, java.awt.BorderLayout.CENTER); }
From source file:org.gephi.ui.utils.ChartsUtils.java
/** * Build new Scatter plot. Appearance can be changed later with the other methods of ChartsUtils. * @param data Data for the plot/*from ww w . ja v a 2 s . c o m*/ * @param title Title for the chart * @param xLabel Text for x label * @param yLabel Text for y label * @param useLines Indicates if lines have to be drawn instead of shapes * @param useLinearRegression Indicates if the scatter plot has to have linear regreesion line drawn * @return Scatter plot for the data and appearance options */ public static JFreeChart buildScatterPlot(final XYSeriesCollection data, final String title, final String xLabel, final String yLabel, final boolean useLines, final boolean useLinearRegression) { JFreeChart scatterPlot = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) scatterPlot.getPlot(); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinePaint(java.awt.Color.GRAY); plot.setRangeGridlinePaint(java.awt.Color.GRAY); setScatterPlotLinesEnabled(scatterPlot, useLines); setScatterPlotLinearRegressionEnabled(scatterPlot, useLinearRegression); return scatterPlot; }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java
/** * Creates a <tt>ChatPanel</tt> which is added to the given chat window. * * @param chatContainer The parent window of this chat panel. *///from w ww . j a va 2s.c om public ChatPanel(ChatContainer chatContainer) { super(new BorderLayout()); this.chatContainer = chatContainer; this.conversationPanel = new ChatConversationPanel(this); this.conversationPanel.setPreferredSize(new Dimension(400, 200)); this.conversationPanel.getChatTextPane().setTransferHandler(new ChatTransferHandler(this)); this.conversationPanelContainer.add(conversationPanel, BorderLayout.CENTER); this.conversationPanelContainer.setBackground(Color.WHITE); initTypingNotificationLabel(conversationPanelContainer); topPanel.setBackground(Color.WHITE); topPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.GRAY)); this.writeMessagePanel = new ChatWritePanel(this); this.messagePane.setBorder(null); this.messagePane.setOpaque(false); this.messagePane.addPropertyChangeListener(new DividerLocationListener()); this.messagePane.setDividerSize(3); this.messagePane.setResizeWeight(1.0D); this.messagePane.setBottomComponent(writeMessagePanel); this.messagePane.setTopComponent(topPanel); this.add(messagePane, BorderLayout.CENTER); if (OSUtils.IS_MAC) { setOpaque(true); setBackground(new Color(GuiActivator.getResources().getColor("service.gui.MAC_PANEL_BACKGROUND"))); } this.addComponentListener(new TabSelectionComponentListener()); }
From source file:com.bdb.weather.display.current.WindGauge.java
/** * Constructor.//w ww . j av a2 s. c o m */ public WindGauge() { this.setPrefSize(200.0, 200.0); lastHeading = 0.0; lastSpeed = 0.0; plot = new DialPlot(); for (int i = 0; i < WIND_DIR_ITEMS; i++) { datasets[i] = new DefaultValueDataset(); plot.setDataset(WIND_DIR_DATASET_INDEX_BASE + i, datasets[i]); } plot.setDataset(WIND_SPEED_DATASET_INDEX, speedDataset); plot.setDataset(WIND_GUST_DATASET_INDEX, gustDataset); plot.setDataset(MAX_WIND_SPEED_DATASET_INDEX, maxSpeedDataset); plot.setDataset(MAX_WIND_GUST_DATASET_INDEX, maxGustDataset); plot.addLayer( new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue))); StandardDialScale scale = new StandardDialScale(0.0, 360.0, 90.0, -360.0, 45.0, 1); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.9); scale.setTickLabelFormatter(new CompassHeadingFormat()); scale.setTickLabelOffset(0.06); scale.setMajorTickPaint(new Color(0, 0, 0, 0)); scale.setTickLabelPaint(Color.BLACK); scale.setMinorTickLength(scale.getMajorTickLength()); scale.setMinorTickStroke(scale.getMajorTickStroke()); plot.addScale(WIND_DIR_SCALE, scale); scale = new StandardDialScale(0.0, 50.0, 225.0, -270.0, 10.0, 9); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.4); scale.setTickLabelFormatter(new DecimalFormat("##")); scale.setTickLabelOffset(.15); scale.setTickLabelPaint(Color.BLACK); plot.addScale(WIND_SPEED_SCALE, scale); DialPointer.Pointer pointer; for (int i = 1; i < WIND_DIR_ITEMS; i++) { pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE + i, false); pointer.setOutlinePaint(Color.RED); plot.addPointer(pointer); } plot.setDialFrame(new StandardDialFrame()); pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE, true); Color fill = Color.CYAN; pointer.setFillPaint(fill); pointer.setOutlinePaint(Color.BLACK); plot.addPointer(pointer); DialCap cap = new DialCap(); plot.setCap(cap); DialPointer.Pin speedPin = new DialPointer.Pin(WIND_SPEED_DATASET_INDEX); speedPin.setPaint(WIND_SPEED_PIN_COLOR); speedPin.setRadius(WIND_SPEED_PIN_RADIUS); speedPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(speedPin); DialPointer.Pin gustPin = new DialPointer.Pin(WIND_GUST_DATASET_INDEX); gustPin.setPaint(WIND_GUST_PIN_COLOR); gustPin.setRadius(WIND_GUST_PIN_RADIUS); gustPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(gustPin); DialPointer.Pin maxSpeedPin = new DialPointer.Pin(MAX_WIND_SPEED_DATASET_INDEX); maxSpeedPin.setPaint(WIND_SPEED_PIN_COLOR); maxSpeedPin.setRadius(MAX_WIND_SPEED_PIN_RADIUS); maxSpeedPin .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(maxSpeedPin); DialPointer.Pin maxGustPin = new DialPointer.Pin(MAX_WIND_GUST_DATASET_INDEX); maxGustPin.setPaint(WIND_GUST_PIN_COLOR); maxGustPin.setRadius(MAX_WIND_GUST_PIN_RADIUS); maxGustPin .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(maxGustPin); speedAnnotation.setAngle(270.0); speedAnnotation.setRadius(.35); speedAnnotation.setPaint(Color.cyan); plot.addLayer(speedAnnotation); double angle = speedAnnotation.getAngle(); double radius = speedAnnotation.getRadius(); avgAnnotation.setPaint(Color.cyan); avgAnnotation.setAngle(angle); avgAnnotation.setRadius(radius + .1); plot.addLayer(avgAnnotation); for (int i = 0; i < WIND_DIR_ITEMS; i++) plot.mapDatasetToScale(WIND_DIR_DATASET_INDEX_BASE + i, WIND_DIR_SCALE); plot.mapDatasetToScale(WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(MAX_WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(MAX_WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE); StandardDialRange range = new StandardDialRange(0.0, 360.0, Color.BLACK); range.setInnerRadius(.70); range.setOuterRadius(.72); range.setScaleIndex(WIND_DIR_SCALE); plot.addLayer(range); JFreeChart chart = new JFreeChart(plot); chart.setBackgroundPaint(Color.GRAY); chartViewer = new ChartViewer(chart); //chartViewer.setMinHeight(100); //chartViewer.setMinWidth(100); //chartViewer.setMaxHeight(400); //chartViewer.setMaxWidth(400); //chartViewer.setBackground(Color.GRAY); //chartViewer.setBorder(new BevelBorder(BevelBorder.RAISED)); this.setCenter(chartViewer); this.setTop(title); BorderPane.setAlignment(title, Pos.CENTER); title.textProperty().bind(titleProperty); setTitle("Wind"); timeline.setCycleCount(9); timeline.setOnFinished((event) -> { datasets[0].setValue(currentHeading); speedDataset.setValue(currentSpeed); lastHeading = currentHeading; lastSpeed = currentSpeed; }); }