List of usage examples for java.awt Color PINK
Color PINK
To view the source code for java.awt Color PINK.
Click Source Link
From source file:org.mwc.debrief.editable.test.EditableTests.java
private Editable getEditable(IType type) { Editable editable = null;//from w ww. j a v a 2 s . c o m switch (type.getFullyQualifiedName()) { case "Debrief.Wrappers.SensorWrapper": SensorWrapper sensor = new SensorWrapper("tester"); final java.util.Calendar cal = new java.util.GregorianCalendar(2001, 10, 4, 4, 4, 0); // and create the list of sensor contact data items cal.set(2001, 10, 4, 4, 4, 0); sensor.add(new SensorContactWrapper("tester", new HiResDate(cal.getTime().getTime()), null, null, null, null, null, 1, sensor.getName())); cal.set(2001, 10, 4, 4, 4, 23); sensor.add(new SensorContactWrapper("tester", new HiResDate(cal.getTime().getTime()), null, null, null, null, null, 1, sensor.getName())); editable = sensor; break; case "MWC.GUI.Shapes.ChartFolio": editable = new ChartFolio(false, Color.white); break; case "org.mwc.cmap.naturalearth.wrapper.NELayer": editable = new NELayer(Activator.getDefault().getDefaultStyleSet()); break; case "MWC.GUI.VPF.CoverageLayer$ReferenceCoverageLayer": final LibrarySelectionTable LST = null; final DebriefFeatureWarehouse myWarehouse = new DebriefFeatureWarehouse(); final FeaturePainter fp = new FeaturePainter("libref", "Coastline"); fp.setVisible(true); editable = new CoverageLayer.ReferenceCoverageLayer(LST, myWarehouse, "libref", "libref", "Coastline", fp); break; case "MWC.GUI.Chart.Painters.ETOPOPainter": editable = new ETOPOPainter("etopo", null); break; case "MWC.GUI.ETOPO.ETOPO_2_Minute": editable = new ETOPO_2_Minute("etopo"); break; case "MWC.GUI.ExternallyManagedDataLayer": editable = new ExternallyManagedDataLayer("test", "test", "test"); break; case "MWC.GUI.Shapes.CircleShape": editable = new CircleShape(new WorldLocation(2d, 2d, 2d), 2d); break; case "Debrief.Wrappers.Track.SplittableLayer": editable = new SplittableLayer(true); break; case "org.mwc.debrief.satc_interface.data.SATC_Solution": final ISolversManager solvMgr = SATC_Activator.getDefault().getService(ISolversManager.class, true); final ISolver newSolution = solvMgr.createSolver("test"); editable = new SATC_Solution(newSolution); break; case "MWC.GUI.Shapes.PolygonShape": editable = new PolygonShape(null); break; case "ASSET.GUI.Painters.NoiseSourcePainter": editable = new ASSET.GUI.Painters.NoiseSourcePainter.PainterTest().getEditable(); break; case "ASSET.GUI.Painters.ScenarioNoiseLevelPainter": editable = new ASSET.GUI.Painters.ScenarioNoiseLevelPainter.NoiseLevelTest().getEditable(); break; case "ASSET.GUI.Workbench.Plotters.ScenarioParticipantWrapper": editable = new ScenarioParticipantWrapper(new SSN(12), null); break; case "Debrief.Wrappers.PolygonWrapper": // get centre of area WorldLocation centre = new WorldLocation(12, 12, 12); // create the shape, based on the centre final Vector<PolygonNode> path2 = new Vector<PolygonNode>(); final PolygonShape newShape = new PolygonShape(path2); // and now wrap the shape final PolygonWrapper theWrapper = new PolygonWrapper("New Polygon", newShape, PlainShape.DEFAULT_COLOR, null); // store the new point newShape.add(new PolygonNode("1", centre, (PolygonShape) theWrapper.getShape())); editable = theWrapper; break; case "Debrief.Wrappers.Track.AbsoluteTMASegment": WorldSpeed speed = new WorldSpeed(5, WorldSpeed.Kts); double course = 33; WorldLocation origin = new WorldLocation(12, 12, 12); HiResDate startTime = new HiResDate(11 * 60 * 1000); HiResDate endTime = new HiResDate(17 * 60 * 1000); editable = new AbsoluteTMASegment(course, speed, origin, startTime, endTime); break; case "Debrief.Wrappers.Track.RelativeTMASegment": speed = new WorldSpeed(5, WorldSpeed.Kts); course = 33; final WorldVector offset = new WorldVector(12, 12, 0); editable = new RelativeTMASegment(course, speed, offset, null); break; case "Debrief.Wrappers.Track.PlanningSegment": speed = new WorldSpeed(5, WorldSpeed.Kts); course = 33; final WorldDistance worldDistance = new WorldDistance(5, WorldDistance.MINUTES); editable = new PlanningSegment("test", course, speed, worldDistance, Color.WHITE); break; case "org.mwc.debrief.satc_interface.data.wrappers.BMC_Wrapper": BearingMeasurementContribution bmc = new BearingMeasurementContribution(); bmc.setName("Measured bearing"); bmc.setAutoDetect(false); editable = new BMC_Wrapper(bmc); break; case "org.mwc.debrief.satc_interface.data.wrappers.FMC_Wrapper": FrequencyMeasurementContribution fmc = new FrequencyMeasurementContribution(); fmc.setName("Measured frequence"); editable = new FMC_Wrapper(fmc); break; case "Debrief.Wrappers.SensorContactWrapper": origin = new WorldLocation(0, 0, 0); editable = new SensorContactWrapper("blank track", new HiResDate(new java.util.Date().getTime()), new WorldDistance(1, WorldDistance.DEGS), 55d, origin, java.awt.Color.red, "my label", 1, "theSensorName"); break; case "Debrief.Wrappers.FixWrapper": final Fix fx = new Fix(new HiResDate(12, 0), new WorldLocation(2d, 2d, 2d), 2d, 2d); final TrackWrapper tw = new TrackWrapper(); tw.setName("here ew arw"); FixWrapper ed = new FixWrapper(fx); ed.setTrackWrapper(tw); editable = ed; break; case "Debrief.Wrappers.ShapeWrapper": centre = new WorldLocation(2d, 2d, 2d); editable = new ShapeWrapper("new ellipse", new EllipseShape(centre, 0, new WorldDistance(0, WorldDistance.DEGS), new WorldDistance(0, WorldDistance.DEGS)), java.awt.Color.red, null); break; case "Debrief.GUI.Tote.Painters.PainterManager": final StepControl stepper = new Debrief.GUI.Tote.Swing.SwingStepControl(null, null, null, null, null, null); editable = new PainterManager(stepper); break; case "Debrief.Wrappers.TMAContactWrapper": origin = new WorldLocation(2, 2, 0); final HiResDate theDTG = new HiResDate(new java.util.Date().getTime()); final EllipseShape theEllipse = new EllipseShape(origin, 45, new WorldDistance(10, WorldDistance.DEGS), new WorldDistance(5, WorldDistance.DEGS)); theEllipse.setName("test ellipse"); editable = new TMAContactWrapper("blank sensor", "blank track", theDTG, origin, 5d, 6d, 1d, Color.pink, "my label", theEllipse, "some symbol"); break; case "MWC.GUI.JFreeChart.NewFormattedJFreeChart": XYPlot plot = new XYPlot(); DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); plot.setRenderer(renderer); editable = new NewFormattedJFreeChart("test", new java.awt.Font("Dialog", 0, 18), plot, false); break; case "org.mwc.cmap.core.ui_support.swt.SWTCanvasAdapter": final Editable[] edit = new Editable[1]; Display.getDefault().syncExec(new Runnable() { @Override public void run() { edit[0] = new SWTCanvasAdapter(null); } }); editable = edit[0]; break; case "ASSET.Models.Decision.Conditions.OrCondition": System.out.println(type.getFullyQualifiedName() + " hasn't public constructor."); return null; case "ASSET.Models.Decision.Movement.RectangleWander": final WorldLocation topLeft = SupportTesting.createLocation(0, 10000); final WorldLocation bottomRight = SupportTesting.createLocation(10000, 0); final WorldArea theArea = new WorldArea(topLeft, bottomRight); editable = new RectangleWander(theArea, "rect wander"); break; case "org.mwc.debrief.satc_interface.data.wrappers.BMC_Wrapper$BearingMeasurementWrapper": bmc = new BearingMeasurementContribution(); bmc.setName("Measured bearing"); bmc.setAutoDetect(false); CoreMeasurement cm = new CoreMeasurement(new Date()); BMC_Wrapper bmcw = new BMC_Wrapper(bmc); editable = bmcw.new BearingMeasurementWrapper(cm); break; case "org.mwc.debrief.satc_interface.data.wrappers.FMC_Wrapper$FrequencyMeasurementEditable": fmc = new FrequencyMeasurementContribution(); fmc.setName("Measured frequence"); FMC_Wrapper fmcw = new FMC_Wrapper(fmc); cm = new CoreMeasurement(new Date()); editable = fmcw.new FrequencyMeasurementEditable(cm); break; case "ASSET.GUI.SuperSearch.Plotters.SSGuiSupport$ParticipantListener": SSGuiSupport ssgs = new SSGuiSupport(); ssgs.setScenario(new MultiForceScenario()); editable = new SSGuiSupport.ParticipantListener(new CoreParticipant(12), ssgs); break; case "ASSET.GUI.Workbench.Plotters.BasePlottable": // skip it return null; case "MWC.TacticalData.GND.GTrack": // skip it return null; default: break; } if (editable != null) { return editable; } Class<?> clazz; try { clazz = Class.forName(type.getFullyQualifiedName()); } catch (ClassNotFoundException e1) { //e1.printStackTrace(); System.out.println("CNFE " + e1.getMessage() + " " + type.getFullyQualifiedName()); return null; } try { @SuppressWarnings("unused") Method infoMethod = clazz.getDeclaredMethod("getInfo", new Class[0]); } catch (Exception e) { return null; } try { editable = (Editable) clazz.newInstance(); } catch (Exception e) { Constructor<?>[] constructors = clazz.getConstructors(); for (Constructor<?> constructor : constructors) { try { Class<?>[] paramTypes = constructor.getParameterTypes(); Object[] params = new Object[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { Class<?> paramType = paramTypes[i]; if (HiResDate.class.equals(paramType)) { params[i] = new HiResDate(new Date()); } else if (WorldDistance.class.equals(paramType)) { params[i] = new WorldDistance(12d, WorldDistance.DEGS); } else if (WorldSpeed.class.equals(paramType)) { params[i] = new WorldSpeed(12, WorldSpeed.M_sec); } else if (WorldLocation.class.equals(paramType)) { params[i] = new WorldLocation(12, 12, 12); } else if ("java.lang.String".equals(paramType.getName())) { params[i] = "test"; } else if (!paramType.isPrimitive()) { params[i] = null; } else { if (paramType.equals(int.class)) { params[i] = new Integer("0"); } if (paramType.equals(boolean.class)) { params[i] = Boolean.FALSE; } if (paramType.equals(long.class)) { params[i] = new Long("0"); } if (paramType.equals(double.class)) { params[i] = new Double("0"); } if (paramType.equals(float.class)) { params[i] = new Float("0"); } if (paramType.equals(short.class)) { params[i] = new Short("0"); } } } editable = (Editable) constructor.newInstance(params); break; } catch (Exception e1) { // ignore //System.out.println(e1.getMessage()); //e1.printStackTrace(); } } } if (editable == null) { System.out.println("Can't instantiate type " + type.getFullyQualifiedName()); } return editable; }
From source file:cn.InstFS.wkr.NetworkMining.UIs.TimeSeriesChart1.java
public static Color getcolor(int i) { switch (i) {/*from w w w. j a v a2s. c o m*/ case 1: return Color.red; case 2: return Color.blue; case 3: return Color.cyan; case 4: return Color.gray; case 5: return Color.green; case 6: return Color.magenta; case 7: return Color.orange; case 8: return Color.yellow; case 9: return Color.white; case 0: return Color.pink; default: return Color.black; } }
From source file:com.voterData.graph.Graph.java
public static JFreeChart getRaceDistbn2008(Map<String, Double> dataMap) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); for (String key : dataMap.keySet()) { if (key.equals("A_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Asian", "REP"); } else if (key.equals("B_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "REP"); } else if (key.equals("I_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "REP"); } else if (key.equals("O_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Other", "REP"); } else if (key.equals("M_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "REP"); } else if (key.equals("U_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "REP"); } else if (key.equals("W_Rep_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "White", "REP"); } else if (key.equals("A_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Asian", "DEM"); } else if (key.equals("B_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "DEM"); } else if (key.equals("I_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "DEM"); } else if (key.equals("O_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Other", "DEM"); } else if (key.equals("M_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "DEM"); } else if (key.equals("U_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "DEM"); } else if (key.equals("W_Dem_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "White", "DEM"); } else if (key.equals("A_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Asian", "UNA"); } else if (key.equals("B_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "UNA"); } else if (key.equals("I_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "UNA"); } else if (key.equals("O_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Other", "UNA"); } else if (key.equals("M_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "UNA"); } else if (key.equals("U_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "UNA"); } else if (key.equals("W_Una_2008")) { defaultcategorydataset.addValue(dataMap.get(key), "White", "UNA"); }/* w w w . j a va 2 s .c o m*/ } JFreeChart jfreechart = ChartFactory.createBarChart("Race Distribution - 2008", "Party", "% of votes", defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); BarRenderer renderer = (BarRenderer) categoryplot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setSeriesPaint(0, Color.ORANGE); renderer.setSeriesPaint(1, Color.MAGENTA); renderer.setSeriesPaint(2, Color.PINK); renderer.setSeriesPaint(3, Color.YELLOW); renderer.setSeriesPaint(4, Color.cyan); renderer.setSeriesPaint(5, Color.RED); renderer.setSeriesPaint(6, Color.green); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); categoryplot.setRenderer(renderer); return jfreechart; }
From source file:com.prezerak.windmill.gui.AveragesPanel.java
private void plotEverything() { try {//from w w w.ja va 2s . c o m final XYPlot plot = chart.getXYPlot(); ValueAxis domainAxis = plot.getDomainAxis(); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setAutoRange(true); if (domainAxis instanceof DateAxis) { DateAxis axis = (DateAxis) domainAxis; // customise axis here... //axis.setRange(new Date(startDate), new Date(endDate)); long startT = datasetVel.getDataItem(0).getPeriod().getLastMillisecond(); long endT = datasetVel.getDataItem(datasetVel.getItemCount() - 1).getPeriod().getLastMillisecond(); ; DateFormat formatter; long duration = endT - startT; long _24hrs = 1000 * 60 * 60 * 24; long _3mins = 1000 * 60 * 3; if (duration > _24hrs) { formatter = new SimpleDateFormat("HH:mm dd-MMM"); } else if (endDate - startDate > _3mins && endDate - startDate <= _24hrs) formatter = new SimpleDateFormat("HH:mm"); else //smaller than 3mins formatter = new SimpleDateFormat("HH:mm:ss"); axis.setDateFormatOverride(formatter); } TimeSeriesCollection seriesVel = new TimeSeriesCollection(); seriesVel.addSeries(datasetVel); plot.setDataset(0, seriesVel); final NumberAxis velRangeAxis = (NumberAxis) plot.getRangeAxis(); velRangeAxis.setRange(0.0, maxY); plot.setRangeAxis(velRangeAxis); plot.mapDatasetToRangeAxis(0, 0); XYLineAndShapeRenderer velocityRenderer = (XYLineAndShapeRenderer) plot.getRenderer(0); velocityRenderer.setBaseShapesVisible(true); velocityRenderer.setBaseShapesFilled(false); velocityRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd-MM-yy, hh:mm:ss a"), new DecimalFormat("00.0"))); velocityRenderer.setSeriesPaint(0, Color.BLACK); if (!rdbtnVelocity.isSelected()) { velocityRenderer.setSeriesVisible(0, false); } else { velocityRenderer.setSeriesVisible(0, true); } TimeSeriesCollection seriesDir = new TimeSeriesCollection(); seriesDir.addSeries(datasetDir); plot.setDataset(1, seriesDir); final ValueAxis dirRangeAxis = new NumberAxis("Direction"); dirRangeAxis.setRange(0.0, 370.0); plot.setRangeAxis(1, dirRangeAxis); plot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer dirRenderer = (XYLineAndShapeRenderer) plot.getRenderer(1); if (dirRenderer == null) dirRenderer = new XYLineAndShapeRenderer(); dirRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd-MM-yy, hh:mm:ss a"), new DecimalFormat("00.0"))); plot.setRenderer(1, dirRenderer); dirRenderer.setSeriesPaint(0, Color.BLUE); if (!rdbtnDirection.isSelected()) { dirRenderer.setSeriesVisible(0, false); } else { dirRenderer.setSeriesVisible(0, true); } final ValueAxis alarmsRangeAxis = new NumberAxis("Alarms"); alarmsRangeAxis.setRange(0.0, 1); alarmsRangeAxis.setVisible(false); XYBarRenderer gustRenderer = null; TimePeriodValuesCollection seriesGust = new TimePeriodValuesCollection(datasetGust); plot.setDataset(2, seriesGust); plot.setRangeAxis(2, alarmsRangeAxis); plot.mapDatasetToRangeAxis(2, 2); gustRenderer = (XYBarRenderer) plot.getRenderer(2); if (gustRenderer == null) gustRenderer = new XYBarRenderer(); plot.setRenderer(2, gustRenderer); gustRenderer.setSeriesPaint(0, Color.PINK); if ((rdbtnVelocity.isSelected() || rdbtnDirection.isSelected()) && rdbtnGust.isSelected()) gustRenderer.setSeriesVisible(0, true); else gustRenderer.setSeriesVisible(0, false); XYBarRenderer higherRenderer = null; TimePeriodValuesCollection seriesHigher = new TimePeriodValuesCollection(datasetHigher); plot.setDataset(3, seriesHigher); plot.setRangeAxis(3, alarmsRangeAxis); plot.mapDatasetToRangeAxis(3, 2); higherRenderer = (XYBarRenderer) plot.getRenderer(3); if (higherRenderer == null) higherRenderer = new XYBarRenderer(); plot.setRenderer(3, higherRenderer); higherRenderer.setSeriesPaint(0, Color.RED); if ((rdbtnVelocity.isSelected() || rdbtnDirection.isSelected()) && rdbtnHigher.isSelected()) higherRenderer.setSeriesVisible(0, true); else higherRenderer.setSeriesVisible(0, false); TimePeriodValuesCollection seriesHigh = new TimePeriodValuesCollection(datasetHigh); plot.setDataset(4, seriesHigh); plot.setRangeAxis(4, alarmsRangeAxis); plot.mapDatasetToRangeAxis(4, 2); XYBarRenderer highRenderer = (XYBarRenderer) plot.getRenderer(4); if (highRenderer == null) highRenderer = new XYBarRenderer(); plot.setRenderer(4, highRenderer); highRenderer.setSeriesPaint(0, new Color(206, 33, 85)); if ((rdbtnVelocity.isSelected() || rdbtnDirection.isSelected()) && rdbtnHigh.isSelected()) highRenderer.setSeriesVisible(0, true); else highRenderer.setSeriesVisible(0, false); } catch (OutOfMemoryError e) { WindMill.logger.warn("Out of Memory in plotEverything"); } }
From source file:org.adempiere.apps.graph.ChartBuilder.java
private void setupCategoryChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesPaint(2, Color.YELLOW); renderer.setSeriesPaint(3, Color.GREEN); renderer.setSeriesPaint(4, Color.ORANGE); renderer.setSeriesPaint(5, Color.CYAN); renderer.setSeriesPaint(6, Color.MAGENTA); renderer.setSeriesPaint(7, Color.GRAY); renderer.setSeriesPaint(8, Color.PINK); plot.setRenderer(renderer);/*from w w w .ja va2s .c o m*/ }
From source file:org.mathIT.gui.GraphViewer.java
/** * Gets relevance clusters for this graph and marks them in the canvas. *///w ww . j a va 2 s . c om private void displayRelevanceClusters() { ArrayList<OrderedSet<Integer>> list = invokerGraph.getRelevanceClusters().getClusters(); // Change the vertex color palette to mark the most relevant vertices red: palette = new java.awt.Color[] { java.awt.Color.YELLOW, // category 0 java.awt.Color.BLUE, // category 1 java.awt.Color.GREEN, // category 2 java.awt.Color.MAGENTA, // category 3 java.awt.Color.RED, // category 4 java.awt.Color.ORANGE, java.awt.Color.CYAN, java.awt.Color.LIGHT_GRAY, java.awt.Color.PINK, java.awt.Color.BLACK }; // add a listener for ToolTips canvas.setVertexToolTipTransformer(new ToStringLabeller<V>() { /* (non-Javadoc) * @see edu.uci.ics.jung.visualization.decorators.DefaultToolTipFunction#getToolTipText(java.lang.Object) */ @Override @SuppressWarnings("unchecked") public String transform(V v) { if (v instanceof Graph) { return ((Graph<V>) v).getVertices().toString(); } //return super.transform((V) v); return "Network relevance: " + org.mathIT.util.Formats.O_DOT_A3.format(invokerGraph.getRelevance(v.getIndex())); } }); // ---- Vertex color: ---- canvas.getRenderer().setVertexRenderer(new VertexFillColor(list)); canvas.repaint(); }
From source file:com.voterData.graph.Graph.java
public static JFreeChart getRaceDistbn2012(Map<String, Double> dataMap) { DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); for (String key : dataMap.keySet()) { if (key.equals("A_Rep_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Asian", "REP"); } else if (key.equals("B_Rep_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "REP"); } else if (key.equals("I_Rep_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "REP"); } else if (key.equals("O_Rep_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Other", "REP"); } else if (key.equals("M_Rep_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "REP"); } else if (key.equals("U_Rep_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "REP"); } else if (key.equals("W_Rep_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "White", "REP"); } else if (key.equals("A_Dem_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Asian", "DEM"); } else if (key.equals("B_Dem_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "DEM"); } else if (key.equals("I_Dem_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "DEM"); } else if (key.equals("O_Dem_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Other", "DEM"); } else if (key.equals("M_Dem_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "DEM"); } else if (key.equals("U_Dem_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "DEM"); } else if (key.equals("W_Dem_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "White", "DEM"); } else if (key.equals("A_Una_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Asian", "UNA"); } else if (key.equals("B_Una_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "African American/Black", "UNA"); } else if (key.equals("I_Una_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "American Indian/Alaska Native", "UNA"); } else if (key.equals("O_Una_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Other", "UNA"); } else if (key.equals("M_Una_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Multiracial", "UNA"); } else if (key.equals("U_Una_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "Undefined", "UNA"); } else if (key.equals("W_Una_2012")) { defaultcategorydataset.addValue(dataMap.get(key), "White", "UNA"); }//w w w.j a va 2s. c o m } JFreeChart jfreechart = ChartFactory.createBarChart("Race Distribution - 2012", "Party", "% of votes", defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); BarRenderer renderer = (BarRenderer) categoryplot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setSeriesPaint(0, Color.cyan); renderer.setSeriesPaint(1, Color.pink); renderer.setSeriesPaint(2, Color.red); renderer.setSeriesPaint(3, Color.orange); renderer.setSeriesPaint(4, Color.green); renderer.setSeriesPaint(5, Color.yellow); renderer.setSeriesPaint(6, Color.magenta); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); categoryplot.setRenderer(renderer); return jfreechart; }
From source file:edu.ucla.stat.SOCR.analyses.gui.Survival.java
protected void doGraph() { graphPanel.removeAll();// w w w . ja v a 2 s .c om ////////System.out.println("in doGraph"); //graphPanel.add(description, BorderLayout.SOUTH); JFreeChart scatterChart = null; ChartPanel chartPanel1 = null; ChartPanel chartPanel2 = null; Chart chartFactory = new Chart(); String lineType = "excludesZeroNoShape"; /* double[] survivalTimePlot = new double[plotSize]; double[] survivalRatePlot = new double[plotSize]; //////////System.out.println("doGraph survivalTimePlot.length = " + survivalTimePlot.length); //////////System.out.println("doGraph survivalRatePlot.length = " + survivalRatePlot.length); int newIndex = 0; for (int i = 0; i < survivalRate.length; i++) { for (int j = 0; j < survivalRate[i].length; j++) { survivalTimePlot[newIndex] = survivalTime[i][j]; survivalRatePlot[newIndex] = survivalRate[i][j]; newIndex++; } } */ /* double[][] survivalTimePlot = new double[survivalTime.length][]; double[][] survivalRatePlot = new double[survivalRate.length][]; // create the first point (time = 0, rate = 1) for (int i = 0; i < survivalTime.length; i++) { survivalTimePlot[i] = new double[survivalTime[i].length + 1]; survivalRatePlot[i] = new double[survivalRate[i].length + 1]; survivalTimePlot[i][0] = 0; survivalRatePlot[i][0] = 1; for (int j = 1; j < survivalTimePlot[i].length; j++) { survivalTimePlot[i][j] = survivalTime[i][j - 1]; survivalRatePlot[i][j] = survivalRate[i][j - 1]; } } */ boolean useCI = true; // whether to plot the confidence interval. ////////System.out.println("useCI = " + useCI); double[][] survivalTimePlot = new double[survivalTime.length][]; double[][] survivalRatePlot = new double[survivalRate.length][]; double[][] survivalRateUpperCIPlot = new double[survivalRate.length][]; double[][] survivalRateLowerCIPlot = new double[survivalRate.length][]; // create the first point (time = 0, rate = 1) double tempTime = 0, tempRate = 0, tempRateUpperCI = 0, tempRateLowerCI = 0; int increment = 2; int arrayLength = 0; int k = 0; // index for survivalTime array, not for survivalTimePlot. for (int i = 0; i < survivalTime.length; i++) { arrayLength = 2 * survivalRate[i].length + increment; k = 0; // why add 2? one for the initial point, one for the last point. survivalTimePlot[i] = new double[arrayLength]; survivalRatePlot[i] = new double[arrayLength]; survivalRateUpperCIPlot[i] = new double[arrayLength]; survivalRateLowerCIPlot[i] = new double[arrayLength]; survivalTimePlot[i][0] = 0; survivalRatePlot[i][0] = 1; survivalRateUpperCIPlot[i][0] = 1; survivalRateLowerCIPlot[i][0] = 1; int j = 1; ////////System.out.println(" before loop survivalTimePlot["+i+"].length= " +survivalTimePlot[i].length); for (j = 1; j < survivalTimePlot[i].length - 1; j++) { //////////System.out.println("j = " + j + " survivalTimePlot["+i+"].length = " + survivalTimePlot[i].length + ", k = " + k); ////////System.out.println("in loop j = " + j); if (j % 2 == 1) { ////////System.out.println("in if j = " + j + ", k = " + k); survivalTimePlot[i][j] = survivalTime[i][k]; survivalRatePlot[i][j] = survivalRatePlot[i][j - 1]; survivalRateUpperCIPlot[i][j] = survivalRateUpperCIPlot[i][j - 1]; survivalRateLowerCIPlot[i][j] = survivalRateLowerCIPlot[i][j - 1]; tempTime = survivalTimePlot[i][j]; tempRate = survivalRatePlot[i][j]; tempRateUpperCI = survivalRateUpperCIPlot[i][j]; tempRateLowerCI = survivalRateLowerCIPlot[i][j]; } else { //////////System.out.println("in elsej = " + j); survivalTimePlot[i][j] = tempTime; survivalRatePlot[i][j] = survivalRate[i][k]; survivalRateUpperCIPlot[i][j] = upperCI[i][k]; survivalRateLowerCIPlot[i][j] = lowerCI[i][k]; k++; } ////////System.out.println("i = " + i + ", j = " + j + ", k = " + k + ", time["+i+"]["+j+"] = " + survivalTimePlot[i][j] + ". rate["+i+"]["+j+"] = " + survivalRatePlot[i][j]); } int index = j;//survivalTimePlot[i].length-1;//survivalTimePlot[i].length; ////////System.out.println("index = " + index); ////////System.out.println("maxTime["+i+"] = " + maxTime[i]); survivalTimePlot[i][index] = maxTime[i]; ////////System.out.println("survivalTimePlot["+i+"]["+index+"] = " + survivalTimePlot[i][index]); survivalRatePlot[i][index] = survivalRatePlot[i][index - 1]; survivalRateUpperCIPlot[i][index] = survivalRateUpperCIPlot[i][index - 1]; survivalRateLowerCIPlot[i][index] = survivalRateLowerCIPlot[i][index - 1]; } int numberGroups = 0, lineSetCount = 0, tempIndex = 0; double[][] finalTimeArray = null; double[][] finalRateArray = null; String[] finalGroupNames = null; int numberOfLines = 0; //lineSetCount * groupNames.length; Color[] colorArray = null;//new Color[numberOfLines]; ////////System.out.println("lineSetCount = " + lineSetCount); if (useCI) { numberGroups = groupNames.length; lineSetCount = 3; // use 4 if using censor points. tempIndex = 0; numberOfLines = lineSetCount * numberGroups; finalTimeArray = new double[numberOfLines][]; finalRateArray = new double[numberOfLines][]; finalGroupNames = new String[numberOfLines]; ////////System.out.println("numberOfLines = " + numberOfLines); colorArray = new Color[numberOfLines]; // why 3? one for rate, one for upper CI, one for lower CI. for (int i = 0; i < numberGroups; i++) { // repeat the same time. finalTimeArray[tempIndex] = survivalTimePlot[i]; finalTimeArray[tempIndex + 1] = survivalTimePlot[i]; finalTimeArray[tempIndex + 2] = survivalTimePlot[i]; //finalTimeArray[tempIndex+3] = censoredTime[i]; finalRateArray[tempIndex] = survivalRatePlot[i]; finalRateArray[tempIndex + 1] = survivalRateUpperCIPlot[i]; finalRateArray[tempIndex + 2] = survivalRateLowerCIPlot[i]; //finalRateArray[tempIndex+3] = censoredRate[i]; finalGroupNames[tempIndex] = groupNames[i]; finalGroupNames[tempIndex + 1] = groupNames[i] + " Upper CI"; finalGroupNames[tempIndex + 2] = groupNames[i] + " Lower CI"; //finalGroupNames[tempIndex+3] = groupNames[i] + " Censored"; if (i % 5 == 0) { colorArray[tempIndex] = Color.RED; colorArray[tempIndex + 1] = Color.PINK; colorArray[tempIndex + 2] = Color.PINK; } else if (i % 5 == 1) { colorArray[tempIndex] = Color.BLUE; colorArray[tempIndex + 1] = Color.CYAN; colorArray[tempIndex + 2] = Color.CYAN; } else if (i % 5 == 2) { colorArray[tempIndex] = Color.GRAY; colorArray[tempIndex + 1] = Color.LIGHT_GRAY; colorArray[tempIndex + 2] = Color.LIGHT_GRAY; } else if (i % 5 == 3) { colorArray[tempIndex] = Color.MAGENTA; colorArray[tempIndex + 1] = Color.PINK; colorArray[tempIndex + 2] = Color.PINK; } else { colorArray[tempIndex] = Color.GREEN; colorArray[tempIndex + 1] = Color.YELLOW; colorArray[tempIndex + 2] = Color.YELLOW; } tempIndex += lineSetCount; } } else { numberGroups = groupNames.length; lineSetCount = 2; tempIndex = 0; finalTimeArray = new double[lineSetCount * numberGroups][]; finalRateArray = new double[lineSetCount * numberGroups][]; finalGroupNames = new String[lineSetCount * numberGroups]; // why 3? one for rate, one for upper CI, one for lower CI. for (int i = 0; i < numberGroups; i++) { // repeat the same time. finalTimeArray[tempIndex] = survivalTimePlot[i]; finalTimeArray[tempIndex + 1] = censoredTime[i]; finalRateArray[tempIndex] = survivalRatePlot[i]; finalRateArray[tempIndex + 1] = censoredRate[i]; finalGroupNames[tempIndex] = groupNames[i]; //finalGroupNames[tempIndex+1] = groupNames[i] + " Censored"; tempIndex += lineSetCount; } } //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", groupNames.length, groupNames, survivalTimePlot, survivalRatePlot, lineType); //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", lineSetCount * groupNames.length, finalGroupNames, finalTimeArray, finalRateArray, lineType); // this one has color. //public JFreeChart getLineChart(String title, String xLabel, String yLabel, double[] x, double[] y, Color[] colors, String other) //public JFreeChart getLineChart(String title, String xLabel, String yLabel, int numberOfLines, String[] lineNames, double[][] x, double[][] y, Color[] colors, String other) //int numberOfLines = lineSetCount * groupNames.length; //Color[] colors = new Color[numberOfLines]; //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", numberOfLines, finalGroupNames, finalTimeArray, finalRateArray, colorArray, lineType); scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", lineSetCount * groupNames.length, finalGroupNames, finalTimeArray, finalRateArray, colorArray, lineType); // this one has color. //for (int i = 0; i < survivalTime.length; i++) { //scatterChart = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", survivalTimePlot, survivalRatePlot, lineType); //} scatterChart.setTitle("Expected Survival Times with 95% Confidence Limits"); chartPanel1 = new ChartPanel(scatterChart, false); chartPanel1.setPreferredSize(new Dimension(plotWidth, plotHeight)); JPanel innerPanel = new JPanel(); JScrollPane graphPane = new JScrollPane(innerPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); graphPanel.add(graphPane); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS)); innerPanel.add(chartPanel1); // Add a second plot without the confidence intervals (confidence limits) int lineSetCount1 = lineSetCount - 2; int tempIndex1 = 0; double[][] finalTimeArray1 = new double[lineSetCount1 * numberGroups][]; double[][] finalRateArray1 = new double[lineSetCount1 * numberGroups][]; String[] finalGroupNames1 = new String[lineSetCount1 * numberGroups]; for (int i = 0; i < numberGroups; i++) { // repeat the same time. finalTimeArray1[tempIndex1] = survivalTimePlot[i]; //finalTimeArray1[tempIndex1+1] = censoredTime[i]; finalRateArray1[tempIndex1] = survivalRatePlot[i]; //finalRateArray1[tempIndex1+1] = censoredRate[i]; finalGroupNames1[tempIndex1] = groupNames[i]; tempIndex1 += lineSetCount1; } JFreeChart scatterChart1 = chartFactory.getLineChart("Rate vs. Time", "Time", "Rate", (lineSetCount1) * groupNames.length, finalGroupNames1, finalTimeArray1, finalRateArray1, colorArray, lineType); // this one has color. scatterChart1.setTitle("Expected Survival Times (Only)"); chartPanel2 = new ChartPanel(scatterChart1, false); chartPanel2.setPreferredSize(new Dimension(plotWidth, plotHeight)); innerPanel.add(chartPanel2); graphPanel.validate(); }
From source file:com.vgi.mafscaling.VECalc.java
protected boolean displayData() { try {/*w w w. j a va 2 s . c o m*/ int cnt; double x, y, val; boolean isMaf = (dataType.getSelectedIndex() == 0 ? true : false); ArrayList<LogData> data; HashMap<Double, ArrayList<LogData>> yData; Color[][] colorMatrix = new Color[corrTable.getRowCount()][corrTable.getColumnCount()]; for (int i = 1; i < xAxisArray.size() + 1; ++i) { newTable.setValueAt(origTable.getValueAt(0, i), 0, i); corrTable.setValueAt(origTable.getValueAt(0, i), 0, i); corrCountTable.setValueAt(origTable.getValueAt(0, i), 0, i); for (int j = 1; j < yAxisArray.size() + 1; ++j) { if (i == 1) { newTable.setValueAt(origTable.getValueAt(j, 0), j, 0); corrTable.setValueAt(origTable.getValueAt(j, 0), j, 0); corrCountTable.setValueAt(origTable.getValueAt(j, 0), j, 0); } x = xAxisArray.get(i - 1); y = yAxisArray.get(j - 1); yData = xData.get(x); if (yData == null) newTable.setValueAt(origTable.getValueAt(j, i), j, i); else { data = yData.get(y); if (data == null) newTable.setValueAt(origTable.getValueAt(j, i), j, i); else { cnt = data.size(); val = 0; for (LogData d : data) val += (isMaf ? d.sderr : d.afrerr); val /= cnt; corrTable.setValueAt(val, j, i); corrCountTable.setValueAt(cnt, j, i); if (cnt > minCellHitCount) { val = 1 + (val / 100.0 * corrApplied) / 100.0; if (isMaf) newTable.setValueAt(Double.valueOf(origTable.getValueAt(j, i).toString()) / val, j, i); else newTable.setValueAt(Double.valueOf(origTable.getValueAt(j, i).toString()) * val, j, i); colorMatrix[j][i] = Color.PINK; } else newTable.setValueAt(origTable.getValueAt(j, i), j, i); } } } } Utils.colorTable(newTable); for (int i = 0; i < colorMatrix.length; ++i) colorMatrix[i][0] = Color.LIGHT_GRAY; for (int i = 0; i < colorMatrix[0].length; ++i) colorMatrix[0][i] = Color.LIGHT_GRAY; ((BgColorFormatRenderer) corrTable.getDefaultRenderer(Object.class)).setColors(colorMatrix); ((BgColorFormatRenderer) corrCountTable.getDefaultRenderer(Object.class)).setColors(colorMatrix); plotCorrectionData(); return true; } catch (Exception e) { logger.error(e); JOptionPane.showMessageDialog(null, e, "Error processing data", JOptionPane.ERROR_MESSAGE); } return false; }
From source file:com.peterbochs.instrument.InstrumentPanel.java
private static JFreeChart createChart(XYZDataset dataset) { NumberAxis xAxis = new NumberAxis("address (" + jBlockSizeComboBox.getSelectedItem() + ")"); xAxis.setLowerMargin(0.0);//from w ww . ja va2 s .c o m xAxis.setUpperMargin(0.0); xAxis.setAxisLinePaint(Color.cyan); xAxis.setTickMarkPaint(Color.cyan); // xAxis.setAutoTickUnitSelection(false); // xAxis.setTickUnit(new NumberTickUnit(1)); // NumberFormat nf = NumberFormat.getPercentInstance(); // xAxis.setNumberFormatOverride(nf); // xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis yAxis = new NumberAxis("address (" + jBlockSizeComboBox.getSelectedItem() + " KB)"); // yAxis.setAutoRangeIncludesZero(true); // yAxis.setInverted(false); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setAxisLinePaint(Color.pink); yAxis.setTickMarkPaint(Color.pink); // yAxis.setTickUnit(new NumberTickUnit(10)); // yAxis.setTickLabelFont(new Font("Dialog", 0, 7)); // yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); MyXYBlockRenderer renderer = new MyXYBlockRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); // plot.setBackgroundPaint(Color.white); // plot.setDomainGridlineStroke(new BasicStroke(1)); plot.setDomainGridlinePaint(Color.white); // plot.setRangeGridlineStroke(new BasicStroke(1)); plot.setRangeGridlinePaint(Color.white); // JFreeChart chart = new JFreeChart("Memory read/write hot zone", new // Font("Serif", Font.PLAIN, 12), plot, true); JFreeChart chart = new JFreeChart("Memory read/write hot zone", plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); return chart; }