Java 类org.jfree.chart.axis.TickUnits 实例源码

项目:PhET    文件:ZoomControl.java   
private void setRange( int index ) {

    ZoomSpec spec = _specs[ index ];
    Range range = spec.getRange();
    double tickSpacing = spec.getTickSpacing();
    String tickPattern = spec.getTickPattern();
    TickUnits tickUnits = new TickUnits();
    tickUnits.add( new NumberTickUnit( tickSpacing, new DecimalFormat( tickPattern ) ) );

    Iterator i = _plots.iterator();
    while ( i.hasNext() ) {
        XYPlot plot = (XYPlot) i.next();
        if ( _orientation == HORIZONTAL ) {
            plot.getDomainAxis().setRange( range );
            plot.getDomainAxis().setStandardTickUnits( tickUnits );
        }
        else {
            plot.getRangeAxis().setRange( range );
            plot.getRangeAxis().setStandardTickUnits( tickUnits );
        }
    }

    _zoomInButton.setEnabled( index > 0 );
    _zoomOutButton.setEnabled( index < _specs.length - 1 );
}
项目:PhET    文件:ZoomControl.java   
private void updateAxis() {

        // Range
        AxisSpec axisSpec = _zoomSpec.getAxisSpec( _zoomIndex );
        Range range = axisSpec.getRange();

        // Ticks
        double tickSpacing = axisSpec.getTickSpacing();
        DecimalFormat tickFormat = axisSpec.getTickFormat();
        TickUnits tickUnits = new TickUnits();
        tickUnits.add( new NumberTickUnit( tickSpacing, tickFormat ) );

        // Adjust the proper axis in each plot
        Iterator i = _plots.iterator();
        while ( i.hasNext() ) {
            XYPlot plot = (XYPlot) i.next();
            if ( _orientation == HORIZONTAL ) {
                plot.getDomainAxis().setRange( range );
                plot.getDomainAxis().setStandardTickUnits( tickUnits );
            }
            else {
                plot.getRangeAxis().setRange( range );
                plot.getRangeAxis().setStandardTickUnits( tickUnits );
            }
        }
    }
项目:parabuild-ci    文件:StatisticsUtils.java   
/**
 * Returns a collection of tick units for integer values.
 */
