logo       

Re: Grid with Dots: msg#00053

java.netbeans.modules.graph.user

Subject: Re: Grid with Dots


Hi Chris,

I have added a new "test.move.SnapToGridTest" example into
"graph/examples" module. If you would like to implement your own
SnapToGridMoveStrategy, look at file:
org/netbeans/modules/visual/actions/SnapToGridMoveStrategy.java

Regards,
David


Chris Palmer wrote:
> Hi Guys!
>
> I am getting into this an reviewing the thread again. I was wondering
> in the existing visual web pack and mobility modules is there a good
> example of "snapping to grid"?
>
> Chris
>
>
> Joelle Lam wrote:
>
>> Hello Chris,
>>
>> In M9 VWP Page Navigation did not include the Grid Dot background.
>> Per a earlier recommendation, I planned to added it back in and have
>> just done so. I used FlowScene as my example as well.
>>
>> Regards,
>> Joelle
>>
>> Chris Palmer wrote:
>>
>>> HI David!
>>>
>>> Thank you very much for the help. This answered a few more questions...
>>>
>>> Chris
>>>
>>>
>>> David Kaspar wrote:
>>>
>>>> Hi Chris,
>>>>
>>>> For painting dots grid you can:
>>>> 1) Use a texture paint that you can use set as a background of your
>>>> scene. This is fastest implementation but it does not allow to change
>>>> the grid-size. For details, see a first few lines in:
>>>> mobility/designer2/flow/src/org/netbeans/modules/vmd/api/flow/visual/FlowScene.java
>>>>
>>>>
>>>> 2) Extend a Scene class you are using and override its paint method
>>>> and
>>>> draw your dots there. Be aware that painting an 2d-array dots could be
>>>> very slow when you have over 1000+ dots drawn on the scene.
>>>>
>>>> Regarding MoveStrategies:
>>>> Unfortunately I do not have a test for it but here it is how it
>>>> should work:
>>>> private int gridWidth = 32;
>>>> private int gridHeight = 32;
>>>> WidgetAction moveAction = ActionFactory.createMoveAction (new
>>>> MoveStrategy () {
>>>> public Point locationSuggested (Widget widget, Point
>>>> originalLocation, Point suggestedLocation) {
>>>> return new Point (suggestedLocation.x - suggestedLocation.x %
>>>> gridWidth, suggestedLocation.y - suggestedLocation.y % gridHeight);
>>>> }
>>>> }, null);
>>>> myWidget.getActions ().addAction (moveAction);
>>>> // now the myWidget could be moved on the scene and its position
>>>> will be
>>>> snapped to the grid
>>>>
>>>> If you want to, you can look at the "visualweb" code but I think they
>>>> are not using grid-dots feature (I assume your are talking
>>>> "web/jsf/navigator" module).
>>>>
>>>> Regards,
>>>> David
>>>>
>>>>
>>>> Chris Palmer wrote:
>>>>
>>>>
>>>>> Hi David!
>>>>>
>>>>> All this helps a lot thank you! Besides the move strategies outlined.
>>>>> Visually drawing the dots on the scene is quite important as well. I
>>>>> was wondering if there was an example or if I should look at the
>>>>> visual web pack code.....
>>>>>
>>>>> Chris
>>>>>
>>>>> David Kaspar wrote:
>>>>>
>>>>>> Hi Chris,
>>>>>>
>>>>>> It really depends on what exactly should be the behaviour of
>>>>>> "grid-with-dots" functionality.
>>>>>>
>>>>>> 1) If you want to have widgets to align to a grid during their
>>>>>> movement
>>>>>> then:
>>>>>> a) use a MoveAction created with your own MoveStrategy where you
>>>>>> calculate with your grid-size. For example see:
>>>>>> graph/lib/src/org/netbeans/modules/visual/action/SnapToGridMoveStrategy.java
>>>>>>
>>>>>>
>>>>>> 2) If you want Widgets to be instantly aligned to a grid, then you
>>>>>> should implement an Layout interface and assign it to the scene
>>>>>> or layer
>>>>>> widget. This makes the children Widgets to be alligned instantly.
>>>>>>
>>>>>> 3) If you want to allow users to move Widgets on a scene freely
>>>>>> within a
>>>>>> grid then:
>>>>>> a) implement the 1. case,
>>>>>> b) when you add a new Widget to a scene, check/calculate correct
>>>>>> preferred location of the new Widget based on the grid-size,
>>>>>> c) when an user changes the grid height or width, then
>>>>>> change/recalculate new correct preferred locations of all Widgets.
>>>>>>
>>>>>> Regards,
>>>>>> David
>>>>>>
>>>>>>
>>>>>> Chris Palmer wrote:
>>>>>>
>>>>>>> Hello!
>>>>>>>
>>>>>>> I would like to implement a simple Grid Layout where the user can
>>>>>>> change the width and height of the grid and the widgets could
>>>>>>> snap to
>>>>>>> this grid. So a grid 60 X 60 would reflect 60 little grid boxes.
>>>>>>>
>>>>>>> Would the visual web pack be the best example to look at?
>>>>>>>
>>>>>>> Chris
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>>> To unsubscribe, e-mail:
>>>>>>> users-unsubscribe-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>>>>>>> For additional commands, e-mail:
>>>>>>> users-help-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>> To unsubscribe, e-mail:
>>>>>> users-unsubscribe-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>>>>>> For additional commands, e-mail:
>>>>>> users-help-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail:
>>>> users-unsubscribe-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>>>> For additional commands, e-mail:
>>>> users-help-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>>>>
>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> users-unsubscribe-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>> For additional commands, e-mail:
>> users-help-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
> For additional commands, e-mail:
> users-help-Hi7mZnf3vbIkiw2pgZvNdR2eb7JE58TQ@xxxxxxxxxxxxxxxx
>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise