當前位置: 首頁>>代碼示例>>Java>>正文


Java DateAxis.setRange方法代碼示例

本文整理匯總了Java中org.jfree.chart.axis.DateAxis.setRange方法的典型用法代碼示例。如果您正苦於以下問題:Java DateAxis.setRange方法的具體用法?Java DateAxis.setRange怎麽用?Java DateAxis.setRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jfree.chart.axis.DateAxis的用法示例。


在下文中一共展示了DateAxis.setRange方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSetRange

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
/**
 * Test that the setRange() method works.
 */
public void testSetRange() {

    DateAxis axis = new DateAxis("Test Axis");
    Calendar calendar = Calendar.getInstance();
    calendar.set(1999, Calendar.JANUARY, 3);
    Date d1 = calendar.getTime();
    calendar.set(1999, Calendar.JANUARY, 31);
    Date d2 = calendar.getTime();
    axis.setRange(d1, d2);

    DateRange range = (DateRange) axis.getRange();
    assertEquals(d1, range.getLowerDate());
    assertEquals(d2, range.getUpperDate());

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:19,代碼來源:DateAxisTests.java

示例2: testJava2DToValue

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
/**
 * Test the translation of Java2D values to data values.
 */
public void testJava2DToValue() {
    DateAxis axis = new DateAxis();
    axis.setRange(50.0, 100.0); 
    Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0);
    double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);  
    assertTrue(same(y1, 95.8333333, 1.0)); 
    double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);   
    assertTrue(same(y2, 95.8333333, 1.0)); 
    double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);   
    assertTrue(same(x1, 58.125, 1.0)); 
    double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);   
    assertTrue(same(x2, 58.125, 1.0)); 
    axis.setInverted(true);
    double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);  
    assertTrue(same(y3, 54.1666667, 1.0)); 
    double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);   
    assertTrue(same(y4, 54.1666667, 1.0)); 
    double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);   
    assertTrue(same(x3, 91.875, 1.0)); 
    double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);   
    assertTrue(same(x4, 91.875, 1.0));   
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:DateAxisTests.java

示例3: testJava2DToValue

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
/**
 * Test the translation of Java2D values to data values.
 */
public void testJava2DToValue() {
    DateAxis axis = new DateAxis();
    axis.setRange(50.0, 100.0);
    Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0);
    double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);
    assertTrue(same(y1, 95.8333333, 1.0));
    double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);
    assertTrue(same(y2, 95.8333333, 1.0));
    double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);
    assertTrue(same(x1, 58.125, 1.0));
    double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);
    assertTrue(same(x2, 58.125, 1.0));
    axis.setInverted(true);
    double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT);
    assertTrue(same(y3, 54.1666667, 1.0));
    double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT);
    assertTrue(same(y4, 54.1666667, 1.0));
    double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP);
    assertTrue(same(x3, 91.875, 1.0));
    double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM);
    assertTrue(same(x4, 91.875, 1.0));
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:26,代碼來源:DateAxisTests.java

示例4: showChart

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
public JFreeChart showChart(IntervalXYDataset dataset) {

		JFreeChart chart = ChartFactory.createHistogram("", "", "", dataset, PlotOrientation.VERTICAL, true, false, false);

		chart.setBackgroundPaint(Color.white);
		XYPlot plot = (XYPlot) chart.getPlot();
		plot.setBackgroundPaint(Color.lightGray);
		plot.setDomainGridlinesVisible(false);
		plot.setRangeGridlinesVisible(false);
		plot.setRangeAxis(new LogarithmicAxis("packetCount"));

		NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
		rangeAxis.setVisible(false);

		rangeAxis.setAutoTickUnitSelection(true);
		rangeAxis.setAutoRangeIncludesZero(true);
		DateAxis dAxis = new DateAxis();
		dAxis.setRange((long) ControlsJPanel.QW_MIN * 1000L, (long) ControlsJPanel.QW_MAX * 1000L);
		plot.setDomainAxis(dAxis);

		plot.setRenderer(new XYAreaRenderer());
		plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
		chart.setPadding(new RectangleInsets(0, 0, 0, 0));

		return chart;
	}
 
開發者ID:nullbox,項目名稱:Data-and-Information-Visualization-Project,代碼行數:27,代碼來源:ControlsJPanel.java

示例5: test1472942

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
/**
 * A test for bug report 1472942.  The DateFormat.equals() method is not
 * checking the range attribute.
 */
