text:
#include "Object2D.h"

#ifdef printMessages
#warning "            Inside Object2D.cpp"
#endif

edk::Object2D::Object2D(){
    //
    this->selected=NULL;
    //rotation
    this->angle=0.0f;
    //Scale
    this->size = edk::size2f32(1.f,1.f);
    this->canDeleteObject=true;
    this->actions.setReadXMLActionFunction(&edk::Object2D::readXMLAction);
}

edk::Object2D::~Object2D(){
    this->actions.cleanReadXMLActionFunction();
    //dtor
    if(this->canDeleteObject){
        this->cleanMeshes();
    }
    else{
        this->meshes.cantDestroy();
        this->meshes.cantDeleteMeshes();
        this->animationPosition.cantDeleteGroup();
        this->animationRotation.cantDeleteGroup();
        this->animationSize.cantDeleteGroup();
        this->actions.cantDeleteGroup();
    }
    this->canDeleteObject=true;
}

//Function to read the actions
edk::Action* edk::Object2D::readXMLAction(edk::classID thisPointer,edk::uint32 actionCode){
    switch(actionCode){
    case 1u:
    {
        //ActionPosition
        return new edk::Object2D::ActionPosition((edk::Object2D*)thisPointer,edk::vec2f32(0,0));
        break;
    }
    case 2u:
    {
        //ActionMove
        return new edk::Object2D::ActionMove((edk::Object2D*)thisPointer,0,edk::vec2f32(0,0));
        break;
    }
    case 3u:
    {
        //ActionSetSize
        return new edk::Object2D::ActionSetSize((edk::Object2D*)thisPointer,edk::size2f32(1,1));
        break;
    }
    case 4u:
    {
        //ActionSize
        return new edk::Object2D::ActionSize((edk::Object2D*)thisPointer,0,edk::size2f32(1,1));
        break;
    }
    case 5u:
    {
        //ActionSetAngle
        return new edk::Object2D::ActionSetAngle((edk::Object2D*)thisPointer,0);
        break;
    }
    case 6u:
    {
        //ActionAngle
        return new edk::Object2D::ActionAngle((edk::Object2D*)thisPointer,0,0);
        break;
    }
    case 7u:
    {
        //ActionMeshName
        return new edk::Object2D::ActionMeshName((edk::Object2D*)thisPointer,0,NULL,false);
        break;
    }
    case 8u:
    {
        //ActionMeshStop
        return new edk::Object2D::ActionMeshStop((edk::Object2D*)thisPointer,0);
        break;
    }
    }
    return new edk::ActionZero();
}

