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

项目: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    文件:LogAxis.java   
/**
 * Sets the tick unit for the axis and, if requested, sends an 
 * {@link AxisChangeEvent} to all registered listeners.  In addition, an 
 * option is provided to turn off the "auto-select" feature for tick units 
 * (you can restore it using the 
 * {@link ValueAxis#setAutoTickUnitSelection(boolean)} method).
 *
 * @param unit  the new tick unit (<code>null</code> not permitted).
 * @param notify  notify listeners?
 * @param turnOffAutoSelect  turn off the auto-tick selection?
 */
public void setTickUnit(NumberTickUnit unit, boolean notify, 
                        boolean turnOffAutoSelect) {

    if (unit == null) {
        throw new IllegalArgumentException("Null 'unit' argument.");   
    }
    this.tickUnit = unit;
    if (turnOffAutoSelect) {
        setAutoTickUnitSelection(false, false);
    }
    if (notify) {
        notifyListeners(new AxisChangeEvent(this));
    }

}
项目:PhET    文件:ChartNode.java   
public EatingAndExerciseControlGraph( PhetPCanvas canvas, ControlGraphSeries series, String title, int minY, int maxY, TimeSeriesModel timeSeriesModel ) {
    super( canvas, series, title, minY, maxY, timeSeriesModel );
    gradientButtonNode = new HTMLImageButtonNode( EatingAndExerciseResources.getString( "time.reset" ), new PhetFont( Font.BOLD, 12 ), Color.green );
    gradientButtonNode.addActionListener( new ActionListener() {
        public void actionPerformed( ActionEvent e ) {
            resetChartArea();
        }
    } );
    addChild( gradientButtonNode );

    axisLabel = new PNode();
    PText text = new EatingAndExercisePText( EatingAndExerciseResources.getString( "units.time.yrs" ) );
    axisLabel.addChild( text );
    axisLabel.addChild( new PhetPPath( new Arrow( new Point2D.Double( text.getFullBounds().getMaxX(), text.getFullBounds().getCenterY() ),
                                                  new MutableVector2D( 20, 0 ), 6, 6, 2, 0.5, true ).getShape(), Color.black ) );
    addChild( axisLabel );

    NumberAxis numberAxis = (NumberAxis) getJFreeChartNode().getChart().getXYPlot().getDomainAxis();

    numberAxis.setTickUnit( new NumberTickUnit( 2.0 * DEFAULT_RANGE_YEARS / 12.0 ) );
    numberAxis.setNumberFormatOverride( new YearMonthFormat() );

    relayout();
}
项目:Prism-gsoc16    文件:PrismLogarithmicAxis.java   
/**
 * Sets the tick unit for the axis and, if requested, sends an 
 * {@link AxisChangeEvent} to all registered listeners.  In addition, an 
 * option is provided to turn off the "auto-select" feature for tick units 
 * (you can restore it using the 
 * {@link ValueAxis#setAutoTickUnitSelection(boolean)} method).
 *
 * @param unit  the new tick unit (<code>null</code> not permitted).
 * @param notify  notify listeners?
 * @param turnOffAutoSelect  turn off the auto-tick selection?
 */
