@Test public void trimLabelsDays1() { List< String > input = Arrays.asList( "2014/11/05 00:00:00.000000000" , "2014/11/06 00:00:00.000000000" , "2014/11/07 00:00:00.000000000" , "2014/11/08 00:00:00.000000000" , "2014/11/09 00:00:00.000000000" ); List< String > expected = Arrays.asList( "2014/11/05" , "11/06" , "11/07" , "11/08" , "11/09" ); List< String > found = TimeScales.trimLabels( input ); assertThat( found , equalTo( expected ) ); }
static List<String> trimLabels( List< String > labels ) { if ( labels.size() <= 1 ) { return labels; } int greatestChangingPrecision = calculateGreatestChangingField( labels ); ArrayList< String > rtn = new ArrayList< String >( labels.size() ); DateTrimmer firstDate = new DateTrimmer( labels.get( 0 ) ); rtn.add( firstDate.getCompactForm( DateTrimmer.NO_PRECISION , greatestChangingPrecision ) ); for ( int i=1 ; i<labels.size() ; i++ ) { String prevLabel = labels.get( i-1 ); String nextLabel = labels.get( i ); int redundancePrecision = greatestRedundancePrecision( prevLabel , nextLabel ); DateTrimmer f = new DateTrimmer( nextLabel ); String trimmedLabel = f.getCompactForm( redundancePrecision , greatestChangingPrecision ); rtn.add( trimmedLabel ); } return rtn; }
TimeScales { static List<String> trimLabels( List< String > labels ) { if ( labels.size() <= 1 ) { return labels; } int greatestChangingPrecision = calculateGreatestChangingField( labels ); ArrayList< String > rtn = new ArrayList< String >( labels.size() ); DateTrimmer firstDate = new DateTrimmer( labels.get( 0 ) ); rtn.add( firstDate.getCompactForm( DateTrimmer.NO_PRECISION , greatestChangingPrecision ) ); for ( int i=1 ; i<labels.size() ; i++ ) { String prevLabel = labels.get( i-1 ); String nextLabel = labels.get( i ); int redundancePrecision = greatestRedundancePrecision( prevLabel , nextLabel ); DateTrimmer f = new DateTrimmer( nextLabel ); String trimmedLabel = f.getCompactForm( redundancePrecision , greatestChangingPrecision ); rtn.add( trimmedLabel ); } return rtn; } }
TimeScales { static List<String> trimLabels( List< String > labels ) { if ( labels.size() <= 1 ) { return labels; } int greatestChangingPrecision = calculateGreatestChangingField( labels ); ArrayList< String > rtn = new ArrayList< String >( labels.size() ); DateTrimmer firstDate = new DateTrimmer( labels.get( 0 ) ); rtn.add( firstDate.getCompactForm( DateTrimmer.NO_PRECISION , greatestChangingPrecision ) ); for ( int i=1 ; i<labels.size() ; i++ ) { String prevLabel = labels.get( i-1 ); String nextLabel = labels.get( i ); int redundancePrecision = greatestRedundancePrecision( prevLabel , nextLabel ); DateTrimmer f = new DateTrimmer( nextLabel ); String trimmedLabel = f.getCompactForm( redundancePrecision , greatestChangingPrecision ); rtn.add( trimmedLabel ); } return rtn; }  }
TimeScales { static List<String> trimLabels( List< String > labels ) { if ( labels.size() <= 1 ) { return labels; } int greatestChangingPrecision = calculateGreatestChangingField( labels ); ArrayList< String > rtn = new ArrayList< String >( labels.size() ); DateTrimmer firstDate = new DateTrimmer( labels.get( 0 ) ); rtn.add( firstDate.getCompactForm( DateTrimmer.NO_PRECISION , greatestChangingPrecision ) ); for ( int i=1 ; i<labels.size() ; i++ ) { String prevLabel = labels.get( i-1 ); String nextLabel = labels.get( i ); int redundancePrecision = greatestRedundancePrecision( prevLabel , nextLabel ); DateTrimmer f = new DateTrimmer( nextLabel ); String trimmedLabel = f.getCompactForm( redundancePrecision , greatestChangingPrecision ); rtn.add( trimmedLabel ); } return rtn; }  static TimeScale linearAbsoluteScale(); }
TimeScales { static List<String> trimLabels( List< String > labels ) { if ( labels.size() <= 1 ) { return labels; } int greatestChangingPrecision = calculateGreatestChangingField( labels ); ArrayList< String > rtn = new ArrayList< String >( labels.size() ); DateTrimmer firstDate = new DateTrimmer( labels.get( 0 ) ); rtn.add( firstDate.getCompactForm( DateTrimmer.NO_PRECISION , greatestChangingPrecision ) ); for ( int i=1 ; i<labels.size() ; i++ ) { String prevLabel = labels.get( i-1 ); String nextLabel = labels.get( i ); int redundancePrecision = greatestRedundancePrecision( prevLabel , nextLabel ); DateTrimmer f = new DateTrimmer( nextLabel ); String trimmedLabel = f.getCompactForm( redundancePrecision , greatestChangingPrecision ); rtn.add( trimmedLabel ); } return rtn; }  static TimeScale linearAbsoluteScale(); final static int HOUR_FIELD_ID; final static int FIRST_HOUR; final static int DAY_FIELD_ID; final static int FIRST_DAY; final static int WEEK_FIELD_ID; final static int FIRST_WEEK; }