public void test1472942() {
    DateAxis a1 = new DateAxis("Test");
    DateAxis a2 = new DateAxis("Test");
    assertTrue(a1.equals(a2));

    // range
    a1.setRange(new Date(1L), new Date(2L));
    assertFalse(a1.equals(a2));
    a2.setRange(new Date(1L), new Date(2L));
    assertTrue(a1.equals(a2));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:16,代碼來源:DateAxisTests.java

示例6: createChartPanel

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
private void createChartPanel(String title, long time) {
	YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
	chart = ChartFactory.createTimeSeriesChart(title, X_AXIS_TITLE, "",
			dataset, true, true, true);
	XYPlot plot = (XYPlot) chart.getPlot();

	DeviationRenderer errorRenderer = new DeviationRenderer();
	errorRenderer.setShapesVisible(false);
	errorRenderer.setLinesVisible(true);
	errorRenderer.setAlpha(0.0f);
	// errorRenderer.setDrawYError(false);
	// errorRenderer.setDrawXError(false);
	plot.setRenderer(errorRenderer);

	plot.setBackgroundPaint(Color.WHITE);
	plot.setRangeGridlinePaint(Color.DARK_GRAY);
	plot.setDomainGridlinePaint(Color.DARK_GRAY);
	upperDomainBound = (time / 1000) + ((interval - 1) * step / 1000);
	DateAxis domain = (DateAxis) plot.getDomainAxis();
	domain.setAutoRange(false);
	domain.setRange((time / 1000), upperDomainBound);
	RelativeDateFormat rdf = new RelativeDateFormat();
	rdf.setHourSuffix(":");
	rdf.setMinuteSuffix(":");
	rdf.setSecondSuffix("");
	rdf.setSecondFormatter(new DecimalFormat("0"));
	domain.setDateFormatOverride(rdf);
	plot.setDomainAxis(domain);
	plotPanel = new ChartPanel(chart, true);
	setSizeOfComponent(plotPanel, new Dimension(plotWidth, plotHeight));
	container.add(plotPanel, BorderLayout.CENTER);
	container.add(createRadioBoxes(visType == VisualizationType.Metric),
			BorderLayout.SOUTH);
	setSizeOfComponent(container, new Dimension(plotWidth, plotHeight
			+ boxOffset));
}
 
開發者ID:flyroom,項目名稱:PeerfactSimKOM_Clone,代碼行數:37,代碼來源:MetricsPlot.java

示例7: updatePlotter

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
@Override
protected void updatePlotter() {
	int categoryCount = prepareData();
	String maxClassesProperty = ParameterService
			.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
	int maxClasses = 20;
	try {
		if (maxClassesProperty != null) {
			maxClasses = Integer.parseInt(maxClassesProperty);
		}
	} catch (NumberFormatException e) {
		// LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
		// LogService.WARNING);
		LogService.getRoot().log(Level.WARNING,
				"com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
	}
	boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

	JFreeChart chart = createChart(this.dataset, createLegend);

	// set the background color for the chart...
	chart.setBackgroundPaint(Color.white);

	// domain axis
	if (axis[INDEX] >= 0) {
		if (!dataTable.isNominal(axis[INDEX])) {
			if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
				DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
				domainAxis.setTimeZone(Tools.getPreferredTimeZone());
				chart.getXYPlot().setDomainAxis(domainAxis);
				if (getRangeForDimension(axis[INDEX]) != null) {
					domainAxis.setRange(getRangeForDimension(axis[INDEX]));
				}
				domainAxis.setLabelFont(LABEL_FONT_BOLD);
				domainAxis.setTickLabelFont(LABEL_FONT);
				domainAxis.setVerticalTickLabels(isLabelRotating());
			}
		} else {
			LinkedHashSet<String> values = new LinkedHashSet<String>();
			for (DataTableRow row : dataTable) {
				String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
				if (stringValue.length() > 40) {
					stringValue = stringValue.substring(0, 40);
				}
				values.add(stringValue);
			}
			ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]),
					values.toArray(new String[values.size()]));
			categoryAxis.setLabelFont(LABEL_FONT_BOLD);
			categoryAxis.setTickLabelFont(LABEL_FONT);
			categoryAxis.setVerticalTickLabels(isLabelRotating());
			chart.getXYPlot().setDomainAxis(categoryAxis);
		}
	}

	// legend settings
	LegendTitle legend = chart.getLegend();
	if (legend != null) {
		legend.setPosition(RectangleEdge.TOP);
		legend.setFrame(BlockBorder.NONE);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
		legend.setItemFont(LABEL_FONT);
	}

	AbstractChartPanel panel = getPlotterPanel();
	if (panel == null) {
		panel = createPanel(chart);
	} else {
		panel.setChart(chart);
	}

	// ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
	panel.getChartRenderingInfo().setEntityCollection(null);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:75,代碼來源:SeriesChartPlotter.java

