Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Change the Color of the Grid
Change the Color of the Grid [message #754203] Tue, 01 November 2011 11:07 Go to next message
Lars Heinemann is currently offline Lars HeinemannFriend
Messages: 20
Registered: January 2011
Junior Member

Hi,

I found a way to hide/show the grid in the diagram editor but I am wondering if there is a way to change it's color. Does anybody know how to achieve this?

Best regards
Lars
Re: Change the Color of the Grid [message #754222 is a reply to message #754203] Tue, 01 November 2011 13:53 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
It seems that is deeply hardcoded in class
org.eclipse.graphiti.internal.util.DefaultLook Confused

Actually, there is a LookManager that is oriented (I guess)
to support some pluggable "Looks" but
1) The LookManager is "internal" (not intended to be accessed by client code)
2) The LookManager methods are accesed statically and it does not support pluggin other looks
3) The DefaultLook look itself does not take its values (eg colors) from some configuration or properties file, but from hardcoded strings.
4) The ILook properties (few) are not very clear to me, for example, for example, i'm not sure about how these Major/MinorGridLineDistance relate with the Diagram gridUnit, etc


Re: Change the Color of the Grid [message #754230 is a reply to message #754222] Tue, 01 November 2011 14:00 Go to previous messageGo to next message
Lars Heinemann is currently offline Lars HeinemannFriend
Messages: 20
Registered: January 2011
Junior Member

Yeah, looking at the code it seems this is not intended to be modified by anybody. Would be really nice to give that stuff a public API.
Re: Change the Color of the Grid [message #754231 is a reply to message #754230] Tue, 01 November 2011 14:28 Go to previous messageGo to next message
Lars Heinemann is currently offline Lars HeinemannFriend
Messages: 20
Registered: January 2011
Junior Member

So I at least managed to change the minor grid color with the below lines...

IColorConstant cc = ...
GraphicsAlgorithm ga = myDiagram.getGraphicsAlgorithm();
ga.setForeground(GraphitiUi.getGaService().manageColor(myDiagram, cc));


But going this way you loose the major line color it seams and that looks not as good as the initial style.
Re: Change the Color of the Grid [message #754336 is a reply to message #754230] Wed, 02 November 2011 08:48 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Yes, this stuff is internal now, but it would make sense to open it up. Would you file an extension bugzilla for that?

Thanks,
Michael
Re: Change the Color of the Grid [message #754390 is a reply to message #754336] Wed, 02 November 2011 12:23 Go to previous messageGo to next message
Lars Heinemann is currently offline Lars HeinemannFriend
Messages: 20
Registered: January 2011
Junior Member

Opened a bugzilla issue 362658

Thank you.
Re: Change the Color of the Grid [message #1048353 is a reply to message #754231] Wed, 24 April 2013 10:46 Go to previous messageGo to next message
Saniya Mirajkar is currently offline Saniya MirajkarFriend
Messages: 30
Registered: August 2012
Member
Hi Lars,

Can you please provide the pointers as how did you hide/show the grid of the diagram?
Re: Change the Color of the Grid [message #1051836 is a reply to message #1048353] Mon, 29 April 2013 09:14 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Saniya,

you can set the grid unit property on your diagram instance using
setGridUnit to -1 to hide the grid.

Michael
Re: Change the Color of the Grid [message #1052982 is a reply to message #1051836] Wed, 01 May 2013 17:08 Go to previous message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 65
Registered: April 2012
Member
Hi Saniya,
To hide grid I took the solution from Activiti project. In MyDiagramEditor:

@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    // hides grid on diagram, but you can reenable it
    if (getGraphicalViewer() != null && getGraphicalViewer().getEditPartRegistry() != null) {
        ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) getGraphicalViewer().getEditPartRegistry().get(LayerManager.ID);
        IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
        gridFigure.setVisible(false);
    }
}


Marek
Previous Topic:How to draw feedback shapes?
Next Topic:Auto save Editor
Goto Forum:
  


Current Time: Sun Dec 21 18:56:48 GMT 2014

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

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