aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs125
1 files changed, 107 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 2640f08..e577fbe 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -443,7 +443,16 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
443 endPoint.X = (int) x; 443 endPoint.X = (int) x;
444 endPoint.Y = (int) y; 444 endPoint.Y = (int) y;
445 Image image = ImageHttpRequest(nextLine); 445 Image image = ImageHttpRequest(nextLine);
446 graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); 446 if (image != null)
447 {
448 graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y);
449 }
450 else
451 {
452 graph.DrawString("URL couldn't be resolved or is", new Font("Arial",6), myBrush, startPoint);
453 graph.DrawString("not an image. Please check URL.", new Font("Arial", 6), myBrush, new Point(startPoint.X, 12 + startPoint.Y));
454 graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
455 }
447 startPoint.X += endPoint.X; 456 startPoint.X += endPoint.X;
448 startPoint.Y += endPoint.Y; 457 startPoint.Y += endPoint.Y;
449 } 458 }
@@ -469,13 +478,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
469 startPoint.X += endPoint.X; 478 startPoint.X += endPoint.X;
470 startPoint.Y += endPoint.Y; 479 startPoint.Y += endPoint.Y;
471 } 480 }
481 else if (nextLine.StartsWith("FillPolygon"))
482 {
483 PointF[] points = null;
484 GetParams(partsDelimiter, ref nextLine, 11, ref points);
485 graph.FillPolygon(myBrush, points);
486 }
472 else if (nextLine.StartsWith("Ellipse")) 487 else if (nextLine.StartsWith("Ellipse"))
473 { 488 {
474 float x = 0; 489 float x = 0;
475 float y = 0; 490 float y = 0;
476 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); 491 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
477 endPoint.X = (int) x; 492 endPoint.X = (int)x;
478 endPoint.Y = (int) y; 493 endPoint.Y = (int)y;
479 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); 494 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
480 startPoint.X += endPoint.X; 495 startPoint.X += endPoint.X;
481 startPoint.Y += endPoint.Y; 496 startPoint.Y += endPoint.Y;
@@ -492,30 +507,31 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
492 nextLine = nextLine.Remove(0, 8); 507 nextLine = nextLine.Remove(0, 8);
493 nextLine = nextLine.Trim(); 508 nextLine = nextLine.Trim();
494 509
495 string [] fprops = nextLine.Split(partsDelimiter); 510 string[] fprops = nextLine.Split(partsDelimiter);
496 foreach (string prop in fprops) { 511 foreach (string prop in fprops)
497 512 {
513
498 switch (prop) 514 switch (prop)
499 { 515 {
500 case "B": 516 case "B":
501 if (!(myFont.Bold)) 517 if (!(myFont.Bold))
502 myFont = new Font(myFont, myFont.Style | FontStyle.Bold); 518 myFont = new Font(myFont, myFont.Style | FontStyle.Bold);
503 break; 519 break;
504 case "I": 520 case "I":
505 if (!(myFont.Italic)) 521 if (!(myFont.Italic))
506 myFont = new Font(myFont, myFont.Style | FontStyle.Italic); 522 myFont = new Font(myFont, myFont.Style | FontStyle.Italic);
507 break; 523 break;
508 case "U": 524 case "U":
509 if (!(myFont.Underline)) 525 if (!(myFont.Underline))
510 myFont = new Font(myFont, myFont.Style | FontStyle.Underline); 526 myFont = new Font(myFont, myFont.Style | FontStyle.Underline);
511 break; 527 break;
512 case "S": 528 case "S":
513 if (!(myFont.Strikeout)) 529 if (!(myFont.Strikeout))
514 myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout); 530 myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout);
515 break; 531 break;
516 case "R": 532 case "R":
517 myFont = new Font(myFont, FontStyle.Regular); 533 myFont = new Font(myFont, FontStyle.Regular);
518 break; 534 break;
519 } 535 }
520 } 536 }
521 } 537 }
@@ -532,6 +548,57 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
532 float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture); 548 float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
533 drawPen.Width = size; 549 drawPen.Width = size;
534 } 550 }
551 else if (nextLine.StartsWith("PenCap"))
552 {
553 bool start = true, end = true;
554 nextLine = nextLine.Remove(0, 6);
555 nextLine = nextLine.Trim();
556 string[] cap = nextLine.Split(partsDelimiter);
557 if (cap[0].ToLower() == "start")
558 end = false;
559 else if (cap[0].ToLower() == "end")
560 start = false;
561 else if (cap[0].ToLower() != "both")
562 return;
563 string type = cap[1].ToLower();
564
565 if (end)
566 {
567 switch (type)
568 {
569 case "arrow":
570 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
571 break;
572 case "round":
573 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
574 break;
575 case "diamond":
576 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
577 break;
578 case "flat":
579 drawPen.EndCap = System.Drawing.Drawing2D.LineCap.Flat;
580 break;
581 }
582 }
583 if (start)
584 {
585 switch (type)
586 {
587 case "arrow":
588 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
589 break;
590 case "round":
591 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
592 break;
593 case "diamond":
594 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
595 break;
596 case "flat":
597 drawPen.StartCap = System.Drawing.Drawing2D.LineCap.Flat;
598 break;
599 }
600 }
601 }
535 else if (nextLine.StartsWith("PenColour")) 602 else if (nextLine.StartsWith("PenColour"))
536 { 603 {
537 nextLine = nextLine.Remove(0, 9); 604 nextLine = nextLine.Remove(0, 9);
@@ -542,7 +609,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
542 if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex)) 609 if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
543 { 610 {
544 newColour = Color.FromArgb(hex); 611 newColour = Color.FromArgb(hex);
545 } 612 }
546 else 613 else
547 { 614 {
548 // this doesn't fail, it just returns black if nothing is found 615 // this doesn't fail, it just returns black if nothing is found
@@ -582,18 +649,40 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
582 } 649 }
583 } 650 }
584 651
652 private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref PointF[] points)
653 {
654 line = line.Remove(0, startLength);
655 string[] parts = line.Split(partsDelimiter);
656 if (parts.Length > 1 && parts.Length % 2 == 0)
657 {
658 points = new PointF[parts.Length / 2];
659 for (int i = 0; i < parts.Length; i = i + 2)
660 {
661 string xVal = parts[i].Trim();
662 string yVal = parts[i+1].Trim();
663 float x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture);
664 float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture);
665 PointF point = new PointF(x, y);
666 points[i / 2] = point;
667 }
668 }
669 }
670
585 private Bitmap ImageHttpRequest(string url) 671 private Bitmap ImageHttpRequest(string url)
586 { 672 {
673 try
674 {
587 WebRequest request = HttpWebRequest.Create(url); 675 WebRequest request = HttpWebRequest.Create(url);
588//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 676//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
589//Ckrinke Stream str = null; 677//Ckrinke Stream str = null;
590 HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); 678 HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
591 if (response.StatusCode == HttpStatusCode.OK) 679 if (response.StatusCode == HttpStatusCode.OK)
592 { 680 {
593 Bitmap image = new Bitmap(response.GetResponseStream()); 681 Bitmap image = new Bitmap(response.GetResponseStream());
594 return image; 682 return image;
683 }
595 } 684 }
596 685 catch { }
597 return null; 686 return null;
598 } 687 }
599 } 688 }