Skip to content

Commit

Permalink
ttools: add transparency config item for histogram layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mbtaylor authored and mmpcn committed Nov 27, 2014
1 parent ff84150 commit 98cb02e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -90,6 +90,12 @@ public Specifier<Integer> createSpecifier() {
.createSliderKey( new ConfigMeta( "translevel", "Transparency Level" ),
0.1, 0.001, 2, true );

/** Config key for "normal" transparency - it's just 1-alpha. */
public static final ConfigKey<Double> TRANSPARENCY =
DoubleConfigKey.createSliderKey( new ConfigMeta( "transparency",
"Transparency" ),
0, 0, 1, false );

/** Config key for line thickness. */
private static final ConfigKey<Integer> THICKNESS = createThicknessKey( 1 );

Expand Down
Expand Up @@ -117,6 +117,7 @@ public CoordGroup getCoordGroup() {
public ConfigKey[] getStyleKeys() {
return new ConfigKey[] {
StyleKeys.COLOR,
StyleKeys.TRANSPARENCY,
BinSizer.BINSIZER_KEY,
CUMULATIVE_KEY,
NORM_KEY,
Expand All @@ -128,7 +129,11 @@ public ConfigKey[] getStyleKeys() {
}

public HistoStyle createStyle( ConfigMap config ) {
Color color = config.get( StyleKeys.COLOR );
Color baseColor = config.get( StyleKeys.COLOR );
double alpha = 1 - config.get( StyleKeys.TRANSPARENCY );
float[] rgba = baseColor.getRGBComponents( new float[ 4 ] );
rgba[ 3 ] *= alpha;
Color color = new Color( rgba[ 0 ], rgba[ 1 ], rgba[ 2 ], rgba[ 3 ] );
BarStyle.Form barForm = config.get( StyleKeys.BAR_FORM );
BarStyle.Placement placement = BarStyle.PLACE_OVER;
boolean cumulative = config.get( CUMULATIVE_KEY );
Expand Down

0 comments on commit 98cb02e

Please sign in to comment.