//Actions
edk::Object2D::ActionPosition::ActionPosition(edk::Object2D* object, edk::vec2f32 position){
    this->position=position;
    this->object=object;
    this->code = 1u;
}
//run action function
void edk::Object2D::ActionPosition::runAction(){
    this->object->position = this->position;
}
//write to XML
bool edk::Object2D::ActionPosition::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionZero::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write the position
                    xml->addSelectedNextAttribute("positionX",this->position.x);
                    xml->addSelectedNextAttribute("positionY",this->position.y);

                    ret=true;
                    //select father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionPosition::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read the position
                    this->position.x = edk::String::strToInt32(xml->getSelectedAttributeValueByName("positionX"));
                    this->position.y = edk::String::strToInt32(xml->getSelectedAttributeValueByName("positionY"));

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::vec2f32 edk::Object2D::ActionPosition::getPosition(){
    return this->position;
}
edk::Object2D::ActionMove::ActionMove(edk::Object2D* object,edk::float32 duration, edk::vec2f32 position){
    this->position=position;
    this->duration = duration;
    this->object=object;
    this->code = 2u;
}
//run action function
void edk::Object2D::ActionMove::runAction(){
    this->object->animationPosition.cleanTracks();
    edk::uint32 track = this->object->animationPosition.newTrack();
    this->object->animationPosition.addFirstInterpolationLine(track,0,this->object->position.x,this->object->position.y,this->duration,this->position.x,this->position.y);
    this->object->animationPosition.playForwardAllTracks();
}
//write to XML
bool edk::Object2D::ActionMove::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionZero::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write the position
                    xml->addSelectedNextAttribute("positionX",this->position.x);
                    xml->addSelectedNextAttribute("positionY",this->position.y);
                    //write the duration
                    xml->addSelectedNextAttribute("duration",this->duration);

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionMove::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read the position
                    this->position.x = edk::String::strToInt32(xml->getSelectedAttributeValueByName("positionX"));
                    this->position.y = edk::String::strToInt32(xml->getSelectedAttributeValueByName("positionY"));
                    //read duration
                    this->duration = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("duration"));

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::vec2f32 edk::Object2D::ActionMove::getPosition(){
    return this->position;
}
edk::float32 edk::Object2D::ActionMove::getDuration(){
    return this->duration;
}
edk::Object2D::ActionSetSize::ActionSetSize(edk::Object2D* object, edk::size2f32 size){
    this->object=object;
    this->size=size;
    this->code = 3u;
}
//run action function
void edk::Object2D::ActionSetSize::runAction(){
    this->object->size = this->size;
}
//write to XML
bool edk::Object2D::ActionSetSize::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionZero::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write the size
                    xml->addSelectedNextAttribute("width",this->size.width);
                    xml->addSelectedNextAttribute("height",this->size.height);

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionSetSize::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read the code
                    this->size.width = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("width"));
                    this->size.height = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("height"));

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::size2f32 edk::Object2D::ActionSetSize::getSize(){
    return this->size;
}
edk::Object2D::ActionSize::ActionSize(edk::Object2D* object,edk::float32 duration, edk::size2f32 size){
    this->size=size;
    this->duration = duration;
    this->object=object;
    this->code = 4u;
}
//run action function
void edk::Object2D::ActionSize::runAction(){
    this->object->animationSize.cleanAnimations();
    this->object->animationSize.addFirstInterpolationLine(0,this->object->size.width,this->object->size.height,this->duration,this->size.width,this->size.height);
    this->object->animationSize.playForward();
}
//write to XML
bool edk::Object2D::ActionSize::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionZero::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write the size
                    xml->addSelectedNextAttribute("width",this->size.width);
                    xml->addSelectedNextAttribute("height",this->size.height);
                    //write the duration
                    xml->addSelectedNextAttribute("duration",this->duration);

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionSize::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read the code
                    this->size.width = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("width"));
                    this->size.height = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("height"));
                    //read the duration
                    this->duration = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("duration"));

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::size2f32 edk::Object2D::ActionSize::getSize(){
    return this->size;
}
edk::float32 edk::Object2D::ActionSize::getDuration(){
    return this->duration;
}
edk::Object2D::ActionSetAngle::ActionSetAngle(edk::Object2D* object, edk::float32 angle){
    this->object = object;
    this->angle = angle;
    this->code = 5u;
}
//run action function
void edk::Object2D::ActionSetAngle::runAction(){
    this->object->angle = this->angle;
}
//write to XML
bool edk::Object2D::ActionSetAngle::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionZero::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write angle
                    xml->addSelectedNextAttribute("angle",this->angle);

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionSetAngle::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read angle
                    this->angle = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("angle"));

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::float32 edk::Object2D::ActionSetAngle::getAngle(){
    return this->angle;
}
edk::Object2D::ActionAngle::ActionAngle(edk::Object2D* object,edk::float32 duration, edk::float32 angle){
    this->object = object;
    this->duration = duration;
    this->angle = angle;
    this->code = 6u;
}
//run action function
void edk::Object2D::ActionAngle::runAction(){
    this->object->animationRotation.cleanAnimations();
    this->object->animationRotation.addFirstInterpolationLine(0,this->object->angle,this->duration,this->angle);
    this->object->animationRotation.playForward();
}
//write to XML
bool edk::Object2D::ActionAngle::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionZero::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write angle
                    xml->addSelectedNextAttribute("angle",this->angle);
                    //write the duration
                    xml->addSelectedNextAttribute("duration",this->duration);

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionAngle::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read angle
                    this->angle = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("angle"));
                    //read duratio
                    this->duration = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("duration"));

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::float32 edk::Object2D::ActionAngle::getAngle(){
    return this->angle;
}
edk::float32 edk::Object2D::ActionAngle::getDuration(){
    return this->duration;
}
edk::Object2D::ActionMeshName::ActionMeshName(edk::Object2D* object,edk::uint32 id, edk::char8* name,bool loop){
    this->object=object;
    this->loop = loop;
    this->id = id;
    this->setName(name);
    this->code = 7u;
}
//run action function
void edk::Object2D::ActionMeshName::runAction(){
    //load the mesh
    edk::shape::Mesh2D* mesh = this->object->getMesh(this->id);
    if(mesh){
        mesh->selectedAnimationSetLoop(this->loop);
        mesh->selectedAnimationPlayNameForward(this->name());
    }
}
//write to XML
bool edk::Object2D::ActionMeshName::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionName::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write the loop
                    if(this->loop){
                        xml->setSelectedString("loopOn");
                    }
                    else{
                        xml->setSelectedString("loopOff");
                    }

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionMeshName::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    edk::ActionName::readFromXML(xml,id);
    this->id = 7u;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read the loop
                    if(edk::String::strCompare((edk::char8*)"loopOn",xml->getSelectedString())){
                        this->loop=true;
                    }
                    else{
                        this->loop=false;
                    }

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::uint32 edk::Object2D::ActionMeshName::getId(){
    return this->id;
}
bool edk::Object2D::ActionMeshName::getLoop(){
    return this->loop;
}
edk::Object2D::ActionMeshStop::ActionMeshStop(edk::Object2D* object,edk::uint32 id){
    this->object=object;
    this->id = id;
    this->code = 8u;
}
//run action function
void edk::Object2D::ActionMeshStop::runAction(){
    //load the mesh
    edk::shape::Mesh2D* mesh = this->object->getMesh(this->id);
    if(mesh){
        mesh->selectedAnimationStop();
    }
}
//write to XML
bool edk::Object2D::ActionMeshStop::writeToXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(edk::ActionZero::writeToXML(xml,id)){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //write the ID
                    xml->addSelectedNextAttribute("id",this->id);

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//read XML
bool edk::Object2D::ActionMeshStop::readFromXML(edk::XML* xml,edk::uint32 id){
    bool ret=false;
    if(xml){
        edk::char8* number = edk::String::uint32ToStr(id);
        if(number){
            edk::char8* name = edk::String::strCat("Action_",number);
            if(name){
                //create the Action
                if(xml->selectChild(name)){
                    //read the id
                    this->id = edk::String::strToInt64(xml->getSelectedAttributeValueByName("id"));

                    ret=true;
                    //then select the father
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] number;
        }
    }
    return ret;
}
//GET
edk::uint32 edk::Object2D::ActionMeshStop::getId(){
    return this->id;
}

//create a new mesh and add to the meshs stack
edk::shape::Mesh2D* edk::Object2D::newMesh(edk::uint32* position){
    return this->meshes.pushNewMesh(position);
}

//clean the obect
void edk::Object2D::clean(){
    //
    this->cleanSelected();
    this->cleanMeshes();
    this->pivo = 0.f;
    this->animationPosition.cleanTracks();
    this->animationRotation.cleanAnimationNameSelected();
    this->animationRotation.cleanAnimationNames();
    this->animationRotation.cleanAnimations();
    this->animationSize.cleanAnimationNameSelected();
    this->animationSize.cleanAnimationNames();
    this->animationSize.cleanAnimations();

    this->position = 0.f;
    this->angle = 0.f;
    this->size = 0.f;

    this->removeAllActions();
}
//Add a list to the Object2D
edk::uint32 edk::Object2D::addMesh(edk::shape::Mesh2D* mesh){
    //test if the list exist
    if(mesh){
        edk::uint32 ret = 0u;
        //then add the mesh to the list
        ret = this->meshes.pushBackMesh(mesh,false);
        if(ret<this->meshes.size()){
            //test if select the first
            if(this->meshes.size()==1u) this->selectMesh(0u);
            return ret;
        }
    }

    //else return falses
    return 0u;
}
//remove a polygonlist
bool edk::Object2D::removeMesh(edk::uint32 position){
    //remove the mesh
    return this->meshes.removeMesh(position);
}
//remove all meshes
void edk::Object2D::cleanMeshes(){
    this->cleanSelected();
    this->meshes.removeAllMeshes();
}

//Select the polygonList
bool edk::Object2D::selectMesh(edk::uint32 position){
    //free the selected
    this->cleanSelected();
    if((this->selected = this->meshes.getMesh(position))){
        return true;
    }
    //else return false
    return false;
}
//return the selected textureID
edk::uint32 edk::Object2D::selectedGetTextureID(edk::uint8 number){
    //test if have one selected mesh
    if(this->selected){
        //return the number
        return this->selected->material.getTexture(number);
    }
    //else return false
    return 0u;
}
//free the selected
void edk::Object2D::cleanSelected(){
    //
    this->selected=NULL;
}
//return the number of meshs
edk::uint32 edk::Object2D::getMeshSize(){
    return this->meshes.size();
}
//return the mesh pointer
edk::shape::Mesh2D* edk::Object2D::getMesh(edk::uint32 position){
    return this->meshes.getMesh(position);
}
//remove all meshes
void edk::Object2D::removeAllMesh(){
    this->cleanMeshes();
}
//set the polygonsColor
bool edk::Object2D::setPolygonColor(edk::uint32 position,edk::color4f32 color){
    if(this->meshes.getMesh(position)){
        this->meshes.getMesh(position)->setPolygonsColor(color);
    }
    return false;
}
bool edk::Object2D::setPolygonColor(edk::uint32 position,edk::float32 r,edk::float32 g,edk::float32 b,edk::float32 a){
    return this->setPolygonColor(position,edk::color4f32(r,g,b,a));
}

void edk::Object2D::setPolygonsColor(edk::color4f32 color){
    edk::uint32 size = this->meshes.size();
    for(edk::uint32 i=0u;i<size;i++){
        if(this->meshes.getMesh(i)){
            this->meshes.getMesh(i)->setPolygonsColor(color);
        }
    }
}
void edk::Object2D::setPolygonsColor(edk::float32 r,edk::float32 g,edk::float32 b,edk::float32 a){
    this->setPolygonsColor(edk::color4f32(r,g,b,a));
}
void edk::Object2D::setPolygonsColorR(edk::float32 r){
    edk::uint32 size = this->meshes.size();
    for(edk::uint32 i=0u;i<size;i++){
        if(this->meshes.getMesh(i)){
            this->meshes.getMesh(i)->setPolygonsColorR(r);
        }
    }
}
void edk::Object2D::setPolygonsColorG(edk::float32 g){
    edk::uint32 size = this->meshes.size();
    for(edk::uint32 i=0u;i<size;i++){
        if(this->meshes.getMesh(i)){
            this->meshes.getMesh(i)->setPolygonsColorG(g);
        }
    }
}
void edk::Object2D::setPolygonsColorB(edk::float32 b){
    edk::uint32 size = this->meshes.size();
    for(edk::uint32 i=0u;i<size;i++){
        if(this->meshes.getMesh(i)){
            this->meshes.getMesh(i)->setPolygonsColorB(b);
        }
    }
}
void edk::Object2D::setPolygonsColorA(edk::float32 a){
    edk::uint32 size = this->meshes.size();
    for(edk::uint32 i=0u;i<size;i++){
        if(this->meshes.getMesh(i)){
            this->meshes.getMesh(i)->setPolygonsColorA(a);
        }
    }
}

//LIGHT
//EDK_LIGHT_LIMIT
bool edk::Object2D::setLight(edk::uint32 position,edk::light::Light light){
    if(position<EDK_LIGHT_LIMIT){
        this->lights[position] = light;
        return true;
    }
    return false;
}
bool edk::Object2D::cleanLight(edk::uint32 position){
    if(position<EDK_LIGHT_LIMIT){
        //
        this->lights[position].clean();
        return true;
    }
    return false;
}
bool edk::Object2D::lightOn(edk::uint32 position){
    if(position<EDK_LIGHT_LIMIT){
        //add the light on the tree
        this->lights[position].on=true;
        return true;
    }
    return false;
}
bool edk::Object2D::lightOff(edk::uint32 position){
    if(position<EDK_LIGHT_LIMIT){
        //remove the position from the tree
        this->lights[position].on=false;
        return true;
    }
    return false;
}

//play all mesh animations
void edk::Object2D::playMeshAnimations(){
    edk::uint32 size = this->meshes.size();
    edk::shape::Mesh2D* mesh;
    for(edk::uint32 i=0u;i<size;i++){
        mesh = this->meshes.getMesh(i);
        if(mesh){
            edk::uint32 polySize = mesh->getPolygonSize();
            for(edk::uint32 j=0u;j<polySize;j++){
                mesh->selectAnimationFramesFromPolygon(j);
                mesh->selectedAnimationPlayForward();
            }
        }
    }
}
bool edk::Object2D::playMeshAnimations(edk::uchar32 position){
    edk::shape::Mesh2D* mesh = this->meshes.getMesh(position);
    if(mesh){
        edk::uint32 polySize = mesh->getPolygonSize();
        for(edk::uint32 j=0u;j<polySize;j++){
            mesh->selectAnimationFramesFromPolygon(j);
            mesh->selectedAnimationPlayForward();
        }
        return true;
    }
    return false;
}
//pause polygons animations
void edk::Object2D::pauseMeshAnimations(){
    edk::uint32 size = this->meshes.size();
    edk::shape::Mesh2D* mesh;
    for(edk::uint32 i=0u;i<size;i++){
        mesh = this->meshes.getMesh(i);
        if(mesh){
            edk::uint32 polySize = mesh->getPolygonSize();
            for(edk::uint32 j=0u;j<polySize;j++){
                mesh->selectAnimationFramesFromPolygon(j);
                mesh->selectedAnimationPause();
            }
        }
    }
}
bool edk::Object2D::pauseMeshAnimations(edk::uchar32 position){
    edk::shape::Mesh2D* mesh = this->meshes.getMesh(position);
    if(mesh){
        edk::uint32 polySize = mesh->getPolygonSize();
        for(edk::uint32 j=0u;j<polySize;j++){
            mesh->selectAnimationFramesFromPolygon(j);
            mesh->selectedAnimationPause();
        }
        return true;
    }
    return false;
}
//update mesh animations
void edk::Object2D::updateMeshAnimations(){
    //update mesh animations
    edk::uint32 size = this->meshes.size();
    edk::shape::Mesh2D *mesh;
    for(edk::uint32 i=0u;i<size;i++){
        mesh = this->meshes.getMesh(i);
        if(mesh){
            mesh->updateFramesAnimations();
        }
    }
}
void edk::Object2D::updateMeshAnimations(edk::float32 seconds){
    //update mesh animations
    edk::uint32 size = this->meshes.size();
    edk::shape::Mesh2D *mesh;
    for(edk::uint32 i=0u;i<size;i++){
        mesh = this->meshes.getMesh(i);
        if(mesh){
            mesh->updateFramesAnimations(seconds);
        }
    }
}
bool edk::Object2D::updateMeshAnimationsFromPosition(edk::uchar32 position){
    edk::shape::Mesh2D* mesh = this->meshes.getMesh(position);
    if(mesh){
        edk::uint32 polySize = mesh->getPolygonSize();
        for(edk::uint32 j=0u;j<polySize;j++){
            mesh->selectAnimationFramesFromPolygon(j);
            mesh->updateFramesAnimations();
        }
        return true;
    }
    return false;
}
bool edk::Object2D::updateMeshAnimationsFromPosition(edk::uchar32 position,edk::float32 seconds){
    edk::shape::Mesh2D* mesh = this->meshes.getMesh(position);
    if(mesh){
        edk::uint32 polySize = mesh->getPolygonSize();
        for(edk::uint32 j=0u;j<polySize;j++){
            mesh->selectAnimationFramesFromPolygon(j);
            mesh->updateFramesAnimations(seconds);
        }
        return true;
    }
    return false;
}

//update all animations
bool edk::Object2D::updateAnimations(){
    bool ret=false;
    this->animationPosition.updateClockAnimation();
    this->animationRotation.updateClockAnimation();
    this->animationSize.updateClockAnimation();
    //test if are playing the animations
    if(this->animationPosition.isPlaying()){
        //
        edk::vec2f32 posTemp;
        posTemp.x = this->animationPosition.getClockX();
        posTemp.y = this->animationPosition.getClockY();
        //set the value
        this->position = posTemp;
        ret=true;
    }
    if(this->animationRotation.isPlaying()){
        //
        edk::float32 angleTemp = this->animationRotation.getClockX();
        //set the value
        this->angle = angleTemp;
        ret=true;
    }
    if(this->animationSize.isPlaying()){
        //
        edk::size2f32 sizeTemp;
        sizeTemp.width = this->animationSize.getClockX();
        sizeTemp.height = this->animationSize.getClockY();
        //set the value
        this->size = sizeTemp;
        ret=true;
    }
    this->updateMeshAnimations();
    return ret;
}
bool edk::Object2D::updateAnimations(edk::float32 seconds){
    bool ret=false;
    this->animationPosition.updateClockAnimation(seconds);
    this->animationRotation.updateClockAnimation(seconds);
    this->animationSize.updateClockAnimation(seconds);
    //test if are playing the animations
    if(this->animationPosition.isPlaying()){
        //
        edk::vec2f32 posTemp;
        posTemp.x = this->animationPosition.getClockX();
        posTemp.y = this->animationPosition.getClockY();
        //set the value
        this->position = posTemp;
        ret=true;
    }
    if(this->animationRotation.isPlaying()){
        //
        edk::float32 angleTemp = this->animationRotation.getClockX();
        //set the value
        this->angle = angleTemp;
        ret=true;
    }
    if(this->animationSize.isPlaying()){
        //
        edk::size2f32 sizeTemp;
        sizeTemp.width = this->animationSize.getClockX();
        sizeTemp.height = this->animationSize.getClockY();
        //set the value
        this->size = sizeTemp;
        ret=true;
    }
    this->updateMeshAnimations(seconds);
    return ret;
}

//ACTIONS
//play actions
void edk::Object2D::playForwardActions(){
    this->actions.playForward();
}
void edk::Object2D::playForwardInActions(edk::float32 second){
    this->actions.playForwardIn(second);
}
void edk::Object2D::pauseActions(){
    this->actions.pause();
}
void edk::Object2D::stopActions(){
    this->actions.stop();
}
//set loop
void edk::Object2D::setLoopActions(bool loop){
    this->actions.setLoop(loop);
}
void edk::Object2D::loopOnActions(){
    this->actions.loopOn();
}
void edk::Object2D::loopOffActions(){
    this->actions.loopOff();
}

//return if are playing
bool edk::Object2D::isPlayingActions(){
    return this->actions.isPlaying();
}
bool edk::Object2D::isPausedActions(){
    return this->actions.isPaused();
}
//update actions
void edk::Object2D::updateActions(){
    this->actions.update();
}
//remove actions
void edk::Object2D::removeAllActions(){
    this->actions.clean();
}
void edk::Object2D::cleanAllActions(){
    this->actions.clean();
}
bool edk::Object2D::removeActionSecond(edk::float32 second){
    this->actions.removeSecond(second);
}
//Add zero action
bool edk::Object2D::actionZero(edk::float32 second){
    return this->actions.addAction(second,new edk::ActionZero);
}
//add move action
bool edk::Object2D::actionSetPosition(edk::float32 second,edk::vec2f32 position){
    return this->actions.addAction(second,new edk::Object2D::ActionPosition(this,position));
}
bool edk::Object2D::actionSetPosition(edk::float32 second,edk::float32 x,edk::float32 y){
    return this->actionSetPosition(second,edk::vec2f32(x,y));
}
//add move action
bool edk::Object2D::actionMove(edk::float32 second,edk::float32 duration, edk::vec2f32 position){
    //create the action
    if (this->actions.addAction(second,new edk::Object2D::ActionMove(this,duration,position))){
        this->actions.addZeroAction(second+duration);
        return true;
    }
    return false;
}
bool edk::Object2D::actionMove(edk::float32 second,edk::float32 duration, edk::float32 x,edk::float32 y){
    return this->actionMove(second,duration, edk::vec2f32(x,y));
}
bool edk::Object2D::actionMoveTo(edk::float32 start,edk::float32 end, edk::vec2f32 position){
    return this->actionMove(start,end-start, position);
}
bool edk::Object2D::actionMoveTo(edk::float32 start,edk::float32 end, edk::float32 x,edk::float32 y){
    return this->actionMove(start,end-start,x,y);
}
//add scale action
bool edk::Object2D::actionSetSize(edk::float32 second,edk::size2f32 size){
    //create the action
    return this->actions.addAction(second,new edk::Object2D::ActionSetSize(this,size));
}
bool edk::Object2D::actionSetSize(edk::float32 second,edk::float32 width,edk::float32 height){
    return this->actionSetSize(second,edk::size2f32(width,height));
}
bool edk::Object2D::actionSetSize(edk::float32 second,edk::float32 size){
    return this->actionSetSize(second,size,size);
}
//add scale action
bool edk::Object2D::actionScale(edk::float32 second,edk::float32 duration, edk::size2f32 size){
    //create the action
    if (this->actions.addAction(second,new edk::Object2D::ActionSize(this,duration,size))){
        this->actions.addZeroAction(second+duration);
        return true;
    }
    return false;
}
bool edk::Object2D::actionScale(edk::float32 second,edk::float32 duration, edk::float32 width,edk::float32 height){
    return this->actionScale(second,duration, edk::size2f32( width,height));
}
bool edk::Object2D::actionScale(edk::float32 second,edk::float32 duration, edk::float32 size){
    return this->actionScale(second,duration, size,size);
}
bool edk::Object2D::actionScaleTo(edk::float32 start,edk::float32 end, edk::size2f32 size){
    return this->actionScale(start,end-start, size);
}
bool edk::Object2D::actionScaleTo(edk::float32 start,edk::float32 end, edk::float32 width,edk::float32 height){
    return this->actionScale(start,end-start, width,height);
}
bool edk::Object2D::actionScaleTo(edk::float32 start,edk::float32 end, edk::float32 size){
    return this->actionScale(start,end-start, size);
}
//add angle action
bool edk::Object2D::actionSetAngle(edk::float32 second,edk::float32 angle){
    return this->actions.addAction(second,new edk::Object2D::ActionSetAngle(this,angle));
}
//add angle action
bool edk::Object2D::actionRotateFor(edk::float32 second,edk::float32 duration, edk::float32 angle){
    if(this->actions.addAction(second,new edk::Object2D::ActionAngle(this,duration,angle))){
        this->actions.addZeroAction(second);
        return true;
    }
    return false;
}
bool edk::Object2D::actionRotateTo(edk::float32 start,edk::float32 end, edk::float32 angle){
    return this->actionRotateFor(start,end-start, angle);
}
//MESH SPRITE SHEET
bool edk::Object2D::actionPlayName(edk::float32 second,edk::uint32 id,edk::char8* name,bool loop){
    //
    return this->actions.addAction(second,new edk::Object2D::ActionMeshName(this,id,name,loop));
}
bool edk::Object2D::actionPlayName(edk::float32 second,edk::uint32 id,const edk::char8* name,bool loop){
    //
    return actionPlayName(second,id,(edk::char8*)name,loop);
}
bool edk::Object2D::actionPlayNameFor(edk::float32 second,edk::float32 duration,edk::uint32 id,edk::char8* name){
    if(this->actions.addAction(second,new edk::Object2D::ActionMeshName(this,id,name,true))){
        //add the stop action
        this->actions.addAction(second+duration,new edk::Object2D::ActionMeshStop(this,id));
        return true;
    }
    return false;
}
bool edk::Object2D::actionPlayNameFor(edk::float32 second,edk::float32 duration,edk::uint32 id,const edk::char8* name){
    return this->actionPlayNameFor(second,duration,id,(edk::char8*)name);
}

//DRAW
//print the mesh
void edk::Object2D::print(){
    edk::uint32 size = this->meshes.size();
    edk::shape::Mesh2D* mesh;
    //print all polygonList
    for(edk::uint32 i=0u;i<size;i++){
        //
        mesh = this->meshes.getMesh(i);
        if(mesh){
            //
            printf("\nMESH %u"
                   ,i
                   );
            mesh->print();
        }
    }
}
//draw the mesh
void edk::Object2D::draw(){
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);
    //glEnable(GL_RESCALE_NORMAL);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }

    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        edk::uint32 size = this->meshes.size();
        for(edk::uint32 i=size;i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                if(mesh->material.haveOneTexture()){
                    mesh->drawOneTexture();
                }
                else{
                    mesh->drawMultiTexture();
                }
            }
        }
    }
    else{
        edk::uint32 size = this->meshes.size();
        for(edk::uint32 i=size;i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                if(mesh->material.haveOneTexture()){
                    mesh->drawOneTexture();
                }
                else{
                    mesh->drawMultiTexture();
                }
            }
        }
    }
    //glEnable(GL_RESCALE_NORMAL);
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
}
void edk::Object2D::drawOneTexture(){
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //print all polygonList
    for(edk::uint32 i=this->meshes.size();i>0u;i--){
        //
        mesh = this->meshes.getMesh(i-1u);
        if(mesh){
            mesh->drawOneTexture();
        }
    }
    edk::GU::guPopMatrix();
}
void edk::Object2D::drawOneTextureWithLight(){
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        for(edk::uint32 i=this->meshes.size();i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                mesh->drawOneTexture();
            }
        }
    }
    else{
        for(edk::uint32 i=this->meshes.size();i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                mesh->drawOneTexture();
            }
        }
    }
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
}
void edk::Object2D::drawWithoutMaterial(){
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //print all polygonList
    for(edk::uint32 i=this->meshes.size();i>0u;i--){
        //
        mesh = this->meshes.getMesh(i-1u);
        if(mesh){
            mesh->drawWithoutMaterial();
        }
    }
    edk::GU::guPopMatrix();
}
void edk::Object2D::drawWithoutMaterialWithLight(){
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        for(edk::uint32 i=this->meshes.size();i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                mesh->drawWithoutMaterial();
            }
        }
    }
    else{
        for(edk::uint32 i=this->meshes.size();i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                mesh->drawWithoutMaterial();
            }
        }
    }
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
}
void edk::Object2D::drawWire(){
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //print all polygonList
    for(edk::uint32 i=this->meshes.size();i>0u;i--){
        //
        mesh = this->meshes.getMesh(i-1u);
        if(mesh){
            mesh->drawWirePolygons();
        }
    }
    edk::GU::guPopMatrix();
}
bool edk::Object2D::drawMesh(edk::uint32 meshPosition){
    bool ret=false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);
    //glEnable(GL_RESCALE_NORMAL);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }

    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        if(meshPosition < this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                if(mesh->material.haveOneTexture()){
                    mesh->drawOneTexture();
                }
                else{
                    mesh->drawMultiTexture();
                }
                ret=true;
            }
        }
    }
    else{
        if(meshPosition < this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                if(mesh->material.haveOneTexture()){
                    mesh->drawOneTexture();
                }
                else{
                    mesh->drawMultiTexture();
                }
                ret=true;
            }
        }
    }
    //glEnable(GL_RESCALE_NORMAL);
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawPolygon(edk::uint32 meshPosition,edk::uint32 polygon){
    bool ret=false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);
    //glEnable(GL_RESCALE_NORMAL);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }

    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        if(meshPosition < this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                if(mesh->material.haveOneTexture()){
                    ret = mesh->drawPolygonOneTexture(polygon);
                }
                else{
                    ret = mesh->drawPolygonMultiTexture(polygon);
                }
            }
        }
    }
    else{
        if(meshPosition < this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                if(mesh->material.haveOneTexture()){
                    ret = mesh->drawPolygonOneTexture(polygon);
                }
                else{
                    ret = mesh->drawPolygonMultiTexture(polygon);
                }
            }
        }
    }
    //glEnable(GL_RESCALE_NORMAL);
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawMeshOneTexture(edk::uint32 meshPosition){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //
    if(meshPosition<this->meshes.size()){
        mesh = this->meshes.getMesh(meshPosition);
        if(mesh){
            mesh->drawOneTexture();
            ret = true;
        }
    }
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawPolygonOneTexture(edk::uint32 meshPosition,edk::uint32 polygon){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //
    if(meshPosition<this->meshes.size()){
        mesh = this->meshes.getMesh(meshPosition);
        if(mesh){
            ret = mesh->drawPolygonOneTexture(polygon);
        }
    }
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawMeshOneTextureWithLight(edk::uint32 meshPosition){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        if(meshPosition < this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                mesh->drawOneTexture();
                ret = true;
            }
        }
    }
    else{
        for(edk::uint32 i=this->meshes.size();i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                mesh->drawOneTexture();
                ret = true;
            }
        }
    }
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawPolygonOneTextureWithLight(edk::uint32 meshPosition,edk::uint32 polygon){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        if(meshPosition < this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                ret = mesh->drawPolygonOneTexture(polygon);
            }
        }
    }
    else{
        for(edk::uint32 i=this->meshes.size();i>0u;i--){
            //
            mesh = this->meshes.getMesh(i-1u);
            if(mesh){
                ret = mesh->drawPolygonOneTexture(polygon);
            }
        }
    }
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawMeshWithoutMaterial(edk::uint32 meshPosition){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //print all polygonList
    if(meshPosition<this->meshes.size()){
        mesh = this->meshes.getMesh(meshPosition);
        if(mesh){
            mesh->drawWithoutMaterial();
            ret = true;
        }
    }
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawPolygonWithoutMaterial(edk::uint32 meshPosition,edk::uint32 polygon){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //print all polygonList
    if(meshPosition<this->meshes.size()){
        mesh = this->meshes.getMesh(meshPosition);
        if(mesh){
            ret = mesh->drawPolygonWithoutMaterial(polygon);
        }
    }
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawMeshWithoutMaterialWithLight(edk::uint32 meshPosition){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        if(meshPosition<this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                mesh->drawWithoutMaterial();
                ret=true;
            }
        }
    }
    else{
        if(meshPosition<this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                mesh->drawWithoutMaterial();
                ret=true;
            }
        }
    }
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawPolygonWithoutMaterialWithLight(edk::uint32 meshPosition,edk::uint32 polygon){
    bool ret = false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();

    edk::GU::guEnable(GU_LIGHTING);

    bool haveLight=false;

    {
        for(edk::uint32 i=0u;i<EDK_LIGHT_LIMIT;i++){
            if(this->lights[i].on){
                edk::GU::guEnable(GU_LIGHT0+i);
                this->lights[i].draw(i);
                haveLight=true;

            }
            else{
                edk::GU::guDisable(GU_LIGHT0+i);
            }
        }
    }
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    if(haveLight){
        if(meshPosition<this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                ret = mesh->drawPolygonWithoutMaterial(polygon);
            }
        }
    }
    else{
        if(meshPosition<this->meshes.size()){
            mesh = this->meshes.getMesh(meshPosition);
            if(mesh){
                ret = mesh->drawPolygonWithoutMaterial(polygon);
            }
        }
    }
    edk::GU::guDisable(GU_LIGHTING);
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawMeshWire(edk::uint32 meshPosition){
    bool ret=false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //print all polygonList
    if(meshPosition<this->meshes.size()){
        mesh = this->meshes.getMesh(meshPosition);
        if(mesh){
            mesh->drawWirePolygons();
            ret = true;
        }
    }
    edk::GU::guPopMatrix();
    return ret;
}
bool edk::Object2D::drawPolygonWire(edk::uint32 meshPosition,edk::uint32 polygon){
    bool ret=false;
    //put the transformation on a stack
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add rotation
    edk::GU::guRotateZf32(this->angle);
    //add scale
    edk::GU::guScale2f32(this->size);
    //set the pivo
    edk::GU::guTranslate2f32(this->pivo*-1.0f);

    edk::shape::Mesh2D* mesh;
    //print all polygonList
    if(meshPosition<this->meshes.size()){
        mesh = this->meshes.getMesh(meshPosition);
        if(mesh){
            ret = mesh->drawWirePolygon(polygon);
        }
    }
    edk::GU::guPopMatrix();
    return ret;
}