示例8: updatePlotter

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
@Override
protected void updatePlotter() {
    int categoryCount = prepareData();
    String maxClassesProperty = ParameterService.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {
        if (maxClassesProperty != null)
            maxClasses = Integer.parseInt(maxClassesProperty);
    } catch (NumberFormatException e) {
        //LogService.getGlobal().log("Series plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.", LogService.WARNING);
        LogService.getRoot().log(Level.WARNING, "com.rapidminer.gui.plotter.charts.SeriesChartPlotter.parsing_property_error");
    }
    boolean createLegend = categoryCount > 0 && categoryCount < maxClasses;

    JFreeChart chart = createChart(this.dataset, createLegend);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // domain axis
    if (axis[INDEX] >= 0) {
        if (!dataTable.isNominal(axis[INDEX])) {
            if (dataTable.isDate(axis[INDEX]) || dataTable.isDateTime(axis[INDEX])) {
                DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[INDEX]));
                domainAxis.setTimeZone(Tools.getPreferredTimeZone());
                chart.getXYPlot().setDomainAxis(domainAxis);
                if (getRangeForDimension(axis[INDEX]) != null)
                    domainAxis.setRange(getRangeForDimension(axis[INDEX]));
                domainAxis.setLabelFont(LABEL_FONT_BOLD);
                domainAxis.setTickLabelFont(LABEL_FONT);
                domainAxis.setVerticalTickLabels(isLabelRotating());
            }
        } else {
            LinkedHashSet<String> values = new LinkedHashSet<String>();
            for (DataTableRow row : dataTable) {
                String stringValue = dataTable.mapIndex(axis[INDEX], (int) row.getValue(axis[INDEX]));
                if (stringValue.length() > 40)
                    stringValue = stringValue.substring(0, 40);
                values.add(stringValue);
            }
            ValueAxis categoryAxis = new SymbolAxis(dataTable.getColumnName(axis[INDEX]), values.toArray(new String[values.size()]));
            categoryAxis.setLabelFont(LABEL_FONT_BOLD);
            categoryAxis.setTickLabelFont(LABEL_FONT);
            categoryAxis.setVerticalTickLabels(isLabelRotating());
            chart.getXYPlot().setDomainAxis(categoryAxis);
        }
    }

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(LABEL_FONT);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}
 
開發者ID:rapidminer,項目名稱:rapidminer-5,代碼行數:68,代碼來源:SeriesChartPlotter.java

示例9: configureChart

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
@Override
public void configureChart(JFreeChart chart) {
    // this setup is required before any data is in the chart
    // or auto ranging on the y-axis breaks
    if (app.getBooleanProperty("chartRelativeTime")) {
        LineChartBuilder.setRelativeAxis(chart, app.getMinSystemTime());
    }
    else {
        LineChartBuilder.setAbsoluteAxis(chart);
    }

    DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
    Interval current = app.getIntervalManager().getCurrentInterval();

    axis.setTimeZone(app.getDisplayTimeZone());

    if (chart.getXYPlot().getRenderer().getBaseToolTipGenerator().getClass() == TimeAndValueTooltipGenerator.class) {
        ((TimeAndValueTooltipGenerator) chart.getXYPlot().getRenderer().getBaseToolTipGenerator()).setTimeZone(app
                .getDisplayTimeZone());
    }

    if (Interval.DEFAULT.equals(current)) {
        if (app.getMinSystemTime() == 0) {
            // implies no current datasets, so keep the axis range sane
            // fixes near infinite loop displaying chart with no data
            long now = System.currentTimeMillis();
            axis.setRange(now - (86400000 / 2), now + ((86400000 - 1000) / 2));
        }
        else {
            long min = app.getMinSystemTime();
            long max = app.getMaxSystemTime();

            // exception thrown if min and max are the same
            if (min == max) {
                min -= 1000;
            }

            axis.setRange(min, max);
        }
    }
    else {
        axis.setRange(current.getStart(), current.getEnd());
    }
}
 
開發者ID:nmonvisualizer,項目名稱:nmonvisualizer,代碼行數:45,代碼來源:LineChartBuilderPlugin.java

示例10: renderPreChart

import org.jfree.chart.axis.DateAxis; //導入方法依賴的package包/類
protected JFreeChart renderPreChart(Map<String, OXFFeatureCollection> entireCollMap, String[] observedProperties,
        ArrayList<TimeSeriesCollection> timeSeries, Calendar begin, Calendar end) {

    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title
            "Date", // x-axis label
            observedProperties[0], // y-axis label
            timeSeries.get(0), // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
            );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // add additional datasets:
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setRange(begin.getTime(), end.getTime());
    axis.setDateFormatOverride(new SimpleDateFormat());
    axis.setTimeZone(end.getTimeZone());
    for (int i = 1; i < observedProperties.length; i++) {
        XYDataset additionalDataset = timeSeries.get(i);
        plot.setDataset(i, additionalDataset);
        plot.setRangeAxis(i, new NumberAxis(observedProperties[i]));
        // plot.getRangeAxis(i).setRange((Double)
        // overAllSeriesCollection.getMinimum(i),
        // (Double) overAllSeriesCollection.getMaximum(i));
        plot.mapDatasetToRangeAxis(i, i);
        // plot.getDataset().getXValue(i, i);
    }
    return chart;
}
 
開發者ID:52North,項目名稱:SensorWebClient,代碼行數:43,代碼來源:DiagramRenderer.java


注:本文中的org.jfree.chart.axis.DateAxis.setRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。