Package org.jfree.chart.axis

Examples of org.jfree.chart.axis.NumberAxis


//          numberAxis.setTickUnit(new NumberTickUnit(axisRange/tickCount));
//      }
//    }
    if(axis instanceof NumberAxis)
    {
      NumberAxis numberAxis = (NumberAxis)axis;
      int axisRange = (int)numberAxis.getRange().getLength();
      if(axisRange > 0)
      {
        if(tickInterval != null)
        {
          if(numberAxis.getNumberFormatOverride() != null)
          {
            numberAxis.setTickUnit(new NumberTickUnit(tickInterval.doubleValue(), numberAxis.getNumberFormatOverride()));
          }
          else
          {
            numberAxis.setTickUnit(new NumberTickUnit(tickInterval.doubleValue()));
          }
        }
        else if (tickCount != null)
        {
          int newTickUnitSize = axisRange / tickCount.intValue();
          if(newTickUnitSize > numberAxis.getTickUnit().getSize())
          {
            int tickUnitSize = newTickUnitSize;
     
            //preferably multiple of 5 values should be used as tick units lengths:
            int i = 1;
            while(tickUnitSize > 9)
            {
              tickUnitSize /= 10;
              i *= 10;
            }
            tickUnitSize *= i;
            newTickUnitSize = tickUnitSize + i/2;
     
            if(newTickUnitSize > 0 && axisRange / newTickUnitSize > tickCount.intValue())
            {
              newTickUnitSize += i / 2;
            }
            if(numberAxis.getNumberFormatOverride() != null)
            {
              numberAxis.setTickUnit(new NumberTickUnit(newTickUnitSize, numberAxis.getNumberFormatOverride()));
            }
            else
            {
              numberAxis.setTickUnit(new NumberTickUnit(newTickUnitSize));
            }
          }
        }
      }
    }
View Full Code Here


      return;
    }
   
    if(axis instanceof NumberAxis)
    {
      NumberAxis numberAxis = (NumberAxis)axis;
      int axisRange = (int)numberAxis.getRange().getLength();
      if(axisRange > 0)
      {
        if(tickInterval != null)
        {
          if(numberAxis.getNumberFormatOverride() != null)
          {
            numberAxis.setTickUnit(new NumberTickUnit(tickInterval.doubleValue(), numberAxis.getNumberFormatOverride()));
          }
          else
          {
            numberAxis.setTickUnit(new NumberTickUnit(tickInterval.doubleValue()));
          }
        }
        else if (tickCount != null)
        {
          if(numberAxis.getNumberFormatOverride() != null)
          {
            numberAxis.setTickUnit(new NumberTickUnit(axisRange / tickCount.intValue(), numberAxis.getNumberFormatOverride()));
          }
          else
          {
            numberAxis.setTickUnit(new NumberTickUnit(axisRange / tickCount.intValue()));
          }
        }
      }
    }
//    else if(axis instanceof DateAxis)
View Full Code Here

        plot.setDomainGridlinePaint(Color.white);
        plot.setDomainGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.white);
       
        // set the range axis to display integers only...
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setUpperMargin(0.0);
       
        // disable bar outlines...
        BarRenderer renderer = (BarRenderer) plot.getRenderer();
        renderer.setDrawBarOutline(false);
       
View Full Code Here

        if (normalized) {
            domainAxis.setRange(-0.05, 1.05);
        } else {
            domainAxis.setRange(dSeries.getMinX() - 1, dSeries.getMaxX() + 1);
        }
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(-1, dSeries.getMaxY() + 0.1 * dSeries.getMaxY());
    }
View Full Code Here

    JFreeChart chart = ChartFactory.createXYLineChart(chartName, xDomain, yDomain, collection, PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    Range rangeBounds = collection.getRangeBounds(true);
    double upper = Math.min(rangeBounds.getUpperBound(), rangeBounds.getLowerBound()*5);
    if(upper == 0.0){ upper = 10000; }
    if(rangeBounds.getLowerBound() == upper){
      yAxis.setRangeWithMargins(rangeBounds.getLowerBound()-rangeBounds.getLowerBound()*.1,upper+upper*.1);
    }
    else{
      yAxis.setRangeWithMargins(rangeBounds.getLowerBound(),upper);
    }
    return chart;
  }