public static TickUnitSource createWordedTimeTickUnits() {

  final TickUnits units = new TickUnits();
  units.add(new WordedTimeTickUnit(1));
  units.add(new WordedTimeTickUnit(2));
  units.add(new WordedTimeTickUnit(5));
  units.add(new WordedTimeTickUnit(10));
  units.add(new WordedTimeTickUnit(20));
  units.add(new WordedTimeTickUnit(50));
  units.add(new WordedTimeTickUnit(100));
  units.add(new WordedTimeTickUnit(200));
  units.add(new WordedTimeTickUnit(500));
  units.add(new WordedTimeTickUnit(1000));
  units.add(new WordedTimeTickUnit(2000));
  units.add(new WordedTimeTickUnit(5000));
  units.add(new WordedTimeTickUnit(10000));
  units.add(new WordedTimeTickUnit(20000));
  units.add(new WordedTimeTickUnit(50000));
  units.add(new WordedTimeTickUnit(100000));
  units.add(new WordedTimeTickUnit(200000));
  units.add(new WordedTimeTickUnit(500000));
  units.add(new WordedTimeTickUnit(1000000));
  units.add(new WordedTimeTickUnit(2000000));
  units.add(new WordedTimeTickUnit(5000000));
  units.add(new WordedTimeTickUnit(10000000));
  units.add(new WordedTimeTickUnit(20000000));
  units.add(new WordedTimeTickUnit(50000000));
  units.add(new WordedTimeTickUnit(100000000));
  units.add(new WordedTimeTickUnit(200000000));
  units.add(new WordedTimeTickUnit(500000000));
  units.add(new WordedTimeTickUnit(1000000000));
  units.add(new WordedTimeTickUnit(2000000000));
  units.add(new WordedTimeTickUnit(5000000000.0));
  units.add(new WordedTimeTickUnit(10000000000.0));
  return units;
}
项目:PhET    文件:PositionAxis.java   
public PositionAxis() {
    String label = QTResources.getString( "axis.position" ) + " (" + QTResources.getString( "units.position" ) + ")";
    setLabel( label );
    setLabelFont( QTConstants.AXIS_LABEL_FONT );
    setRange( QTConstants.POSITION_RANGE );
    TickUnits xUnits = (TickUnits) NumberAxis.createIntegerTickUnits();
    setStandardTickUnits( xUnits );
}
项目:PhET    文件:TPChart.java   
public TPDomainAxis() {
    super( "titrant volume (mL)" );
    setRange( TPConstants.TITRANT_VOLUME_RANGE.getMin(), TPConstants.TITRANT_VOLUME_RANGE.getMax() );
    // ticks every 5 units
    TickUnits tickUnits = new TickUnits();
    tickUnits.add( new NumberTickUnit( 5, new DecimalFormat( "0" ) ) );
    setStandardTickUnits( tickUnits );
    setAutoTickUnitSelection( true );
}
项目:PhET    文件:TPChart.java   
public TPRangeAxis() {
    super( "pH" );
    setRange( TPConstants.PH_RANGE.getMin(), TPConstants.PH_RANGE.getMax() );
    // ticks every 1 unit
    TickUnits tickUnits = new TickUnits();
    tickUnits.add( new NumberTickUnit( 1, new DecimalFormat( "0" ) ) );
    setStandardTickUnits( tickUnits );
    setAutoTickUnitSelection( true );
}
项目:PhET    文件:BSPositionAxis.java   
public BSPositionAxis() {

    setRange( BSConstants.POSITION_VIEW_RANGE );

    String label = BSResources.getString( "axis.position" ) + " (" + BSResources.getString( "units.position" ) + ")";
    setLabel( label );
    setLabelFont( BSConstants.AXIS_LABEL_FONT );
    setTickLabelFont( BSConstants.AXIS_TICK_LABEL_FONT );

    // Tick units
    TickUnits tickUnits = new TickUnits();
    tickUnits.add( new NumberTickUnit( BSConstants.POSITION_TICK_SPACING, BSConstants.POSITION_TICK_FORMAT ) );
    setStandardTickUnits( tickUnits );
    setAutoTickUnitSelection( true );
}
项目:GpsdInspector    文件:GpsInspector.java   
/**
 * Creates a sample chart.
 *
 * @param dataset  the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createPolarPlot(final XYDataset dataset)
{
    final JFreeChart chart = ChartFactory.createPolarChart(
        "Satellite Locations",
        dataset,
        false, //lengend
        true,  // tooltips
        false // url
    );
    final PolarPlot plot = (PolarPlot) chart.getPlot();

    chart.setBackgroundPaint(new Color(220,220,220));

    ChartTheme dark = StandardChartTheme.createDarknessTheme();
    dark.apply(chart);
    plot.setOutlinePaint(Color.BLACK);


    //final DefaultPolarItemRenderer renderer = (DefaultPolarItemRenderer) plot.getRenderer();
    // set renderer - using my custom one
    SctterPlotItemGPSRenderer rend = new SctterPlotItemGPSRenderer();
    plot.setRenderer(rend);

    // set horizon = 0-90
    ValueAxis axis = plot.getAxis();
    axis.setRange(0.0,90.0);
    // set tick spacing
    //axis.getRange().
    //axis.setAutoTickUnitSelection(false);
    //axis.setAutoRangeMinimumSize(3);
    TickUnits tu = new TickUnits();
    tu.add( new NumberTickUnit(15));
    axis.setStandardTickUnits( tu );


    return chart;
}
项目:astor    文件:TickUnitsTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits();
    TickUnits t2 = (TickUnits) NumberAxis.createIntegerTickUnits();
    assertTrue(t1.equals(t2));
    assertTrue(t2.equals(t1));
}
项目:vimarsha    文件:TimeSlicedClassiferForm.java   
private JFreeChart createChart(XYSeriesCollection dataSet, String chartTitle) {
    JFreeChart chart = ChartFactory.createXYLineChart(
            chartTitle,
            "Time slice number",
            "Classification",
            dataSet,
            PlotOrientation.VERTICAL,
            true,
            true,
            false
    );

    XYPlot plot = chart.getXYPlot();
    NumberAxis range = (NumberAxis) plot.getRangeAxis();

    range.setRange(0, 1.1);
    TickUnits units = new TickUnits();
    units.add(new NumberTickUnit(0));
    units.add(new NumberTickUnit(0.5));
    units.add(new NumberTickUnit(1));

    range.setStandardTickUnits(units);
    range.setNumberFormatOverride(new DecimalFormat() {
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            if (number == 1)
                return toAppendTo.append("badfs");
            else if (number == 0.5)
                return toAppendTo.append("badma");
            else
                return toAppendTo.append("good");
        }
    });

    return chart;
}
项目:UbikSim    文件:Periodogram.java   
private JFreeChart createChart(final XYDataset data,String title) {

        final JFreeChart chart = ChartFactory.createScatterPlot(
            title,
            "X",
            "Y",
            data,
            PlotOrientation.VERTICAL,
            false,
            true,
            false
        );

        final XYPlot plot = chart.getXYPlot();
        //plot.getRenderer().setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());

        final ValueAxis domainAxis = new NumberAxis("Time");
        domainAxis.setUpperMargin(0.50);
        domainAxis.setRange(0, 24);
        TickUnits units = new TickUnits();
        units.add(new NumberTickUnit(1));
        domainAxis.setStandardTickUnits(units);
        plot.setDomainAxis(domainAxis);

        final ValueAxis rangeAxis = plot.getRangeAxis();
        rangeAxis.setUpperMargin(0.30);
        rangeAxis.setLowerMargin(0.50);
        rangeAxis.setStandardTickUnits(units);

        return chart;

    }
项目:jasperreports    文件:ChartUtil.java   
public TickUnitSource createIntegerTickUnits(Locale locale)
{
       DecimalFormatSymbols formatSymbols = DecimalFormatSymbols.getInstance(locale);

    // copied from NumberAxis.createIntegerTickUnits() to preserve backward behaviour
       TickUnits units = new TickUnits();
    DecimalFormat df0 = new DecimalFormat("0", formatSymbols);
       DecimalFormat df1 = new DecimalFormat("#,##0", formatSymbols);
       units.add(new NumberTickUnit(1, df0));
       units.add(new NumberTickUnit(2, df0));
       units.add(new NumberTickUnit(5, df0));
       units.add(new NumberTickUnit(10, df0));
       units.add(new NumberTickUnit(20, df0));
       units.add(new NumberTickUnit(50, df0));
       units.add(new NumberTickUnit(100, df0));
       units.add(new NumberTickUnit(200, df0));
       units.add(new NumberTickUnit(500, df0));
       units.add(new NumberTickUnit(1000, df1));
       units.add(new NumberTickUnit(2000, df1));
       units.add(new NumberTickUnit(5000, df1));
       units.add(new NumberTickUnit(10000, df1));
       units.add(new NumberTickUnit(20000, df1));
       units.add(new NumberTickUnit(50000, df1));
       units.add(new NumberTickUnit(100000, df1));
       units.add(new NumberTickUnit(200000, df1));
       units.add(new NumberTickUnit(500000, df1));
       units.add(new NumberTickUnit(1000000, df1));
       units.add(new NumberTickUnit(2000000, df1));
       units.add(new NumberTickUnit(5000000, df1));
       units.add(new NumberTickUnit(10000000, df1));
       units.add(new NumberTickUnit(20000000, df1));
       units.add(new NumberTickUnit(50000000, df1));
       units.add(new NumberTickUnit(100000000, df1));
       units.add(new NumberTickUnit(200000000, df1));
       units.add(new NumberTickUnit(500000000, df1));
       units.add(new NumberTickUnit(1000000000, df1));
       units.add(new NumberTickUnit(2000000000, df1));
       units.add(new NumberTickUnit(5000000000.0, df1));
       units.add(new NumberTickUnit(10000000000.0, df1));

    // adding further values by default because 1E10 is not enough for some people
    // using getNumberInstance because that's what NumberAxis.createIntegerTickUnits does
    units.add(new NumberTickUnit(20000000000L, df1));
    units.add(new NumberTickUnit(50000000000L, df1));
    units.add(new NumberTickUnit(100000000000L, df1));
    units.add(new NumberTickUnit(200000000000L, df1));
    units.add(new NumberTickUnit(500000000000L, df1));
    units.add(new NumberTickUnit(1000000000000L, df1));
    units.add(new NumberTickUnit(2000000000000L, df1));
    units.add(new NumberTickUnit(5000000000000L, df1));
    units.add(new NumberTickUnit(10000000000000L, df1));
    units.add(new NumberTickUnit(20000000000000L, df1));
    units.add(new NumberTickUnit(50000000000000L, df1));
    units.add(new NumberTickUnit(100000000000000L, df1));
    units.add(new NumberTickUnit(200000000000000L, df1));
    units.add(new NumberTickUnit(500000000000000L, df1));
    units.add(new NumberTickUnit(1000000000000000L, df1));
    units.add(new NumberTickUnit(2000000000000000L, df1));
    units.add(new NumberTickUnit(5000000000000000L, df1));
    units.add(new NumberTickUnit(10000000000000000L, df1));
    units.add(new NumberTickUnit(20000000000000000L, df1));
    units.add(new NumberTickUnit(50000000000000000L, df1));
    units.add(new NumberTickUnit(100000000000000000L, df1));
    units.add(new NumberTickUnit(200000000000000000L, df1));
    units.add(new NumberTickUnit(500000000000000000L, df1));
    units.add(new NumberTickUnit(1000000000000000000L, df1));
    units.add(new NumberTickUnit(2000000000000000000L, df1));
    units.add(new NumberTickUnit(5000000000000000000L, df1));

    return units;
}
项目:opencards    文件:SchedulePlanningPanel.java   
public SchedulePlanningPanel() {
        setLayout(new BorderLayout());

        // setup the stacked bar chart
        dataset = new DefaultCategoryDataset();
        final JFreeChart chart = ChartFactory.createStackedBarChart(
                null,  // chart title
                Utils.getRB().getString("CardTableModel.stats.weekSchedule"),                  // domain axis label
//                "# cards",                     // range axis label
                null,                     // range axis label
                dataset,                     // data
                PlotOrientation.VERTICAL,    // the plot orientation
                false,                        // legend
                true,                        // tooltips
                false                        // urls
        );

        StackedBarRenderer renderer = new StackedBarRenderer();
        renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

        //green
        renderer.setItemMargin(0.0);
        Paint greenPaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
        renderer.setSeriesPaint(1, greenPaint);
        renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());


        //blue
        Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF));
        renderer.setSeriesPaint(0, bluePaint);
        renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());


//        Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88));
//        renderer.setSeriesPaint(1, p2);
//        renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
//
//        Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
//        renderer.setSeriesPaint(2, p3);
//        renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator());

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setRenderer(renderer);
        valueAxis = plot.getRangeAxis();
        TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits();
        valueAxis.setStandardTickUnits(units);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPopupMenu(null);
        chartPanel.setDomainZoomable(false);
        chartPanel.setRangeZoomable(false);

        add(chartPanel, BorderLayout.CENTER);

        rebuildPanel(new HashSet<CardFile>());
    }
项目:opencards    文件:LTMStateGraphPanel.java   
public LTMStateGraphPanel() {
        setLayout(new BorderLayout());

        // setup the stacked bar chart
        dataset = new DefaultCategoryDataset();
        final JFreeChart chart = ChartFactory.createStackedBarChart(
                null,  // chart title
                Utils.getRB().getString("CardTableModel.stats.learnsuccess"),                  // domain axis label
//                "# cards",                     // range axis label
                null,                     // range axis label
                dataset,                     // data
                PlotOrientation.VERTICAL,    // the plot orientation
                false,                        // legend
                true,                        // tooltips
                false                        // urls
        );

        StackedBarRenderer renderer = new StackedBarRenderer();
        renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

        renderer.setItemMargin(0.0);
        Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF));
        renderer.setSeriesPaint(0, bluePaint);
        renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());

//        Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88));
//        renderer.setSeriesPaint(1, p2);
//        renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
//
//        Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
//        renderer.setSeriesPaint(2, p3);
//        renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator());

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setRenderer(renderer);
        valueAxis = plot.getRangeAxis();
        TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits();
        valueAxis.setStandardTickUnits(units);

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPopupMenu(null);
        chartPanel.setDomainZoomable(false);
        chartPanel.setRangeZoomable(false);
        add(chartPanel, BorderLayout.CENTER);

        rebuildPanel(new HashSet<CardFile>());

        learnedPerfectly = Utils.getRB().getString("CardTableModel.stats.perfect");
        learnedNotYet = Utils.getRB().getString("CardTableModel.stats.notatall");
        learnedNaJa = Utils.getRB().getString("CardTableModel.stats.well");
    }
项目:HTML5_WebSite    文件:WaterfallChartDemo1.java   
/**
   * Returns the chart.
   * 
   * @param dataset  the dataset.
   *
   * @return The chart.
   */
  protected JFreeChart createChart(CategoryDataset dataset) {

      JFreeChart chart = ChartFactory.createWaterfallChart(
          chartTitle,
          domainLabel,
          rangeLabel,
          dataset,
          PlotOrientation.VERTICAL,
          !legendPanelOn,
          true,
          false
      );
      chart.setBackgroundPaint(Color.white);

      CategoryPlot plot = chart.getCategoryPlot();
      plot.setBackgroundPaint(Color.lightGray);
      plot.setRangeGridlinePaint(Color.white);
      plot.setRangeGridlinesVisible(true);
      plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

      ValueAxis rangeAxis = plot.getRangeAxis();

      // create a custom tick unit collection...
      DecimalFormat formatter = new DecimalFormat("##,###");
      formatter.setNegativePrefix("(");
      formatter.setNegativeSuffix(")");
      TickUnits standardUnits = new TickUnits();
      standardUnits.add(new NumberTickUnit(5, formatter));
      standardUnits.add(new NumberTickUnit(10, formatter));
      standardUnits.add(new NumberTickUnit(20, formatter));
      standardUnits.add(new NumberTickUnit(50, formatter));
      standardUnits.add(new NumberTickUnit(100, formatter));
      standardUnits.add(new NumberTickUnit(200, formatter));
      standardUnits.add(new NumberTickUnit(500, formatter));
      standardUnits.add(new NumberTickUnit(1000, formatter));
      standardUnits.add(new NumberTickUnit(2000, formatter));
      standardUnits.add(new NumberTickUnit(5000, formatter));
      rangeAxis.setStandardTickUnits(standardUnits);

      BarRenderer renderer = (BarRenderer) plot.getRenderer();
      renderer.setDrawBarOutline(false);
renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

      DecimalFormat labelFormatter = new DecimalFormat("$##,###.00");
      labelFormatter.setNegativePrefix("(");
      labelFormatter.setNegativeSuffix(")");
      renderer.setBaseItemLabelGenerator(
          new StandardCategoryItemLabelGenerator("{2}", labelFormatter)
      );
      renderer.setBaseItemLabelsVisible(true);

setCategorySummary(dataset);
      return chart;
  }
