<commit_before>/*
 * Last modification information:
 * $Revision: 1.2 $
 * $Date: 2007-03-18 04:07:34 $
 * $Author: imoncada $
 *
 * Licence Information
 * Copyright 2007 The Concord Consortium 
*/
package org.concord.datagraph.state;

import java.awt.Color;

import org.concord.datagraph.engine.DataGraphable;
import org.concord.framework.data.stream.DefaultDataStore;
import org.concord.framework.otrunk.DefaultOTObject;
import org.concord.framework.otrunk.OTObject;
import org.concord.framework.otrunk.OTObjectList;
import org.concord.framework.otrunk.OTResourceSchema;
import org.concord.framework.otrunk.view.OTAction;
//import org.concord.otrunk.view.OTObjectListViewer;

/**
 * OTAddGraphableAction
 * Class name and description
 *
 * Date created: Mar 5, 2007
 *
 * @author <NAME><p>
 *
 */
public class OTAddGraphableAction extends DefaultOTObject
	implements OTAction
{
	public static interface ResourceSchema extends OTResourceSchema
	{
		public OTDataGraph getDataGraph();
		public void setDataGraph(OTDataGraph dg);
		
		public OTObjectList getGraphablesToAdd();
		public void setGraphablesToAdd(OTObjectList list);
	}
	protected ResourceSchema resources;
	
	public OTAddGraphableAction(ResourceSchema resources)
	{
		super(resources);
		this.resources = (ResourceSchema)resources;
	}
	
	/**
	 * @see org.concord.framework.otrunk.view.OTAction#doAction()
	 */
	public void doAction()
	{
		OTDataGraph dataGraph = resources.getDataGraph();
		
		if (dataGraph.getGraphables().size() > 0){
			//Test: modify the first OT graphable
			OTDataGraphable otGraphable = (OTDataGraphable)dataGraph.getGraphables().get(0);
			otGraphable.setColor((int)(Math.random()*16777216));
			
			return;
		}
		
		//XXX: Add a default data graphable for now
		OTDataGraphable otDataG = getGraphableToAdd();
		
		dataGraph.getGraphables().add(otDataG);
	}

	/**
	 * @return
	 */
	private OTDataGraphable getGraphableToAdd()
	{
		//XXX: Add the first data graphable for now
		OTObjectList otObjList = resources.getGraphablesToAdd();
		OTDataGraphable dataG = (OTDataGraphable)otObjList.get(0);
		return dataG;
	}

	/**<commit_msg>Added OTFrameDisplayAction, which is an action that shows an otobject inside of a specific frame. I had to add a new OTActionContext interface so the action can have access to the view context from the class calling doAction(). All the classes implementing OTAction were modified accordingly.<commit_after>/*
 * Last modification information:
 * $Revision: 1.3 $
 * $Date: 2007-09-26 18:39:31 $
 * $Author: imoncada $
 *
 * Licence Information
 * Copyright 2007 The Concord Consortium 
*/
package org.concord.datagraph.state;

import java.awt.Color;

import org.concord.datagraph.engine.DataGraphable;
import org.concord.framework.data.stream.DefaultDataStore;
import org.concord.framework.otrunk.DefaultOTObject;
import org.concord.framework.otrunk.OTObject;
import org.concord.framework.otrunk.OTObjectList;
import org.concord.framework.otrunk.OTResourceSchema;
import org.concord.framework.otrunk.view.OTAction;
//import org.concord.otrunk.view.OTObjectListViewer;
import org.concord.framework.otrunk.view.OTActionContext;

/**
 * OTAddGraphableAction
 * Class name and description
 *
 * Date created: Mar 5, 2007
 *
 * @author <NAME><p>
 *
 */
public class OTAddGraphableAction extends DefaultOTObject
	implements OTAction
{
	public static interface ResourceSchema extends OTResourceSchema
	{
		public OTDataGraph getDataGraph();
		public void setDataGraph(OTDataGraph dg);
		
		public OTObjectList getGraphablesToAdd();
		public void setGraphablesToAdd(OTObjectList list);
	}
	protected ResourceSchema resources;
	
	public OTAddGraphableAction(ResourceSchema resources)
	{
		super(resources);
		this.resources = (ResourceSchema)resources;
	}
	
	/**
	 * @see org.concord.framework.otrunk.view.OTAction#doAction(org.concord.framework.otrunk.view.OTActionContext)
	 */
	public void doAction(OTActionContext context)
	{
		OTDataGraph dataGraph = resources.getDataGraph();
		
		if (dataGraph.getGraphables().size() > 0){
			//Test: modify the first OT graphable
			OTDataGraphable otGraphable = (OTDataGraphable)dataGraph.getGraphables().get(0);
			otGraphable.setColor((int)(Math.random()*16777216));
			
			return;
		}
		
		//XXX: Add a default data graphable for now
		OTDataGraphable otDataG = getGraphableToAdd();
		
		dataGraph.getGraphables().add(otDataG);
	}

	/**
	 * @return
	 */
	private OTDataGraphable getGraphableToAdd()
	{
		//XXX: Add the first data graphable for now
		OTObjectList otObjList = resources.getGraphablesToAdd();
		OTDataGraphable dataG = (OTDataGraphable)otObjList.get(0);
		return dataG;
	}

	/**
{'fraction_non_alphanumeric': 0.1035076393372068, 'fraction_numerical': 0.015493867010974823, 'mean_word_length': 4.81, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6740882', 'n_tokens_mistral': 1625, 'n_tokens_neox': 1445, 'n_words': 328}