List of usage examples for org.jfree.chart.plot.dial DialValueIndicator getAngle
public double getAngle()
From source file:com.bdb.weather.display.current.Hygrometer.java
private ChartViewer createChartElements() { humidityPlot.addLayer(//w w w.ja v a 2s. c o m new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue))); StandardDialScale scale = new StandardDialScale(Humidity.MIN_HUMIDITY.get(), Humidity.MAX_HUMIDITY.get(), 240.0, -300.0, 10.0, 9); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.9); scale.setTickLabelFormatter(new DecimalFormat("#")); scale.setTickLabelOffset(.2); scale.setTickLabelPaint(Color.BLACK); humidityPlot.addScale(0, scale); humidityPlot.setDialFrame(new StandardDialFrame()); DialValueIndicator valueInd = new DialValueIndicator(0); valueInd.setNumberFormat(new DecimalFormat("# '%rH'")); Color c = new Color(255, 255, 255, 0); valueInd.setBackgroundPaint(c); valueInd.setOutlinePaint(c); valueInd.setPaint(Color.cyan); humidityPlot.addLayer(valueInd); double angle = valueInd.getAngle(); double radius = valueInd.getRadius(); trendAnnotation.setPaint(Color.cyan); trendAnnotation.setAngle(angle); trendAnnotation.setRadius(radius + .1); humidityPlot.addLayer(trendAnnotation); DialPointer.Pointer pointer = new DialPointer.Pointer(0); humidityPlot.addPointer(pointer); DialCap cap = new DialCap(); cap.setRadius(cap.getRadius() * 1.5); humidityPlot.setCap(cap); range = new StandardDialRange(Humidity.MIN_HUMIDITY.get(), Humidity.MAX_HUMIDITY.get(), Color.BLACK); range.setInnerRadius(.40); range.setOuterRadius(.45); range.setScaleIndex(0); humidityPlot.addLayer(range); JFreeChart chart = new JFreeChart(humidityPlot); chart.setBackgroundPaint(Color.GRAY); ChartViewer chartViewer = new ChartViewer(chart); //chartViewer.setMinHeight(100); //chartViewer.setMinWidth(100); //chartViewer.setMaxHeight(400); //chartViewer.setMaxWidth(400); //chartViewer.setBackground(Color.GRAY); return chartViewer; }
From source file:com.bdb.weather.display.current.Barometer.java
private ChartViewer createChartElements(Pressure min, Pressure max) { Color backgroundDialColor = StageUtilities .toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_DIAL_COLOR)); Paint backgroundPaint = new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, backgroundDialColor); DialBackground background = new DialBackground(backgroundPaint); plot.addLayer(background);/*from w w w . j a va 2 s . co m*/ double dialTickIncrements = .2; switch (Pressure.getDefaultUnit()) { case IN_HG: dialTickIncrements = .2; break; case HECTO_PASCAL: case MILLIBAR: dialTickIncrements = 10.0; break; } scale = new StandardDialScale(min.get(), max.get(), 240.0, -300.0, dialTickIncrements, 10); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.9); scale.setTickLabelFormatter(Pressure.getDefaultFormatter()); scale.setTickLabelOffset(.25); scale.setTickLabelPaint( StageUtilities.toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_SCALE_TEXT))); scale.setMajorTickPaint( StageUtilities.toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_SCALE_TICK))); scale.setMinorTickPaint( StageUtilities.toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_SCALE_TICK))); plot.addScale(0, scale); plot.setDialFrame(new StandardDialFrame()); DialValueIndicator valueInd = new DialValueIndicator(0); // // Set background and outline paint to be completely transparent so they do not show at all // valueInd.setBackgroundPaint(new Color(255, 255, 255, 0)); valueInd.setOutlinePaint(new Color(255, 255, 255, 0)); valueInd.setPaint(StageUtilities.toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_VALUE))); valueInd.setNumberFormat(Pressure.getDefaultUnit().getFormatterWithUnit()); plot.addLayer(valueInd); double angle = valueInd.getAngle(); double radius = valueInd.getRadius(); trendAnnotation.setPaint(StageUtilities.toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_VALUE))); trendAnnotation.setAngle(angle); trendAnnotation.setRadius(radius + .1); plot.addLayer(trendAnnotation); DialPointer.Pointer pointer = new DialPointer.Pointer(0); plot.addPointer(pointer); DialCap cap = new DialCap(); cap.setRadius(cap.getRadius() * 1.5); plot.setCap(cap); range = new StandardDialRange(0.0, 360.0, StageUtilities.toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_VALUE_RANGE))); range.setInnerRadius(.40); range.setOuterRadius(.45); range.setScaleIndex(0); plot.addLayer(range); JFreeChart chart = new JFreeChart(plot); chart.setBackgroundPaint( StageUtilities.toAwtColor(colorPrefs.getColorPref(ColorPreferences.GUAGE_BACKGROUND))); ChartViewer chartViewer = new ChartViewer(chart); chartViewer.setMinHeight(200); chartViewer.setMinWidth(200); chartViewer.setMaxHeight(10000); chartViewer.setMaxWidth(10000); //chartViewer.setBorder(new BevelBorder(BevelBorder.RAISED)); return chartViewer; }