public void setTickUnit(NumberTickUnit unit, boolean notify, 
                        boolean turnOffAutoSelect) {

    if (unit == null) {
        throw new IllegalArgumentException("Null 'unit' argument.");   
    }
    this.tickUnit = unit;
    if (turnOffAutoSelect) {
        setAutoTickUnitSelection(false, false);
    }
    if (notify) {
        notifyListeners(new AxisChangeEvent(this));
    }

}
项目:vizardous    文件:CellDivisionTimeChart2D.java   
@Override
public final JFreeChart createJFreeChart(XYDataset dataset) {
    String timeUnit = this.forest.getMetaxml().getAllFrames().get(0).getElapsedTimeUnit();

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Individual division times", // chart title
            "Generation [-]", // domain axis label
            String.format("Division time [%s]", timeUnit), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    this.styleChart(chart);

    // Customize the domain axis
    final NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();
    domainAxis.setTickUnit(new NumberTickUnit(1.0)); // Generations are
                                                        // integers..

    return chart;
}
项目:viewpark    文件:ImageAction.java   
public String BarChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    List<Datas> list = new IncomeDao().getDatas2(park.getParkid());
    for (Datas datas : list) {
        dataset.addValue(datas.getMoney(), "", datas.getYear() + "年"
                + datas.getMonth() + "月");
    }
    ChartFactory.setChartTheme(getStandardChartTheme());
    chart = ChartFactory.createBarChart3D("停车场柱状图", "月份", "金额", dataset,
            PlotOrientation.VERTICAL, true, false, false);// 数据区的方向
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryAxis axis = plot.getDomainAxis();// 数据区的分类轴
    axis.setLowerMargin(0);// 分类轴下(左)边距
    axis.setUpperMargin(0);// 分类轴上(右)边距
    axis.setLabelFont(new Font("宋体", Font.BOLD, 14));// 坐标轴标题字体
    axis.setTickLabelFont(new Font("宋体", Font.BOLD, 14));// 坐标轴标尺值字体
    NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();// 获取纵轴坐标
    numberaxis.setTickLabelPaint(Color.GRAY);// 纵轴标签颜色
    numberaxis.setAutoTickUnitSelection(false); // 纵坐标的默认间距值
    numberaxis.setTickUnit(new NumberTickUnit(300));// 设置纵坐标间距值
    chart.setTitle(getTitle());
    return SUCCESS;
}
项目:scalalab    文件:jPlot.java   
/**
 * Defines delta between ticks on the specified axis.
 *
 * @param delta the delta
 */
public void setTickUnit(AxisEnum axis, double delta) {

    if (m_chart != null) {
        NumberAxis rangeAxis = getAxis(axis);

        //  change the auto tick unit selection to integer units only...
        //  rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
        rangeAxis.setTickUnit(new NumberTickUnit(delta));
    }

    switch (axis) {
        case X:
            m_xTickDelta = delta;
            break;
        case Y:
            m_yTickDelta = delta;
            break;
    }
}
项目:limpet    文件:ChartBuilder.java   
@Override
public final NumberTickUnit getTickUnit()
{
  final NumberTickUnit tickUnit = super.getTickUnit();
  if (tickUnit.getSize() < 15)
  {
    return tickUnit;
  }
  else if (tickUnit.getSize() < 45)
  {
    return new NumberTickUnit(30);
  }
  else if (tickUnit.getSize() < 90)
  {
    return new NumberTickUnit(45);
  }
  else if (tickUnit.getSize() < 180)
  {
    return new NumberTickUnit(90);
  }
  else
  {
    return new NumberTickUnit(180);
  }
}
项目:nabs    文件:LogAxis.java   
/**
 * Sets the tick unit for the axis and, if requested, sends an 
 * {@link AxisChangeEvent} to all registered listeners.  In addition, an 
 * option is provided to turn off the "auto-select" feature for tick units 
 * (you can restore it using the 
 * {@link ValueAxis#setAutoTickUnitSelection(boolean)} method).
 *
 * @param unit  the new tick unit (<code>null</code> not permitted).
 * @param notify  notify listeners?
 * @param turnOffAutoSelect  turn off the auto-tick selection?
 */
