JGoObject Visibility in Mutiple Views


What are good techniques for making same JGoObjects of the same JGoDocument visible in JGoViewX and not visible in JGoViewY.


The easiest thing to do is to override the paint method to either be a no-op or a call to the super method depending on the JGoView passed as the second argument.


Hi Walter ,thanks for reply. What I am trying to do is something like this. Have a single document that contains square objects and circle objects. Attach that document to 2 views (i.e SquareJGoView, CircleJGoView) and show the squares in the SquareJGoView and have the circles invisible and vice versa in the CircleJGoView. I would appreciate if you show me a technique for this.


Here’s a better way of doing what you want, assuming you can put all the squares in one JGoLayer and all the circles into another one.
Let’s say there are three layers in your document, one for links, one for squares, and one for circles:
Then in your SquareJGoView subclass, override:
public JGoLayer getFirstLayer() {
return linksLayer;
public JGoLayer getLastLayer() {
return squaresLayer;
public JGoLayer getNextLayer(JGoLayer layer) {
if (layer == linksLayer) return squaresLayer;
return null;
public JGoLayer getPrevLayer(JGoLayer layer) {
if (layer == squaresLayer) return linksLayer;
return null;
You’ll need to initialize two fields to refer to their corresponding layers:
private JGoLayer linksLayer;
private JGoLayer squaresLayer;
Similarly, in your CircleJGoView subclass, override the same methods but substitute the circlesLayer for the squaresLayer.
This way all of the JGoView operations on document objects will only consider two layers, although each view subclass will work with a different set of two layers.
Of course, you can generalize this idea. What JGoView ought to have is its own list of document layers, in the order it wants, rather than always using the JGoDocument’s list of layers.


This is beautiful. I think this should work for me. I have not yet understood the relationship between the Layer, Document and View. I will go through documentation for more clarity. Thanks Walter.