项目:webanno    文件:MonitoringPage.java   
private JFreeChart createProgressChart(Map<String, Integer> chartValues, int aMaxValue,
        boolean aIsPercentage)
{
    // fill dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if (aMaxValue > 0) {
        for (String chartValue : chartValues.keySet()) {
            dataset.setValue(chartValues.get(chartValue), "Completion", chartValue);
        }
    }

    // create chart
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset,
            PlotOrientation.HORIZONTAL, false, false, false);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setOutlineVisible(false);
    plot.setBackgroundPaint(null);
    plot.setNoDataMessage("No data");
    plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0, 20, 0, 20));
    if (aMaxValue > 0) {
        plot.getRangeAxis().setRange(0.0, aMaxValue);
        ((NumberAxis) plot.getRangeAxis()).setNumberFormatOverride(new DecimalFormat("0"));
        // For documents less than 10, avoid repeating the number of documents such
        // as 0 0 1 1 1 - NumberTickUnit automatically determines the range
        if (!aIsPercentage && aMaxValue <= 10) {
            TickUnits standardUnits = new TickUnits();
            NumberAxis tick = new NumberAxis();
            tick.setTickUnit(new NumberTickUnit(1));
            standardUnits.add(tick.getTickUnit());
            plot.getRangeAxis().setStandardTickUnits(standardUnits);
        }
    }
    else {
        plot.getRangeAxis().setVisible(false);
        plot.getDomainAxis().setVisible(false);
    }

    BarRenderer renderer = new BarRenderer();
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    // renderer.setGradientPaintTransformer(new
    // StandardGradientPaintTransformer(
    // GradientPaintTransformType.HORIZONTAL));
    renderer.setSeriesPaint(0, Color.BLUE);
    chart.getCategoryPlot().setRenderer(renderer);

    return chart;
}