public void setTickUnit(NumberTickUnit unit, boolean notify, 
                        boolean turnOffAutoSelect) {

    if (unit == null) {
        throw new IllegalArgumentException("Null 'unit' argument.");   
    }
    this.tickUnit = unit;
    if (turnOffAutoSelect) {
        setAutoTickUnitSelection(false, false);
    }
    if (notify) {
        notifyListeners(new AxisChangeEvent(this));
    }

}
项目:svarog    文件:RocDialog.java   
public XYPlot getRocPlot() {
    if (rocPlot == null) {

        NumberAxis xAxis = new NumberAxis();
        xAxis.setAutoRange(false);
        xAxis.setRange(0,1);
        xAxis.setTickUnit(new NumberTickUnit(0.2));
        xAxis.setLabel(_("False positive rate"));

        NumberAxis yAxis = new NumberAxis();
        yAxis.setAutoRange(false);
        yAxis.setRange(0,1);
        yAxis.setTickUnit(new NumberTickUnit(0.2));
        yAxis.setLabel(_("True positive rate"));

        rocPlot = new XYPlot(null, xAxis, yAxis, getPlotRenderer());
        AxisSpace axisSpace = new AxisSpace();
        axisSpace.setBottom(AXIS_SPACE_SIZE);
        axisSpace.setLeft(AXIS_SPACE_SIZE);
        rocPlot.setFixedDomainAxisSpace(axisSpace);
        rocPlot.setFixedRangeAxisSpace(axisSpace);


    }
    return rocPlot;
}
项目:svarog    文件:ResponseChartPanel.java   
/**
 * Sets the maximum value to be shown on the domain axis (x-axis).
 * @param maximum maximum value to be shown
 */
public void setMaximumDomainAxisValue(double maximum) {
    NumberAxis domainAxis = (NumberAxis) getPlot().getDomainAxis();

    double unit = maximum / 16;

    if (unit > 0.65) {
        unit = Math.round(unit);
    } else if (unit > 0.25) {
        unit = 0.5;
    } else if (unit > 0.1) {
        unit = 0.25;
    } else {
        unit = 0.1;
    }

    domainAxis.setRange(0, maximum);
    domainAxis.setTickUnit(new NumberTickUnit(unit));
}
项目:svarog    文件:DtfOrderCriteriaPanel.java   
private static JFreeChart createChart(final XYSeriesWithLegend[] criteria) {
    final XYSeriesCollection dataset = new XYSeriesCollection();
    for (XYSeries serie : criteria) {
        dataset.addSeries(serie);
    }
    final JFreeChart chart = ChartFactory.createXYLineChart("Model order selection", "model order", "criterion value", dataset, PlotOrientation.VERTICAL, true, false, false);
    final XYPlot plot = chart.getXYPlot();
    ((NumberAxis) plot.getDomainAxis()).setTickUnit(new NumberTickUnit(1.0));
    final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setLegendItemToolTipGenerator(new XYSeriesLabelGenerator() {
        @Override
        public String generateLabel(XYDataset xyd, int i) {
            return (i>=0 && i<criteria.length) ? criteria[i].getLegend() : "";
        }
    });
    for (int i=0; i<dataset.getSeriesCount(); ++i) {
        renderer.setSeriesShapesVisible(i, true);
        renderer.setSeriesShapesFilled(i, true);
    }
    return chart;
}
项目:jamel    文件:JamelAxis.java   
@Override
protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {

    final double raw = this.getRange().getLength();
    final double magnitude = Math.pow(10, Math.floor(Math.log10(raw)));
    double newSize = magnitude / 5;
    while (true) {
        int nticks = (int) (raw / newSize);
        if (nticks <= 10) {
            break;
        }
        newSize = newSize * 2;
    }
    if (this.integerUnit && newSize < 1) {
        newSize = 1;
    }
    final NumberTickUnit unit2 = new NumberTickUnit(newSize);
    setTickUnit(unit2, false, false);

}
项目:parabuild-ci    文件:NumberAxisTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));

    //private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    //private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    //private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    //private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));


}
项目:parabuild-ci    文件:LogAxis.java   
/**
 * Creates a new <code>LogAxis</code> with the given label.
 * 
 * @param label  the axis label (<code>null</code> permitted).
 */