//draw the pivo
void edk::Object2D::drawPivo(edk::float32 size,edk::color3f32 color){
    //
    edk::GU::guPushMatrix();
    //add translate
    edk::GU::guTranslate2f32(this->position);
    //add scale
    edk::GU::guScale2f32(edk::size2f32(size,size));

    //lineSize
    edk::GU::guLineWidth(3);

    //set the colors
    edk::GU::guColor3f32(color);
    //draw the lines
    edk::GU::guBegin(GU_LINES);
    //LINE 1
    edk::GU::guVertex2f32(-0.5f,-0.5f);
    edk::GU::guVertex2f32( 0.5f, 0.5f);
    //LINE 2
    edk::GU::guVertex2f32(-0.5f, 0.5f);
    edk::GU::guVertex2f32( 0.5f,-0.5f);
    edk::GU::guEnd();

    //lineSize
    edk::GU::guLineWidth(1);

    //
    edk::GU::guPopMatrix();
}

//XML
bool edk::Object2D::writeToXML(edk::XML* xml,edk::uint32 id){
    if(xml){
        bool ret=false;
        //create the nameID
        edk::char8* nameID = edk::String::int64ToStr(id);
        if(nameID){
            //concat
            edk::char8* name = edk::String::strCat((edk::char8*)"object_",nameID);
            if(name){
                //create the name
                if(xml->addSelectedNextChild(name)){
                    if(xml->selectChild(name)){
                        //WRITE
                        //write the mesh
                        edk::uint32 size = this->meshes.size();
                        edk::shape::Mesh2D* mesh;
                        for(edk::uint32 i=0u;i<size;i++){
                            mesh = this->meshes.getMesh(i);
                            if(mesh){
                                mesh->writeToXML(xml,i);
                            }
                        }

                        //write pivo
                        edk::char8* temp=NULL;
                        temp = edk::String::float32ToStr(this->pivo.x);
                        if(temp){
                            xml->addSelectedNextAttribute((edk::char8*)"pivoX",temp);
                            delete[] temp;
                        }
                        temp = edk::String::float32ToStr(this->pivo.y);
                        if(temp){
                            xml->addSelectedNextAttribute((edk::char8*)"pivoY",temp);
                            delete[] temp;
                        }

                        //write objectValues
                        //position
                        temp = edk::String::float32ToStr(this->position.x);
                        if(temp){
                            xml->addSelectedNextAttribute((edk::char8*)"positionX",temp);
                            delete[] temp;
                        }
                        temp = edk::String::float32ToStr(this->position.y);
                        if(temp){
                            xml->addSelectedNextAttribute((edk::char8*)"positionY",temp);
                            delete[] temp;
                        }
                        //size
                        temp = edk::String::float32ToStr(this->size.width);
                        if(temp){
                            xml->addSelectedNextAttribute((edk::char8*)"sizeW",temp);
                            delete[] temp;
                        }
                        temp = edk::String::float32ToStr(this->size.height);
                        if(temp){
                            xml->addSelectedNextAttribute((edk::char8*)"sizeH",temp);
                            delete[] temp;
                        }
                        //angle
                        temp = edk::String::float32ToStr(this->angle);
                        if(temp){
                            xml->addSelectedNextAttribute((edk::char8*)"angle",temp);
                            delete[] temp;
                        }

                        //write animations
                        this->animationPosition.writeToXML(xml,0u);
                        this->animationRotation.writeToXML(xml,1u);
                        this->animationSize.writeToXML(xml,2u);

                        //write the actins
                        this->actions.writeToXML(xml,0u);

                        ret=true;
                        xml->selectFather();
                    }
                }
                delete[] name;
            }
            delete[] nameID;
        }
        return ret;
    }
    return false;
}
bool edk::Object2D::readFromXML(edk::XML* xml,edk::uint32 id){
    if(xml){
        bool ret=false;
        //create the nameID
        edk::char8* nameID = edk::String::int64ToStr(id);
        if(nameID){
            //concat
            edk::char8* name = edk::String::strCat((edk::char8*)"object_",nameID);
            if(name){
                //create the name
                if(xml->selectChild(name)){
                    this->cleanMeshes();
                    //read mesh
                    edk::shape::Mesh2D* mesh;
                    edk::uint32 count=0u;
                    edk::uint32 position=0u;
                    do{
                        mesh = this->newMesh(&position);
                        if(mesh){
                            if(!mesh->readFromXML(xml,count)){
                                this->removeMesh(position);
                                mesh=NULL;
                            }
                        }
                        count++;
                    }while(mesh);
                    //read pivo
                    this->pivo = edk::vec2f32(edk::String::strToFloat32(xml->getSelectedAttributeValueByName("pivoX")),
                                              edk::String::strToFloat32(xml->getSelectedAttributeValueByName("pivoY"))
                                              );
                    //read the object values
                    //position
                    this->position = edk::vec2f32(edk::String::strToFloat32(xml->getSelectedAttributeValueByName("positionX")),
                                                  edk::String::strToFloat32(xml->getSelectedAttributeValueByName("positionY"))
                                                  );
                    //size
                    this->size = edk::size2f32(edk::String::strToFloat32(xml->getSelectedAttributeValueByName("sizeW")),
                                               edk::String::strToFloat32(xml->getSelectedAttributeValueByName("sizeH"))
                                               );
                    //angle
                    this->angle = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("angle"));

                    //write animations
                    this->animationPosition.readFromXML(xml,0u);
                    this->animationRotation.readFromXML(xml,1u);
                    this->animationSize.readFromXML(xml,2u);

                    //ACTIONS
                    this->actions.readFromXML(xml,0u,this);

                    ret=true;
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] nameID;
        }
        return ret;
    }
    return false;
}
bool edk::Object2D::readFromXMLFromPack(edk::pack::FilePackage* pack,edk::XML* xml,edk::uint32 id){
    if(xml && pack){
        bool ret=false;
        //create the nameID
        edk::char8* nameID = edk::String::int64ToStr(id);
        if(nameID){
            //concat
            edk::char8* name = edk::String::strCat((edk::char8*)"object_",nameID);
            if(name){
                //create the name
                if(xml->selectChild(name)){
                    this->cleanMeshes();
                    //read mesh
                    edk::shape::Mesh2D* mesh;
                    edk::uint32 count=0u;
                    edk::uint32 position=0u;
                    do{
                        mesh = this->newMesh(&position);
                        if(mesh){
                            if(!mesh->readFromXMLFromPack(pack,xml,count)){
                                this->removeMesh(position);
                                mesh=NULL;
                            }
                        }
                        count++;
                    }while(mesh);
                    //read pivo
                    this->pivo = edk::vec2f32(edk::String::strToFloat32(xml->getSelectedAttributeValueByName("pivoX")),
                                              edk::String::strToFloat32(xml->getSelectedAttributeValueByName("pivoY"))
                                              );
                    //read the object values
                    //position
                    this->position = edk::vec2f32(edk::String::strToFloat32(xml->getSelectedAttributeValueByName("positionX")),
                                                  edk::String::strToFloat32(xml->getSelectedAttributeValueByName("positionY"))
                                                  );
                    //size
                    this->size = edk::size2f32(edk::String::strToFloat32(xml->getSelectedAttributeValueByName("sizeW")),
                                               edk::String::strToFloat32(xml->getSelectedAttributeValueByName("sizeH"))
                                               );
                    //angle
                    this->angle = edk::String::strToFloat32(xml->getSelectedAttributeValueByName("angle"));

                    //write animations
                    this->animationPosition.readFromXML(xml,0u);
                    this->animationRotation.readFromXML(xml,1u);
                    this->animationSize.readFromXML(xml,2u);

                    //ACTIONS
                    this->actions.readFromXML(xml,0u,this);

                    ret=true;
                    xml->selectFather();
                }
                delete[] name;
            }
            delete[] nameID;
        }
        return ret;
    }
    return false;
}

