Просмотр исходного кода

Remove default events, and serialiaze gauge

tentone 5 лет назад
Родитель
Сommit
3ec5532d3f
3 измененных файлов с 20 добавлено и 22 удалено
  1. 0 10
      source/objects/Box.js
  2. 0 10
      source/objects/Circle.js
  3. 20 2
      source/objects/chart/Gauge.js

+ 0 - 10
source/objects/Box.js

@@ -48,16 +48,6 @@ Box.prototype.constructor = Box;
 Box.prototype.type = "Box";
 Object2D.register(Box, "Box");
 
-Box.prototype.onPointerEnter = function(pointer, viewport)
-{
-	this.fillStyle = new ColorStyle("#CCCCCC");
-};
-
-Box.prototype.onPointerLeave = function(pointer, viewport)
-{
-	this.fillStyle = new ColorStyle("#FFFFFF");
-};
-
 Box.prototype.isInside = function(point)
 {
 	return this.box.containsPoint(point);

+ 0 - 10
source/objects/Circle.js

@@ -55,16 +55,6 @@ Circle.prototype.isInside = function(point)
 	return point.length() <= this.radius;
 };
 
-Circle.prototype.onPointerEnter = function(pointer, viewport)
-{
-	this.fillStyle = new ColorStyle("#CCCCCC");
-};
-
-Circle.prototype.onPointerLeave = function(pointer, viewport)
-{
-	this.fillStyle = new ColorStyle("#FFFFFF");
-};
-
 Circle.prototype.draw = function(context, viewport, canvas)
 {
 	context.beginPath();

+ 20 - 2
source/objects/chart/Gauge.js

@@ -150,7 +150,16 @@ Gauge.prototype.serialize = function(recursive)
 {
 	var data = Object2D.prototype.serialize.call(this, recursive);
 
-	// TODO <ADD CODE HERE>
+	data.value = this.value;
+	data.min = this.min;
+	data.max = this.max;
+	data.radius = this.radius;
+	data.lineWidth = this.lineWidth;
+	data.startAngle = this.startAngle;
+	data.endAngle = this.endAngle;
+	data.dial = this.dial;
+	data.baseStyle = this.baseStyle !== null ? this.baseStyle.serialize() : null;
+	data.barStyle = this.barStyle !== null ? this.barStyle.serialize() : null;
 
 	return data;
 };
@@ -159,7 +168,16 @@ Gauge.prototype.parse = function(data, root)
 {
 	Object2D.prototype.parse.call(this, data, root);
 
-	// TODO <ADD CODE HERE>
+	this.value = data.value;
+	this.min = data.min;
+	this.max = data.max;
+	this.radius = data.radius;
+	this.lineWidth = data.lineWidth;
+	this.startAngle = data.startAngle;
+	this.endAngle = data.endAngle;
+	this.dial = data.dial;
+	this.baseStyle = data.baseStyle !== null ? Style.parse(data.baseStyle) : null;
+	this.barStyle = data.barStyle !== null ? Style.parse(data.barStyle) : null;
 };