Customize Scalable Polygon Figure [message #1052833] |
Tue, 30 April 2013 12:03  |
Eclipse User |
|
|
|
Hi all,
In my Diagram I've created a Figure associated to a Node.
This figure is a Scalable Polygon:
<actualFigure
xsi:type="gmfgraph:ScalablePolygon">
<backgroundColor
xsi:type="gmfgraph:ConstantColor"
value="lightGray"/>
<maximumSize
dx="80"
dy="35"/>
<minimumSize
dx="80"
dy="35"/>
<preferredSize
dx="80"
dy="35"/>
<insets
top="15"
left="5"
right="5"/>
<children
xsi:type="gmfgraph:Label"
name="ContainmentAssociationTriangleLabel"
text=""/>
<template
x="40"/>
<template
y="35"/>
<template
x="80"
y="35"/>
</actualFigure>
Basically it is a triangle with a label.
The associated node is a child of another node which is represent with a rectangle.
In the diagram the triangle is attached to the south border ot the rectangle.
I achieved it by setting the property "Affixed Parent Size" of the Node to "SOUTH".
Now I would like to customize three aspects:
- I would like to make the border of the triangle of a different color based on the content of the label. I'm already able to change the color of the triangle background programmatically but I don't know hot to do the same for setting the color of the border.
- I would like to disable the possibility of moving the triangle (or at least disable the possibility of moving it in a position different from the bottom border of the rectangle) and I would like to center its top vertex on the center of the rectangle bottom border. Currently it is automatically created on the bottom side but not in the center.
- I would like to disable the possibility of resizing the triangle. It is not necessary and when the user try to do it an exception is generated (see below)
Thanks in advance,
Luca
!ENTRY org.eclipse.ui 4 0 2013-04-30 18:02:42.324
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.ClassCastException: org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator cannot be cast to org.eclipse.draw2d.geometry.Rectangle
at org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getCurrentConstraintFor(XYLayoutEditPolicy.java:102)
at org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:55)
at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getConstraintFor(ConstrainedLayoutEditPolicy.java:244)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:227)
at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getAddCommand(ConstrainedLayoutEditPolicy.java:184)
at org.eclipse.gef.editpolicies.LayoutEditPolicy.getCommand(LayoutEditPolicy.java:216)
at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getCommand(ConstrainedLayoutEditPolicy.java:214)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getCommand(XYLayoutEditPolicy.java:329)
at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:500)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy.getDropCommand(DragDropEditPolicy.java:112)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy.getDropCommand(DiagramDragDropEditPolicy.java:151)
at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy.getCommand(DragDropEditPolicy.java:75)
at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:502)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.getCommand(DragEditPartsTrackerEx.java:63)
at org.eclipse.gef.tools.DragEditPartsTracker.handleDragInProgress(DragEditPartsTracker.java:370)
at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleDragInProgress(DragEditPartsTrackerEx.java:177)
at org.eclipse.gef.tools.AbstractTool.mouseDrag(AbstractTool.java:1114)
at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool.java:538)
at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:259)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseMoved(DomainEventDispatcher.java:363)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseMove(LightweightSystem.java:543)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:212)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4136)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1458)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1481)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1271)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3982)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3621)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.71816 seconds