44 lines
1.5 KiB
Groovy
44 lines
1.5 KiB
Groovy
|
import com.jdbernard.timeanalyzer.processors.*
|
||
|
import com.jdbernard.timeanalyzer.categories.*
|
||
|
import com.jdbernard.timeanalyzer.categorizationplans.*
|
||
|
import com.jdbernard.timeanalyzer.chart.*
|
||
|
import com.jdbernard.timeanalyzer.events.*
|
||
|
import com.jdbernard.timestamper.core.*
|
||
|
import com.quantumdigital.ithelp.timeanalyzer.*
|
||
|
import org.joda.time.*
|
||
|
import org.joda.time.format.*
|
||
|
import org.jfree.chart.*
|
||
|
import org.jfree.data.general.*
|
||
|
import org.jfree.util.SortOrder
|
||
|
|
||
|
tep = new TimelineEventProcessor()
|
||
|
tep.exclusions << ~/.*Home.*/
|
||
|
|
||
|
pf = PeriodFormat.getDefault()
|
||
|
|
||
|
topcat = new FilteredCategory("Top Category")
|
||
|
|
||
|
twoLevelCatPlan = new TwoLevelCategorizationPlan()
|
||
|
descriptionBasedCatPlan = new DescriptionBasedCategorizationPlan()
|
||
|
topcat.categorizationPlans << twoLevelCatPlan
|
||
|
topcat.categorizationPlans << descriptionBasedCatPlan
|
||
|
|
||
|
loadEvents = { file, processor ->
|
||
|
fileSource = new FileTimelineSource(file.toURI())
|
||
|
timeline = fileSource.read()
|
||
|
return processor.process(timeline) }
|
||
|
|
||
|
makePieDataset = { category ->
|
||
|
DefaultPieDataset dpds = new DefaultPieDataset()
|
||
|
category.categories.each { cat ->
|
||
|
dpds.setValue(cat.description, cat.duration.standardSeconds) }
|
||
|
category.events.each { entry ->
|
||
|
dpds.setValue(entry.description, entry.duration.standardSeconds) }
|
||
|
dpds.sortByValues(SortOrder.DESCENDING)
|
||
|
|
||
|
return dpds }
|
||
|
|
||
|
makeFrame = { categoryName, dataset ->
|
||
|
return new ChartFrame(categoryName,
|
||
|
ChartFactory.createPieChart("Time Spent", dataset, true, true, false)) }
|