View Full Code Here

      XYItemRenderer solutionRenderer = getRouteRenderer(solution);
      plot.setDataset(2, solution);
      plot.setRenderer(2, solutionRenderer);
    }
   
    NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();
   
    if(boundingBox == null){
      xAxis.setRangeWithMargins(getDomainRange(problem));
      yAxis.setRangeWithMargins(getRange(problem));
    }
    else{
      xAxis.setRangeWithMargins(new Range(boundingBox.minX, boundingBox.maxX));
      yAxis.setRangeWithMargins(new Range(boundingBox.minY, boundingBox.maxY));
    }
   
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);
   
View Full Code Here

      xyDataset.addSeries(targetSeries);

    }

    ValueAxis timeAxis = null;
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false);
    int timeIndex = -1;
    boolean timeAxisIsDate = false;
    if (forecaster instanceof TSLagUser && data != null) {
      TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
      if (!lagMaker.isUsingAnArtificialTimeIndex()
          && lagMaker.getAdjustForTrends()) {
        String timeName = lagMaker.getTimeStampField();
        if (data.attribute(timeName).isDate()) {
          timeAxis = new DateAxis("");
          timeAxisIsDate = true;
          timeIndex = data.attribute(timeName).index();
        }
      }
    }

    if (timeAxis == null) {
      timeAxis = new NumberAxis("");
      ((NumberAxis) timeAxis).setAutoRangeIncludesZero(false);
    }

    // now populate the series
    boolean hasConfidenceIntervals = false;
View Full Code Here

          + "-ahead", false, false);
      xyDataset.addSeries(targetSeries);
    }

    ValueAxis timeAxis = null;
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false);
    int timeIndex = -1;
    boolean timeAxisIsDate = false;
    if (forecaster instanceof TSLagUser && data != null) {
      TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
      if (!lagMaker.isUsingAnArtificialTimeIndex()
          && lagMaker.getAdjustForTrends()) {
        String timeName = lagMaker.getTimeStampField();
        if (data.attribute(timeName).isDate()) {
          timeAxis = new DateAxis("");
          timeAxisIsDate = true;
          timeIndex = data.attribute(timeName).index();
        }
      }
    }

    if (timeAxis == null) {
      timeAxis = new NumberAxis("");
      ((NumberAxis) timeAxis).setAutoRangeIncludesZero(false);
    }

    // now populate the series
    // for (int i = 0; i < preds.size(); i++) {
View Full Code Here

          + "-predicted", false, false);
      xyDataset.addSeries(targetSeries);
    }

    ValueAxis timeAxis = null;
    NumberAxis valueAxis = new NumberAxis("");
    valueAxis.setAutoRangeIncludesZero(false);
    int timeIndex = -1;
    boolean timeAxisIsDate = false;
    double artificialTimeStart = 0;
    double lastRealTimeValue = Utils.missingValue();
    if (forecaster instanceof TSLagUser && history != null) {
      TSLagMaker lagMaker = ((TSLagUser) forecaster).getTSLagMaker();
      if (!lagMaker.isUsingAnArtificialTimeIndex()
          && lagMaker.getAdjustForTrends()) {
        String timeName = lagMaker.getTimeStampField();
        if (history.attribute(timeName).isDate()) {
          timeAxis = new DateAxis("");
          timeAxisIsDate = true;
          timeIndex = history.attribute(timeName).index();
        }
      } else {
        try {
          artificialTimeStart = (history != null) ? 1 : lagMaker
              .getArtificialTimeStartValue() + 1;
        } catch (Exception ex) {
        }
      }
    }

    if (timeAxis == null) {
      timeAxis = new NumberAxis("");
      ((NumberAxis) timeAxis).setAutoRangeIncludesZero(false);
    }

    boolean hasConfidenceIntervals = false;
View Full Code Here

    public static void createBoxplot(DefaultBoxAndWhiskerCategoryDataset scatterDataset, PrintStream outStream,
            String title, String xAxisLabel, String yAxisLabel, Font lableFont ) throws IOException{
      
        CategoryAxis xAxis = new CategoryAxis(xAxisLabel);
        xAxis.setLabelFont(lableFont);
        NumberAxis yAxis = new NumberAxis(yAxisLabel);
        yAxis.setTickLabelFont(lableFont);
        yAxis.setAutoRangeIncludesZero(false);
        yAxis.setRange(0, 100);
        yAxis.setLabelFont(lableFont);
       
        BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
        renderer.setFillBox(true);
        renderer.setBaseLegendTextFont(lableFont);
        renderer.setStroke(new BasicStroke( 5.0f ));
View Full Code Here

TOP

Related Classes of org.jfree.chart.axis.NumberAxis

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.