//cant delete
void edk::Object2D::cantDeleteObject2D(){
    this->canDeleteObject=false;
}

bool edk::Object2D::cloneFrom(edk::Object2D* obj){
    if(obj){
        this->cleanSelected();
        this->cleanMeshes();

        //copy the meshs
        edk::uint32 size = obj->meshes.size();
        edk::shape::Mesh2D* temp = NULL;
        edk::shape::Mesh2D* mesh = NULL;
        for(edk::uint32 i=0u;i<size;i++){
            temp = obj->meshes.getMesh(i);
            if(temp){
                mesh = this->newMesh();
                if(mesh){
                    //*mesh = *temp;
                    mesh->cloneFrom(temp);
                }
            }
        }
        //copy pivo
        this->pivo = obj->pivo;
        //copy the animations
        //this->animationPosition = obj->animationPosition;
        this->animationPosition.cloneFrom(&obj->animationPosition);
        //this->animationRotation = obj->animationRotation;
        this->animationRotation.cloneFrom(&obj->animationRotation);
        //this->animationSize = obj->animationSize;
        this->animationSize.cloneFrom(&obj->animationSize);

        this->position = obj->position;
        this->angle = obj->angle;
        this->size = obj->size;

        /*
class ActionPosition 1
class ActionMove     2
class ActionSetSize  3
class ActionSize     4
class ActionSetAngle 5
class ActionAngle    6
class ActionMeshName 7
class ActionMeshStop 8
*/

        //copy the actions
        this->actions.clean();
        size = obj->actions.getKeySize();
        edk::uint32 actionSize = 0u;
        edk::float32 second=0.f;
        edk::uint64 code = 0u;
        for(edk::uint32 i=0u;i<size;i++){
            //load the kay second
            second = obj->actions.getKeySecond(i);
            //load the size of actions inside de key
            actionSize = obj->actions.getActionsSize(i);
            for(edk::uint32 j=0u;j<actionSize;j++){
                //get the action code
                code = obj->actions.getActionCode(i,j);

                switch(code){
                case 1u:
                {
                    //ActionPosition
                    edk::Object2D::ActionPosition* temp = (edk::Object2D::ActionPosition*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionPosition(this,temp->getPosition()));
                    break;
                }
                case 2u:
                {
                    //ActionMove
                    edk::Object2D::ActionMove* temp = (edk::Object2D::ActionMove*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionMove(this,temp->getDuration(),temp->getPosition()));
                    break;
                }
                case 3u:
                {
                    //ActionSetSize
                    edk::Object2D::ActionSetSize* temp = (edk::Object2D::ActionSetSize*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionSetSize(this,temp->getSize()));
                    break;
                }
                case 4u:
                {
                    //ActionSize
                    edk::Object2D::ActionSize* temp = (edk::Object2D::ActionSize*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionSize(this,temp->getDuration(),temp->getSize()));
                    break;
                }
                case 5u:
                {
                    //ActionSetAngle
                    edk::Object2D::ActionSetAngle* temp = (edk::Object2D::ActionSetAngle*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionSetAngle(this,temp->getAngle()));
                    break;
                }
                case 6u:
                {
                    //ActionAngle
                    edk::Object2D::ActionAngle* temp = (edk::Object2D::ActionAngle*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionAngle(this,temp->getDuration(),temp->getAngle()));
                    break;
                }
                case 7u:
                {
                    //ActionMeshName
                    edk::Object2D::ActionMeshName* temp = (edk::Object2D::ActionMeshName*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionMeshName(this,temp->getId(),temp->getName(),temp->getLoop()));
                    break;
                }
                case 8u:
                {
                    //ActionMeshStop
                    edk::Object2D::ActionMeshStop* temp = (edk::Object2D::ActionMeshStop*)obj->actions.getActionInKey(i,j);
                    this->actions.addAction(second,new edk::Object2D::ActionMeshStop(this,temp->getId()));
                    break;
                }
                default:
                {
                    //actionZero
                    this->actions.addAction(second,new edk::ActionZero());
                }
                }
            }
        }
        return true;
    }
    return false;
}


