Skip to content

Commit

Permalink
Merge pull request #496 from p2t2/DEV3.2.1.1
Browse files Browse the repository at this point in the history
Dev3.2.1.1
  • Loading branch information
mreposa committed Jul 8, 2015
2 parents c0315df + e6bb2c4 commit ac96297
Show file tree
Hide file tree
Showing 20 changed files with 769 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Figaro/figaro_build.properties
@@ -1 +1 @@
version=3.2.1.0
version=3.2.1.1
Expand Up @@ -20,7 +20,7 @@ import scala.math.{ log, exp }
/**
* An exponential distribution in which the parameter is a constant.
*/
class AtomicExponential(name: Name[Double], lambda: Double, collection: ElementCollection)
class AtomicExponential(name: Name[Double], val lambda: Double, collection: ElementCollection)
extends Element[Double](name, collection) with Atomic[Double] {
type Randomness = Double

Expand Down
13 changes: 11 additions & 2 deletions Figaro/src/main/scala/com/cra/figaro/util/ColorGradient.scala
@@ -1,5 +1,14 @@
/**
*
/*
* ColorGradient.scala
* A Factory for color schemes to be used in tables, charts, histograms, etc
*
* Created By: Glenn Takata (gtakata@cra.com)
* Creation Date: Apr 9, 2015
*
* Copyright 2015 Avrom J. Pfeffer and Charles River Analytics, Inc.
* See http://www.cra.com or email figaro@cra.com for information.
*
* See http://www.github.com/p2t2/figaro for a copy of the software license.
*/
package com.cra.figaro.util

Expand Down
@@ -0,0 +1,36 @@
/*
* DataView.scala
* Internal data repository/method for use by tables, charts, histograms, etc
*
* Created By: Glenn Takata (gtakata@cra.com)
* Creation Date: Apr 9, 2015
*
* Copyright 2015 Avrom J. Pfeffer and Charles River Analytics, Inc.
* See http://www.cra.com or email figaro@cra.com for information.
*
* See http://www.github.com/p2t2/figaro for a copy of the software license.
*/
package com.cra.figaro.util.visualization

import prefuse.data.Table
import prefuse.data.query.NumberRangeModel
import prefuse.util.ui.ValuedRangeModel

/**
* @author Glenn Takata (gtakata@cra.com)
*
* Mar 17, 2015
*/
trait DataView {
def name: String
def title: String
def range: ValuedRangeModel

def nValues: Int

def getTable: Table

def yMax: Double
def dataType: Int
def yRangeModel: NumberRangeModel
}
@@ -1,21 +1,36 @@
/*
* ResultsGUI.scala
* The main controller for visualizations.
* Coordinates data input and display as well as user interaction with displays.
*
* Created By: Glenn Takata (gtakata@cra.com)
* Creation Date: Mar 16, 2015
*
* Copyright 2015 Avrom J. Pfeffer and Charles River Analytics, Inc.
* See http://www.cra.com or email figaro@cra.com for information.
*
* See http://www.github.com/p2t2/figaro for a copy of the software license.
*/
package com.cra.figaro.util.visualization

import scala.swing._
import com.cra.figaro.util.visualization.results.{ ResultsTable, ResultsView }
import com.cra.figaro.language.{Element}
import com.cra.figaro.util.visualization.results.{ ContinuousData, DiscreteData, ResultsData, ResultsTable, ResultsView }
import com.cra.figaro.util.visualization.histogram.{ Histogram }
import com.cra.figaro.util.visualization.distribution.{Distribution}
import com.cra.figaro.util.visualization.reduction.DataReduction
import com.cra.figaro.util.ColorGradient
import scala.swing.event.Event
import scala.swing.event.TableRowsSelected
import com.cra.figaro.util.visualization.results.ResultsData

/**
* @author Glenn Takata (gtakata@cra.com)
*/

case class NewResult(result: ResultsData[_]) extends Event
case class NewResult(result: ResultsData) extends Event

class ResultHandler extends Publisher {
def newResult(result: ResultsData[_]) {
def newResult(result: ResultsData) {
Swing.onEDT(
publish(NewResult(result))
)
Expand All @@ -28,14 +43,19 @@ class EmptyTab extends BoxPanel(Orientation.Vertical) {
}

object ResultsGUI extends SimpleSwingApplication {
val TAB_WIDTH = 400
val TAB_WIDTH = 600
val TAB_HEIGHT = 300

val TABLE_WIDTH = 400
val TABLE_WIDTH = 600
val TABLE_HEIGHT = 250

val results = new ResultHandler
def addResult(result: ResultsData[_]) {
// def addResult(result: ResultsData) {
def addResult(name: String, dist: Any) {
val result = dist match {
case l: List[(Double, Double)] => DiscreteData(name, DataReduction.binToDistribution(l))
case e: Element[_] => ContinuousData(name, e)
}
results.newResult(result)
}

Expand Down Expand Up @@ -89,18 +109,31 @@ object ResultsGUI extends SimpleSwingApplication {
}
case TableRowsSelected(source, range, false) => {
val row = table.getSelectedRow
println(row)
// println(row)
updateHistogram(row)
mainPanel.revalidate()
mainPanel.repaint
}
}

private def updateHistogram(result: ResultsData[_]) {
private def updateHistogram(result: ResultsData) {
graphs.pages.clear()

val histogram = new Histogram(new ResultsView(result), currentColor)
graphs.pages += new TabbedPane.Page(result.name, histogram)

result match {
case DiscreteData(name, dist) => {
val color = currentColor
val histogramTab = new Histogram(new ResultsView(result), color)
graphs.pages += new TabbedPane.Page(result.name + " Distribution", histogramTab)
}
case ContinuousData(name, dist) => {
val color = ColorGradient.HEATMAP
val distributionTab = new Distribution(new ResultsView(result), color)
graphs.pages += new TabbedPane.Page(result.name + " Density", distributionTab)

}
case _ =>
}

graphs.revalidate
graphs.repaint
}
Expand Down

0 comments on commit ac96297

Please sign in to comment.