コード例 #1
0
ファイル: FeatureCreator.cs プロジェクト: ututrc/ME-UnitySDK
        private void CreateAnnotation(AnnotationElement annotation, Feature feature)
        {
            if (annotation.name.IsNullOrEmpty())
            {
                return;
            }

            AnnotationCreator creator = FindObjectOfType <AnnotationCreator> ();

            if (creator == null)
            {
                return;
            }

            AnnotationsRoot root = feature.gameObject.GetComponentInChildren <AnnotationsRoot> ();

            if (root == null)
            {
                GameObject rootGO = new GameObject("Annotations");
                rootGO.transform.SetParent(feature.transform, false);
                rootGO.transform.localPosition = Vector3.zero;
                root = rootGO.AddComponent <AnnotationsRoot> ();
            }

            AnnotationVisualization.AnnotationData data = new AnnotationVisualization.AnnotationData();
            data.name        = annotation.name;
            data.description = annotation.description;
            data.position    = new Vector3(annotation.ParsePos()[0], annotation.ParsePos()[1], annotation.ParsePos()[2]);

            creator.CreateAnnotation(data, root.gameObject);
        }
コード例 #2
0
        UserElementMixin(
            String name,
            Location location,
            String documentation,
            AnnotationElement annotationElement)
        {
            this._name          = name;
            this._location      = location;
            this._documentation = documentation;

            throw new NotImplementedException();
//        ImmutableMap.Builder<String, String> annotations = ImmutableMap.builder();
//        if (annotationElement != null) {
//            annotations.putAll(annotationElement.values());
//        }
//        this._annotations = annotations.build();
        }
