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:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYCorrelationScatterPlot.java
private Color getColorForIHCLevelResult(String result) { //OVEREXPRESSED,POSITIVE,HIGH String res = result.trim();//from w w w. j a v a 2 s . c om if (res.equalsIgnoreCase("OVEREXPRESSED") || res.equalsIgnoreCase("POSITIVE") || res.equalsIgnoreCase("HIGH")) { return Color.GREEN; } //INTERMEDIATE,BORDERLINE,LOW,WEAK OVEREXPRESSED if (res.equalsIgnoreCase("INTERMEDIATE") || res.equalsIgnoreCase("BORDERLINE") || res.equalsIgnoreCase("LOW") || res.equalsIgnoreCase("WEAK OVEREXPRESSED")) { return Color.YELLOW; } //NEGATIVE,NO OVEREXPRESSION, ZERO if (res.equalsIgnoreCase("NEGATIVE") || res.equalsIgnoreCase("NO OVEREXPRESSION") || res.equalsIgnoreCase("ZERO")) { return Color.RED; } return Color.GRAY; }
From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYCorrelationScatterPlot.java
private Color getColorForIHCLossResult(String result) { String res = result.trim();/*from w w w .j a va 2 s.c om*/ //NO LOSS if (res.equalsIgnoreCase("NO LOSS")) { return Color.GREEN; } if (res.equalsIgnoreCase("PARTIAL LOSS")) { return Color.YELLOW; } //PARTIAL LOSS //TOTAL LOSS if (res.equalsIgnoreCase("TOTAL LOSS")) { return Color.BLUE; } return Color.GRAY; }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Builds the content panel with a title bar and settings. *//*from w w w .j a v a2 s .c om*/ private void buildContentPanel(JXTitledPanel container, JScrollPane component, boolean opaque) { container.getContentContainer().setLayout(new BorderLayout()); container.setBorder(null); container.setTitleFont(new Font("Tahoma", Font.BOLD, 18)); container.setTitleForeground(UIConstants.HEADER_TITLE_TEXT_COLOR); JLabel mirthConnectImage = new JLabel(); mirthConnectImage.setIcon(UIConstants.MIRTHCONNECT_LOGO_GRAY); mirthConnectImage.setText(" "); mirthConnectImage.setToolTipText(UIConstants.MIRTHCONNECT_TOOLTIP); mirthConnectImage.setCursor(new Cursor(Cursor.HAND_CURSOR)); mirthConnectImage.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { BareBonesBrowserLaunch.openURL(UIConstants.MIRTHCONNECT_URL); } }); ((JPanel) container.getComponent(0)).add(mirthConnectImage); component.setBorder(new LineBorder(Color.GRAY, 1)); component.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); component.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); container.getContentContainer().add(component); }
From source file:edu.ucla.stat.SOCR.analyses.gui.Survival.java
protected void doGraph() { graphPanel.removeAll();//from ww w . ja v a2 s . com ////////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:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
JFreeChart actualLabChartRefPlusMeds(String demographicNo, String labType, String identifier, String testName, String patientName, String chartTitle, String[] drugs) { org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection(); ArrayList<Map<String, Serializable>> list = null; MiscUtils.getLogger().debug(/*from www. j ava2 s .c o m*/ " lab type >" + labType + "< >" + labType.equals("loinc") + "<" + testName + " " + identifier); if (labType.equals("loinc")) { try { Connection conn = DbConnectionFilter.getThreadLocalDbConnection(); list = CommonLabTestValues.findValuesByLoinc2(demographicNo, identifier, conn); MiscUtils.getLogger().debug("List ->" + list.size()); conn.close(); } catch (Exception ed) { MiscUtils.getLogger().error("Error", ed); } } else { list = CommonLabTestValues.findValuesForTest(labType, demographicNo, testName, identifier); } String typeYAxisName = ""; ArrayList<OHLCDataItem> dataItems = new ArrayList<OHLCDataItem>(); String typeLegendName = "Lab Value"; typeYAxisName = "type Y"; boolean nameSet = false; TimeSeries newSeries = new TimeSeries(typeLegendName, Day.class); for (Map mdb : list) { if (!nameSet) { typeYAxisName = (String) mdb.get("units"); typeLegendName = (String) mdb.get("testName"); if (typeLegendName == null) { typeLegendName = testName; } newSeries.setKey(typeLegendName); nameSet = true; } newSeries.addOrUpdate(new Day((Date) mdb.get("collDateDate")), Double.parseDouble("" + mdb.get("result"))); log.debug("RANGE " + mdb.get("range")); if (mdb.get("range") != null) { String range = (String) mdb.get("range"); if (range.indexOf("-") != -1) { String[] sp = range.split("-"); double open = Double.parseDouble(sp[0]); double high = Double.parseDouble(sp[1]); double low = Double.parseDouble(sp[0]); double close = Double.parseDouble(sp[1]); double volume = 1045; dataItems.add(new OHLCDataItem(new Day((Date) mdb.get("collDateDate")).getStart(), open, high, low, close, volume)); } } } dataset.addSeries(newSeries); JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Days", typeYAxisName, dataset, true, true, true); XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setAutoRange(true); log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin() + " eee " + plot.getDomainAxis().getLowerMargin()); plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin() * 6); plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin() * 6); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 1.7); plot.getDomainAxis().setUpperMargin(0.9); plot.getDomainAxis().setLowerMargin(0.9); plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4); ValueAxis va = plot.getRangeAxis(); va.setAutoRange(true); XYItemRenderer renderer = plot.getRenderer(); //DateFormat.getInstance() XYItemLabelGenerator generator = new StandardXYItemLabelGenerator("{1} \n {2}", new SimpleDateFormat("yyyy.MM.dd"), new DecimalFormat("0.00")); renderer.setSeriesItemLabelGenerator(0, generator);//setLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairPaint(Color.GRAY); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rend = (XYLineAndShapeRenderer) renderer; rend.setBaseShapesVisible(true); rend.setBaseShapesFilled(true); } plot.setRenderer(renderer); if (dataItems != null && dataItems.size() > 0) { OHLCDataItem[] ohlc = dataItems.toArray(new OHLCDataItem[dataItems.size()]); XYDataset referenceRangeDataset = new DefaultOHLCDataset("Normal Reference Range", ohlc); plot.setDataset(1, referenceRangeDataset); plot.mapDatasetToRangeAxis(1, 0); plot.setRenderer(1, new HighLowRenderer()); } XYTaskDataset drugDataset = getDrugDataSet(demographicNo, drugs); //DateAxis xAxis = new DateAxis("Date/Time"); //DateAxis xAxis = plot.getRangeAxis(); SymbolAxis yAxis = new SymbolAxis("Meds", getDrugSymbol(demographicNo, drugs)); yAxis.setGridBandsVisible(false); XYBarRenderer xyrenderer = new XYBarRenderer(); xyrenderer.setUseYInterval(true); xyrenderer.setBarPainter(new StandardXYBarPainter()); //XYPlot xyplot = new XYPlot(drugDataset, xAxis, yAxis, xyrenderer); XYPlot xyplot = new XYPlot(drugDataset, plot.getDomainAxis(), yAxis, xyrenderer); xyplot.getDomainAxis().setUpperMargin(0.9); xyplot.getDomainAxis().setLowerMargin(0.9); CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(new DateAxis("Date/Time")); cplot.add(plot); cplot.add(xyplot); /////// chart = new JFreeChart(chartTitle, cplot); chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.migueljl.oscilaciones.forzada.particular.applet1.java
/** * Funcin que contiene la ejecucin de la simulacin del experimento virtual. *//*from ww w.j a v a 2s .c om*/ public void run() { int tespera = (TSIMULACION) / muelle_simulacion.size(); Point2D[] superficie = getSuperficie(); Point2D[] pared = getPared(4); Point2D[] instantanea_muelle; Point2D[] instancia_posicion; Point2D[] instancia_fuerza; Point2D[][] bloque; while (!fin) { instantanea_muelle = getFuncionSimulacion(); instancia_posicion = getFuncionSimulacion2(); instancia_fuerza = getFuncionSimulacion3(); actualizaSimulacion(); grafposicion = new Grafica(instancia_posicion, "Evolucin temporal de la posicin", "Posicin", "Tiempo", "Posicin", true, Color.RED, 1, true); grafposicion.agregarGrafica(lineacero_puntos, "referencia", Color.GRAY, 1, true); if (visualizarf) { grafposicion.agregarGrafica(instancia_fuerza, "fuerza impulsora", Color.BLUE, 1, true); grafposicion.asignarEje(new NumberAxis("Fuerza impulsora"), 2, 1); grafposicion.fijaRango(-100, 100, 2, 1); } grafposicion.fijaRango(-escala, escala, 0, 1); gposicion.actualizaGrafica(grafposicion); simulacion = new Grafica(instantanea_muelle, "Simulacin de la oscilacin del muelle", "Muelle", "X", "Y", false, Color.BLACK, 1, true); bloque = getBloque(instantanea_muelle[instantanea_muelle.length - 1].getX()); simulacion.agregarGrafica(superficie, "Plano", Color.BLACK, 1, true); simulacion.agregarGrafica(pared, "Pared", Color.BLACK, 1, true); simulacion.agregarGrafica(bloque[0], "Lado1", Color.BLUE, 1, true); simulacion.agregarGrafica(bloque[1], "Lado2", Color.BLUE, 1, true); simulacion.agregarGrafica(bloque[2], "Lado3", Color.BLUE, 1, true); simulacion.agregarGrafica(bloque[3], "Lado4", Color.BLUE, 1, true); simulacion.agregarGrafica(bloque[4], "X1", Color.BLUE, 1, true); simulacion.agregarGrafica(bloque[5], "X2", Color.BLUE, 1, true); simulacion.fijaRango(-120, 120, 1, 0); simulacion.fijaRango(-4, 4, 1, 1); simulacion.fijaFondo(Color.WHITE); gsimulacion.actualizaGrafica(simulacion); try { Thread.sleep(tespera); } catch (InterruptedException ex) { Logger.getLogger(applet1.class.getName()).log(Level.SEVERE, null, ex); } repaint(); } }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
/** * *///from w w w .j a v a 2s. co m protected JFreeChart createDialChart() throws JRException { JRMeterPlot jrPlot = (JRMeterPlot) getPlot(); GradientPaint gp = new GradientPaint(new Point(), Color.LIGHT_GRAY, new Point(), Color.BLACK, false); GradientPaint gp2 = new GradientPaint(new Point(), Color.GRAY, new Point(), Color.BLACK); // get data for diagrams DialPlot dialPlot = new DialPlot(); //dialPlot.setView(0.0, 0.0, 1.0, 1.0); if (getDataset() != null) { dialPlot.setDataset((ValueDataset) getDataset()); } StandardDialFrame dialFrame = new StandardDialFrame(); //dialFrame.setRadius(0.60); //dialFrame.setBackgroundPaint(gp2); dialFrame.setForegroundPaint(gp2); dialPlot.setDialFrame(dialFrame); DialBackground db = new DialBackground(gp); db.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); dialPlot.setBackground(db); StandardDialScale scale = null; int dialUnitScale = 1; Range range = convertRange(jrPlot.getDataRange()); if (range != null) { double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound())); dialUnitScale = ChartThemesUtilities.getScale(bound); double lowerBound = ChartThemesUtilities.getTruncatedValue(range.getLowerBound(), dialUnitScale); double upperBound = ChartThemesUtilities.getTruncatedValue(range.getUpperBound(), dialUnitScale); scale = new StandardDialScale(lowerBound, upperBound, 225, -270, (upperBound - lowerBound) / 6, 15); if ((lowerBound == (int) lowerBound && upperBound == (int) upperBound && scale.getMajorTickIncrement() == (int) scale.getMajorTickIncrement()) || dialUnitScale > 1) { scale.setTickLabelFormatter(new DecimalFormat("#,##0")); } else if (dialUnitScale == 1) { scale.setTickLabelFormatter(new DecimalFormat("#,##0.0")); } else if (dialUnitScale <= 0) { scale.setTickLabelFormatter(new DecimalFormat("#,##0.00")); } } else { scale = new StandardDialScale(); } scale.setTickRadius(0.9); scale.setTickLabelOffset(0.16); JRFont tickLabelFont = jrPlot.getTickLabelFont(); Integer defaultBaseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT), tickLabelFont, defaultBaseFontSize); scale.setTickLabelFont(themeTickLabelFont); scale.setMajorTickStroke(new BasicStroke(1f)); scale.setMinorTickStroke(new BasicStroke(0.3f)); scale.setMajorTickPaint(Color.WHITE); scale.setMinorTickPaint(Color.WHITE); scale.setTickLabelsVisible(true); scale.setFirstTickLabelVisible(true); dialPlot.addScale(0, scale); List intervals = jrPlot.getIntervals(); if (intervals != null && intervals.size() > 0) { int size = Math.min(3, intervals.size()); int colorStep = 0; if (size > 3) colorStep = 255 / (size - 3); for (int i = 0; i < size; i++) { JRMeterInterval interval = (JRMeterInterval) intervals.get(i); Range intervalRange = convertRange(interval.getDataRange()); double intervalLowerBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getLowerBound(), dialUnitScale); double intervalUpperBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getUpperBound(), dialUnitScale); Color color = i < 3 ? (Color) ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i) : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0); ScaledDialRange dialRange = new ScaledDialRange(intervalLowerBound, intervalUpperBound, interval.getBackgroundColor() == null ? color : interval.getBackgroundColor(), 12f); dialRange.setInnerRadius(0.41); dialRange.setOuterRadius(0.41); dialPlot.addLayer(dialRange); } } JRValueDisplay display = jrPlot.getValueDisplay(); String displayVisibility = display != null && getChart().hasProperties() ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE) : "false"; if (Boolean.parseBoolean(displayVisibility)) { ScaledDialValueIndicator dvi = new ScaledDialValueIndicator(0, dialUnitScale); dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); // dvi.setFont(JRFontUtil.getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD)); dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); dvi.setPaint(Color.WHITE); String pattern = display.getMask() != null ? display.getMask() : "#,##0.####"; if (pattern != null) dvi.setNumberFormat(new DecimalFormat(pattern)); dvi.setRadius(0.15); dvi.setValueAnchor(RectangleAnchor.CENTER); dvi.setTextAnchor(TextAnchor.CENTER); //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale))); dialPlot.addLayer(dvi); } String label = getChart().hasProperties() ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL) : null; if (label != null) { JRFont displayFont = jrPlot.getValueDisplay().getFont(); Font themeDisplayFont = getFont( (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT), displayFont, defaultBaseFontSize); if (dialUnitScale < 0) label = new MessageFormat(label) .format(new Object[] { String.valueOf(Math.pow(10, dialUnitScale)) }); else if (dialUnitScale < 3) label = new MessageFormat(label).format(new Object[] { "1" }); else label = new MessageFormat(label) .format(new Object[] { String.valueOf((int) Math.pow(10, dialUnitScale - 2)) }); String[] textLines = label.split("\\n"); for (int i = 0; i < textLines.length; i++) { DialTextAnnotation dialAnnotation = new DialTextAnnotation(textLines[i]); dialAnnotation.setFont(themeDisplayFont); dialAnnotation.setPaint(Color.WHITE); dialAnnotation.setRadius(Math.sin(Math.PI / 4.0) + i / 10.0); dialAnnotation.setAnchor(TextAnchor.CENTER); dialPlot.addLayer(dialAnnotation); } } //DialPointer needle = new DialPointer.Pointer(); Paint paint = new Color(191, 48, 0); DialPointer needle = new ScaledDialPointer(dialUnitScale, paint, paint); needle.setVisible(true); needle.setRadius(0.91); dialPlot.addLayer(needle); DialCap cap = new DialCap(); cap.setRadius(0.05); cap.setFillPaint(Color.DARK_GRAY); cap.setOutlinePaint(Color.GRAY); cap.setOutlineStroke(new BasicStroke(0.5f)); dialPlot.setCap(cap); JFreeChart jfreeChart = new JFreeChart((String) evaluateExpression(getChart().getTitleExpression()), null, dialPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend().booleanValue()); // Set all the generic options configureChart(jfreeChart, getPlot()); jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); jfreeChart.setBorderVisible(false); return jfreeChart; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java
public void mouseDragged(MouseEvent e) { if (mouse_start_point != null && theDocument.size() > 0) { if (is_moving) { // moving double mz_delta = screenToDataX(mouse_start_point.getX() - e.getPoint().getX()); if (mz_delta > 0.) { double old_upper_bound = thePlot.getDomainAxis().getUpperBound(); double old_lower_bound = thePlot.getDomainAxis().getLowerBound(); double new_upper_bound = Math.min(old_upper_bound + mz_delta, theDocument.getMaxMZ()); double new_lower_bound = old_lower_bound + new_upper_bound - old_upper_bound; thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound)); } else { double old_upper_bound = thePlot.getDomainAxis().getUpperBound(); double old_lower_bound = thePlot.getDomainAxis().getLowerBound(); double new_lower_bound = Math.max(old_lower_bound + mz_delta, theDocument.getMinMZ()); double new_upper_bound = old_upper_bound + new_lower_bound - old_lower_bound; thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound)); }/*from ww w. j ava 2 s .c o m*/ mouse_start_point = e.getPoint(); } else { // zooming Graphics2D g2 = (Graphics2D) theChartPanel.getGraphics(); g2.setXORMode(java.awt.Color.gray); // delete old rectangle if (zoom_rectangle != null) g2.draw(zoom_rectangle); // create new rectangle double start_x = Math.min(e.getX(), mouse_start_point.getX()); double end_x = Math.max(e.getX(), mouse_start_point.getX()); Rectangle2D data_area = theChartPanel.getScreenDataArea((int) start_x, (int) mouse_start_point.getY()); double xmax = Math.min(end_x, data_area.getMaxX()); zoom_rectangle = new Rectangle2D.Double(start_x, data_area.getMinY(), xmax - start_x, data_area.getHeight()); // draw new rectangle g2.draw(zoom_rectangle); g2.dispose(); } } }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * setup GUI layout for the data panel including datatable and summary textArea * *//*from w w w .j av a2 s . c o m*/ protected void initTable() { tModel = new DefaultTableModel(dataObject, columnNames); hModel = new DefaultTableModel(0, 1); dataTable = new JTable(tModel); /* System.out.println("here"); dataTable.getTableHeader().addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { TableColumnModel colModel = dataTable.getColumnModel(); int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex) .getModelIndex(); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } });*/ /*final JTableHeader heading = dataTable.getTableHeader(); dataTable.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint()); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } }); */ dataTable.addKeyListener(this); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); for (int i = 0; i < tModel.getRowCount(); i++) hModel.addRow(new Object[] { (i + 1) + ":" }); headerTable = new JTable(hModel); headerTable.setCellSelectionEnabled(false); headerTable.setEnabled(false); headerTable.setGridColor(Color.gray); headerTable.setShowGrid(true); LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground", "TableHeader.font"); headerTable.setIntercellSpacing(new Dimension(0, 0)); Dimension d = headerTable.getPreferredScrollableViewportSize(); d.width = headerTable.getPreferredSize().width; headerTable.setPreferredScrollableViewportSize(d); headerTable.setRowHeight(dataTable.getRowHeight()); headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer()); JTableHeader corner = headerTable.getTableHeader(); corner.setReorderingAllowed(false); corner.setResizingAllowed(false); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } columnModel = dataTable.getColumnModel(); dTableHeader = new EditableHeader(columnModel); dataTable.setTableHeader(dTableHeader); dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); dataTable.setCellSelectionEnabled(true); dataTable.setColumnSelectionAllowed(true); dataTable.setRowSelectionAllowed(true); hookTableAction(); dataPanel = new JPanel(); summaryPanel = new JTextArea(); // summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2)); Color bg = dataPanel.getBackground(); summaryPanel.setBackground(bg); summaryPanel.setEditable(false); summaryPanel.setForeground(Color.BLACK); dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS)); JScrollPane tablePanel = new JScrollPane(dataTable); tablePanel.setRowHeaderView(headerTable); tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); new JScrollPaneAdjuster(tablePanel); new JTableRowHeaderResizer(tablePanel).setEnabled(true); dataPanel.add(tablePanel); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); dataPanel.add(new JScrollPane(st)); dataPanel.validate(); }