miguelius / hoope

1 stars 0 forks source link

I want to get a graphic representation of my object #1

Closed miguelius closed 10 years ago

miguelius commented 10 years ago

I define an object something like this: " val pepita = object { energia: double position: java.awt.Point image: String

message come = method (double gramos): void {
    System.out.println("pepita comio " + gramos)

    energia = energia + gramos
}

message vola = method (java.awt.Point donde): void {
    energia = Math.max(0,energia - donde.distance(position))
    if (energia < 0.01) {
        System.out.println("pepita se quedo sin energia :(")
    }
    position = donde
}

}

pepita.position = new java.awt.Point(0,0) "

This should place a drawing in position (0,0).

miguelius commented 10 years ago

Done.

Interpreter filter objects having position or image and they are added to the ViewPart.

This is done by a method: void registerGraphicObject(EObject objectMetadata, Object realObject);

It sends the objectMetadata (HoopeObject describing pepita's features) and the real object (pepita).

It creates a Figure and put's it in the position defined in the object. Image should be placed in plugin's project by now. Working using an image from Hoope Lesson.

miguelius commented 10 years ago

Ready.

There's been changes on interface for method: void registerGraphicObject(EObject objectMetadata, Object realObject);

now void registerGraphicObject(String identifier, Object realObject);

This is because view part plugin is not having dependency on the language. If i add, i would have got circular dependency.

By default the image is the one embedded in the plugin (pepita_80.png), but you can add one to your lesson. Just create folder resources in lesson's root and add to it the picture you want.

In the object definition you should place the name of the file as a property: image: String = "my_custom_image.png"

It will show the image in the HoopeView and if you place mouse over it you should be the identifier of the object.