Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Making Labels Visible on Custom Images (Urgent Please)
Making Labels Visible on Custom Images (Urgent Please) [message #180708] Thu, 03 April 2008 10:42 Go to next message
Toyin is currently offline ToyinFriend
Messages: 35
Registered: July 2009
Member
Hi Everyone,
Ive been able to load my custom image on GMF but I can't get to make my
label visible like other regular shapes. Although, when I label the custom
shape, iot shows on the property view but it's not showing on the image
itself.
Does anyone know how make labels visible on custom image or could it be
that it's not possible to make labels visible on custom shapes?

Thanks

Toyin
Re: Making Labels Visible on Custom Images (Urgent Please) [message #180850 is a reply to message #180708] Fri, 04 April 2008 08:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: snej_NO-SPAM_.esuark.de

Toyin Fakorede schrieb:
> Does anyone know how make labels visible on custom image or could it be
> that it's not possible to make labels visible on custom shapes?

Hi Tiyin,

i use custom images too. With a rectangle containing the image figure
you can add a label. So something like this:

Rectangle (border off, no fill)
|
+- your custom image figure
|
+- label figure
|
+- layout you like (in my case XYLayout)


Hth Jens
Re: Making Labels Visible on Custom Images (Urgent Please) [message #180871 is a reply to message #180850] Fri, 04 April 2008 09:48 Go to previous messageGo to next message
Toyin is currently offline ToyinFriend
Messages: 35
Registered: July 2009
Member
Hi Jens, thank for your help.
I tried exactly what you described but its still not showing the label. If
you dont mind, pls could you send me your code -
customfigureEditPart.java.
I want to compare with mine.
Thanks
Re: Making Labels Visible on Custom Images (Urgent Please) [message #180894 is a reply to message #180708] Fri, 04 April 2008 11:41 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Toyin,

> shape, iot shows on the property view but it's not showing on the
> image itself.
Looks like you should use proper layout in your composite figure. One of
the last EclipseCon tutorials contains an example where we use SVG image
as figure for diagram element with label located upon this image. This can
be useful for you: http://www.eclipsecon.org/2008/index.php?page=sub/&id=33 7

> that it's not possible to make labels visible on custom shapes?
No, it should be possible with StackLayout. :-)

-----------------
Alex Shatalin
Re: Making Labels Visible on Custom Images (Urgent Please) [message #181004 is a reply to message #180871] Fri, 04 April 2008 17:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: snej_NO-SPAM_.esuark.de

Toyin Fakorede schrieb:
> If
> you dont mind, pls could you send me your code -
> customfigureEditPart.java.

Its all generated, only the createContents() method is adapted:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
/**
* @generated
*/
public class ActorEditPart extends ShapeNodeEditPart {

/**
* @generated
*/
public static final int VISUAL_ID = 3158;

/**
* @generated
*/
protected IFigure contentPane;

/**
* @generated
*/
protected IFigure primaryShape;

/**
* @generated
*/
public ActorEditPart(View view) {
super(view);
}

/**
* @generated
*/
protected void createDefaultEditPolicies() {

super.createDefaultEditPolicies();
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new
ControlLayer.diagram.edit.policies.ActorItemSemanticEditPoli cy());
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that
would let children add reasonable editpolicies
//
removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpoli cies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
}

/**
* @generated
*/
protected LayoutEditPolicy createLayoutEditPolicy() {
LayoutEditPolicy lep = new LayoutEditPolicy() {

protected EditPolicy createChildEditPolicy(EditPart child) {
EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
if (result == null) {
result = new NonResizableEditPolicy();
}
return result;
}

protected Command getMoveChildrenCommand(Request request) {
return null;
}

protected Command getCreateCommand(CreateRequest request) {
return null;
}
};
return lep;
}

/**
* @generated
*/
protected IFigure createNodeShape() {
ActorFigure figure = new ActorFigure();
return primaryShape = figure;
}

/**
* @generated
*/
public ActorFigure getPrimaryShape() {
return (ActorFigure) primaryShape;
}

/**
* @generated
*/
protected boolean addFixedChild(EditPart childEditPart) {
if (childEditPart instanceof
ControlLayer.diagram.edit.parts.WrapLabel84EditPart) {
((ControlLayer.diagram.edit.parts.WrapLabel84EditPart)
childEditPart).setLabel(getPrimaryShape().getFigureActorRole Figure());
return true;
}
return false;
}

/**
* @generated
*/
protected boolean removeFixedChild(EditPart childEditPart) {

return false;
}

/**
* @generated
*/
protected void addChildVisual(EditPart childEditPart, int index) {
if (addFixedChild(childEditPart)) {
return;
}
super.addChildVisual(childEditPart, -1);
}

/**
* @generated
*/
protected void removeChildVisual(EditPart childEditPart) {
if (removeFixedChild(childEditPart)) {
return;
}
super.removeChildVisual(childEditPart);
}

/**
* @generated
*/
protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {

return super.getContentPaneFor(editPart);
}

/**
* @generated
*/
protected NodeFigure createNodePlate() {
DefaultSizeNodeFigure result = new
DefaultSizeNodeFigure(getMapMode().DPtoLP(42), getMapMode().DPtoLP(62));
return result;
}

/**
* Creates figure for this edit part.
*
* Body of this method does not depend on settings in generation model
* so you may safely remove <i>generated</i> tag and modify it.
*
* @generated
*/
protected NodeFigure createNodeFigure() {
NodeFigure figure = createNodePlate();
figure.setLayoutManager(new StackLayout());
IFigure shape = createNodeShape();
figure.add(shape);
contentPane = setupContentPane(shape);
return figure;
}

/**
* Default implementation treats passed figure as content pane.
* Respects layout one may have set for generated figure.
* @param nodeShape instance of generated figure class
* @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
if (nodeShape.getLayoutManager() == null) {
ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
layout.setSpacing(getMapMode().DPtoLP(5));
nodeShape.setLayoutManager(layout);
}
return nodeShape; // use nodeShape itself as contentPane
}

/**
* @generated
*/
public IFigure getContentPane() {
if (contentPane != null) {
return contentPane;
}
return super.getContentPane();
}

/**
* @generated
*/
public EditPart getPrimaryChildEditPart() {
return
getChildBySemanticHint(ControlLayer.diagram.part.GenloopVisu alIDRegistry

..getType(ControlLayer.diagram.edit.parts.WrapLabel84EditPar t.VISUAL_ID));
}

/**
* @generated NOT
*/
public class ActorFigure extends RectangleFigure {

/**
* @generated
*/
private WrapLabel fFigureActorRoleFigure;

/**
* @generated
*/
public ActorFigure() {

BorderLayout layoutThis = new BorderLayout();
this.setLayoutManager(layoutThis);

this.setOutline(false);
createContents();
}

/**
* @generated NOT
*/
private void createContents() {

URL url =
FileLocator.find(GenloopDiagramEditorPlugin.getInstance().ge tBundle(),
new Path("icons/actor.svg"), null); //$NON-NLS-1$
ScalableImageFigure actorInnerFigure0 = new
ScalableImageFigure(RenderedImageFactory.getInstance(url), false, true,
true);

this.add(actorInnerFigure0, BorderLayout.TOP);

fFigureActorRoleFigure = new WrapLabel();
fFigureActorRoleFigure.setText("role");

this.add(fFigureActorRoleFigure, BorderLayout.BOTTOM);

}

/**
* @generated
*/
private boolean myUseLocalCoordinates = false;

/**
* @generated
*/
protected boolean useLocalCoordinates() {
return myUseLocalCoordinates;
}

/**
* @generated
*/
protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
myUseLocalCoordinates = useLocalCoordinates;
}

/**
* @generated
*/
public WrapLabel getFigureActorRoleFigure() {
return fFigureActorRoleFigure;
}

}

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~


hth Jens
Re: Making Labels Visible on Custom Images (Urgent Please) [message #181219 is a reply to message #180894] Mon, 07 April 2008 15:37 Go to previous messageGo to next message
Toyin is currently offline ToyinFriend
Messages: 35
Registered: July 2009
Member
Hi Alex,
many thanks for your response. I've gone throught the slides, please how
did you label the SVG picture and SVG composite figure. I will appreciate
it if you could describe the process :). I included the Stacklayout but I
didnt see the effect - maybe Im doing it wrongly.
Thanks for your help.
Toyin
Re: Making Labels Visible on Custom Images (Urgent Please) [message #181243 is a reply to message #180894] Mon, 07 April 2008 15:51 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Alex,

You can download sample projects from here: https://eclipsecon.greenmeetingsystems.com/submissions/view/ 337

-----------------
Alex Shatalin
Re: Making Labels Visible on Custom Images (Urgent Please) [message #181261 is a reply to message #181243] Mon, 07 April 2008 16:29 Go to previous message
Toyin is currently offline ToyinFriend
Messages: 35
Registered: July 2009
Member
Thanks very much Alex.
I'm currently viewing them.
thanks once again
Previous Topic:Hyperedges with Junction points (just) in Notation Model
Next Topic:GMF Mindmap Tutorial Validation problems
Goto Forum:
  


Current Time: Tue Apr 23 16:49:26 GMT 2024

Powered by FUDForum. Page generated in 0.03928 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top