text:
import models.registration.*;

public class RegistrationModelUnitTest
{
	public static void main(String[] args)
		throws RegistrationModelException
	{
		System.out.println("RegistrationModelUnitTest");
		RegistrationModel registrationModel = new RegistrationModel();
		String command = args[0];
		String username = args[1];
		String password = args[2];
		switch (command) {
			case "register":
				registrationModel.register(username, password);
				break;
			case "unregister":
				registrationModel.unregister(username);
				break;
			default:
				System.out.println("Unrecognized command: " + command);
				break;
		}
	}
}

redpajama_set_name: RedPajamaGithub


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
J. Bot. , London 5: 170 (1891)

#### Original name
Ascochyta vitalbae Briard & Har., 1891

### Remarks
null


text:
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Microsoft.VisualStudio.UserNotifications.Interop
{
    [ComImport, TypeIdentifier, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("791A7AEF-BFFD-45E8-B164-FC8CDD423D69"), CompilerGenerated]
    public interface IVsUserNotification
    {
        Guid Provider { get; }
        string Identifier { [return: MarshalAs(UnmanagedType.BStr)] get; }
        string Title { [return: MarshalAs(UnmanagedType.BStr)] get; [param: In, MarshalAs(UnmanagedType.BStr)] set; }
        string Description { [return: MarshalAs(UnmanagedType.BStr)] get; [param: In, MarshalAs(UnmanagedType.BStr)] set; }
        uint Severity { get; }
        object Context { [return: MarshalAs(UnmanagedType.Struct)] get; [param: In, MarshalAs(UnmanagedType.Struct)] set; }
        DateTime Creation { get; }
        DateTime Expiration { get; }
        uint State { get; }
    }
}