コード例 #3
0
        /// <summary>
        /// Updates the annotation
        /// </summary>
        public override void UpdateAnnotation()
        {
            if (_image != null && X1 != null && Y1 != null)
            {
                Point           textPosition = new Point();
                Size            desiredSize;
                Rect            heightAndWidthRect;
                RotateTransform rotate = new RotateTransform {
                    Angle = this.Angle
                };
                Point positionedPoint = new Point(0, 0);
                TextElement.Visibility = Visibility.Visible;
                switch (CoordinateUnit)
                {
                case CoordinateUnit.Axis:
                    base.UpdateAnnotation();
                    if (XAxis != null && YAxis != null)
                    {
                        ImageHeight = Annotation.ConvertData(Y2, YAxis);
                        ImageWidth  = Annotation.ConvertData(X2, XAxis);
                        if (CoordinateUnit == CoordinateUnit.Axis && EnableClipping)
                        {
                            x1          = GetClippingValues(x1, XAxis);
                            y1          = GetClippingValues(y1, YAxis);
                            ImageWidth  = GetClippingValues(ImageWidth, XAxis);
                            ImageHeight = GetClippingValues(ImageHeight, YAxis);
                        }

                        Point point = (XAxis.Orientation == Orientation.Horizontal)
                                          ? new Point(
                            this.Chart.ValueToPointRelativeToAnnotation(XAxis, x1),
                            this.Chart.ValueToPointRelativeToAnnotation(YAxis, y1))
                                            : new Point(
                            this.Chart.ValueToPointRelativeToAnnotation(YAxis, y1),
                            this.Chart.ValueToPointRelativeToAnnotation(XAxis, x1));
                        Point point2 = (XAxis.Orientation == Orientation.Horizontal)
                                                     ? new Point(
                            Chart.ValueToPointRelativeToAnnotation(XAxis, ImageWidth),
                            this.Chart.ValueToPointRelativeToAnnotation(YAxis, ImageHeight))
                                                     : new Point(
                            this.Chart.ValueToPointRelativeToAnnotation(YAxis, ImageHeight),
                            Chart.ValueToPointRelativeToAnnotation(XAxis, ImageWidth));
                        point.Y                  = (double.IsNaN(point.Y)) ? 0 : point.Y;
                        point.X                  = (double.IsNaN(point.X)) ? 0 : point.X;
                        point2.Y                 = (double.IsNaN(point2.Y)) ? 0 : point2.Y;
                        point2.X                 = (double.IsNaN(point2.X)) ? 0 : point2.X;
                        heightAndWidthRect       = new Rect(point, point2);
                        _image.Height            = heightAndWidthRect.Height;
                        _image.Width             = heightAndWidthRect.Width;
                        AnnotationElement.Height = heightAndWidthRect.Height;
                        AnnotationElement.Width  = heightAndWidthRect.Width;
                        Point ensurePoint = this.EnsurePoint(point, point2);
                        desiredSize     = new Size(heightAndWidthRect.Width, heightAndWidthRect.Height);
                        positionedPoint = GetElementPosition(
                            new Size(heightAndWidthRect.Width, heightAndWidthRect.Height), ensurePoint);

                        TextElement.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                        if (X2 != null && Y2 != null)
                        {
                            textPosition = GetTextPosition(desiredSize, new Point(0, 0), new Size(TextElement.DesiredSize.Width, TextElement.DesiredSize.Height));
                            Canvas.SetLeft(TextElement, textPosition.X);
                            Canvas.SetTop(TextElement, textPosition.Y);
                            Canvas.SetLeft(AnnotationElement, positionedPoint.X);
                            Canvas.SetTop(AnnotationElement, positionedPoint.Y);
                        }
                        else
                        {
                            _image.Height = 0;
                            _image.Width  = 0;
                            if (ContentTemplate != null)
                            {
                                AnnotationElement.Height = TextElement.DesiredSize.Height;
                                AnnotationElement.Width  = TextElement.DesiredSize.Width;

                                textPosition = GetTextPositionWithX1Y1(point, new Size(TextElement.DesiredSize.Width, TextElement.DesiredSize.Height));
                                Canvas.SetLeft(TextElement, 0);
                                Canvas.SetTop(TextElement, 0);
                                Canvas.SetLeft(AnnotationElement, textPosition.X);
                                Canvas.SetTop(AnnotationElement, textPosition.Y);
                            }
                        }

                        Point centerPoint = new Point(
                            positionedPoint.X + (AnnotationElement.Width / 2),
                            positionedPoint.Y + (AnnotationElement.Height / 2));
                        Rect rotated = this.RotateElement(this.Angle, AnnotationElement);
                        AnnotationElement.RenderTransformOrigin = new Point(0.5, 0.5);
                        AnnotationElement.RenderTransform       = rotate;
                        if (this.Angle > 0)
                        {
                            RotatedRect = new Rect(
                                centerPoint.X - (rotated.Width / 2),
                                centerPoint.Y - (rotated.Height / 2),
                                rotated.Width,
                                rotated.Height);
                        }
                        else
                        {
                            RotatedRect = new Rect(
                                centerPoint.X - (AnnotationElement.Width / 2),
                                centerPoint.Y - (AnnotationElement.Height / 2),
                                AnnotationElement.Width,
                                AnnotationElement.Height);
                        }
                    }

                    break;

                case CoordinateUnit.Pixel:
                    Point elementPoint1 = new Point(Convert.ToDouble(X1), Convert.ToDouble(Y1));
                    Point elementPoint2 = new Point(Convert.ToDouble(X2), Convert.ToDouble(Y2));
                    heightAndWidthRect       = new Rect(elementPoint1, elementPoint2);
                    _image.Height            = heightAndWidthRect.Height;
                    _image.Width             = heightAndWidthRect.Width;
                    AnnotationElement.Height = heightAndWidthRect.Height;
                    AnnotationElement.Width  = heightAndWidthRect.Width;
#if __IOS__ || __ANDROID__
                    positionedPoint = GetElementPosition(_imageBorder, elementPoint1);
#else
                    positionedPoint = GetElementPosition(_image, elementPoint1);
#endif
                    desiredSize = new Size(_image.Width, _image.Height);
                    TextElement.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                    if (X2 != null && Y2 != null)
                    {
                        textPosition = GetTextPosition(
                            desiredSize,
                            new Point(0, 0),
                            new Size(TextElement.DesiredSize.Width, TextElement.DesiredSize.Height));
                        Canvas.SetLeft(AnnotationElement, positionedPoint.X);
                        Canvas.SetTop(AnnotationElement, positionedPoint.Y);
                        Canvas.SetLeft(TextElement, textPosition.X);
                        Canvas.SetTop(TextElement, textPosition.Y);
                    }
                    else
                    {
                        _image.Height = 0;
                        _image.Width  = 0;
                        if (ContentTemplate != null)
                        {
                            AnnotationElement.Height = TextElement.DesiredSize.Height;
                            AnnotationElement.Width  = TextElement.DesiredSize.Width;
                            textPosition             = GetTextPositionWithX1Y1(elementPoint1, new Size(TextElement.DesiredSize.Width, TextElement.DesiredSize.Height));
                            Canvas.SetLeft(TextElement, 0);
                            Canvas.SetTop(TextElement, 0);
                            Canvas.SetLeft(AnnotationElement, textPosition.X);
                            Canvas.SetTop(AnnotationElement, textPosition.Y);
                        }
                    }

                    Rect _rotated = this.RotateElement(this.Angle, AnnotationElement);
                    AnnotationElement.RenderTransformOrigin = new Point(0.5, 0.5);
                    AnnotationElement.RenderTransform       = rotate;
                    Point _centerPoint = new Point(
                        positionedPoint.X + (AnnotationElement.Width / 2),
                        positionedPoint.Y + (AnnotationElement.Height / 2));
                    if (this.Angle > 0)
                    {
                        RotatedRect = new Rect(
                            _centerPoint.X - (_rotated.Width / 2),
                            _centerPoint.Y - (_rotated.Height / 2),
                            _rotated.Width,
                            _rotated.Height);
                    }
                    else
                    {
                        RotatedRect = new Rect(
                            _centerPoint.X - (AnnotationElement.Width / 2),
                            _centerPoint.Y - (AnnotationElement.Height / 2),
                            AnnotationElement.Width,
                            AnnotationElement.Height);
                    }
                    break;
                }
            }
            else if (_image != null)
            {
                _image.Height = 0;
                _image.Width  = 0;
                AnnotationElement.ClearValue(Canvas.LeftProperty);
                AnnotationElement.ClearValue(Canvas.TopProperty);
                TextElement.Visibility = Visibility.Collapsed;
            }
        }
コード例 #4
0
ファイル: ExecutionAdapter.cs プロジェクト: voidALPHA/cgc_viz
        private static void SetAnnotationOnInstructionMutable(MutableObject instruction, AnnotationElement annotation, Dictionary <int, string> comms)
        {
            if (annotation.ByteString.StartsWith("Receive") || annotation.ByteString.StartsWith("Transmit"))
            {
                comms.Add((int)annotation.Header.InstructionCount, annotation.ByteString);
            }

            if (instruction.ContainsKey("AnnotationText") || instruction.ContainsKey("Annotation Event Type"))
            {
                Debug.LogWarningFormat("Overwriting the annotation on an instruction (index {0})...!", annotation.Header.InstructionCount);
            }

            instruction["Annotation Text"]       = annotation.ByteString;
            instruction["Annotation Event Type"] = annotation.EventType;
            instruction["Annotated"]             = true;
        }
コード例 #5
0
ファイル: CallGraph.cs プロジェクト: voidALPHA/cgc_viz
 public void RecordAnnotation(AnnotationElement annotation)
 {
     Annotations.Add(annotation);
 }