//
//  MPT_FeatureBase.m
//  AUCoderDemo
//
//  Created by Andrew Salamon on 11/30/06.
//  Copyright 2006 Machine Perception Laboratory, University of California San Diego. All rights reserved.
//

#import "MPT_FeatureBase.h"


@implementation MPT_FeatureBase
- (id)init
{
	if( self = [super init] )
	{
		NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
		
		NSString *featureDataFileName = [myBundle objectForInfoDictionaryKey:@"FeatureWeights"];
		if( featureDataFileName )
		{
			featureDataFile = [[myBundle pathForResource:featureDataFileName ofType:@"fdtxml"] copy];
			if( !featureDataFile )
				featureDataFile = [[myBundle pathForResource:featureDataFileName ofType:@"fdt"] copy];
			if( !featureDataFile )
				featureDataFile = [[myBundle pathForResource:featureDataFileName ofType:@"fdtbin"] copy];
		}

		NSString *priorDataFileName = [myBundle objectForInfoDictionaryKey:@"FeaturePriors"];
		if( priorDataFileName )
		{
			gpriorFile = [[myBundle pathForResource:priorDataFileName ofType:@"gpriorxml"] copy];
			if( !gpriorFile )
				gpriorFile = [[myBundle pathForResource:priorDataFileName ofType:@"gprior"] copy];
			if( !gpriorFile )
				gpriorFile = [[myBundle pathForResource:priorDataFileName ofType:@"gpriorbin"] copy];
		}
	}
	
	return self;
}

- (void)dealloc
{
	[featureDataFile release];
	[gpriorFile release];
	[super dealloc];
}

- (NSString *)step
{
	return MPT_PluginStep_Features;
}

/** Skip loading labels.
 * We don't have separate view's for displaying data.
 */
- (BOOL)loadLabels
{
	return YES;
}

- (BOOL)handlesLoading
{
	return NO;
}
- (BOOL)loadFeatureData:(void *)fd andGPrior:(void *)prior
{
	return NO;
}
- (NSString *)featureDataFile
{
	return featureDataFile;
}
- (NSString *)gpriorFile
{
	return gpriorFile;
}

- (NSColor *)displayColor
{
	NSDictionary *prefs = [[NSUserDefaults standardUserDefaults] dictionaryForKey:[self pluginID]];
	
	return [prefs objectForKey:@"displayColor"];
}

@end