text:
package javax.portlet.tck.util;

import javax.portlet.tck.beans.TestCaseDetails;
import java.util.HashMap;
import java.util.Map;

/**
 * Defines constants for the test case names and test case details
 * for the JSR 286 API compatibility tests.
 *
 * Note that the backing map is static and not threadsafe. Operations
 * that change the map such as put, remove, etc., should not be used
 * in portlets.
 *
 * @author nick
 */
public class ModuleTestCaseDetails extends TestCaseDetails {

   public final static String V3PORTLETCONFIGTESTS_CONFIG_INIT  = "V3PortletConfigTests_Config_init";
   public final static String V3PORTLETCONFIGTESTS_CONFIG_GETPORTLETMODES = "V3PortletConfigTests_Config_getPortletModes";
   public final static String V3PORTLETCONFIGTESTS_CONFIG_GETWINDOWSTATES = "V3PortletConfigTests_Config_getWindowStates";
   public final static String V3PORTLETCONFIGTESTS_CONFIG_GETPUBLICRENDERPARAMETERDEFINITIONS = "V3PortletConfigTests_Config_getPublicRenderParameterDefinitions";

   private final static Map<String, String> tcd = new HashMap<String, String>();
   static {

      tcd.put(V3PORTLETCONFIGTESTS_CONFIG_INIT, "The PortletConfig object is passed to an annotated init method.");
      tcd.put(V3PORTLETCONFIGTESTS_CONFIG_GETPORTLETMODES, "The PortletConfig.getPortletModes method returns the a list of supported portlet modes for this portlet for a given mimetype.");
      tcd.put(V3PORTLETCONFIGTESTS_CONFIG_GETWINDOWSTATES, "The PortletConfig.getWindowStates method returns the a list of supported window states for this portlet for a given mimetype.");
      tcd.put(V3PORTLETCONFIGTESTS_CONFIG_GETPUBLICRENDERPARAMETERDEFINITIONS, "The PortletConfig.getPublicRenderParameterDefinitions method returns the a list of supported public render parameter definitions for this portlet.");

   }

   /**
    * Constructor.
    *
    * Passes the static test case names - details map to the superclass
    *
    * Note that the backing map is static and not threadsafe. Operations
    * that change the map such as put, remove, etc., should not be used
    * in portlets.
    */
   public ModuleTestCaseDetails() {
     super(tcd);
   }

}


text:
package org.apache.sling.jcr.resource.internal;

import java.util.concurrent.atomic.AtomicReference;

import javax.jcr.RepositoryException;
import javax.jcr.Session;

import org.apache.sling.api.resource.URIProvider;
import org.apache.sling.commons.classloader.DynamicClassLoaderManager;

/**
 * This is a helper class used to pass several services/data to the resource
 * and value map implementations.
 */
public class HelperData {