public LogAxis(String label) {
    super(label, NumberAxis.createIntegerTickUnits());
    setDefaultAutoRange(new Range(0.01, 1.0));
    this.tickUnit = new NumberTickUnit(1.0);
    this.minorTickCount = 10;
    this.setTickMarksVisible(false);
}
项目:parabuild-ci    文件:NumberAxisTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));

    //private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    //private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    //private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    //private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));

    a1.setRangeType(RangeType.POSITIVE);
    assertFalse(a1.equals(a2));
    a2.setRangeType(RangeType.POSITIVE);
    assertTrue(a1.equals(a2));

}
项目:parabuild-ci    文件:NumberTickUnitTests.java   
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashCode() {
    NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00"));
    NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00"));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
项目:StockPrediction    文件:PlotUtil.java   
public static void plot(double[] predicts, double[] actuals, String name) {
    double[] index = new double[predicts.length];
    for (int i = 0; i < predicts.length; i++)
        index[i] = i;
    int min = minValue(predicts, actuals);
    int max = maxValue(predicts, actuals);
    final XYSeriesCollection dataSet = new XYSeriesCollection();
    addSeries(dataSet, index, predicts, "Predicts");
    addSeries(dataSet, index, actuals, "Actuals");
    final JFreeChart chart = ChartFactory.createXYLineChart(
            "Prediction Result", // chart title
            "Index", // x axis label
            name, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL,
            true, // include legend
            true, // tooltips
            false // urls
    );
    XYPlot xyPlot = chart.getXYPlot();
    // X-axis
    final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
    domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
    domainAxis.setTickUnit(new NumberTickUnit(20));
    domainAxis.setVerticalTickLabels(true);
    // Y-axis
    final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
    rangeAxis.setRange(min, max);
    rangeAxis.setTickUnit(new NumberTickUnit(50));
    final ChartPanel panel = new ChartPanel(chart);
    final JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}
项目:NeuralNetworksLite    文件:PlotUtil.java   
public static void plot(double[] predicts, double[] actuals, String name) {
    double[] index = new double[predicts.length];
    for (int i = 0; i < predicts.length; i++)
        index[i] = i;
    int min = minValue(predicts, actuals);
    int max = maxValue(predicts, actuals);
    final XYSeriesCollection dataSet = new XYSeriesCollection();
    addSeries(dataSet, index, predicts, "Predicts");
    addSeries(dataSet, index, actuals, "Actuals");
    final JFreeChart chart = ChartFactory.createXYLineChart(
            "Prediction Result", // chart title
            "Index", // x axis label
            name, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL,
            true, // include legend
            true, // tooltips
            false // urls
    );
    XYPlot xyPlot = chart.getXYPlot();
    // X-axis
    final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
    domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
    domainAxis.setTickUnit(new NumberTickUnit(20));
    domainAxis.setVerticalTickLabels(true);
    // Y-axis
    final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
    rangeAxis.setRange(min, max);
    rangeAxis.setTickUnit(new NumberTickUnit(50));
    final ChartPanel panel = new ChartPanel(chart);
    final JFrame f = new JFrame();
    f.add(panel);
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}
项目:ccu-historian    文件:DefaultLogAxisEditor.java   
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    LogAxis logAxis = (LogAxis) axis;
    if (!isAutoTickUnitSelection()) {
        logAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
项目:ccu-historian    文件:DefaultNumberAxisEditor.java   
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
项目:ccu-historian    文件:DefaultPolarPlotEditor.java   
@Override
public void updatePlotProperties(Plot plot) {
    super.updatePlotProperties(plot);
    PolarPlot pp = (PolarPlot) plot;
    pp.setAngleTickUnit(new NumberTickUnit(this.manualTickUnitValue));
    pp.setAngleOffset(this.angleOffsetValue);
}
项目:jfreechart    文件:DefaultLogAxisEditor.java   
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    LogAxis logAxis = (LogAxis) axis;
    if (!isAutoTickUnitSelection()) {
        logAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
项目:jfreechart    文件:DefaultNumberAxisEditor.java   
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
项目:jfreechart    文件:DefaultPolarPlotEditor.java   
@Override
public void updatePlotProperties(Plot plot) {
    super.updatePlotProperties(plot);
    PolarPlot pp = (PolarPlot) plot;
    pp.setAngleTickUnit(new NumberTickUnit(this.manualTickUnitValue));
    pp.setAngleOffset(this.angleOffsetValue);
}
项目:seqcode-core    文件:ExperimentScaler.java   
/**
 * Make an XY scatter plot from a 2-D dataset and save image.
 * This configuration is used by deepseq.stats.Normalization classes
 *  
 * @param datapoints - 2D dataset (colored grey)
 * @param datapoints_highlight - 2D dataset (colored blue), can be null
 * @param yLine Double - data coordinates of line to be drawn parallel to x axis (used to show scaling line) 
 * @param outFilename - String
 * @param rasterImage - boolean
 */
private void saveXYplot(Matrix datapoints, double scalingTotal, double scalingRatio, String xName, String yName, String outFilename, boolean rasterImage){
    this.setWidth(800);
    this.setHeight(800);
    this.addDataset("other", datapoints, new Color(75,75,75,80), 3);
    this.setXAxisLabel(xName);
    this.setYAxisLabel(yName);
    this.setXLogScale(true);
    this.setYLogScale(true);
    this.setXRangeFromData();
    this.setYRangeFromData();
    if(raxis.getRange().getLowerBound() >0.1){
        raxis.setLowerBound(0.1);
    }
    this.addDomainMarker(scalingTotal);         
    this.addRangeMarker(scalingRatio);

    //Set the tick units according to the range
    double xUpper = daxis.getRange().getUpperBound();
    double xLower = daxis.getRange().getLowerBound();
    if(daxis instanceof org.jfree.chart.axis.NumberAxis)
        ((NumberAxis)daxis).setTickUnit(new NumberTickUnit(5));
    double yUpper = raxis.getRange().getUpperBound();
    double yLower = raxis.getRange().getLowerBound();

    if(raxis instanceof org.jfree.chart.axis.NumberAxis)
        ((NumberAxis)raxis).setTickUnit(new NumberTickUnit(5));

    try {
        this.saveImage(new File(outFilename), width, height, rasterImage);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:seqcode-core    文件:ScatterPlotConfigured.java   
/**
 * Make an MA plot from one or two 2-D datasets (one will be highlighted in a different color) and save image.
 * This configuration is used by deepseq.stats.Normalization classes
 *  
 * @param datapoints - 2D dataset (colored grey)
 * @param datapoints_highlight - 2D dataset (colored blue), can be null
 * @param yLine Double - data coordinates of line to be drawn parallel to x axis (used to show scaling line) 
 * @param outFilename - String
 * @param rasterImage - boolean
 */
public void saveMAplot(Matrix datapoints, Matrix datapoints_highlight, Double yLine, String outFilename, boolean rasterImage){
    this.setWidth(800);
    this.setHeight(800);
    this.setXLogScale(false);
    this.setYLogScale(false);
    this.addDataset("other", datapoints, new Color(75,75,75,60), 3);
    if(datapoints_highlight!=null)
        this.addDataset("highlighted", datapoints_highlight, new Color(0,0,255,60), 3);
    this.setXAxisLabel("A");
    this.setYAxisLabel("M");
    this.setXRange(-20,-5);
    this.setYRange(-6,6);


    //Set the tick units according to the range
    double xUpper = daxis.getRange().getUpperBound();
    double xLower = daxis.getRange().getLowerBound();
    if(daxis instanceof org.jfree.chart.axis.NumberAxis)
        ((NumberAxis)daxis).setTickUnit(new NumberTickUnit(5));
    double yUpper = raxis.getRange().getUpperBound();
    double yLower = raxis.getRange().getLowerBound();
    if(raxis instanceof org.jfree.chart.axis.NumberAxis)
        ((NumberAxis)raxis).setTickUnit(new NumberTickUnit(3));

    //Draw a red line along y = yLine
    if(yLine!=null){
        XYLineAnnotation lineAnnot = new XYLineAnnotation(xLower, yLine, xUpper, yLine, new BasicStroke(1), new Color(255,0,0));
        this.plot.addAnnotation(lineAnnot);
    }

    try {
        this.saveImage(new File(outFilename), width, height, rasterImage);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:seqcode-core    文件:ScatterPlotConfigured.java   
/**
 * A mean-variance plot is log-log scaled, and a line can be drawn along the lowess fit
 * @param datapoints : mean vs variance
 * @param fitLine : coordinates (dataspace) of line
 * @param outFilename
 * @param rasterImage
 */
public void saveMeanVarPlot(Matrix datapoints, Matrix fitLine, String outFilename, boolean rasterImage){
    this.setWidth(800);
    this.setHeight(800);
    this.setXLogScale(true);
    this.setYLogScale(true);
    this.addDataset("MV", datapoints, new Color(75,75,75,60), 3);
    this.setXAxisLabel("Mean");
    this.setYAxisLabel("Var");
    this.setXRange(1, 100000);
    this.setYRange(0.1, 1000000);


    //Set the tick units according to the range
    double xUpper = daxis.getRange().getUpperBound();
    double xLower = daxis.getRange().getLowerBound();
    if(daxis instanceof org.jfree.chart.axis.LogAxis)
        ((LogAxis)daxis).setTickUnit(new NumberTickUnit(1.0));
    double yUpper = raxis.getRange().getUpperBound();
    double yLower = raxis.getRange().getLowerBound();
       if(raxis instanceof org.jfree.chart.axis.LogAxis)
        ((LogAxis)raxis).setTickUnit(new NumberTickUnit(1.0));

    if(fitLine!=null){
        //Draw a blue line along mean=var (Poisson)
        XYLineAnnotation lineAnnot = new XYLineAnnotation(xLower, xLower, xUpper, xUpper, new BasicStroke(2), Color.blue);
        this.plot.addAnnotation(lineAnnot);
        //Draw a red line along the fit line
        this.addDataset("Fit", fitLine, Color.RED, 3, false, true, false);
    }

    try {
        this.saveImage(new File(outFilename), width, height, rasterImage);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:seqcode-core    文件:ScatterPlotMaker.java   
/**
 * Make an MA plot from one or two 2-D datasets (one will be highlighted in a different color) and save image.
 * This configuration is used by deepseq.stats.Normalization classes
 *  
 * @param datapoints - 2D dataset (colored grey)
 * @param datapoints_highlight - 2D dataset (colored blue), can be null
 * @param yLine Double - data coordinates of line to be drawn parallel to x axis (used to show scaling line) 
 * @param outFilename - String
 * @param rasterImage - boolean
 */
public void saveMAplot(Matrix datapoints, Matrix datapoints_highlight, Double yLine, String outFilename, boolean rasterImage){
    this.setWidth(800);
    this.setHeight(800);
    this.setXLogScale(false);
    this.setYLogScale(false);
    this.addDataset("other", datapoints, new Color(75,75,75,80), 3);
    if(datapoints_highlight!=null)
        this.addDataset("highlighted", datapoints_highlight, new Color(0,0,255,80), 3);
    this.setXAxisLabel("A");
    this.setYAxisLabel("M");
    this.setXRangeFromData();
    this.setYRange(-10.5,10.5);

    //Set the tick units according to the range
    double xUpper = daxis.getRange().getUpperBound();
    double xLower = daxis.getRange().getLowerBound();
    //if(daxis instanceof org.jfree.chart.axis.NumberAxis)
    //  ((NumberAxis)daxis).setTickUnit(new NumberTickUnit(5));
    double yUpper = raxis.getRange().getUpperBound();
    double yLower = raxis.getRange().getLowerBound();
    if(raxis instanceof org.jfree.chart.axis.NumberAxis)
        ((NumberAxis)raxis).setTickUnit(new NumberTickUnit(3));
    //Draw a line along y = yLine
    if(yLine!=null){
        XYLineAnnotation lineAnnot = new XYLineAnnotation(xLower, yLine, xUpper, yLine, new BasicStroke(1), new Color(0,0,0));
        this.plot.addAnnotation(lineAnnot);
    }

    try {
        this.saveImage(new File(outFilename), width, height, rasterImage);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目: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    文件:RotationGraph.java   
public RotationGraph( PhetPCanvas pSwingCanvas, ControlGraphSeries series,
                      String label, String title, String units, double min, double max,
                      boolean editable, TimeSeriesModel timeSeriesModel,
                      UpdateStrategy updateStrategy, double maxDomainValue, RotationPlatform iPositionDriven ) {
    super( pSwingCanvas, series,
           label, title, min, max,
           editable, timeSeriesModel, updateStrategy, maxDomainValue, iPositionDriven );
    this.title = title;
    super.getDynamicJFreeChartNode().setAutoUpdateAll( false );

    verticalAxis = new RotationGraphNumberAxis( title + " (" + units + ")" );
    verticalAxis.setRange( getJFreeChartNode().getChart().getXYPlot().getRangeAxis().getRange() );
    getJFreeChartNode().getChart().getXYPlot().setRangeAxis( verticalAxis );

    NumberAxis domainAxis = new NumberAxis( RotationStrings.getString( "variable.time.s" ) );
    domainAxis.setLabelFont( new PhetFont( 12 ) );
    domainAxis.setRange( getJFreeChartNode().getChart().getXYPlot().getDomainAxis().getRange() );
    domainAxis.setTickUnit( new NumberTickUnit( 2.5 ) );
    getJFreeChartNode().getChart().getXYPlot().setDomainAxis( domainAxis );

    getDynamicJFreeChartNode().setBufferedSeries();

    addListener( new Adapter() {
        public void zoomChanged() {
            getDynamicJFreeChartNode().forceUpdateAll();
        }
    } );
}
项目:PhET    文件:RotationGraph.java   
protected void selectVerticalAutoTickUnit( Graphics2D g2,
                                           Rectangle2D dataArea,
                                           RectangleEdge edge ) {
    //modify the value chosen by the superclass
    super.selectVerticalAutoTickUnit( g2, dataArea, edge );
    setTickUnit( new NumberTickUnit( getTickUnit().getSize() * 2 ), false, false );
}
项目: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 );
}
项目:jasperreports    文件:AbstractAxisCustomizer.java   
protected void configNumberAxis(
    NumberAxis numberAxis,
    String tickUnitProp
    ) 
{
    if (numberAxis != null)
    {
        Double tickUnit = getDoubleProperty(tickUnitProp);
        if (tickUnit != null)
        {
            numberAxis.setTickUnit(new NumberTickUnit(tickUnit));
        }
    }
}
项目:jasperreports    文件:ChartUtil.java   
public void setAutoTickUnit(NumberAxis numberAxis)
{
    if (numberAxis.isAutoTickUnitSelection())
    {
        Range range = numberAxis.getRange();
        if (range.getLength() >= AUTO_TICK_UNIT_THRESHOLD)
        {
            // this is a workaround for a floating point error makes JFreeChart
            // select tick units that are too small when the values are very large
            double autoSize = range.getLength() / AUTO_TICK_UNIT_THRESHOLD;
            TickUnit unit = numberAxis.getStandardTickUnits().getCeilingTickUnit(autoSize);
            numberAxis.setTickUnit((NumberTickUnit) unit, false, false);
        }
    }
}
项目:aya-lang    文件:DefaultLogAxisEditor.java   
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    LogAxis logAxis = (LogAxis) axis;
    if (!isAutoTickUnitSelection()) {
        logAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
项目:aya-lang    文件:DefaultNumberAxisEditor.java   
/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel.
 *
 * @param axis  the axis.
 */
@Override
public void setAxisProperties(Axis axis) {
    super.setAxisProperties(axis);
    NumberAxis numberAxis = (NumberAxis) axis;
    if (!isAutoTickUnitSelection()) {
        numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue));
    }
}
项目:aya-lang    文件:DefaultPolarPlotEditor.java   
@Override
public void updatePlotProperties(Plot plot) {
    super.updatePlotProperties(plot);
    PolarPlot pp = (PolarPlot) plot;
    pp.setAngleTickUnit(new NumberTickUnit(this.manualTickUnitValue));
    pp.setAngleOffset(this.angleOffsetValue);
}