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:com.raphfrk.craftproxyclient.gui.CraftProxyGUI.java
public CraftProxyGUI(String buildId) { pf = new PropertiesFile("CraftProxyClientGUI.txt"); try {//from w ww . ja va2 s . c o m pf.load(); } catch (IOException e) { JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to open settings file"); } String defaultHostname = pf.getString("connect_hostname", ""); int defaultPort = pf.getInt("connect_port", 20000); int listenPort = pf.getInt("listen_port", 25565); int desired = pf.getInt("cache_size", 48); try { pf.save(); } catch (IOException e) { JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to save settings file"); } setTitle("CraftProxyClient Local (" + buildId + ")"); setSize(500, 375); setLocation(40, 150); topPanel.setLayout(new BorderLayout()); topPanel.setBorder(new TitledBorder("Remote Server")); topPanel.setBackground(Color.WHITE); secondPanel.setLayout(new BorderLayout()); secondPanel.setBorder(new TitledBorder("Local Server")); secondPanel.setBackground(Color.WHITE); serverName = new JTextField(defaultHostname, 20); TitledBorder border = new TitledBorder("Name"); serverName.setBorder(border); serverName.addActionListener(this); portNum = new JTextField(Integer.toString(defaultPort), 6); border = new TitledBorder("Port"); portNum.setBorder(border); portNum.addActionListener(this); localServerName = new JLabel("localhost"); localServerName.setBackground(Color.GRAY); border = new TitledBorder("Name"); localServerName.setBorder(border); localServerPortnum = new JTextField(Integer.toString(listenPort), 6); border = new TitledBorder("Port"); localServerPortnum.setBorder(border); localServerPortnum.addActionListener(this); topPanel.add(serverName, BorderLayout.CENTER); topPanel.add(portNum, BorderLayout.LINE_END); secondPanel.setLayout(new BorderLayout()); secondPanel.add(localServerName, BorderLayout.CENTER); secondPanel.add(localServerPortnum, BorderLayout.LINE_END); combinedTop.setLayout(new BorderLayout()); combinedTop.add(topPanel, BorderLayout.CENTER); combinedTop.add(secondPanel, BorderLayout.SOUTH); currentSize = new JTextField("Unknown"); currentSize.setBorder(new TitledBorder("Current Size (MB)")); currentSize.setEditable(false); desiredSize = new JTextField(Integer.toString(desired)); desiredSize.setBorder(new TitledBorder("Max Size (MB)")); connect = new JButton(buttonText); connect.addActionListener(this); filePanel = new JPanel(); filePanel.setLayout(new BorderLayout()); JPanel fileLinePanel = new JPanel(); fileLinePanel.setBorder(new TitledBorder("Cache Size")); fileLinePanel.setLayout(new GridLayout(1, 3)); fileLinePanel.add(currentSize); fileLinePanel.add(desiredSize); filePanel.add(fileLinePanel, BorderLayout.CENTER); filePanel.add(connect, BorderLayout.PAGE_END); info = new JLabel(); border = new TitledBorder("Status"); info.setBorder(border); setLayout(new BorderLayout()); add(combinedTop, BorderLayout.PAGE_START); add(info, BorderLayout.CENTER); add(filePanel, BorderLayout.PAGE_END); this.setResizable(false); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.addWindowListener(this); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java
/** * Creates a chart./*w w w .j a va2 s . c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ public JFreeChart createChart() { //http://www.java2s.com/Code/Java/Chart/JFreeChartDualAxisDemo2.htm String xlabel = "Delay (ps)"; String ylabel = "Signal (DN)"; // create the chart with findmaxpoint results final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title xlabel, // x axis label ylabel, // y axis label findMaxpointData_, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); final XYPlot plot = chart.getXYPlot(); // deal with axes and add second dataset final NumberAxis yaxis1 = (NumberAxis) plot.getRangeAxis(); yaxis1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); yaxis1.setLabelFont(new Font("Dialog", Font.PLAIN, 10)); final NumberAxis yaxis2 = new NumberAxis(null); final NumberAxis xaxis = (NumberAxis) plot.getDomainAxis(); xaxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10)); xaxis.setLabelFont(new Font("Dialog", Font.PLAIN, 10)); plot.setRangeAxis(1, yaxis2); plot.setDataset(1, gatePositionData_); plot.mapDatasetToRangeAxis(1, 1); yaxis1.setRange(0, 5000); yaxis2.setRange(-1, 1); yaxis2.setTickLabelsVisible(false); xaxis.setRange(0, 16666); // deal with visuals final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(true, true); renderer1.setSeriesPaint(0, Color.RED); renderer1.setSeriesStroke(0, new BasicStroke(3)); // renderer1.setBaseShapesVisible(true); // renderer1.setSeriesShape(0, ShapeUtilities.createDiagonalCross(4,1)); plot.setRenderer(0, renderer1); // final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true); renderer2.setSeriesPaint(0, Color.CYAN); renderer2.setSeriesShapesFilled(0, Boolean.TRUE); renderer2.setBaseShapesVisible(true); renderer2.setShape(new Rectangle(-2, -100, 4, 200)); renderer2.setOutlineStroke(new BasicStroke(1)); renderer2.setOutlinePaint(Color.GRAY); renderer2.setUseOutlinePaint(true); plot.setRenderer(1, renderer2); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // return chart; }
From source file:org.matsim.counts.algorithms.graphs.CountsLoadCurveGraph.java
@Override public JFreeChart createChart(final int nbr) { String title = this.getChartTitle() + ", Iteration: " + this.iteration_; this.chart_ = ChartFactory.createBarChart(title, "Hour", "Volumes [veh/h]", this.dataset0, PlotOrientation.VERTICAL, true, // legend? true, // tooltips? false // URLs? );/*from w w w . j ava 2 s . c om*/ CategoryPlot plot = this.chart_.getCategoryPlot(); // plot.getRangeAxis().setRange(0.0, 10000.0); // do not set a fixed range for the single link graphs plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); // BarRenderer renderer=(BarRenderer) plot.getRenderer(); BarRenderer renderer = new BarRenderer(); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setSeriesOutlinePaint(1, Color.black); renderer.setSeriesPaint(0, Color.getHSBColor((float) 0.62, (float) 0.56, (float) 0.93)); // Color.orange gives a dirty yellow! renderer.setSeriesPaint(1, Color.getHSBColor((float) 0.1, (float) 0.79, (float) 0.89)); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); renderer.setItemMargin(0.0); // configure plot with light colors instead of the default 3D renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); this.chart_.setBackgroundPaint(Color.getHSBColor((float) 0.0, (float) 0.0, (float) 0.93)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setRangeGridlinesVisible(true); plot.setRenderer(0, renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); // TRRE: plot.setDataset(1, this.dataset1); plot.mapDatasetToRangeAxis(1, 1); final CategoryAxis axis1 = plot.getDomainAxis(); axis1.setCategoryMargin(0.25); // leave a gap of 25% between categories /* TRRE: final ValueAxis axis2 = new NumberAxis("Signed Rel. Error [%]"); plot.setRangeAxis(1, axis2); final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer2.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0)); renderer2.setSeriesPaint(0, Color.black); renderer2.setBaseStroke(new BasicStroke(2.5f)); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); */ return this.chart_; }
From source file:GeMSE.Visualization.ElbowPlot.java
public void Plot(ArrayList<Double[]> pvData, ArrayList<Double[]> dData, int cut) { double maxY = 0; float[] secYColor = new float[3]; Color.RGBtoHSB(153, 245, 255, secYColor); float[] priYColor = new float[3]; Color.RGBtoHSB(255, 255, 255, priYColor); float[] cutColor = new float[3]; Color.RGBtoHSB(255, 255, 0, cutColor); //create the series - add some dummy data XYSeries pvSeries = new XYSeries("Percentage of variance "); for (int i = 1; i < pvData.size(); i++) { pvSeries.add(pvData.get(i)[0], pvData.get(i)[1]); maxY = Math.max(maxY, pvData.get(i)[1]); }/* ww w .ja v a2 s . co m*/ XYSeries dSeries = new XYSeries("Percentage of differences between slopes "); for (int i = 0; i < dData.size(); i++) dSeries.add(dData.get(i)[0], dData.get(i)[1]); XYSeries cutSeries = new XYSeries("Cut "); cutSeries.add(cut, 0.0); cutSeries.add(cut, maxY); //create the datasets XYSeriesCollection pvDataSeries = new XYSeriesCollection(); pvDataSeries.addSeries(pvSeries); XYSeriesCollection cutDataSeries = new XYSeriesCollection(); cutDataSeries.addSeries(cutSeries); XYSeriesCollection dDataSeries = new XYSeriesCollection(); dDataSeries.addSeries(dSeries); //construct the plot XYPlot plot = new XYPlot(); plot.setDataset(0, pvDataSeries); plot.setDataset(1, cutDataSeries); plot.setDataset(2, dDataSeries); // use XYSplineRenderer if you want to smooth the lines. XYLineAndShapeRenderer pvRenderer = new XYLineAndShapeRenderer(); pvRenderer.setSeriesPaint(0, Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); BasicStroke dstroke = new BasicStroke(2.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 1.0f, 10.0f }, 0.0f); XYLineAndShapeRenderer dRenderer = new XYLineAndShapeRenderer(); dRenderer.setSeriesPaint(0, Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); dRenderer.setSeriesStroke(0, dstroke); BasicStroke cutStoke = new BasicStroke(4); // use XYSplineRenderer if you want to smooth the lines. //XYSplineRenderer cutRenderer = new XYSplineRenderer(); XYLineAndShapeRenderer cutRenderer = new XYLineAndShapeRenderer(); cutRenderer.setSeriesPaint(0, Color.getHSBColor(cutColor[0], cutColor[1], cutColor[2])); cutRenderer.setSeriesStroke(0, cutStoke); plot.setRenderer(0, pvRenderer); plot.setRenderer(1, cutRenderer); plot.setRenderer(2, dRenderer); plot.setRangeAxis(0, new NumberAxis("\n\nPercentage of Variance")); plot.setRangeAxis(1, new NumberAxis("Percentage of Difference Between Slopes")); plot.setDomainAxis(new NumberAxis("Number of Clusters\n\n")); //Map the data to the appropriate axis plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToRangeAxis(1, 0); plot.mapDatasetToRangeAxis(2, 1); float[] hsbValues = new float[3]; Color.RGBtoHSB(16, 23, 67, hsbValues); plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2])); Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14); Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12); Font legendFont = new Font("Dialog", Font.PLAIN, 14); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.white); plot.getDomainAxis().setLabelPaint(Color.white); plot.getDomainAxis().setLabelFont(axisLabelFont); plot.getDomainAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); plot.getRangeAxis().setLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2])); plot.getRangeAxis().setLabelFont(axisLabelFont); plot.getRangeAxis().setTickLabelFont(axisTickLabelFont); plot.getRangeAxis(1).setTickLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); plot.getRangeAxis(1).setLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2])); plot.getRangeAxis(1).setLabelFont(axisLabelFont); plot.getRangeAxis(1).setTickLabelFont(axisTickLabelFont); //generate the chart JFreeChart chart = new JFreeChart("\nSuggested number of clusters determined using Elbow method", getFont(), plot, true); chart.getTitle().setPaint(Color.white); chart.getLegend().setBackgroundPaint(Color.black); chart.getLegend().setItemPaint(Color.white); chart.getLegend().setPosition(RectangleEdge.BOTTOM); chart.getLegend().setItemFont(legendFont); float[] hsbValues2 = new float[3]; Color.RGBtoHSB(36, 43, 87, hsbValues2); chart.setBackgroundPaint(Color.getHSBColor(hsbValues2[0], hsbValues2[1], hsbValues2[2])); JPanel chartPanel = new ChartPanel(chart); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); chartPanel.setPreferredSize( new java.awt.Dimension((int) Math.round((gd.getDisplayMode().getWidth() * 1.5) / 3.0), (int) Math.round((gd.getDisplayMode().getHeight() * 1.5) / 3.0))); setContentPane(chartPanel); }
From source file:edu.mit.fss.examples.member.gui.CommSubsystemPanel.java
/** * Instantiates a new communications subsystem panel for a subsystem. * Signals are sent via the associated {@link federate}. * * @param federate the federate//ww w.j ava 2 s .co m * @param subsystem the subsystem */ public CommSubsystemPanel(Federate federate, CommSubsystem subsystem) { this.subsystem = subsystem; logger.trace("Creating and adding receiver panel."); receiverPanel = new ReceiverPanel(subsystem.getReceiver()); logger.trace("Adding receiver panel as an object listener."); listenerList.add(ObjectChangeListener.class, receiverPanel); addTab("Receiver", receiverPanel); logger.trace("Creating and adding transmitter panel."); transmitterPanel = new TransmitterPanel(federate, subsystem.getTransmitter()); logger.trace("Adding transmitter panel as an object listener."); listenerList.add(ObjectChangeListener.class, transmitterPanel); addTab("Transmitter", transmitterPanel); logger.trace("Creating and adding connectivity chart panel."); connectivityChart = ChartFactory.createTimeSeriesChart(null, "Time", "Connectivity", connectDataset, true, false, false); connectivityChart.setBackgroundPaint(getBackground()); if (connectivityChart.getPlot() instanceof XYPlot) { XYPlot xyPlot = (XYPlot) connectivityChart.getPlot(); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES); renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4)); xyPlot.setRenderer(renderer); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); } JPanel chartPanel = new JPanel(new BorderLayout()); chartPanel.add(new ChartPanel(connectivityChart), BorderLayout.CENTER); chartPanel.add(new JButton(exportAction), BorderLayout.SOUTH); addTab("Connectivity", chartPanel); }
From source file:domain.Grafica.java
public JFreeChart createChart(XYDataset dataset) { /*/*w ww. jav a2s .c o m*/ ///* NumberAxis numberaxis = new NumberAxis(""); numberaxis.setAutoRangeIncludesZero(false); DateAxis dateaxis = new DateAxis(""); NumberAxis numberaxis1 = new NumberAxis(""); numberaxis1.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(dataset, dateaxis, numberaxis1, xysplinerenderer); // xyplot.setBackgroundPaint(new Color(238, 242, 250));// // xyplot.setDomainGridlinePaint(new Color(255, 255, 255)); // xyplot.setRangeGridlinePaint(new Color(238, 242, 250)); xyplot.getRenderer().setSeriesPaint(0, Color.RED); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); renderer.setSeriesShapesVisible(0, true);//FIXME Dots // xyplot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, xyplot, false); jfreechart.setBackgroundPaint(Color.white); DateAxis axis = (DateAxis) xyplot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa")); xyplot.getRangeAxis().setUpperBound(maxPeso * 1.25); xyplot.getRangeAxis().setLowerBound(minPeso * 0.75); cargarImagen(); // xyplot.setBackgroundImage(i); //jfreechart.setBackgroundImage(i); return jfreechart; */ JFreeChart chart = ChartFactory.createTimeSeriesChart("", // title "Fecha/Hora", // x-axis label "Pesos(Kg.)", // y-axis label dataset, // data false, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.GRAY); plot.setRangeGridlinePaint(Color.GRAY); /* plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); */ plot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); } NumberAxis range = (NumberAxis) plot.getRangeAxis(); // range.setAutoRangeIncludesZero(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss")); plot.getRangeAxis().setUpperBound(maxPeso * 1.25); plot.getRangeAxis().setLowerBound(minPeso * 0.75); return chart; }
From source file:org.imos.abos.plot.JfreeChartDemo.java
public void createChartPanel() { dataset = createDataset();//from w ww . ja v a2 s . com chart = createChart(dataset); chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(new MouseClick()); chartPanel.setPreferredSize(new java.awt.Dimension(1024, 768)); chartPanel.setMouseZoomable(true, false); chart.addChangeListener(cc); plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.GRAY); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); chart.getLegend().setPosition(RectangleEdge.RIGHT); final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd HH:mm")); }
From source file:de.fuberlin.agcsw.heraclitus.graph.GraphAnalyse.java
private static void initJungViewer() { // Create Layout for Visualization Graph<JungVertex, JungEdge> g = new DirectedSparseMultigraph<JungVertex, JungEdge>(); KKLayout<JungVertex, JungEdge> l = new KKLayout<JungVertex, JungEdge>(g); l.setMaxIterations(100);//ww w.ja va2s . c o m vv = new VisualizationViewer<JungVertex, JungEdge>(l); vv.addComponentListener(new FrameComponentListener()); JungClickOnPickMouseListener lis = new JungClickOnPickMouseListener(); vv.addMouseListener(lis); vv.addMouseMotionListener(lis); vv.setDoubleBuffered(true); //init Mouse Picking DefaultModalGraphMouse gm = new DefaultModalGraphMouse(); gm.setMode(ModalGraphMouse.Mode.PICKING); vv.setGraphMouse(gm); Transformer<JungVertex, Paint> vertexPaint = new Transformer<JungVertex, Paint>() { public Paint transform(JungVertex v) { if (v.getUri() == null) { //this is a literal return Color.GRAY; } if (v.getLabel().startsWith("node")) { //this is a blank node return Color.orange; } return Color.RED; } }; Transformer<JungVertex, Shape> vertexShape = new Transformer<JungVertex, Shape>() { @Override public Shape transform(JungVertex v) { if (v.getLabel().startsWith("node")) { //this is a blank node Arc2D.Double arc = new Arc2D.Double(-15, -15, 30, 30, 0, 360, Arc2D.CHORD); return arc; } RoundRectangle2D.Double rec = new RoundRectangle2D.Double(-65, -12.5, 130, 25, 30, 30); return rec; } }; vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<JungVertex>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<JungEdge>()); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderContext().setVertexShapeTransformer(vertexShape); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); }
From source file:edu.cuny.cat.ui.ClockPanel.java
@Override public void setup(final ParameterDatabase parameters, final Parameter base) { clock = GameController.getInstance().getClock(); dataset = new DefaultValueDataset(); meterplot = new MyMeterPlot(dataset) { /**// w ww . j av a2 s. co m * */ private static final long serialVersionUID = 1L; @Override protected void drawValueLabel(final Graphics2D g2, final Rectangle2D area) { g2.setFont(getValueFont()); g2.setPaint(getValuePaint()); String valueStr = "No value"; if (dataset != null) { final Number n = dataset.getValue(); if (n != null) { if (n.intValue() == 0) { valueStr = "to start"; } else if (n.intValue() == clock.getGameLen() * clock.getDayLen()) { valueStr = "done"; } else { valueStr = "day " + (n.intValue() / clock.getDayLen()) + ", round " + (n.intValue() % clock.getDayLen()); } } } final float x = (float) area.getCenterX(); final float y = (float) area.getCenterY() + MeterPlot.DEFAULT_CIRCLE_SIZE; TextUtilities.drawAlignedString(valueStr, g2, x, y, TextAnchor.TOP_CENTER); } }; meterplot.setRange(new Range(0, clock.getDayLen() * clock.getGameLen())); meterplot.setNeedlePaint( parameters.getColorWithDefault(base.push(ClockPanel.P_NEEDLE), null, Color.darkGray)); meterplot.setDialBackgroundPaint(new Color(0, 255, 0, 64)); meterplot.setDialOutlinePaint(Color.gray); meterplot.setDialShape(DialShape.CHORD); meterplot.setMeterAngle(parameters.getIntWithDefault(base.push(ClockPanel.P_ANGLE), null, 260)); meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(clock.getDayLen()); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); meterplot.setUnits(""); meterplot.setTickLabelFormat(new NumberFormat() { /** * */ private static final long serialVersionUID = 1L; @Override public StringBuffer format(final double number, final StringBuffer toAppendTo, final FieldPosition pos) { return format((long) number, toAppendTo, pos); } @Override public StringBuffer format(final long number, final StringBuffer toAppendTo, final FieldPosition pos) { if (number % clock.getDayLen() == 0) { toAppendTo.append(String.valueOf(number / clock.getDayLen())); } return toAppendTo; } @Override public Number parse(final String source, final ParsePosition parsePosition) { return null; } }); final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, meterplot, false); final ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(parameters.getIntWithDefault(base.push(ClockPanel.P_WIDTH), null, 200), parameters.getIntWithDefault(base.push(ClockPanel.P_HEIGHT), null, 200))); add(panel, BorderLayout.CENTER); initIterationLabel(); initScoreReport(); }
From source file:org.matsim.counts.algorithms.graphs.CountsGEHCurveGraph.java
@Override public JFreeChart createChart(final int nbr) { String title = this.getChartTitle() + ", Iteration: " + this.iteration_; this.chart_ = ChartFactory.createBarChart(title, "Hour", "GEH", this.dataset, PlotOrientation.VERTICAL, false, // legend? false, // tooltips? false // URLs? );/* ww w. ja va2s . co m*/ CategoryPlot plot = this.chart_.getCategoryPlot(); // plot.getRangeAxis().setRange(0.0, 10000.0); // do not set a fixed range for the single link graphs plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); // BarRenderer renderer=(BarRenderer) plot.getRenderer(); // BarRenderer renderer = new BarRenderer(); /* * Chooses the color adaptive based on the value to be shown by a bar. * Values <= 5.0 are green, values >= 10 are red. In between the color is interpolated. */ BarRenderer renderer = new BarRenderer() { @Override public Paint getItemPaint(final int row, final int column) { double value = dataset.getValue(row, column).doubleValue(); if (value <= 5.0) return Color.green; else if (value >= 10) return Color.red; else { if (value < 7.5) { int mixed = mix(Color.yellow.getRGB(), Color.green.getRGB(), (7.5 - value) / 2.5); return new Color(mixed); } else { int mixed = mix(Color.red.getRGB(), Color.yellow.getRGB(), (10.0 - value) / 2.5); return new Color(mixed); } } // if (value <= 5.0) return Color.green; // else if (value >= 10) return Color.red; // else { // int mixed = mix(Color.red.getRGB(), Color.green.getRGB(), (10.0 - value) / 5.0); // return new Color(mixed); // } } }; renderer.setSeriesOutlinePaint(0, Color.black); renderer.setSeriesPaint(0, Color.getHSBColor((float) 0.62, (float) 0.56, (float) 0.93)); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer.setItemMargin(0.0); // configure plot with light colors instead of the default 3D renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); this.chart_.setBackgroundPaint(Color.getHSBColor((float) 0.0, (float) 0.0, (float) 0.93)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setRangeGridlinesVisible(true); plot.setRenderer(0, renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.mapDatasetToRangeAxis(1, 1); final CategoryAxis axis1 = plot.getDomainAxis(); axis1.setCategoryMargin(0.25); // leave a gap of 25% between categories return this.chart_; }