Skip to main content



      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 10:54 Go to next message
Eclipse UserFriend
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 10:54] by Moderator

Re: Style for LineWidth and Linestyle does not work [message #727995 is a reply to message #727579] Thu, 22 September 2011 06:56 Go to previous messageGo to next message
Eclipse UserFriend
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 03:28 Go to previous messageGo to next message
Eclipse UserFriend
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 04:16 Go to previous messageGo to next message
Eclipse UserFriend
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 08:04 Go to previous messageGo to next message
Eclipse UserFriend
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 09:32 Go to previous messageGo to next message
Eclipse UserFriend
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 08:35 Go to previous messageGo to next message
Eclipse UserFriend
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 08:24 Go to previous messageGo to next message
Eclipse UserFriend
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 01:33 Go to previous messageGo to next message
Eclipse UserFriend
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 09:44 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 18:40:05 EDT 2025

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

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

Back to the top