/[libvob]/libvob/org/nongnu/libvob/buoy/impl/FocusWithBuoysManager.java
ViewVC logotype

Diff of /libvob/org/nongnu/libvob/buoy/impl/FocusWithBuoysManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mudyc, Fri Sep 5 13:04:30 2003 UTC revision 1.2 by tjl, Fri Oct 10 13:52:23 2003 UTC
# Line 12  import org.nongnu.libvob.vobs.SimpleConn Line 12  import org.nongnu.libvob.vobs.SimpleConn
12    
13  /** The traditional buoymanager with single focus view port.  /** The traditional buoymanager with single focus view port.
14   */   */
15  public class FocusWithBuoysManager  public class FocusWithBuoysManager implements BuoyManager {
     implements BuoyLinkListener, BuoyManager {  
16      static public boolean dbg = false;      static public boolean dbg = false;
17      static private void p(String s) { System.out.println("FocusWithBuoysManager:: "+s); }      static private void p(String s) { System.out.println("FocusWithBuoysManager:: "+s); }
18    
# Line 38  public class FocusWithBuoysManager Line 37  public class FocusWithBuoysManager
37    
38    
39      // implement      // implement
40      public BuoyViewMainNode getViewMainNode() { return mainNode; }      public BuoyViewMainNode getMainNode() { return mainNode; }
41      private BuoyViewMainNode mainNode;      private BuoyViewMainNode mainNode;
42      private BuoyViewConnector[] connectors;      private BuoyViewConnector[] connectors;
43      private BuoyGeometryConfiguration geometryConf;      private BuoyGeometryConfiguration geometryConf;
# Line 54  public class FocusWithBuoysManager Line 53  public class FocusWithBuoysManager
53    
54      private Map cs = new HashMap();      private Map cs = new HashMap();
55      // implement      // implement
56      public Buoy getBuoy(int cs) { return (Buoy)this.cs.get(""+cs); }      public BuoyManager.Buoy getBuoy(int cs) {
57            return (BuoyManager.Buoy)this.cs.get(""+cs);
58        }
59    
60      // All buoy link calls are collected in this list.      // All buoy link calls are collected in this list.
61      private List linkCalls = new ArrayList();      private List linkCalls = new ArrayList();
# Line 76  public class FocusWithBuoysManager Line 77  public class FocusWithBuoysManager
77      private List links = null;      private List links = null;
78      private int mainVP_CS = -1;      private int mainVP_CS = -1;
79      // implement      // implement
80      public void drawScene(VobScene vs, int mainBoxInto) {      public void draw(VobScene vs, int mainBoxInto) {
81          if (dbg) p("start drawing");          if (dbg) p("start drawing");
82            // first take care of clearing and setting things up.
83            buoyInd = 0;
84          cs.clear();          cs.clear();
85          linkCalls.clear();          linkCalls.clear();
86    
# Line 182  public class FocusWithBuoysManager Line 185  public class FocusWithBuoysManager
185          int otherAnchorCS = otherNode.renderBuoy(vs, into, width,          int otherAnchorCS = otherNode.renderBuoy(vs, into, width,
186                height, linkId, otherAnchor, null);                height, linkId, otherAnchor, null);
187          if (dbg) p("linkR: render the buoy..");          if (dbg) p("linkR: render the buoy..");
188          cs.put(""+into, new Buoy(otherNode, linkId, otherAnchor, into, dir));          cs.put(""+into, getNewBuoy(otherNode, linkId, otherAnchor, into, dir));
189    
190          if (anchorCS >= 0)          if (anchorCS >= 0)
191              vs.map.put(lineConnector, vs.unitSqCS(anchorCS, "UN"),              vs.map.put(lineConnector, vs.unitSqCS(anchorCS, "UN"),
# Line 199  public class FocusWithBuoysManager Line 202  public class FocusWithBuoysManager
202      }      }
203    
204      // implement      // implement
205      public void followLink(Buoy buoy) {      public void moveFocusTo(BuoyManager.Buoy buoy) {
206          animationCsBuoyToMain = buoy.buoyCS;          animationCsBuoyToMain = buoy.getBuoyCS();
207          animationMainVPtoBuoy = buoy.linkId;          animationMainVPtoBuoy = buoy.getLinkId();
208          mainNode = buoy.buoyNode.createMainNode(buoy.linkId, buoy.buoyAnchor);          mainNode = buoy.getNodeType()
209                .createMainNode(buoy.getLinkId(), buoy.getBuoyAnchor());
210      }      }
211    
212    
213    
214        private int buoyInd = 0, buoyInc = 5;
215        private BuoyManager.Buoy [] buoys = new BuoyManager.Buoy[5];
216        private BuoyManager.Buoy getNewBuoy(BuoyViewNodeType nodeType,
217                                            Object linkId, Object anchor,
218                                            int buoyCS, int direction)
219        {
220            // take care if we ran out of array size
221            if (buoyInd >= buoys.length) {
222                BuoyManager.Buoy [] newArray =
223                    new BuoyManager.Buoy[buoys.length + buoyInc];
224                System.arraycopy(buoys, 0, newArray, 0, buoys.length);
225                // is this efficient for memory?
226                for (int i=0; i<buoys.length; i++) buoys[i] = null;
227                buoys = newArray;
228            }
229            
230            if (buoys[buoyInd] == null)
231                buoys[buoyInd] = new BuoyImpl();
232            BuoyManager.Buoy buoy =
233                ((BuoyImpl)buoys[buoyInd]).set(nodeType, linkId, anchor,
234                                               buoyCS, direction);
235            buoyInd += 1;
236            return buoy;
237        }
238          
239    
240    
241        class BuoyImpl implements BuoyManager.Buoy {
242            BuoyViewNodeType nodeType = null;
243            Object linkId = null, anchor = null;
244            int cs = -1, direction = 0;
245            
246            BuoyManager.Buoy set(BuoyViewNodeType nodeType, Object linkId,
247                    Object anchor, int buoyCS, int direction) {
248                this.nodeType = nodeType;
249                this.linkId = linkId;
250                this.anchor = anchor;
251                this.cs = buoyCS;
252                this.direction = direction;
253                return this;
254            }
255    
256            // implement
257            public BuoyViewNodeType getNodeType() { return nodeType; }
258            public Object getLinkId() { return linkId; }
259            public Object getBuoyAnchor() { return anchor; }
260            public int getBuoyCS() { return cs; }
261            public int getDirection() { return direction; }
262        }
263    
264  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26