Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/trapezium/attractor/NearPreservingAttractorSelector.java


1   /*
2    * @(#)NearPreservingAttractorSelector.java
3    *
4    * Copyright (c) 1998 by Trapezium Development LLC.  All Rights Reserved.
5    *
6    * The information in this file is the property of Trapezium Development LLC
7    * and may be used only in accordance with the terms of the license granted
8    * by Trapezium.
9    *
10   */
11  package com.trapezium.attractor;
12  
13  import com.trapezium.vrml.node.space.*;
14  
15  /** The NearPreservingAttractorSelector marks for preservation the nearest
16   *  floater in the attracted floater set.
17   *
18   *  @author          Johannes N. Johannsen
19   *  @version         1.0, 8 Oct 1998
20   *
21   *  @since           1.0
22   */
23  
24  public class NearPreservingAttractorSelector extends AttractorSelector {
25  
26      /** Class constructor */
27      public NearPreservingAttractorSelector() {
28          super();
29      }
30  
31      /** Update the floater-to-be-preserved information, the nearest floater
32       *  in the attracted set is preserved.
33       *
34       *  @param floaterOffsets the offset of each floater to be preserved,
35       *     the attractor offset is the index into this array
36       *  @param floaterDistances the distance between the attractor and
37       *     the current to-be-preserved floater, the attractor offset is
38       *     the index into this array.
39       *  @param floaterOffset the floater that may override previous
40       *     to-be-preserved floater.
41       */
42      public void updatePreservedInfo( int[] floaterOffsets,
43          float[] floaterDistances, int floaterOffset ) {
44          if (( floaterOffsets[ selectedAttractor ] == -1 ) ||
45              ( selectionDistance < floaterDistances[ selectedAttractor ] )) {
46              floaterOffsets[ selectedAttractor ] = floaterOffset;
47              floaterDistances[ selectedAttractor ] = selectionDistance;
48          }
49      }
50  }