strokeandfillelement.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2007 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview A thick wrapper around elements with stroke and fill.
  16. * @author robbyw@google.com (Robby Walker)
  17. */
  18. goog.provide('goog.graphics.ext.StrokeAndFillElement');
  19. goog.require('goog.graphics.ext.Element');
  20. /**
  21. * Interface for a graphics element that has a stroke and fill.
  22. * This is the base interface for ellipse, rectangle and other
  23. * shape interfaces.
  24. * You should not construct objects from this constructor. Use a subclass.
  25. * @param {goog.graphics.ext.Group} group Parent for this element.
  26. * @param {goog.graphics.StrokeAndFillElement} wrapper The thin wrapper to wrap.
  27. * @constructor
  28. * @extends {goog.graphics.ext.Element}
  29. */
  30. goog.graphics.ext.StrokeAndFillElement = function(group, wrapper) {
  31. goog.graphics.ext.Element.call(this, group, wrapper);
  32. };
  33. goog.inherits(
  34. goog.graphics.ext.StrokeAndFillElement, goog.graphics.ext.Element);
  35. /**
  36. * Sets the fill for this element.
  37. * @param {goog.graphics.Fill?} fill The fill object.
  38. */
  39. goog.graphics.ext.StrokeAndFillElement.prototype.setFill = function(fill) {
  40. this.getWrapper().setFill(fill);
  41. };
  42. /**
  43. * Sets the stroke for this element.
  44. * @param {goog.graphics.Stroke?} stroke The stroke object.
  45. */
  46. goog.graphics.ext.StrokeAndFillElement.prototype.setStroke = function(stroke) {
  47. this.getWrapper().setStroke(stroke);
  48. };
  49. /**
  50. * Redraw the rectangle. Called when the coordinate system is changed.
  51. * @protected
  52. * @override
  53. */
  54. goog.graphics.ext.StrokeAndFillElement.prototype.redraw = function() {
  55. this.getWrapper().reapplyStroke();
  56. };