Package org.jfree.data

Examples of org.jfree.data.Range


    JRThermometerPlot jrPlot = (JRThermometerPlot)getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)getDataset());

    Range range = convertRange(jrPlot.getDataRange());

    // Set the boundary of the thermomoter
    chartPlot.setLowerBound(range.getLowerBound());
    chartPlot.setUpperBound(range.getUpperBound());

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    Color color = jrPlot.getMercuryColor();
    if (color != null)
    {
      chartPlot.setMercuryPaint(color);
      chartPlot.setUseSubrangePaint(false);
    }

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont(), getLocale()));
      }
    }

    // Set the location of where the value is displayed
    switch (jrPlot.getValueLocationValue())
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);
View Full Code Here


    StandardDialFrame dialFrame = new StandardDialFrame();
    dialPlot.setDialFrame(dialFrame);

    DialBackground db = new DialBackground(jrPlot.getBackcolor());
    dialPlot.setBackground(db);
    Range range = convertRange(jrPlot.getDataRange());
    StandardDialScale scale =
      new StandardDialScale(
        range.getLowerBound(),
        range.getUpperBound(),
        225,
        -270,
        (range.getUpperBound() - range.getLowerBound())/6,
        15
        );
    scale.setTickRadius(0.9);
    scale.setTickLabelOffset(0.16);
    if(jrPlot.getTickLabelFont() != null)
    {
      scale.setTickLabelFont(JRFontUtil.getAwtFont(jrPlot.getTickLabelFont(), getLocale()));
    }
    scale.setMajorTickStroke(new BasicStroke(1f));
    scale.setMinorTickStroke(new BasicStroke(0.3f));
    scale.setMajorTickPaint(jrPlot.getTickColor());
    scale.setMinorTickPaint(jrPlot.getTickColor());

    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 > 0)
      {
        colorStep = 255 / size;
      }
      for(int i = 0; i < size; i++)
      {
        JRMeterInterval interval = (JRMeterInterval)intervals.get(i);
        Range intervalRange = convertRange(interval.getDataRange());

        Color color = new Color(255 - colorStep * i, 0 + colorStep * i, 0);
       
        StandardDialRange dialRange =
          new StandardDialRange(
            intervalRange.getLowerBound(),
            intervalRange.getUpperBound(),
            interval.getBackgroundColor() == null
              ? color
              : interval.getBackgroundColor()
            );
        dialRange.setInnerRadius(0.41);
View Full Code Here

    if (dataRange == null)
      return null;

    Number low = (Number)evaluateExpression(dataRange.getLowExpression());
    Number high = (Number)evaluateExpression(dataRange.getHighExpression());
    return new Range( low != null ? low.doubleValue() : 0.0,
                 high != null ? high.doubleValue() : 100.0);
  }
