Ejemplo n.º 1
0
        /// <summary>
        /// Constructor. Create from Shape. Shallow copy of subshapes, deep copy of substrokes.
        /// </summary>
        /// <param name="shape">A Shape.</param>
        public Shape(Shape shape)
        {
            this.Name = shape.Name;
            List <Substroke> newSubstrokes = new List <Substroke>(shape._substrokes.Count);

            foreach (Substroke s in shape._substrokes)
            {
                Substroke newS = s.CloneConstruct();
                newS.ParentShape = this;
                newSubstrokes.Add(newS);
            }

            _substrokes = new List <Substroke>(shape._substrokes.Count);
            foreach (Substroke s in newSubstrokes)
            {
                AddSubstroke(s);
            }
            _xmlAttributes = shape._xmlAttributes.Clone();

            AlreadyGrouped = shape.AlreadyGrouped;
            AlreadyLabeled = shape.AlreadyLabeled;
            UserLabeled    = shape.UserLabeled;

            TemplateName    = shape.TemplateName;
            TemplateDrawing = shape.TemplateDrawing;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a Stroke from the corresponding Substrokes and XML attributes
        /// </summary>
        /// <param name="substrokes">Substrokes of the Stroke</param>
        /// <param name="XmlAttrs">The XML attributes of the stroke</param>
        public Stroke(ArrayList substrokes, XmlStructs.XmlShapeAttrs XmlAttrs)
        {
            this.substrokes = new ArrayList();
            this.XmlAttrs   = XmlAttrs;

            this.AddSubstrokes(substrokes);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a Stroke from the corresponding Substrokes and XML attributes
        /// </summary>
        /// <param name="substrokes">Substrokes of the Stroke</param>
        /// <param name="attrs">The XML attributes of the stroke</param>
        public Stroke(IEnumerable <Substroke> substrokes, XmlStructs.XmlShapeAttrs attrs)
        {
            _substrokes         = new List <Substroke>();
            _xmlAttributes      = attrs;
            _xmlAttributes.Type = "stroke";

            AddSubstrokes(substrokes);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a Substroke from an ArrayList of Points and the XML attributes
        /// </summary>
        /// <param name="pts">ArrayList of Points</param>
        /// <param name="XmlAttrs">The XML attributes of the stroke</param>
        public Substroke(ArrayList pts, XmlStructs.XmlShapeAttrs XmlAttrs)
        {
            this.points       = new ArrayList();
            this.parentShapes = new ArrayList();
            this.parentStroke = null;

            this.XmlAttrs = XmlAttrs;
            this.AddPoints(pts);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Construct a Shape with given Shapes, Substrokes, and XML attributes.
        /// </summary>
        /// <param name="shapes">Shapes to add</param>
        /// <param name="substrokes">Substrokes to add</param>
        /// <param name="XmlAttrs">XML attributes of the Shape</param>
        public Shape(ArrayList shapes, ArrayList substrokes, XmlStructs.XmlShapeAttrs XmlAttrs)
        {
            this.shapes      = new ArrayList();
            this.substrokes  = new ArrayList();
            this.parentShape = null;

            this.XmlAttrs = XmlAttrs;
            this.AddShapes(shapes);
            this.AddSubstrokes(substrokes);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a Substroke from a List of Points and the XML attributes
        /// </summary>
        /// <param name="points">List of Points</param>
        /// <param name="XmlAttrs">The XML attributes of the stroke</param>
        public Substroke(IEnumerable <Point> points, XmlStructs.XmlShapeAttrs XmlAttrs)
        {
            List <Point> pts = new List <Point>(points);

            if (pts.Count == 0)
            {
                throw new ArgumentException("Substrokes must contain a nonzero number of points");
            }

            pts.Sort();
            _points        = pts.AsReadOnly();
            _parentShape   = null;
            _parentStroke  = null;
            _endpoints     = null;
            _xmlAttributes = XmlAttrs;

            _spatialLength = new Lazy <double>(calculateSpatialLength);
            _endpoints     = new Lazy <EndPoint[]>(findEndpoints);

            if (_points.Count > 0)
            {
                _xmlAttributes.Time = _points[_points.Count - 1].Time;
            }
            else
            {
                _xmlAttributes.Time = null;
            }

            float minX = Single.PositiveInfinity;
            float maxX = Single.NegativeInfinity;

            float minY = Single.PositiveInfinity;
            float maxY = Single.NegativeInfinity;

            Point point;
            int   len = _points.Count;
            int   i;

            for (i = 0; i < len; ++i)
            {
                point = _points[i];

                minX = Math.Min(minX, point.X);
                minY = Math.Min(minY, point.Y);

                maxX = Math.Max(maxX, point.X);
                maxY = Math.Max(maxY, point.Y);
            }

            _xmlAttributes.Type   = "substroke";
            _xmlAttributes.X      = minX;
            _xmlAttributes.Y      = minY;
            _xmlAttributes.Width  = maxX - minX;
            _xmlAttributes.Height = maxY - minY;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a Substroke from a List of Points and the XML attributes
        /// </summary>
        /// <param name="points">List of Points</param>
        /// <param name="XmlAttrs">The XML attributes of the stroke</param>
        public Substroke(IEnumerable <Point> points, XmlStructs.XmlShapeAttrs XmlAttrs)
        {
            _points        = new List <Point>(points);
            _parentShape   = null;
            _parentStroke  = null;
            _endpoints     = null;
            _xmlAttributes = XmlAttrs;


            _spatialLength = new Lazy <double>(calculateSpatialLength);
            _endpoints     = new Lazy <EndPoint[]>(findEndpoints);

            UpdateAttributes();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Construct a Shape with given Shapes, Substrokes, and XML attributes.
        /// </summary>
        /// <param name="substrokes">Substrokes to add</param>
        /// <param name="XmlAttrs">XML attributes of the Shape</param>
        public Shape(IEnumerable <Substroke> substrokes, XmlStructs.XmlShapeAttrs XmlAttrs)
        {
            correspondingSubCircuit = int.MinValue;
            this._substrokes        = new List <Substroke>();

            this._xmlAttributes = XmlAttrs;

            this.AddSubstrokes(substrokes);

            AlreadyGrouped = false;
            AlreadyLabeled = false;
            UserLabeled    = false;

            Type = (XmlAttrs.Type == null) ? (new ShapeType()) : (Domain.LogicDomain.getType(XmlAttrs.Type));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Construct a Shape with given Shapes, Substrokes, and XML attributes.
        /// </summary>
        /// <param name="substrokes">Substrokes to add</param>
        /// <param name="XmlAttrs">XML attributes of the Shape</param>
        public Shape(IEnumerable <Substroke> substrokes, XmlStructs.XmlShapeAttrs XmlAttrs)
        {
            this._substrokes = new List <Substroke>();

            this._xmlAttributes = XmlAttrs;

            this.AddSubstrokes(substrokes);

            Orientation = 0;

            AlreadyGrouped = false;
            AlreadyLabeled = false;
            UserLabeled    = false;

            Type = (XmlAttrs.Type == null) ? (new ShapeType()) : (Domain.LogicDomain.getType(XmlAttrs.Type));
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a Substroke from an array of Points and the XML attributes
 /// </summary>
 /// <param name="pts">Array of Points</param>
 /// <param name="XmlAttrs">The XML attributes of the stroke</param>
 public Substroke(Point[] pts, XmlStructs.XmlShapeAttrs XmlAttrs)
     : this(new ArrayList(pts), XmlAttrs)
 {
     // Calls the main constructor
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Construct a Shape with given Shapes, Substrokes, and XML attributes.
 /// </summary>
 /// <param name="shapes">Shapes to add</param>
 /// <param name="substrokes">Substrokes to add</param>
 /// <param name="XmlAttrs">XML attributes of the Shape</param>
 public Shape(Shape[] shapes, Substroke[] substrokes, XmlStructs.XmlShapeAttrs XmlAttrs)
     : this(new ArrayList(shapes), new ArrayList(substrokes), XmlAttrs)
 {
     // Calls the main constructor
 }