- Timestamp:
- 09/12/11 18:11:46 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/applets/src/gov/noaa/pmel/sgt/dm/SimpleGrid.java
r174 r191 19 19 import gov.noaa.pmel.util.SoTRange; 20 20 21 import java.beans.PropertyChangeListener; 21 22 import java.beans.PropertyChangeSupport; 22 import java.beans.PropertyChangeListener;23 23 import java.io.Serializable; 24 24 … … 29 29 * @author Donald Denbo 30 30 * @version $Revision: 1.19 $, $Date: 2003/08/22 23:02:38 $ 31 * @since 1.032 31 * @see SGTGrid 33 32 * @see Cartesian 33 * @since 1.0 34 34 */ 35 public class SimpleGrid implements SGTGrid, Cartesian, Cloneable, Serializable { 36 protected double[] xloc_; 37 protected double[] yloc_; 38 // protected GeoDate[] tloc_; 39 protected GeoDateArray tloc_; 40 protected double[] grid_; 41 protected double[] xEdges_; 42 protected double[] yEdges_; 43 // protected GeoDate[] tEdges_; 44 protected GeoDateArray tEdges_; 45 protected boolean hasXEdges_; 46 protected boolean hasYEdges_; 47 protected String title_; 48 protected SGLabel keyTitle_ = null; 49 protected String id_ = null; 50 protected boolean xTime_; 51 protected boolean yTime_; 52 /**@shapeType AggregationLink 53 * @clientRole x*/ 35 public class SimpleGrid 36 implements SGTGrid, Cartesian, Cloneable, Serializable 37 { 38 /** 39 * Default constructor. 40 */ 41 public SimpleGrid() 42 { 43 this( null, (double[]) null, (double[]) null, "" ); 44 } 45 46 /** 47 * Constructor for X and Y coordinates as double. 48 * 49 * @param grid Z values 50 * @param xloc X coordinates 51 * @param yloc Y coordinates 52 * @param title the title 53 */ 54 public SimpleGrid( double[] grid, double[] xloc, 55 double[] yloc, String title ) 56 { 57 grid_ = grid; 58 xloc_ = xloc; 59 yloc_ = yloc; 60 title_ = title; 61 xTime_ = false; 62 yTime_ = false; 63 hasXEdges_ = false; 64 hasYEdges_ = false; 65 xRange_ = computeSoTRange( xloc ); 66 yRange_ = computeSoTRange( yloc ); 67 zRange_ = computeRange2D( grid ); 68 } 69 70 /** 71 * Constructor for X time and Y double. 72 * 73 * @param grid Z values 74 * @param tloc Time coordinates 75 * @param yloc Y coordinates 76 * @param title the title 77 */ 78 public SimpleGrid( double[] grid, GeoDate[] tloc, 79 double[] yloc, String title ) 80 { 81 grid_ = grid; 82 tloc_ = new GeoDateArray( tloc ); 83 yloc_ = yloc; 84 title_ = title; 85 xTime_ = true; 86 yTime_ = false; 87 hasXEdges_ = false; 88 hasYEdges_ = false; 89 xRange_ = computeSoTRange( tloc_ ); 90 yRange_ = computeSoTRange( yloc ); 91 zRange_ = computeRange2D( grid ); 92 } 93 94 /** 95 * Constructor for X double and Y time. 96 * 97 * @param grid Z values 98 * @param xloc X coordinates 99 * @param tloc Time coordinates 100 * @param title the title 101 */ 102 public SimpleGrid( double[] grid, double[] xloc, 103 GeoDate[] tloc, String title ) 104 { 105 grid_ = grid; 106 xloc_ = xloc; 107 tloc_ = new GeoDateArray( tloc ); 108 title_ = title; 109 xTime_ = false; 110 yTime_ = true; 111 hasXEdges_ = false; 112 hasYEdges_ = false; 113 xRange_ = computeSoTRange( xloc ); 114 yRange_ = computeSoTRange( tloc_ ); 115 zRange_ = computeRange2D( grid ); 116 } 117 118 public String getTitle() 119 { 120 return title_; 121 } 122 123 public SGLabel getKeyTitle() 124 { 125 return keyTitle_; 126 } 127 128 /** 129 * Get the unique identifier. The presence of the identifier 130 * is optional, but if it is present it should be unique. This 131 * field is used to search for the layer that contains the data. 132 * 133 * @return unique identifier 134 * @see gov.noaa.pmel.sgt.Pane 135 * @see gov.noaa.pmel.sgt.Layer 136 * @since 2.0 137 */ 138 public String getId() 139 { 140 return id_; 141 } 142 143 /** 144 * Create a copy of the grid. 145 * 146 * @see SGTData 147 * @since 2.0 148 */ 149 public SGTData copy() 150 { 151 SGTGrid newGrid; 152 try 153 { 154 newGrid = (SGTGrid) clone(); 155 } 156 catch( CloneNotSupportedException e ) 157 { 158 newGrid = new SimpleGrid(); 159 } 160 return (SGTData) newGrid; 161 } 162 163 public boolean isXTime() 164 { 165 return xTime_; 166 } 167 168 public boolean isYTime() 169 { 170 return yTime_; 171 } 172 173 public SGTMetaData getXMetaData() 174 { 175 return xMetaData_; 176 } 177 178 public SGTMetaData getYMetaData() 179 { 180 return yMetaData_; 181 } 182 183 public SoTRange getXRange() 184 { 185 return xRange_.copy(); 186 } 187 188 public SoTRange getYRange() 189 { 190 return yRange_.copy(); 191 } 192 193 public void addPropertyChangeListener( PropertyChangeListener l ) 194 { 195 changes_.addPropertyChangeListener( l ); 196 } 197 198 public void removePropertyChangeListener( PropertyChangeListener l ) 199 { 200 changes_.removePropertyChangeListener( l ); 201 } 202 203 public double[] getXArray() 204 { 205 return xloc_; 206 } 207 208 /** 209 * Get the length of the x axis 210 * 211 * @since 2.0 212 */ 213 public int getXSize() 214 { 215 return xloc_.length; 216 } 217 218 public double[] getYArray() 219 { 220 return yloc_; 221 } 222 223 /** 224 * Get the length of the y axis 225 * 226 * @since 2.0 227 */ 228 public int getYSize() 229 { 230 return yloc_.length; 231 } 232 233 public double[] getZArray() 234 { 235 return grid_; 236 } 237 238 public Range2D getZRange() 239 { 240 return zRange_; 241 } 242 243 public GeoDate[] getTimeArray() 244 { 245 return tloc_.getGeoDate(); 246 } 247 248 /** 249 * Get the <code>GeoDateArray</code> object. 250 * 251 * @since 3.0 252 */ 253 public GeoDateArray getGeoDateArray() 254 { 255 return tloc_; 256 } 257 258 /** 259 * Get the length of the Time axis 260 * 261 * @since 2.0 262 */ 263 public int getTSize() 264 { 265 return tloc_.getLength(); 266 } 267 268 public SGTMetaData getZMetaData() 269 { 270 return zMetaData_; 271 } 272 273 public SGTGrid getAssociatedData() 274 { 275 return associatedData_; 276 } 277 278 public boolean hasAssociatedData() 279 { 280 return ( associatedData_ != null ); 281 } 282 283 public boolean hasXEdges() 284 { 285 return hasXEdges_; 286 } 287 288 public double[] getXEdges() 289 { 290 return xEdges_; 291 } 292 293 /** 294 * Return the range of the x edges 295 * 296 * @since 2.0 297 */ 298 public SoTRange getXEdgesRange() 299 { 300 return xEdgesRange_; 301 } 302 303 public boolean hasYEdges() 304 { 305 return hasYEdges_; 306 } 307 308 public double[] getYEdges() 309 { 310 return yEdges_; 311 } 312 313 /** 314 * Return the range of the y edges 315 * 316 * @since 2.0 317 */ 318 public SoTRange getYEdgesRange() 319 { 320 return yEdgesRange_; 321 } 322 323 public GeoDate[] getTimeEdges() 324 { 325 return tEdges_.getGeoDate(); 326 } 327 328 /** 329 * Get the <code>GeoDateArray</code> object. 330 * 331 * @since 3.0 332 */ 333 public GeoDateArray getGeoDateArrayEdges() 334 { 335 return tEdges_; 336 } 337 338 private SoTRange computeSoTRange( double[] array ) 339 { 340 Range2D range = computeRange2D( array ); 341 return new SoTRange.Double( range.start, range.end ); 342 } 343 344 private SoTRange computeSoTRange( GeoDateArray tarray ) 345 { 346 long start = Long.MAX_VALUE; 347 long end = Long.MIN_VALUE; 348 long[] tar = tarray.getTime(); 349 int count = 0; 350 for( int i = 0; i < tar.length; i++ ) 351 { 352 if( !( tar[i] == Long.MAX_VALUE ) ) 353 { 354 start = Math.min( start, tar[i] ); 355 end = Math.max( end, tar[i] ); 356 count++; 357 } 358 } 359 if( count == 0 ) 360 { 361 return new SoTRange.Time( Long.MAX_VALUE, 362 Long.MAX_VALUE ); 363 } 364 else 365 { 366 return new SoTRange.Time( start, end ); 367 } 368 } 369 370 private Range2D computeRange2D( double[] array ) 371 { 372 double start = Double.POSITIVE_INFINITY; 373 double end = Double.NEGATIVE_INFINITY; 374 int count = 0; 375 for( int i = 0; i < array.length; i++ ) 376 { 377 if( !Double.isNaN( array[i] ) ) 378 { 379 start = Math.min( start, array[i] ); 380 end = Math.max( end, array[i] ); 381 count++; 382 } 383 } 384 if( count == 0 ) 385 { 386 return new Range2D( Double.NaN, Double.NaN ); 387 } 388 else 389 { 390 return new Range2D( start, end ); 391 } 392 } 393 394 /** 395 * Set the associated data grid. 396 * <BR><B>Property Change:</B> <code>associatedDataModified</code>. 397 * 398 * @since 2.0 399 */ 400 public void setAssociatedData( SGTGrid assoc ) 401 { 402 associatedData_ = assoc; 403 changes_.firePropertyChange( "associatedDataModified", 404 null, 405 assoc ); 406 } 407 408 /** 409 * Set the values for the x grid edges. 410 */ 411 public void setXEdges( double[] edge ) 412 { 413 xEdges_ = edge; 414 hasXEdges_ = true; 415 xEdgesRange_ = computeSoTRange( edge ); 416 } 417 418 /** 419 * Set the values for the y grid edges. 420 */ 421 public void setYEdges( double[] edge ) 422 { 423 yEdges_ = edge; 424 hasYEdges_ = true; 425 yEdgesRange_ = computeSoTRange( edge ); 426 } 427 428 /** 429 * Set the values for the temporal grid edges. 430 */ 431 public void setTimeEdges( GeoDate[] edge ) 432 { 433 setTimeEdges( new GeoDateArray( edge ) ); 434 } 435 436 /** 437 * @since 3.0 438 */ 439 public void setTimeEdges( GeoDateArray tarray ) 440 { 441 tEdges_ = tarray; 442 if( xTime_ ) 443 { 444 hasXEdges_ = true; 445 xEdgesRange_ = computeSoTRange( tarray ); 446 } 447 else if( yTime_ ) 448 { 449 hasYEdges_ = true; 450 yEdgesRange_ = computeSoTRange( tarray ); 451 } 452 } 453 454 /** 455 * Set the <code>SGTMetaData</code> associated with the x 456 * coordinate. 457 */ 458 public void setXMetaData( SGTMetaData md ) 459 { 460 xMetaData_ = md; 461 } 462 463 /** 464 * Set the <code>SGTMetaData</code> associated with the y 465 * coordinate. 466 */ 467 public void setYMetaData( SGTMetaData md ) 468 { 469 yMetaData_ = md; 470 } 471 472 /** 473 * Set the <code>SGTMetaData</code> associated with the z 474 * coordinate. 475 */ 476 public void setZMetaData( SGTMetaData md ) 477 { 478 zMetaData_ = md; 479 } 480 481 /** 482 * Set the grid title 483 */ 484 public void setTitle( String title ) 485 { 486 title_ = title; 487 } 488 489 /** 490 * Set the title formatted for the <code>VectorKey</code>. 491 */ 492 public void setKeyTitle( SGLabel title ) 493 { 494 keyTitle_ = title; 495 } 496 497 /** 498 * Set the unique identifier. 499 */ 500 public void setId( String ident ) 501 { 502 id_ = ident; 503 } 504 505 /** 506 * Set the x coordinate grid centers 507 * <BR><B>Property Change:</B> <code>dataModified</code>. 508 */ 509 public void setXArray( double[] xloc ) 510 { 511 xloc_ = xloc; 512 xTime_ = false; 513 xRange_ = computeSoTRange( xloc ); 514 changes_.firePropertyChange( "dataModified", 515 new Integer( 0 ), 516 new Integer( xloc.length ) ); 517 } 518 519 /** 520 * Set the y coordinate grid centers 521 * <BR><B>Property Change:</B> <code>dataModified</code>. 522 */ 523 public void setYArray( double[] yloc ) 524 { 525 yloc_ = yloc; 526 yTime_ = false; 527 yRange_ = computeSoTRange( yloc ); 528 changes_.firePropertyChange( "dataModified", 529 new Integer( 0 ), 530 new Integer( yloc.length ) ); 531 } 532 533 /** 534 * Set the z grid values. 535 * <BR><B>Property Change:</B> <code>dataModified</code>. 536 */ 537 public void setZArray( double[] grid ) 538 { 539 grid_ = grid; 540 zRange_ = computeRange2D( grid ); 541 changes_.firePropertyChange( "dataModified", 542 new Integer( 0 ), 543 new Integer( grid.length ) ); 544 } 545 546 /** 547 * set the temporal grid centers 548 * <BR><B>Property Change:</B> <code>dataModified</code>. 549 */ 550 public void setTimeArray( GeoDate[] tloc ) 551 { 552 setTimeArray( new GeoDateArray( tloc ) ); 553 } 554 555 /** 556 * @since 3.0 557 */ 558 public void setTimeArray( GeoDateArray tarray ) 559 { 560 tloc_ = tarray; 561 if( xTime_ ) 562 { 563 xRange_ = computeSoTRange( tarray ); 564 } 565 else if( yTime_ ) 566 { 567 yRange_ = computeSoTRange( tarray ); 568 } 569 changes_.firePropertyChange( "dataModified", 570 new Integer( 0 ), 571 new Integer( tarray.getLength() ) ); 572 } 573 574 // VMIPSL 575 public boolean isRealFullGrid() 576 { 577 return _isRealFullGrid; 578 } 579 580 public void setRealFullGrid( final boolean realFullGrid ) 581 { 582 _isRealFullGrid = realFullGrid; 583 } 584 585 protected double[] xloc_; 586 protected double[] yloc_; 587 // protected GeoDate[] tloc_; 588 protected GeoDateArray tloc_; 589 protected double[] grid_; 590 protected double[] xEdges_; 591 protected double[] yEdges_; 592 // protected GeoDate[] tEdges_; 593 protected GeoDateArray tEdges_; 594 protected boolean hasXEdges_; 595 protected boolean hasYEdges_; 596 protected String title_; 597 protected SGLabel keyTitle_ = null; 598 protected String id_ = null; 599 protected boolean xTime_; 600 protected boolean yTime_; 601 /** 602 * @shapeType AggregationLink 603 * @clientRole x 604 */ 54 605 protected SGTMetaData xMetaData_ = null; 55 /**@shapeType AggregationLink 56 * @clientRole y*/ 606 /** 607 * @shapeType AggregationLink 608 * @clientRole y 609 */ 57 610 protected SGTMetaData yMetaData_ = null; 58 /**@shapeType AggregationLink 59 * @clientRole z*/ 611 /** 612 * @shapeType AggregationLink 613 * @clientRole z 614 */ 60 615 protected SGTMetaData zMetaData_ = null; 61 /**@shapeType AggregationLink 62 * @clientRole associated data*/ 616 /** 617 * @shapeType AggregationLink 618 * @clientRole associated data 619 */ 63 620 protected SGTGrid associatedData_; 64 private SoTRange xRange_ = null; 65 private SoTRange yRange_ = null; 66 private SoTRange xEdgesRange_ = null; 67 private SoTRange yEdgesRange_ = null; 68 private Range2D zRange_ = null; 69 private PropertyChangeSupport changes_ = new PropertyChangeSupport(this); 70 71 /** 72 * Default constructor. 73 */ 74 public SimpleGrid() { 75 this(null, (double[])null, (double[])null, ""); 76 } 77 /** 78 * Constructor for X and Y coordinates as double. 79 * 80 * @param grid Z values 81 * @param xloc X coordinates 82 * @param yloc Y coordinates 83 * @param title the title 84 */ 85 public SimpleGrid(double[] grid, double[] xloc, 86 double[] yloc, String title) { 87 grid_ = grid; 88 xloc_ = xloc; 89 yloc_ = yloc; 90 title_ = title; 91 xTime_ = false; 92 yTime_ = false; 93 hasXEdges_ = false; 94 hasYEdges_ = false; 95 xRange_ = computeSoTRange(xloc); 96 yRange_ = computeSoTRange(yloc); 97 zRange_ = computeRange2D(grid); 98 } 99 /** 100 * Constructor for X time and Y double. 101 * 102 * @param grid Z values 103 * @param tloc Time coordinates 104 * @param yloc Y coordinates 105 * @param title the title 106 */ 107 public SimpleGrid(double[] grid, GeoDate[] tloc, 108 double[] yloc,String title) { 109 grid_ = grid; 110 tloc_ = new GeoDateArray(tloc); 111 yloc_ = yloc; 112 title_ = title; 113 xTime_ = true; 114 yTime_ = false; 115 hasXEdges_ = false; 116 hasYEdges_ = false; 117 xRange_ = computeSoTRange(tloc_); 118 yRange_ = computeSoTRange(yloc); 119 zRange_ = computeRange2D(grid); 120 } 121 /** 122 * Constructor for X double and Y time. 123 * 124 * @param grid Z values 125 * @param xloc X coordinates 126 * @param tloc Time coordinates 127 * @param title the title 128 */ 129 public SimpleGrid(double[] grid, double[] xloc, 130 GeoDate[] tloc,String title) { 131 grid_ = grid; 132 xloc_ = xloc; 133 tloc_ = new GeoDateArray(tloc); 134 title_ = title; 135 xTime_ = false; 136 yTime_ = true; 137 hasXEdges_ = false; 138 hasYEdges_ = false; 139 xRange_ = computeSoTRange(xloc); 140 yRange_ = computeSoTRange(tloc_); 141 zRange_ = computeRange2D(grid); 142 } 143 /** 144 * Create a copy of the grid. 145 * 146 * @since 2.0 147 * @see SGTData 148 */ 149 public SGTData copy() { 150 SGTGrid newGrid; 151 try { 152 newGrid = (SGTGrid)clone(); 153 } catch (CloneNotSupportedException e) { 154 newGrid = new SimpleGrid(); 155 } 156 return (SGTData)newGrid; 157 } 158 public double[] getXArray() { 159 return xloc_; 160 } 161 /** 162 * Get the length of the x axis 163 * 164 * @since 2.0 165 */ 166 public int getXSize() { 167 return xloc_.length; 168 } 169 public double[] getYArray() { 170 return yloc_; 171 } 172 /** 173 * Get the length of the y axis 174 * 175 * @since 2.0 176 */ 177 public int getYSize() { 178 return yloc_.length; 179 } 180 public double[] getZArray() { 181 return grid_; 182 } 183 public GeoDate[] getTimeArray() { 184 return tloc_.getGeoDate(); 185 } 186 /** 187 * Get the <code>GeoDateArray</code> object. 188 * 189 * @since 3.0 190 */ 191 public GeoDateArray getGeoDateArray() { 192 return tloc_; 193 } 194 /** 195 * Get the length of the Time axis 196 * 197 * @since 2.0 198 */ 199 public int getTSize() { 200 return tloc_.getLength(); 201 } 202 public boolean isXTime() { 203 return xTime_; 204 } 205 public boolean isYTime() { 206 return yTime_; 207 } 208 public SGTMetaData getXMetaData() { 209 return xMetaData_; 210 } 211 public SGTMetaData getYMetaData() { 212 return yMetaData_; 213 } 214 public SGTMetaData getZMetaData() { 215 return zMetaData_; 216 } 217 public String getTitle() { 218 return title_; 219 } 220 /** 221 * Set the associated data grid. 222 * <BR><B>Property Change:</B> <code>associatedDataModified</code>. 223 * 224 * @since 2.0 225 */ 226 public void setAssociatedData(SGTGrid assoc) { 227 associatedData_ = assoc; 228 changes_.firePropertyChange("associatedDataModified", 229 null, 230 assoc); 231 } 232 public SGTGrid getAssociatedData() { 233 return associatedData_; 234 } 235 public boolean hasAssociatedData() { 236 return (associatedData_ != null); 237 } 238 public boolean hasXEdges() { 239 return hasXEdges_; 240 } 241 public double[] getXEdges() { 242 return xEdges_; 243 } 244 /** 245 * Set the values for the x grid edges. 246 */ 247 public void setXEdges(double[] edge) { 248 xEdges_ = edge; 249 hasXEdges_ = true; 250 xEdgesRange_ = computeSoTRange(edge); 251 } 252 public boolean hasYEdges() { 253 return hasYEdges_; 254 } 255 public double[] getYEdges() { 256 return yEdges_; 257 } 258 /** 259 * Set the values for the y grid edges. 260 */ 261 public void setYEdges(double[] edge) { 262 yEdges_ = edge; 263 hasYEdges_ = true; 264 yEdgesRange_ = computeSoTRange(edge); 265 } 266 public GeoDate[] getTimeEdges() { 267 return tEdges_.getGeoDate(); 268 } 269 /** 270 * Get the <code>GeoDateArray</code> object. 271 * 272 * @since 3.0 273 */ 274 public GeoDateArray getGeoDateArrayEdges() { 275 return tEdges_; 276 } 277 /** 278 * Set the values for the temporal grid edges. 279 */ 280 public void setTimeEdges(GeoDate[] edge) { 281 setTimeEdges(new GeoDateArray(edge)); 282 } 283 /** 284 * @since 3.0 285 */ 286 public void setTimeEdges(GeoDateArray tarray) { 287 tEdges_ = tarray; 288 if(xTime_) { 289 hasXEdges_ = true; 290 xEdgesRange_ = computeSoTRange(tarray); 291 } else if(yTime_){ 292 hasYEdges_ = true; 293 yEdgesRange_ = computeSoTRange(tarray); 294 } 295 } 296 /** 297 * Set the <code>SGTMetaData</code> associated with the x 298 * coordinate. 299 */ 300 public void setXMetaData(SGTMetaData md) { 301 xMetaData_ = md; 302 } 303 /** 304 * Set the <code>SGTMetaData</code> associated with the y 305 * coordinate. 306 */ 307 public void setYMetaData(SGTMetaData md) { 308 yMetaData_ = md; 309 } 310 /** 311 * Set the <code>SGTMetaData</code> associated with the z 312 * coordinate. 313 */ 314 public void setZMetaData(SGTMetaData md) { 315 zMetaData_ = md; 316 } 317 /** 318 * Set the grid title 319 */ 320 public void setTitle(String title) { 321 title_ = title; 322 } 323 public SGLabel getKeyTitle() { 324 return keyTitle_; 325 } 326 /** Set the title formatted for the <code>VectorKey</code>. */ 327 public void setKeyTitle(SGLabel title) { 328 keyTitle_ = title; 329 } 330 /** 331 * Get the unique identifier. The presence of the identifier 332 * is optional, but if it is present it should be unique. This 333 * field is used to search for the layer that contains the data. 334 * 335 * @since 2.0 336 * @return unique identifier 337 * @see gov.noaa.pmel.sgt.Pane 338 * @see gov.noaa.pmel.sgt.Layer 339 */ 340 public String getId() { 341 return id_; 342 } 343 /** 344 * Set the unique identifier. 345 */ 346 public void setId(String ident) { 347 id_ = ident; 348 } 349 /** 350 * Set the x coordinate grid centers 351 * <BR><B>Property Change:</B> <code>dataModified</code>. 352 */ 353 public void setXArray(double[] xloc) { 354 xloc_ = xloc; 355 xTime_ = false; 356 xRange_ = computeSoTRange(xloc); 357 changes_.firePropertyChange("dataModified", 358 new Integer(0), 359 new Integer(xloc.length)); 360 } 361 /** 362 * Set the y coordinate grid centers 363 * <BR><B>Property Change:</B> <code>dataModified</code>. 364 */ 365 public void setYArray(double[] yloc) { 366 yloc_ = yloc; 367 yTime_ = false; 368 yRange_ = computeSoTRange(yloc); 369 changes_.firePropertyChange("dataModified", 370 new Integer(0), 371 new Integer(yloc.length)); 372 } 373 /** 374 * Set the z grid values. 375 * <BR><B>Property Change:</B> <code>dataModified</code>. 376 */ 377 public void setZArray(double[] grid) { 378 grid_ = grid; 379 zRange_ = computeRange2D(grid); 380 changes_.firePropertyChange("dataModified", 381 new Integer(0), 382 new Integer(grid.length)); 383 } 384 /** 385 * set the temporal grid centers 386 * <BR><B>Property Change:</B> <code>dataModified</code>. 387 */ 388 public void setTimeArray(GeoDate[] tloc) { 389 setTimeArray(new GeoDateArray(tloc)); 390 } 391 /** 392 * @since 3.0 393 */ 394 public void setTimeArray(GeoDateArray tarray) { 395 tloc_ = tarray; 396 if(xTime_) { 397 xRange_ = computeSoTRange(tarray); 398 } else if(yTime_) { 399 yRange_ = computeSoTRange(tarray); 400 } 401 changes_.firePropertyChange("dataModified", 402 new Integer(0), 403 new Integer(tarray.getLength())); 404 } 405 public SoTRange getXRange() { 406 return xRange_.copy(); 407 } 408 public SoTRange getYRange() { 409 return yRange_.copy(); 410 } 411 public Range2D getZRange() { 412 return zRange_; 413 } 414 /** 415 * Return the range of the x edges 416 * 417 * @since 2.0 418 */ 419 public SoTRange getXEdgesRange() { 420 return xEdgesRange_; 421 } 422 /** 423 * Return the range of the y edges 424 * 425 * @since 2.0 426 */ 427 public SoTRange getYEdgesRange() { 428 return yEdgesRange_; 429 } 430 431 public void addPropertyChangeListener(PropertyChangeListener l) { 432 changes_.addPropertyChangeListener(l); 433 } 434 public void removePropertyChangeListener(PropertyChangeListener l) { 435 changes_.removePropertyChangeListener(l); 436 } 437 438 private SoTRange computeSoTRange(double[] array) { 439 Range2D range = computeRange2D(array); 440 return new SoTRange.Double(range.start, range.end); 441 } 442 private SoTRange computeSoTRange(GeoDateArray tarray) { 443 long start = Long.MAX_VALUE; 444 long end = Long.MIN_VALUE; 445 long[] tar = tarray.getTime(); 446 int count = 0; 447 for(int i=0; i < tar.length; i++) { 448 if(!(tar[i] == Long.MAX_VALUE)) { 449 start = Math.min(start, tar[i]); 450 end = Math.max(end, tar[i]); 451 count++; 452 } 453 } 454 if(count == 0) { 455 return new SoTRange.Time(Long.MAX_VALUE, 456 Long.MAX_VALUE); 457 } else { 458 return new SoTRange.Time(start, end); 459 } 460 } 461 private Range2D computeRange2D(double[] array) { 462 double start = Double.POSITIVE_INFINITY; 463 double end = Double.NEGATIVE_INFINITY; 464 int count = 0; 465 for(int i=0; i < array.length; i++) { 466 if(!Double.isNaN(array[i])) { 467 start = Math.min(start, array[i]); 468 end = Math.max(end, array[i]); 469 count++; 470 } 471 } 472 if(count == 0) { 473 return new Range2D(Double.NaN, Double.NaN); 474 } else { 475 return new Range2D(start, end); 476 } 477 } 621 private SoTRange xRange_ = null; 622 private SoTRange yRange_ = null; 623 private SoTRange xEdgesRange_ = null; 624 private SoTRange yEdgesRange_ = null; 625 private Range2D zRange_ = null; 626 private PropertyChangeSupport changes_ = new PropertyChangeSupport( this ); 627 //VMIPSL 628 private boolean _isRealFullGrid = true; 478 629 }
Note: See TracChangeset
for help on using the changeset viewer.