Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Style with LineWidth and LineStyle does not work
Style with LineWidth and LineStyle does not work [message #727579] Wed, 21 September 2011 14:54 Go to next message
Christian B is currently offline Christian BFriend
Messages: 68
Registered: August 2011
Member
Hi,

i tried to use my own style (same way like the tutorial proposes):
public static Style getStyleForGroup(Diagram diagram) {
	final String styleId = "group";

	Style style = findStyle(diagram, styleId);

	IGaService gaService = Graphiti.getGaService();
	if (style == null) { // style not found - create new style
		style = gaService.createStyle(diagram, styleId);
		style.setForeground(gaService.manageColor(diagram,
				GROUP_FOREGROUND));
		style.setBackground(gaService.manageColor(diagram,
				GROUP_BACKGROUND));
		style.setLineWidth(5);
		style.setLineStyle(LineStyle.DOT);
		style.setTransparency(0.8);
	}
	return style;
}

I set the style for a rectangle this way:
Rectangle rectangle = gaService.createRectangle(containerShape);
rectangle.setStyle(StyleUtil.getStyleForGroup(targetDiagram));

The Problem ist, only backgroundcolor and foreground color work, linewidth, linestyle and transparency are ignored...

if i set these properties directly to the rectangle, it works:
Rectangle rectangle = gaService.createRectangle(containerShape);
rectangle.setStyle(StyleUtil.getStyleForGroup(targetDiagram));
rectangle.setTransparency(0.8);
rectangle.setLineStyle(LineStyle.DOT);
rectangle.setLineWidth(5);


Any ideas?

One further question: Is it possible to make only the rectangle transparent and not its border too?

[Updated on: Wed, 21 September 2011 14:54]

Report message to a moderator

Re: Style for LineWidth and Linestyle does not work [message #727995 is a reply to message #727579] Thu, 22 September 2011 10:56 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
That happens because linewidth, linestyle and transparency have default
values defined that are automatically set for new graphic algorithms and let
the values defined at the style be ignored. Would need to reset the values
at the graphics algorithms (to null) to get the values from the style.

This is very confusing and actually we have just improved that behavior for
the Juno M2 version of Graphiti, see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352542

HTH,
Michael


"buschcobolt" schrieb im Newsbeitrag news:j5ct5b$ue$1@news.eclipse.org...

Hi,

i tried to use my own style (same way like the tutorial proposes):
public static Style getStyleForGroup(Diagram diagram) {
final String styleId = "group";

Style style = findStyle(diagram, styleId);

IGaService gaService = Graphiti.getGaService();
if (style == null) { // style not found - create new style
style = gaService.createStyle(diagram, styleId);
style.setForeground(gaService.manageColor(diagram,
GROUP_FOREGROUND));
style.setBackground(gaService.manageColor(diagram,
GROUP_BACKGROUND));
style.setLineWidth(5);
style.setLineStyle(LineStyle.DOT);
style.setTransparency(0.8);
}
return style;
}
I set the style for a rectangle this way:
Rectangle rectangle = gaService.createRectangle(containerShape);
rectangle.setStyle(StyleUtil.getStyleForGroup(targetDiagram));
The Problem ist, only backgroundcolor and foreground color work, linewidth,
linestyle and transparency are ignored...

if i set these properties directly to the rectangle, it works:
Rectangle rectangle = gaService.createRectangle(containerShape);
rectangle.setStyle(StyleUtil.getStyleForGroup(targetDiagram));
rectangle.setTransparency(0.8);
rectangle.setLineStyle(LineStyle.DOT);
rectangle.setLineWidth(5);

Any ideas?

One further question: Is it possible to make only the rectangle transparent
and not its border too?
Re: Style for LineWidth and Linestyle does not work [message #728387 is a reply to message #727995] Fri, 23 September 2011 07:28 Go to previous messageGo to next message
Christian B is currently offline Christian BFriend
Messages: 68
Registered: August 2011
Member
thx, then i live with it Wink

i posted one further question:
Is it possible to make only the rectangle transparent
and not its border too?
Re: Style for LineWidth and Linestyle does not work [message #728406 is a reply to message #728387] Fri, 23 September 2011 08:16 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Sorry, I missed that one: that is not possible since transparency always
relates to the complete rectangle. A workaround would be to add a
non-transparent rectangle drawing the border and add a child rectangle (via
direct graphics algorithm nesting) that defines the transparent filling.

HTH,
Michael


"buschcobolt" schrieb im Newsbeitrag news:j5hbog$i51$1@news.eclipse.org...

thx, then i live with it ;)

i posted one further question:
Is it possible to make only the rectangle transparent
and not its border too?
Re: Style for LineWidth and Linestyle does not work [message #994126 is a reply to message #728406] Wed, 26 December 2012 13:04 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 30
Registered: August 2012
Member
I try to set my own style as discussed in above thread at the rectangle level which works fine for me.

This works correctly when I do not have any update feature associated.But when I apply update feature for the rectangle, the style that I applied stops working.

I tried to reset the style after updation.But at this point it does not take the linewidth and linestyle I give.

Is it that the defined style style is overwritten while updating?
Re: Style for LineWidth and Linestyle does not work [message #996617 is a reply to message #994126] Wed, 02 January 2013 14:32 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hemlata,

I'm afraid I didn't understand what you actually do in your update feature.
What do you mean with reset the style? Can you provide some coding?

Michael
Re: Style for LineWidth and Linestyle does not work [message #998167 is a reply to message #996617] Wed, 09 January 2013 13:35 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 30
Registered: August 2012
Member
Hi Michael,

I have the following stuff in my Add feature:

 

  Rectangle roundedRectangle = gaService.createRectangle(containerShape);

    roundedRectangle.setLineStyle(null);
    roundedRectangle.setLineWidth(null);
    roundedRectangle.setStyle(null);

    Style varStyle = gaService.createStyle(diagram_, STYLE_ID);

        varStyle.setForeground(gaService
                .manageColor(diagram_, CLASS_FOREGROUND));
        varStyle.setBackground(gaService.manageColor(diagram_,
                CLASS_BACKGROUND_YELLOW));

        varStyle.setLineStyle(LineStyle.SOLID);
        varStyle.setLineWidth(2);
        varStyle.setLineVisible(true);

      roundedRectangle.setStyle(varStyle);


This works as expected when I do not have an update feature defined at all.When I add the update feature the above style applied does not work.In update feature I just update the texts in rectangle and nothing related to style.

Re: Style for LineWidth and Linestyle does not work [message #998669 is a reply to message #998167] Thu, 10 January 2013 13:24 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hemlata,

this looks good and I don't see an issue here...

Without debugging that it will not be possible to answer. Are both features
(add and update) correctly called?

Michael
Re: Style for LineWidth and Linestyle does not work [message #1000159 is a reply to message #998669] Mon, 14 January 2013 06:33 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 30
Registered: August 2012
Member
Yes both the features are correctly called and Update feature also works as expected except for the style part.
Re: Style for LineWidth and Linestyle does not work [message #1000334 is a reply to message #1000159] Mon, 14 January 2013 14:44 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
As I said, I would need to debug that. Can you provide a stripped down
version of that?

Michael
Previous Topic:Content assistant provided?
Next Topic:invoke Create Feature
Goto Forum:
  


Current Time: Mon Dec 22 01:30:33 GMT 2014

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

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