333 float a = (((int)span) != 0) ? (above * v.getAlignment(View.Y_AXIS)) / span: 0; 334 return a; 335 default: 336 throw new IllegalArgumentException("Invalid axis: " + axis); 337 } 338 } 339 340 public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f) { 341 super.changedUpdate(changes, a, f); 342 int pos = changes.getOffset(); 343 if (pos <= getStartOffset() && (pos + changes.getLength()) >= 344 getEndOffset()) { 345 setPropertiesFromAttributes(); 346 } 347 } 348 349 /** 350 * Determines the preferred span for this view along an 351 * axis. 352 * 353 * @param axis may be either <code>View.X_AXIS</code> 354 * or <code>View.Y_AXIS</code> 355 * @return the span the view would like to be rendered into >= 0; 356 * typically the view is told to render into the span 357 * that is returned, although there is no guarantee; 358 * the parent may choose to resize or break the view 359 * @exception IllegalArgumentException for an invalid axis type 360 */ 361 public float getPreferredSpan(int axis) { 362 return super.getPreferredSpan(axis); 363 } 364 365 /** 366 * Determines the minimum span for this view along an 367 * axis. 368 * 369 * @param axis may be either <code>View.X_AXIS</code> 370 * or <code>View.Y_AXIS</code> 371 * @return the span the view would like to be rendered into >= 0; 372 * typically the view is told to render into the span 373 * that is returned, although there is no guarantee; 374 * the parent may choose to resize or break the view 375 * @exception IllegalArgumentException for an invalid axis type 376 */ 377 public float getMinimumSpan(int axis) { 378 return super.getMinimumSpan(axis); 379 } 380 381 /** 382 * Determines the maximum span for this view along an 383 * axis. 384 * 385 * @param axis may be either <code>View.X_AXIS</code> 386 * or <code>View.Y_AXIS</code> 387 * @return the span the view would like to be rendered into >= 0; 388 * typically the view is told to render into the span 389 * that is returned, although there is no guarantee; 390 * the parent may choose to resize or break the view 391 * @exception IllegalArgumentException for an invalid axis type 392 */ 393 public float getMaximumSpan(int axis) { 394 return super.getMaximumSpan(axis); 395 } 396 397 /** 398 * Update any cached values that come from attributes. 399 */ 400 protected void setPropertiesFromAttributes() { 401 402 // update attributes 403 StyleSheet sheet = getStyleSheet(); 404 attr = sheet.getViewAttributes(this); 405 406 // Reset the painter 411 (short) painter.getInset(BOTTOM, this), 412 (short) painter.getInset(RIGHT, this)); 413 } 414 415 // Get the width/height 416 cssWidth = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.WIDTH); 417 cssHeight = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.HEIGHT); 418 } 419 420 /** 421 * Convenient method to get the StyleSheet. 422 * 423 * @return the StyleSheet 424 */ 425 protected StyleSheet getStyleSheet() { 426 HTMLDocument doc = (HTMLDocument) getDocument(); 427 return doc.getStyleSheet(); 428 } 429 430 /** 431 * Constrains <code>want</code> to fit in the minimum size specified 432 * by <code>min</code>. 433 */ 434 private void constrainSize(int axis, SizeRequirements want, 435 SizeRequirements min) { 436 if (min.minimum > want.minimum) { 437 want.minimum = want.preferred = min.minimum; 438 want.maximum = Math.max(want.maximum, min.maximum); 439 } 440 } 441 442 private AttributeSet attr; 443 private StyleSheet.BoxPainter painter; 444 445 private CSS.LengthValue cssWidth; 446 private CSS.LengthValue cssHeight; 447 448 } | 333 float a = (((int)span) != 0) ? (above * v.getAlignment(View.Y_AXIS)) / span: 0; 334 return a; 335 default: 336 throw new IllegalArgumentException("Invalid axis: " + axis); 337 } 338 } 339 340 public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f) { 341 super.changedUpdate(changes, a, f); 342 int pos = changes.getOffset(); 343 if (pos <= getStartOffset() && (pos + changes.getLength()) >= 344 getEndOffset()) { 345 setPropertiesFromAttributes(); 346 } 347 } 348 349 /** 350 * Determines the preferred span for this view along an 351 * axis. 352 * 353 * @param axis may be either {@code View.X_AXIS} 354 * or {@code View.Y_AXIS} 355 * @return the span the view would like to be rendered into >= 0; 356 * typically the view is told to render into the span 357 * that is returned, although there is no guarantee; 358 * the parent may choose to resize or break the view 359 * @exception IllegalArgumentException for an invalid axis type 360 */ 361 public float getPreferredSpan(int axis) { 362 return super.getPreferredSpan(axis); 363 } 364 365 /** 366 * Determines the minimum span for this view along an 367 * axis. 368 * 369 * @param axis may be either {@code View.X_AXIS} 370 * or {@code View.Y_AXIS} 371 * @return the span the view would like to be rendered into >= 0; 372 * typically the view is told to render into the span 373 * that is returned, although there is no guarantee; 374 * the parent may choose to resize or break the view 375 * @exception IllegalArgumentException for an invalid axis type 376 */ 377 public float getMinimumSpan(int axis) { 378 return super.getMinimumSpan(axis); 379 } 380 381 /** 382 * Determines the maximum span for this view along an 383 * axis. 384 * 385 * @param axis may be either {@code View.X_AXIS} 386 * or {@code View.Y_AXIS} 387 * @return the span the view would like to be rendered into >= 0; 388 * typically the view is told to render into the span 389 * that is returned, although there is no guarantee; 390 * the parent may choose to resize or break the view 391 * @exception IllegalArgumentException for an invalid axis type 392 */ 393 public float getMaximumSpan(int axis) { 394 return super.getMaximumSpan(axis); 395 } 396 397 /** 398 * Update any cached values that come from attributes. 399 */ 400 protected void setPropertiesFromAttributes() { 401 402 // update attributes 403 StyleSheet sheet = getStyleSheet(); 404 attr = sheet.getViewAttributes(this); 405 406 // Reset the painter 411 (short) painter.getInset(BOTTOM, this), 412 (short) painter.getInset(RIGHT, this)); 413 } 414 415 // Get the width/height 416 cssWidth = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.WIDTH); 417 cssHeight = (CSS.LengthValue) attr.getAttribute(CSS.Attribute.HEIGHT); 418 } 419 420 /** 421 * Convenient method to get the StyleSheet. 422 * 423 * @return the StyleSheet 424 */ 425 protected StyleSheet getStyleSheet() { 426 HTMLDocument doc = (HTMLDocument) getDocument(); 427 return doc.getStyleSheet(); 428 } 429 430 /** 431 * Constrains {@code want} to fit in the minimum size specified 432 * by {@code min}. 433 */ 434 private void constrainSize(int axis, SizeRequirements want, 435 SizeRequirements min) { 436 if (min.minimum > want.minimum) { 437 want.minimum = want.preferred = min.minimum; 438 want.maximum = Math.max(want.maximum, min.maximum); 439 } 440 } 441 442 private AttributeSet attr; 443 private StyleSheet.BoxPainter painter; 444 445 private CSS.LengthValue cssWidth; 446 private CSS.LengthValue cssHeight; 447 448 } |