List of usage examples for org.jfree.data.time Second Second
public Second(Date time, TimeZone zone)
From source file:net.commerce.zocalo.freechart.ChartTest.java
private TimePeriodValuesCollection makeupSeriesValues() { TimePeriodValues aValues = new TimePeriodValues("volleyball"); TimePeriodValues bValues = new TimePeriodValues("climbing"); TimePeriodValues cValues = new TimePeriodValues("hockey"); Minute now = new Minute(); aValues.add(new TimePeriodValue(new Second(2, now), .2)); bValues.add(new TimePeriodValue(new Second(2, now), .4)); cValues.add(new TimePeriodValue(new Second(2, now), .4)); aValues.add(new TimePeriodValue(new Second(14, now), .25)); bValues.add(new TimePeriodValue(new Second(14, now), .35)); cValues.add(new TimePeriodValue(new Second(14, now), .4)); aValues.add(new TimePeriodValue(new Second(22, now), .26)); bValues.add(new TimePeriodValue(new Second(22, now), .35)); cValues.add(new TimePeriodValue(new Second(22, now), .39)); aValues.add(new TimePeriodValue(new Second(32, now), .23)); bValues.add(new TimePeriodValue(new Second(32, now), .37)); cValues.add(new TimePeriodValue(new Second(32, now), .38)); aValues.add(new TimePeriodValue(new Second(45, now), .33)); bValues.add(new TimePeriodValue(new Second(45, now), .31)); cValues.add(new TimePeriodValue(new Second(45, now), .37)); aValues.add(new TimePeriodValue(new Second(58, now), .33)); bValues.add(new TimePeriodValue(new Second(58, now), .31)); cValues.add(new TimePeriodValue(new Second(58, now), .37)); TimePeriodValuesCollection series = new TimePeriodValuesCollection(); series.addSeries(aValues);/*from w w w .j av a 2 s . co m*/ series.addSeries(bValues); series.addSeries(cValues); return series; }
From source file:net.commerce.zocalo.freechart.ChartTest.java
private TimePeriodValuesCollection createTopValues(Minute now) { TimePeriodValues bValues = new TimePeriodValues("hockey"); bValues.add(new TimePeriodValue(new Second(2, now), .6)); bValues.add(new TimePeriodValue(new Second(12, now), .55)); bValues.add(new TimePeriodValue(new Second(24, now), .46)); bValues.add(new TimePeriodValue(new Second(35, now), .21)); bValues.add(new TimePeriodValue(new Second(42, now), .43)); bValues.add(new TimePeriodValue(new Second(54, now), .53)); bValues.add(new TimePeriodValue(new Second(58, now), .53)); TimePeriodValuesCollection bSeries = new TimePeriodValuesCollection(); bSeries.addSeries(bValues);//from ww w. ja v a 2 s. c o m return bSeries; }
From source file:net.commerce.zocalo.freechart.ChartTest.java
private TimePeriodValuesCollection createBottomValues(Minute now) { TimePeriodValues aValues = new TimePeriodValues("volleyball"); aValues.add(new TimePeriodValue(new Second(2, now), .2)); aValues.add(new TimePeriodValue(new Second(12, now), .25)); aValues.add(new TimePeriodValue(new Second(29, now), .26)); aValues.add(new TimePeriodValue(new Second(35, now), .18)); aValues.add(new TimePeriodValue(new Second(45, now), .33)); aValues.add(new TimePeriodValue(new Second(58, now), .33)); TimePeriodValuesCollection aSeries = new TimePeriodValuesCollection(); aSeries.addSeries(aValues);/* ww w . j av a 2 s .co m*/ return aSeries; }
From source file:org.jfree.data.time.Second.java
/** * Creates a new instance by parsing a string. The string is assumed to * be in the format "YYYY-MM-DD HH:MM:SS", perhaps with leading or trailing * whitespace./*w w w. j a v a 2s . c o m*/ * * @param s the string to parse. * * @return The second, or <code>null</code> if the string is not parseable. */ public static Second parseSecond(String s) { Second result = null; s = s.trim(); String daystr = s.substring(0, Math.min(10, s.length())); Day day = Day.parseDay(daystr); if (day != null) { String hmsstr = s.substring(Math.min(daystr.length() + 1, s.length()), s.length()); hmsstr = hmsstr.trim(); int l = hmsstr.length(); String hourstr = hmsstr.substring(0, Math.min(2, l)); String minstr = hmsstr.substring(Math.min(3, l), Math.min(5, l)); String secstr = hmsstr.substring(Math.min(6, l), Math.min(8, l)); int hour = Integer.parseInt(hourstr); if ((hour >= 0) && (hour <= 23)) { int minute = Integer.parseInt(minstr); if ((minute >= 0) && (minute <= 59)) { Minute m = new Minute(minute, new Hour(hour, day)); int second = Integer.parseInt(secstr); if ((second >= 0) && (second <= 59)) { result = new Second(second, m); } } } } return result; }
From source file:skoa.helpers.Graficos.java
/****************************************************************** * Funcion obtenerSerieEvolucion(): obtiene la serie de un fichero* ******************************************************************/ private TimeSeries obtenerSerieEvolucion() { String naux = ""; //si la longitud es 20 o 21, se trata de un fichero directo de una consulta A. //porque la df puede ser x.x.x o x.x.xx if (nombreFichero.length() == 20 || nombreFichero.length() == 21) naux = nombreFichero.substring(nombreFichero.indexOf("-") + 3, nombreFichero.indexOf(".txt")); //Saca la DG del nombre del fich. //si la longitud es 22, se trata de un fichero de una consulta A previa. else if (nombreFichero.length() == 22) naux = nombreFichero.substring(nombreFichero.indexOf("-") + 5, nombreFichero.indexOf(".txt")); //si la longitud es 23, se trata de un fichero (sin unificar) de una consulta D previa. else if (nombreFichero.length() == 23) naux = nombreFichero.substring(nombreFichero.indexOf("-") + 6, nombreFichero.indexOf(".txt")); //si se trata de un fichero de una consulta B o C previa. else if (nombreFichero.indexOf("h") >= 0) naux = nombreFichero.substring(nombreFichero.indexOf("h") + 2, nombreFichero.indexOf(".txt")); naux = naux.replaceAll("-", "/"); //Para que las DGs sea x/xx/xx en vez de x-xx-xx TimeSeries serie = new TimeSeries(naux); File archivo = new File(ruta + nombreFichero); FileReader fr = null;// w w w. j a v a2s . c o m BufferedReader linea = null; String line; try { fr = new FileReader(archivo); linea = new BufferedReader(fr); //Se crea para leer las lineas int d = 0, m = 0, a = 0, a1 = 0, m1 = 0, d1 = 0, j, h1, h2, h3; double e = 0; String aux, h, minutos, segundos; int min_ant = 0, sec_ant = 0, vez1 = 0; //min_prim mira si es el primero, para comparar ant y act. Day day1 = null; while ((line = linea.readLine()) != null) { //Lectura del fichero int i = line.indexOf("\t"); String f = line.substring(0, i); String valor = line.substring(i + 1); //Obtencion del dia, mes y ao de la fecha. j = f.indexOf("-"); aux = f.substring(0, j); a = Integer.parseInt(aux); f = f.substring(j + 1); j = f.indexOf("-"); aux = f.substring(0, j); m = Integer.parseInt(aux); f = f.substring(j + 1); j = f.indexOf(" "); aux = f.substring(0, j); d = Integer.parseInt(aux); //Obtencion de la hora de la fecha. f = f.substring(j + 1); if (fechaInicial.contentEquals("")) fechaInicial = d + "/" + m + "/" + a + " " + f; //Variable para la grfica fechaFinal = d + "/" + m + "/" + a + " " + f; j = f.indexOf(":"); h = f.substring(0, j); f = f.substring(j + 1); j = f.indexOf(":"); minutos = f.substring(0, j); segundos = f.substring(j + 1); if (a1 == 0 & m1 == 0 & d1 == 0) { //Inicializacin: Primera fecha. a1 = a; m1 = m; d1 = d; day1 = new Day(d1, m1, a1); } else { if (a1 != a) { a1 = a; if (m1 != m) m1 = m; if (d1 != d) d1 = d; day1 = new Day(d1, m1, a1); } else if (m1 != m) { m1 = m; if (d1 != d) d1 = d; day1 = new Day(d1, m1, a1); } else if (d1 != d) { d1 = d; day1 = new Day(d1, m1, a1); } } //Comprueba si es boolean. Si lo es, se le asigna 0 o 1 //para poder representarlo en la grfica. Si no, su <<valor>>. if (posiblesBooleanos(valor, 1)) e = 1; else if (posiblesBooleanos(valor, 0)) e = 0; else { //NO ES UN BOOLEANO. int u = valor.indexOf(" "); valor = valor.substring(0, u); e = Double.parseDouble(valor); } //Comprobamos que la hora no coincida, para que si coincide, introducir en la serie slo //la primera aparicin de la fecha con su valor, por ser este ms representativo segn lo visto. if (vez1 == 0) { min_ant = h1 = Integer.parseInt(minutos); //minutos h2 = Integer.parseInt(h); //hora sec_ant = h3 = Integer.parseInt(segundos); //segundos serie.addOrUpdate(new Second(h3, new Minute(h1, new Hour(h2, day1))), e);//Montamos la serie en base a los segundos, minutos, hora y da vez1 = 1; } else { h1 = Integer.parseInt(minutos); //minutos h2 = Integer.parseInt(h); //hora h3 = Integer.parseInt(segundos); //segundos if (min_ant == h1) { //Si el minuto es =, comprobamos los segundos if (sec_ant == h3) { } //Si los segundos son =, no se introduce nada en la serie. else { //Si los segundos son !=, se introduce en la serie. serie.addOrUpdate(new Second(h3, new Minute(h1, new Hour(h2, day1))), e);//Montamos la serie en base a los segundos, minutos, hora y da sec_ant = h3; } } else { //Si el minuto es !=, se introduce en la serie. serie.addOrUpdate(new Second(h3, new Minute(h1, new Hour(h2, day1))), e);//Montamos la serie en base a los segundos, minutos, hora y da min_ant = h1; sec_ant = h3; } } } } catch (Exception e) { e.printStackTrace(); } finally { try { if (null != fr) fr.close(); //Se cierra si todo va bien. } catch (Exception e2) { //Sino salta una excepcion. e2.printStackTrace(); } } return serie; }
From source file:GUI.ServerUI_Client.java
public void actionPerformed(final ActionEvent e) { try {//from w ww . j a va 2s . c om //Create a Second object to solve duplicate time series series.addOrUpdate(new Second(new Date(), TimeZone.getDefault()), Client.RTInputStream.bytesGraph); //System.err.println("RTin.byteCnt="+RTInputStream.byteCnt); } catch (Exception ex) { ex.printStackTrace(); } finally { Client.RTInputStream.bytesGraph = 0; } }
From source file:skoa.helpers.Graficos.java
/***************************************************************************************** * Obtiene la serie de un fichero para la consulta D, que es un poco diferente a la de A.* *****************************************************************************************/ private TimeSeries obtenerSerieEvolucion2() { String naux1 = "", naux2; //x-x-xx-x-x-xx.txt naux1 = nombreFichero.substring(nombreFichero.indexOf(".txt") - 13, nombreFichero.indexOf(".txt") - 7); //Saca la DG del nombre del fich. naux1 = naux1.replaceAll("-", "/"); //Para que las DGs sea x/xx/xx en vez de x-xx-xx naux2 = nombreFichero.substring(nombreFichero.indexOf(".txt") - 6, nombreFichero.indexOf(".txt")); //Saca la DG del nombre del fich. naux2 = naux2.replaceAll("-", "/"); //Para que las DGs sea x/xx/xx en vez de x-xx-xx naux1 = naux1 + "-" + naux2; TimeSeries serie = new TimeSeries(naux1); File archivo = new File(ruta + nombreFichero); FileReader fr = null;// ww w . ja v a2 s . c o m BufferedReader linea = null; String line; try { fr = new FileReader(archivo); linea = new BufferedReader(fr); //Se crea para leer las lineas int d = 0, m = 0, a = 0, a1 = 0, m1 = 0, d1 = 0, j, h1, h2, h3; double e = 0; String aux, h, minutos, segundos; int min_ant = 0, sec_ant = 0, vez1 = 0; //min_prim mira si es el primero, para comparar ant y act. Day day1 = null; while ((line = linea.readLine()) != null) { //Lectura del fichero int i = line.indexOf("\t"); String f = line.substring(0, i); String valor = line.substring(i + 1); //Obtencion del dia, mes y ao de la fecha. j = f.indexOf("-"); aux = f.substring(0, j); a = Integer.parseInt(aux); f = f.substring(j + 1); j = f.indexOf("-"); aux = f.substring(0, j); m = Integer.parseInt(aux); f = f.substring(j + 1); j = f.indexOf(" "); aux = f.substring(0, j); d = Integer.parseInt(aux); //Obtencion de la hora de la fecha. f = f.substring(j + 1); if (fechaInicial.contentEquals("")) fechaInicial = d + "/" + m + "/" + a + " " + f; //Variable para la grfica fechaFinal = d + "/" + m + "/" + a + " " + f; j = f.indexOf(":"); h = f.substring(0, j); f = f.substring(j + 1); j = f.indexOf(":"); minutos = f.substring(0, j); segundos = f.substring(j + 1); if (a1 == 0 & m1 == 0 & d1 == 0) { //Inicializacin: Primera fecha. a1 = a; m1 = m; d1 = d; day1 = new Day(d1, m1, a1); } else { if (a1 != a) { a1 = a; if (m1 != m) m1 = m; if (d1 != d) d1 = d; day1 = new Day(d1, m1, a1); } else if (m1 != m) { m1 = m; if (d1 != d) d1 = d; day1 = new Day(d1, m1, a1); } else if (d1 != d) { d1 = d; day1 = new Day(d1, m1, a1); } } //Comprueba si es boolean. Si lo es, se le asigna 0 1 //para poder representarlo en la grfica. Si no, su <<valor>>. if (posiblesBooleanos(valor, 1)) e = 1; else if (posiblesBooleanos(valor, 0)) e = 0; else { //NO ES UN BOOLEANO. int u = valor.indexOf(" "); valor = valor.substring(0, u); e = Double.parseDouble(valor); } //Comprobamos que la hora no coincida, para que si coincide, introducir en la serie slo //la primera aparicin de la fecha con su valor, por ser este ms representativo segn lo visto. if (vez1 == 0) { min_ant = h1 = Integer.parseInt(minutos); //minutos h2 = Integer.parseInt(h); //hora sec_ant = h3 = Integer.parseInt(segundos); //segundos serie.addOrUpdate(new Second(h3, new Minute(h1, new Hour(h2, day1))), e);//Montamos la serie en base a los segundos, minutos, hora y da vez1 = 1; } else { h1 = Integer.parseInt(minutos); //minutos h2 = Integer.parseInt(h); //hora h3 = Integer.parseInt(segundos); //segundos if (min_ant == h1) { //Si el minuto es =, comprobamos los segundos if (sec_ant == h3) { } //Si los segundos son =, no se introduce nada en la serie. else { //Si los segundos son !=, se introduce en la serie. serie.addOrUpdate(new Second(h3, new Minute(h1, new Hour(h2, day1))), e);//Montamos la serie en base a los segundos, minutos, hora y da sec_ant = h3; } } else { //Si el minuto es !=, se introduce en la serie. serie.addOrUpdate(new Second(h3, new Minute(h1, new Hour(h2, day1))), e);//Montamos la serie en base a los segundos, minutos, hora y da min_ant = h1; sec_ant = h3; } } } } catch (Exception e) { e.printStackTrace(); } finally { try { if (null != fr) fr.close(); //Se cierra si todo va bien. } catch (Exception e2) { //Sino salta una excepcion. e2.printStackTrace(); } } return serie; }