pmur002 / gridgraphics

Redraw base graphics as grid graphics
33 stars 8 forks source link

Is makeContext necessary while using makeContent? #17

Closed Anirban166 closed 3 years ago

Anirban166 commented 3 years ago

Hi @pmur002

I have a question: When using a makeContent method for a grob class we define, is it a must to use a makeContext method for it as well?

For reference, I'm working on refactoring the directlabels codebase which currently uses a drawDetails method on a grob class named dlgrob, but it doesn't use a preDrawDetails and a corresponding postDrawDetails method. Also, the sole purpose of using makeContent (instead of drawDetails) here is to make use of grid.force. It's one of my objectives as stated here, and this plan (3rd point) is what I'll be going ahead with.

In the current setup, drawDetails.dlgrob is called with the current ggplot/lattice panel as the current viewport. This is required in order to compute text size correctly via grid functions convertX/convertY. So I would like to know, will the current viewport be taken as the current panel while using makeContent as well? (then I suppose we don't have to use makeContext?)

pmur002 commented 3 years ago

In general, no, a makeContext() is not a requirement. The current viewport when makeContent() is called should be the current ggplot/lattice panel.

Anirban166 commented 3 years ago

Gotcha! Thank you for confirming this.