    private static final URIProvider[] EMPTY_URLPROVIDERS = new URIProvider[0];

    private final AtomicReference<DynamicClassLoaderManager> dynamicClassLoaderManagerReference;
    private final AtomicReference<URIProvider[]> uriProviderReference;

    private volatile String[] namespacePrefixes;

    public HelperData(final AtomicReference<DynamicClassLoaderManager> dynamicClassLoaderManagerReference, AtomicReference<URIProvider[]> uriProviderReference) {
        this.dynamicClassLoaderManagerReference = dynamicClassLoaderManagerReference;
        this.uriProviderReference = uriProviderReference;
    }

    public String[] getNamespacePrefixes(final Session session)
    throws RepositoryException {
        if ( this.namespacePrefixes == null ) {
            this.namespacePrefixes = session.getNamespacePrefixes();
        }
        return this.namespacePrefixes;
    }

    public ClassLoader getDynamicClassLoader() {
        final DynamicClassLoaderManager dclm = this.dynamicClassLoaderManagerReference.get();
        if ( dclm == null ) {
            return null;
        }
        return dclm.getDynamicClassLoader();
    }

    public URIProvider[] getURIProviders() {
        URIProvider[] ups = this.uriProviderReference.get();
        if ( ups == null) {
            ups = EMPTY_URLPROVIDERS;
        }
        return ups;
    }
}


text:
package com.avc.avcinstaller.installation.fragment;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.avc.avcinstaller.activity.R;
import com.avc.avcinstaller.activity.SignatureActivity;
import com.avc.avcinstaller.general.model.Constants;
import com.avc.avcinstaller.general.model.User;
import com.avc.avcinstaller.webservice.responseModel._30_AsbestosRegister;
import com.teamnikaml.webservicelib.model.Dictionary;
import com.teamnikaml.webservicelib.webservice.FileuploadWebService;

public class AsbestosRegisterFragment extends Fragment {

	private TextView asbestosTextView;
	private ImageView signatureImageView;
	private Button noAsbetosRegisterButton;
	private Bitmap signatureBitmap;
	private List<Dictionary> parameterList = new ArrayList<Dictionary>();
	private _30_AsbestosRegister asbestosRegisterResponse = new _30_AsbestosRegister();
	private String asbestosRegisterPath;

	@SuppressLint("HandlerLeak")
	private final Handler myHandler = new Handler() {
		public void handleMessage(Message msg) {
			setData();
			System.out.println(asbestosRegisterResponse);
		}

		private void setData() {
			// TODO Auto-generated method stub

		}
	};

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_asbestos_register,
				container, false);
		getActivity().setTitle("Asbestos Register");
		init(rootView);
		return rootView;
	}

	private void init(View v) {

		asbestosTextView = (TextView) v
				.findViewById(R.id.asbetos_register_text_view);
		signatureImageView = (ImageView) v
				.findViewById(R.id.customer_sign_imageview);
		noAsbetosRegisterButton = (Button) v
				.findViewById(R.id.no_asbestos_registerButton);
		signatureBitmap = BitmapFactory.decodeResource(getResources(),
				R.drawable.signature);
		signatureBitmap = Bitmap.createScaledBitmap(signatureBitmap, 300, 150,
				false);
		signatureImageView.setImageBitmap(signatureBitmap);
		asbestosTextView.setText(Constants.ASBESTOS_REGISTER);

		noAsbetosRegisterButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub

				if (noAsbetosRegisterButton.getText().equals(
						"No Asbestos Register")) {
					asbestosTextView.setText(Constants.NO_ASBESTOS_REGISTER);
				} else {

					/*
					 * conn.setRequestProperty("uploaded_file", sourceFileUri);
					 * conn.setRequestProperty("requestKeyword", "uploadfile");
					 * conn.addRequestProperty("userkey", "userkey");
					 */

					/*
					 * AsbestosRegisterWebservice asbestosRegisterWebservice =
					 * new AsbestosRegisterWebservice();
					 * asbestosRegisterWebservice
					 * .setSourceFileUri(Constants.tempSignaturePath);
					 * asbestosRegisterWebservice.getAsbestosRegister();
					 */
					callWebService();

					Fragment fragment = new RoomReview1Fragment();
					FragmentManager fragmentManager = getFragmentManager();
					FragmentTransaction ft = fragmentManager.beginTransaction();
					ft.replace(R.id.frameLayout_home, fragment);
					ft.addToBackStack(null).commit();
				}
			}
		});

		signatureImageView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity(),
						SignatureActivity.class);
				startActivityForResult(intent, 101);
			}
		});

	}

	private void callWebService() {
		// TODO Auto-generated method stub

		User user = User.getUser();

		parameterList.add(new Dictionary("userKey", user.getUserKey()));
		parameterList.add(new Dictionary("requestKeyword", "asbestosRegister"));
		parameterList.add(new Dictionary("uploaded_file", asbestosRegisterPath,
				3));

		System.out.println(Constants.tempSignaturePath);

		FileuploadWebService fileuploadWebService = new FileuploadWebService(
				Constants.ASBESTOS_REGISTER_URL_30, parameterList,
				asbestosRegisterResponse);
		FileuploadWebService.setHandler(myHandler);
		fileuploadWebService.getService();

	}

	@SuppressLint("SimpleDateFormat")
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		if (requestCode == 101 && resultCode == Activity.RESULT_OK) {
			signatureBitmap = Constants.tempSignature;
			String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
					.format(new Date());
			String imageFileName = "Asbestos_register_" + timeStamp;
			Constants.createImageFile(imageFileName, getActivity());
			asbestosRegisterPath = Constants.tempSignaturePath;

			signatureBitmap = Bitmap.createScaledBitmap(signatureBitmap, 300,
					150, false);
			signatureImageView.setImageBitmap(signatureBitmap);
			noAsbetosRegisterButton.setText("Done");

		}

	}

}


text:
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

	<aop:config>
		<aop:aspect ref="monitoringAspect">
			<aop:before method="before" pointcut="execution(* increment*())" />
			<aop:around method="around" pointcut="execution(* increment*())" />
		</aop:aspect>
	</aop:config>

	<bean id="monitoringAspect" class="org.springframework.aop.aspectj.JoinPointMonitorAspect">
		<property name="counter" ref="counter"/>
	</bean>

	<bean id="counter" class="org.springframework.aop.aspectj.Counter"/>

</beans>


text:
'use strict';

import isArrayLike from './isArrayLike';
import isGraph from './isGraph';
import isPlainObject from 'lodash/lang/isPlainObject';
import objectSize from 'lodash/collection/size';

/**
 * Returns the number of elements in the container. That is
 * the number of elements in the array or object or the length
 * of a string.
 *
 * @param {(string|Object|ArrayLike|Graph)} obj
 *    Object to determine the length of
 *
 * @return {number} The number of elements
 * @throws {TypeError} When length cannot be determined
 */
export default function size(obj) {
  if (isGraph(obj)) {
    return obj.numberOfNodes();
  }
  else if(typeof obj === 'string' || isArrayLike(obj)) {
    return obj.length;
  }
  else if(isPlainObject(obj)) {
    return objectSize(obj);
  }
  else {
    throw new TypeError(
      'Expected a graph object, array, string or object, but got %s instead',
      typeof obj
    );
  }
}


text:
package org.fountainmc.api.chat;

import java.util.List;

import org.fountainmc.api.chat.events.ClickEvent;
import org.fountainmc.api.chat.values.Text;
import org.junit.Test;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

public class LegacyComponentTest {

