List of usage examples for org.jfree.chart.axis DateTickUnitType MINUTE
DateTickUnitType MINUTE
To view the source code for org.jfree.chart.axis DateTickUnitType MINUTE.
Click Source Link
From source file:MWC.GUI.JFreeChart.DateAxisEditor.java
public static TickUnits createStandardDateTickUnitsAsTickUnits() { final TickUnits units = new TickUnits(); // milliseconds units.add(new OptimisedDateTickUnit(DateTickUnitType.MILLISECOND, 500, new RNFormatter("HH:mm:ss.SSS"))); // seconds//from w w w .j a v a2 s . com units.add(new OptimisedDateTickUnit(DateTickUnitType.SECOND, 1, new RNFormatter("HH:mm:ss"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.SECOND, 5, new RNFormatter("HH:mm:ss"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.SECOND, 10, new RNFormatter("HH:mm:ss"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.SECOND, 30, new RNFormatter("HH:mm:ss"))); // minutes units.add(new OptimisedDateTickUnit(DateTickUnitType.MINUTE, 1, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.MINUTE, 2, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.MINUTE, 5, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.MINUTE, 10, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.MINUTE, 15, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.MINUTE, 20, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.MINUTE, 30, new RNFormatter("HH:mm"))); // hours units.add(new OptimisedDateTickUnit(DateTickUnitType.HOUR, 1, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.HOUR, 2, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.HOUR, 4, new RNFormatter("HH:mm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.HOUR, 6, new RNFormatter("ddHHmm"))); units.add(new OptimisedDateTickUnit(DateTickUnitType.HOUR, 12, new RNFormatter("ddHHmm"))); // days units.add(new OptimisedDateTickUnit(DateTickUnitType.DAY, 1, new RNFormatter("d-MMM"))); return units; }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeTimeChartData.java
private TickUnits getUnits(CalendarFieldSplitPeriod period) { int field = period.getField(); boolean good_match = false; for (DateTickUnitType unit : new DateTickUnitType[] { DateTickUnitType.SECOND, DateTickUnitType.MINUTE, DateTickUnitType.HOUR, DateTickUnitType.DAY, DateTickUnitType.MONTH, DateTickUnitType.YEAR }) { if (field == unit.getCalendarField()) { TickUnits units = new TickUnits(); int count = period.getCount(); int nsplit = period.getNsplit(); if (count == 1 && nsplit == 1) { return null; // let jfree work it out. }//from w w w .jav a2 s. c o m if (nsplit > 50) { return null; // period unit is too small } // include all multiples that are exact factors of count for (int i = 1; i <= count; i++) { if (count % i == 0) { units.add(new DateTickUnit(unit, i)); if (i > 1 && (count / i) < 8) { good_match = true; } } } // now larger multiples of count that factor nsplit for (int i = 2; i < nsplit && i < 50; i++) { if (nsplit % i == 0) { units.add(new DateTickUnit(unit, i * count)); if (i > 1 && (nsplit / i) < 8) { good_match = true; } } } if (good_match) { return units; } return null; } } return null; }
From source file:com.sdk.connector.chart.CoherenceDomainRenderer.java
public CoherenceDomainRenderer(final String title, JPanel panel, String side) { sdf = Protocol.getInstance().getTimestampFormat(); serieFFT.setKey(side + " FFT Based"); serieLomb.setKey(side + " Lomb Based"); serieMemse.setKey(side + " AR Based"); dataset.addSeries(serieFFT);/*from www . java2 s . c om*/ dataset.addSeries(serieLomb); dataset.addSeries(serieMemse); chart = ChartFactory.createTimeSeriesChart(title, java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("coherence.xlabel"), java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("coherence.ylabel"), dataset, true, true, false); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100); //chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.GREEN)); // chart.setBackgroundPaint(new Color(220,255,220,0)); //chart.setBackgroundImage(new javax.swing.ImageIcon(getClass().getResource("/com/sdk/connector/resources/background.png")).getImage()); chart.addSubtitle(rangeAnnotation); plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, sdf, new DecimalFormat("0.00"))); renderer.setSeriesOutlinePaint(0, Color.BLACK); if (side.startsWith( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) { renderer.setSeriesPaint(0, Color.BLUE); leftSide = true; } else { renderer.setSeriesPaint(0, Color.RED); leftSide = false; } renderer.setSeriesShape(0, new Ellipse2D.Double(-1.0, -1.0, 3.0, 3.0)); DateTickUnit dtUnit = new DateTickUnit(DateTickUnitType.MINUTE, 1, tickSDF); final DateAxis domainAxis = (DateAxis) plot.getDomainAxis(); domainAxis.setTickUnit(dtUnit); // ValueAxis axis = plot.getDomainAxis(); // axis = plot.getRangeAxis(); // ((NumberAxis) axis).setTickUnit(new NumberTickUnit(100)); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); // plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f)); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("message.wait")); plot.setRangePannable(true); plot.setDomainPannable(true); Color color1 = new Color(0, 0, 0, 24); Color color2 = new Color(255, 255, 255, 24); GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2); plot.setBackgroundPaint(gp); chartPanel = new ChartPanel(chart); panel.setLayout(new GridLayout(0, 1)); panel.add(chartPanel); panel.repaint(); panel.revalidate(); }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeTimeChartData.java
private TickUnits getUnits() { TickUnits units = new TickUnits(); units.add(new DateTickUnit(DateTickUnitType.SECOND, 1)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 1)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 10)); units.add(new DateTickUnit(DateTickUnitType.MINUTE, 15)); units.add(new DateTickUnit(DateTickUnitType.HOUR, 1)); units.add(new DateTickUnit(DateTickUnitType.HOUR, 12)); units.add(new DateTickUnit(DateTickUnitType.DAY, 1)); units.add(new DateTickUnit(DateTickUnitType.DAY, 7)); units.add(new DateTickUnit(DateTickUnitType.MONTH, 1)); units.add(new DateTickUnit(DateTickUnitType.MONTH, 3)); units.add(new DateTickUnit(DateTickUnitType.MONTH, 6)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 1)); units.add(new DateTickUnit(DateTickUnitType.YEAR, 10)); return units; }
From source file:com.sdk.connector.chart.TimeDomainRenderer.java
public TimeDomainRenderer(final String title, JPanel panel, String side, String type) { sdf = protocol.getTimestampFormat(); this.side = side + type; this.type = type; serie.setKey(side);//from ww w . ja v a 2 s.c om dataset.addSeries(serie); String legendX = ""; if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("RR"))) { legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle") .getString("timeRR.ylabel"); } else { legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle") .getString("timeBC.ylabel"); } chart = ChartFactory.createTimeSeriesChart(title, java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("time.xlabel"), legendX, dataset, true, true, false); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100); //chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.GREEN)); // chart.setBackgroundPaint(new Color(220,255,220,0)); //chart.setBackgroundImage(new javax.swing.ImageIcon(getClass().getResource("/com/sdk/connector/resources/background.png")).getImage()); chart.addSubtitle(rangeAnnotation); plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, sdf, new DecimalFormat("0.00"))); renderer.setSeriesOutlinePaint(0, Color.BLACK); if (side.startsWith( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) { renderer.setSeriesPaint(0, Color.BLUE); } else { renderer.setSeriesPaint(0, Color.RED); } renderer.setSeriesShape(0, new Ellipse2D.Double(-1.0, -1.0, 3.0, 3.0)); if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("BC"))) { renderer.setSeriesShape(0, new Rectangle2D.Double(-1.0, -1.0, 3.0, 3.0)); } DateTickUnit dtUnit = new DateTickUnit(DateTickUnitType.MINUTE, 1, tickSDF); final DateAxis domainAxis = (DateAxis) plot.getDomainAxis(); domainAxis.setTickUnit(dtUnit); // ValueAxis axis = plot.getDomainAxis(); // axis = plot.getRangeAxis(); // ((NumberAxis) axis).setTickUnit(new NumberTickUnit(100)); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); // plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f)); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage( java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("CALIBRATING...")); plot.setRangePannable(true); plot.setDomainPannable(true); Color color1 = new Color(0, 0, 0, 24); Color color2 = new Color(255, 255, 255, 24); GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2); plot.setBackgroundPaint(gp); chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(this); panel.setLayout(new GridLayout(0, 1)); panel.add(chartPanel); panel.repaint(); panel.revalidate(); }
From source file:MWC.GUI.JFreeChart.DateAxisEditor.java
/** * Returns a collection of standard date tick units. This collection will be * used by default, but you are free to create your own collection if you want * to (see the setStandardTickUnits(...) method inherited from the ValueAxis * class)./*from w w w.ja v a2 s .com*/ * * @return a collection of standard date tick units. */ public static ArrayList<MWCDateTickUnitWrapper> createStandardDateTickUnitsAsArrayList() { final ArrayList<MWCDateTickUnitWrapper> units = new ArrayList<MWCDateTickUnitWrapper>(); units.add(MWCDateTickUnitWrapper.getAutoScale()); // ////////////////////////////////////////////////////// // milliseconds units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MILLISECOND, 500, "HH:mm:ss.SSS")); // seconds units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 1, "HH:mm:ss")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 5, "HH:mm:ss")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 10, "HH:mm:ss")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 30, "HH:mm:ss")); // minutes units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 1, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 2, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 5, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 10, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 15, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 20, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 30, "HH:mm")); // hours units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 1, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 2, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 4, "HH:mm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 6, "ddHHmm")); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 12, "ddHHmm")); // days units.add(new MWCDateTickUnitWrapper(DateTickUnitType.DAY, 1, "d-MMM")); // ///////////////////////////////////////////////////// // // milliseconds // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MILLISECOND, // 500, "HH:mm:ss.SSS")); // // // seconds // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 1, // "HH:mm:ss")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 5, // "HH:mm:ss")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 10, // "HH:mm:ss")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 30, // "HH:mm:ss")); // // // minutes // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 1, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 2, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 5, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 10, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 15, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 20, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.MINUTE, 30, // "HH:mm")); // // // hours // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 1, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 2, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 4, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 6, // "HH:mm")); // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.HOUR, 12, // "d-MMM, HH:mm")); // // // days // units.add(new MWCDateTickUnitWrapper(DateTickUnitType.DAY, 1, // "d-MMM")); // absolute seconds units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 1, RELATIVE_DTG_FORMAT)); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 5, RELATIVE_DTG_FORMAT)); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 10, RELATIVE_DTG_FORMAT)); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 30, RELATIVE_DTG_FORMAT)); units.add(new MWCDateTickUnitWrapper(DateTickUnitType.SECOND, 60, RELATIVE_DTG_FORMAT)); return units; }
From source file:com.freedomotic.jfrontend.extras.GraphPanel.java
private void createChart(UsageDataFrame points, String title) { series = new TimeSeries(title); for (UsageData d : points.getData()) { Date resultdate = d.getDateTime(); Millisecond ms_read = new Millisecond(resultdate); int poweredValue = -1; if (d.getObjBehavior().equalsIgnoreCase("powered")) { poweredValue = d.getObjValue().equalsIgnoreCase("true") ? 1 : 0; } else if (d.getObjBehavior().equalsIgnoreCase("brigthness")) { try { poweredValue = Integer.parseInt(d.getObjValue()); } catch (NumberFormatException ex) { poweredValue = -1;// w w w . j a va2s . c o m } } series.addOrUpdate(ms_read, poweredValue); } XYDataset xyDataset = new TimeSeriesCollection(series); chart = ChartFactory.createTimeSeriesChart("Chart", "TIME", "VALUE", xyDataset, true, // legend true, // tooltips false // urls ); chart.setAntiAlias(true); // Set plot styles XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); // Set series line styles plot.setRenderer(new XYStepRenderer()); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setShapesVisible(true); renderer.setShapesFilled(true); } // Set date axis style DateAxis axis = (DateAxis) plot.getDomainAxis(); String formatString = "MM-dd HH"; DateTickUnitType dtut = DateTickUnitType.HOUR; if (jComboGranularity.getSelectedItem().equals("Year")) { formatString = "yyyy"; dtut = DateTickUnitType.YEAR; } else if (jComboGranularity.getSelectedItem().equals("Month")) { axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM")); dtut = DateTickUnitType.MONTH; } else if (jComboGranularity.getSelectedItem().equals("Day")) { axis.setDateFormatOverride(new SimpleDateFormat("MM-dd")); dtut = DateTickUnitType.DAY; } else if (jComboGranularity.getSelectedItem().equals("Minute")) { formatString = "MM-dd HH:mm"; dtut = DateTickUnitType.MINUTE; } else if (jComboGranularity.getSelectedItem().equals("Second")) { formatString = "HH:mm:SS"; dtut = DateTickUnitType.SECOND; } DateFormat formatter = new SimpleDateFormat(formatString); DateTickUnit unit = new DateTickUnit(dtut, 1, formatter); axis.setTickUnit(unit); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(800, 500)); graphPanel.removeAll(); graphPanel.add(chartPanel); }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * Returns the specific org.jfree.chart.axis.DateTickUnit time unit constant * related to the String value passed as argument * //from ww w .ja va 2 s . co m * @param timePeriodUnit - a String represented by one of the following * accepted values: ["Year", "Month", "Day", "Hour", "Minute", "Second", "Millisecond"] * @return the specific org.jfree.chart.axis.DateTickUnit time unit constant */ protected DateTickUnitType getTimePeriodUnit(String timePeriodUnit) { if (timePeriodUnit == null) return DateTickUnitType.DAY; return timePeriodUnit.equals("Year") ? DateTickUnitType.YEAR : timePeriodUnit.equals("Month") ? DateTickUnitType.MONTH : timePeriodUnit.equals("Hour") ? DateTickUnitType.HOUR : timePeriodUnit.equals("Minute") ? DateTickUnitType.MINUTE : timePeriodUnit.equals("Second") ? DateTickUnitType.SECOND : timePeriodUnit.equals("Millisecond") ? DateTickUnitType.MILLISECOND : DateTickUnitType.DAY; }