View Full Code Here

  {
    String label = interval.getLabel();
    if (label == null)
      label = "";

    Range range = convertRange(interval.getDataRange());

    Color color = interval.getBackgroundColor() != null ? interval.getBackgroundColor() : (Color)ChartThemesConstants.TRANSPARENT_PAINT;
    float[] components = color.getRGBColorComponents(null);

    float alpha = interval.getAlphaDouble() == null ? (float)JRMeterInterval.DEFAULT_TRANSPARENCY : interval.getAlphaDouble().floatValue();
View Full Code Here

    JRThermometerPlot jrPlot = (JRThermometerPlot)getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)getDataset());

    Range range = convertRange(jrPlot.getDataRange());

    // Set the boundary of the thermomoter
    chartPlot.setLowerBound(range.getLowerBound());
    chartPlot.setUpperBound(range.getUpperBound());

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    Color color = jrPlot.getMercuryColor();
    if (color != null)
    {
      chartPlot.setMercuryPaint(color);
      chartPlot.setUseSubrangePaint(false);
    }

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
//        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()));
      }
    }

    // Set the location of where the value is displayed
    ValueLocationEnum valueLocation = jrPlot.getValueLocationValue();
    switch (valueLocation)
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);
View Full Code Here

    StandardDialFrame dialFrame = new StandardDialFrame();
    dialPlot.setDialFrame(dialFrame);

    DialBackground db = new DialBackground(jrPlot.getBackcolor());
    dialPlot.setBackground(db);
    Range range = convertRange(jrPlot.getDataRange());
    //double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));

    StandardDialScale scale =
      new StandardDialScale(
        range.getLowerBound(),
        range.getUpperBound(),
        225,
        -270,
        (range.getUpperBound() - range.getLowerBound())/6,
        15
        );
    scale.setTickRadius(0.9);
    scale.setTickLabelOffset(0.16);
    JRBaseFont font = new JRBaseFont();
    JRFontUtil.copyNonNullOwnProperties(getPlotSettings().getTickLabelFont(), font);
    JRFontUtil.copyNonNullOwnProperties(jrPlot.getTickLabelFont(), font);
    font = new JRBaseFont(getChart(), font);
    scale.setTickLabelFont(JRFontUtil.getAwtFont(font, getLocale()));
    scale.setMajorTickStroke(new BasicStroke(1f));
    scale.setMinorTickStroke(new BasicStroke(0.3f));
    scale.setMajorTickPaint(jrPlot.getTickColor());
    scale.setMinorTickPaint(jrPlot.getTickColor());

    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 > 0)
        colorStep = 255 / size;
     
      for(int i = 0; i < size; i++)
      {
        JRMeterInterval interval = (JRMeterInterval)intervals.get(i);
        Range intervalRange = convertRange(interval.getDataRange());

        Color color = new Color(255 - colorStep * i, 0 + colorStep * i, 0);
       
        StandardDialRange dialRange =
          new StandardDialRange(
            intervalRange.getLowerBound(),
            intervalRange.getUpperBound(),
            interval.getBackgroundColor() == null
              ? color
              : interval.getBackgroundColor()
            );
        dialRange.setInnerRadius(0.41);
View Full Code Here

    chartPlot.setTickLabelFont(themeTickLabelFont);
   
    Color tickColor = jrPlot.getTickColor() == null ? Color.BLACK : jrPlot.getTickColor();
    chartPlot.setTickPaint(tickColor);
    int dialUnitScale = 1;
    Range range = convertRange(jrPlot.getDataRange());
    if(range != null)
    {
      // Set the meter's range
      chartPlot.setRange(range);
      double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));
      dialUnitScale = ChartThemesUtilities.getScale(bound);
      if((range.getLowerBound() == (int)range.getLowerBound() &&
          range.getUpperBound() == (int)range.getUpperBound() &&
          tickInterval == (int)tickInterval) ||
          dialUnitScale > 1
          )
      {
        chartPlot.setTickLabelFormat(new DecimalFormat("#,##0"));
View Full Code Here

    // Set the generic options
    configureChart(jfreeChart, getPlot());
    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    Range range = convertRange(jrPlot.getDataRange());

    if(range != null)
    {
      // Set the boundary of the thermomoter
      chartPlot.setLowerBound(range.getLowerBound());
      chartPlot.setUpperBound(range.getUpperBound());
    }
    chartPlot.setGap(0);

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    List seriesPaints = (List)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
   
    Paint paint = jrPlot.getMercuryColor();
    if(paint != null)
    {
      chartPlot.setUseSubrangePaint(false);
    }
    else
    {
      //it has no effect, but is kept for backward compatibility reasons
      paint = (Paint)seriesPaints.get(0);
    }
   
    chartPlot.setMercuryPaint(paint);

    chartPlot.setThermometerPaint(THERMOMETER_COLOR);
    chartPlot.setThermometerStroke(new BasicStroke(2f));
    chartPlot.setOutlineVisible(false);
    chartPlot.setValueFont(chartPlot.getValueFont().deriveFont(Font.BOLD));

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
//        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()).deriveFont(Font.BOLD));
      }
    }

    // Set the location of where the value is displayed
    // Set the location of where the value is displayed
    ValueLocationEnum valueLocation = jrPlot.getValueLocationValue();
    switch (valueLocation)
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    return jfreeChart;
  }
View Full Code Here

    DialBackground db = new DialBackground(ChartThemesConstants.TRANSPARENT_PAINT);
    dialPlot.setBackground(db);
    ScaledDialScale 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 ScaledDialScale(
          lowerBound,
          upperBound,
          210,
          -240,
          (upperBound - lowerBound)/6,
          1
          );
      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 ScaledDialScale();
    }
    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.7f));
    scale.setMajorTickPaint(Color.BLACK);
    scale.setMinorTickPaint(Color.BLACK);
    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 =
View Full Code Here

    if (dataRange == null)
      return null;

    Number low = (Number)evaluateExpression(dataRange.getLowExpression());
    Number high = (Number)evaluateExpression(dataRange.getHighExpression());
    return new Range( low != null ? low.doubleValue() : 0.0,
                 high != null ? high.doubleValue() : 100.0);
  }
View Full Code Here

TOP

Related Classes of org.jfree.data.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.