    @Test
    public void simpleLegacyText() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("Hello, world!");
        assertThat(converted, hasSize(1));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, world!"));
    }

    @Test
    public void simpleLegacyTextWithColor() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7cHello, world!");
        assertThat(converted, hasSize(1));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, world!"));
    }

    @Test
    public void simpleLegacyTextTwoColors() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7cHello, \u00a7eworld!");
        assertThat(converted, hasSize(2));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, "));
        assertThat(converted.get(1).getColor(), equalTo(ChatColor.YELLOW));
        assertThat(converted.get(1).getValue().getText(), equalTo("world!"));
    }

    @Test
    public void simpleLegacyTextFormattingAndColor() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7c\u00a7lHello, world!");
        assertThat(converted, hasSize(1));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));
        assertThat(converted.get(0).isBold(), is(true));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, world!"));
    }

    @Test
    public void simpleLegacyTextWithOverlappingColors() {
        // The last color (&e) should be used.
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7c\u00a7eHello, world!");
        assertThat(converted, hasSize(1));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.YELLOW));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, world!"));
    }

    @Test
    public void simpleLegacyTextWithManyFormattingCodes() {
        // The last color (&e) should be used.
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7c\u00a7l\u00a7nHello, world!");
        assertThat(converted, hasSize(1));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));
        assertThat(converted.get(0).isBold(), is(true));
        assertThat(converted.get(0).isUnderlined(), is(true));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, world!"));
    }

    @Test
    public void simpleLegacyTextWithColorTextThenFormat() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7cHello, \u00a7lworld!");
        assertThat(converted, hasSize(2));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));
        assertThat(converted.get(0).isBold(), is(false));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, "));

        assertThat(converted.get(1).getColor(), equalTo(ChatColor.RED));
        assertThat(converted.get(1).isBold(), is(true));
        assertThat(converted.get(1).getValue().getText(), equalTo("world!"));
    }

    @Test
    public void simpleLegacyTextReset() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7c\u00a7lHello, \u00a7rworld!");
        assertThat(converted, hasSize(2));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));
        assertThat(converted.get(0).isBold(), is(true));
        assertThat(converted.get(0).getValue().getText(), equalTo("Hello, "));

        assertThat(converted.get(1).getColor(), equalTo(ChatColor.WHITE));
        assertThat(converted.get(1).isBold(), is(false));
        assertThat(converted.get(1).getValue().getText(), equalTo("world!"));
    }

    @Test
    public void simpleLegacyTextUrl() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("http://fountainmc.org");
        assertThat(converted, hasSize(1));
        ClickEvent event = converted.get(0).getClickEvent();
        assertThat(event != null, is(true));
        assertThat(event.getAction(), equalTo(ClickEvent.Action.OPEN_URL));
        assertThat(event.getValue(), equalTo("http://fountainmc.org"));
        assertThat(converted.get(0).getValue().getText(), equalTo("http://fountainmc.org"));
    }

    @Test
    public void simpleLegacyTextUrlBetweenText() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("abc mumble http://fountainmc.org grumble xyz");
        assertThat(converted, hasSize(3));

        assertThat(converted.get(0).getValue().getText(), equalTo("abc mumble "));

        ClickEvent event = converted.get(1).getClickEvent();
        assertThat(event != null, is(true));
        assertThat(event.getAction(), equalTo(ClickEvent.Action.OPEN_URL));
        assertThat(event.getValue(), equalTo("http://fountainmc.org"));
        assertThat(converted.get(1).getValue().getText(), equalTo("http://fountainmc.org"));

        assertThat(converted.get(2).getValue().getText(), equalTo(" grumble xyz"));
    }

    @Test
    public void simpleLegacyTextUrlPreservesFormatting() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7ctest http://fountainmc.org tset");
        assertThat(converted, hasSize(3));

        assertThat(converted.get(0).getValue().getText(), equalTo("test "));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));

        ClickEvent event = converted.get(1).getClickEvent();
        assertThat(event != null, is(true));
        assertThat(event.getAction(), equalTo(ClickEvent.Action.OPEN_URL));
        assertThat(event.getValue(), equalTo("http://fountainmc.org"));
        assertThat(converted.get(1).getValue().getText(), equalTo("http://fountainmc.org"));
        assertThat(converted.get(1).getColor(), equalTo(ChatColor.RED));

        assertThat(converted.get(2).getValue().getText(), equalTo(" tset"));
        assertThat(converted.get(2).getColor(), equalTo(ChatColor.RED));
    }

    @Test
    public void simpleLegacyTextUrlSeparateFormatting() {
        List<Component<Text>> converted = Components.INSTANCE.forLegacyText("\u00a7ctest \u00a7rhttp://fountainmc.org tset");
        assertThat(converted, hasSize(3));

        assertThat(converted.get(0).getValue().getText(), equalTo("test "));
        assertThat(converted.get(0).getColor(), equalTo(ChatColor.RED));

        ClickEvent event = converted.get(1).getClickEvent();
        assertThat(event != null, is(true));
        assertThat(event.getAction(), equalTo(ClickEvent.Action.OPEN_URL));
        assertThat(event.getValue(), equalTo("http://fountainmc.org"));
        assertThat(converted.get(1).getValue().getText(), equalTo("http://fountainmc.org"));
        assertThat(converted.get(1).getColor(), equalTo(ChatColor.WHITE));
    }

}


text:
<?php

$title = 'an error occurred';
$body = $this->exception;
$this->title = 'Error';
$this->header = 'An error occurred';
$this->body = $body;


text:
package org.literacybridge.dashboard.services;

import org.hibernate.SessionFactory;
import org.literacybridge.dashboard.dbTables.syncOperations.UpdateValidationError;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.IOException;

/**
 */
@Repository(value = "updateValidationErrorWriter")
public class UpdateValidationErrorWriter {

  @Resource
  private SessionFactory sessionFactory;

  @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
  public void write(UpdateValidationError updateValidationError) throws IOException {
    sessionFactory.getCurrentSession().saveOrUpdate(updateValidationError);
  }

}


text:
/*
  The aim of this topic is:
    Reverse words in a sentence
    Inspired from: http://www.programcreek.com/2014/05/leetcode-reverse-words-in-a-string-ii-java/

    Hypothesis:
      - inputs contain only characters a-z, A-Z and space
      - there is always a word between two spaces
      - string never starts or ends by a space
    Example: "the sky is blue" becomes "blue is sky the"
*/

#include <string>

// Algorithm to be tested

std::string reverse_words(std::string const& in);


text:
package org.attribyte.relay;

import com.codahale.metrics.Metric;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import org.attribyte.api.Logger;
import org.attribyte.sql.pool.ConnectionPool;
import org.attribyte.sql.pool.PasswordSource;
import org.attribyte.sql.pool.contrib.PropertiesPasswordSource;
import org.attribyte.util.InitUtil;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
 * A base class for creating suppliers that require a relational database.
 */
public abstract class RDBSupplier implements Supplier {

   /**
    * Called by implementation to initialize pools after construction.
    * @param props The properties.
    * @param logger The logger.
    * @throws Exception on initialization error.
    */
   protected void initPools(final Properties props, final Logger logger) throws Exception {
      InitUtil dbProps = new InitUtil("rdb.", props);
      String credentialsFilename = Strings.nullToEmpty(dbProps.getProperty("credentialsFile")).trim();
      final PasswordSource passwordSource;
      if(!credentialsFilename.isEmpty()) {
         File credentialsFile = new File(credentialsFilename);
         if(!credentialsFile.exists()) {
            throw new Exception(String.format("The 'rdb.credentialsFile', '%s' does not exist", credentialsFilename));
         }

         if(!credentialsFile.canRead()) {
            throw new Exception(String.format("The 'rdb.credentialsFile', '%s' can't be read", credentialsFilename));
         }

         Properties credentialsProps = new Properties();
         credentialsProps.load(new ByteArrayInputStream(Files.toByteArray(credentialsFile)));
         passwordSource = new PropertiesPasswordSource(credentialsProps);
      } else {
         passwordSource = null;
      }

      List<ConnectionPool.Initializer> initializers = ConnectionPool.Initializer.fromProperties(dbProps.getProperties(), passwordSource, logger);
      if(initializers.size() == 0) {
         throw new Exception("No connection pool found");
      }

      String defaultPoolName = Strings.nullToEmpty(dbProps.getProperty("defaultPoolName")).trim();

      if(defaultPoolName.isEmpty()) {
         ImmutableMap.Builder<String, ConnectionPool> connectionPools = ImmutableMap.builder();
         this.defaultConnectionPool = initializers.get(0).createPool();
         connectionPools.put(this.defaultConnectionPool.getName(), this.defaultConnectionPool);
         for(int i = 1; i < initializers.size(); i++) {
            ConnectionPool curr = initializers.get(i).createPool();
            connectionPools.put(curr.getName(), curr);
         }
         this.connectionPools = connectionPools.build();
      } else {
         ImmutableMap.Builder<String, ConnectionPool> connectionPools = ImmutableMap.builder();
         for(ConnectionPool.Initializer init : initializers) {
            ConnectionPool pool = init.createPool();
            connectionPools.put(pool.getName(), pool);
         }
         this.connectionPools = connectionPools.build();
         this.defaultConnectionPool = this.connectionPools.get(defaultPoolName);
         if(this.defaultConnectionPool == null) {
            throw new Exception(String.format("The default connection pool, '%s', was not configured", defaultPoolName));
         }
      }
   }

   /**
    * Shutdown all pools - to be called by implementations during {@code shutdown}.
    */
   protected void shutdownPools() {
      for(ConnectionPool pool : connectionPools.values()) {
         pool.shutdown();
      }
   }

   @Override
   public Map<String, Metric> getMetrics() {
      ImmutableMap.Builder<String, Metric> builder = ImmutableMap.builder();
      for(ConnectionPool pool : connectionPools.values()) {
         builder.put(pool.getName(), pool.getMetrics());
      }
      return builder.build();
   }

   /**
    * The logger.
    */
   protected Logger logger;

   /**
    * The default connection pool.
    */
   protected ConnectionPool defaultConnectionPool;

   /**
    * Named connection pools.
    */
   protected Map<String, ConnectionPool> connectionPools;
}