I have following problem: I am creating an aplication for creating UML diagrams. Right now just to simplify everything I assume only couple of available diagram elements:
- class
- interface
- generalization
- interface implementation
- association
- aggregation
I decided to create one common abstract class for all of that elements:
abstract DiagramElement which has 2 subclasses also abstract:
- DiagramRelation
- DiagramObject
Nextly DiagramRelation has 4 subclasses:
- Generalization
- InterfaceImplementation
- Assosication
- Aggregation
And DiagramObject has 2 subclasses:
- Interface
- Class
I really wanted to post a picture so it would be all much more simplier but I don't have enough reputation points so sorry.
I came across following problem: each of this element have a different visual representation, ie: interface has only methods etc so each of this element will need to be show differently - I don't want to use multiple "if" instructions for it.
I use WPF and I decided that every control will place it's contest into StackPanel which will be placed inside MyContextControl (inherits after ContextControl and add interface atribute):
public interface IDiagramElementDraw
{
public StackPanel Draw();
}
public MyContextControl : ContextControl
{
private IDiagramElementDraw _drawingInterface;
private StackPanel context;
public DrawControl()
{
context = _drawingInterface.Draw();
}
}
But I don't know which class should implement IDiagramElementDraw interface - I don't want to implement it at the level of Interface, Class, Generalization etc classes because I want them to only represent logical information about each element.
I would appreciate any help, feel free to post complete different solution - this one may be completely wrong, this was just my idea.
Aucun commentaire:
Enregistrer un commentaire