├── .gitignore ├── NPlot ├── GtkTest │ ├── GtkSamples │ │ ├── GtkPlotQE.cs │ │ ├── GtkPlotSample.cs │ │ ├── GtkPlotWave.cs │ │ ├── PlotABC.cs │ │ ├── PlotCandle.cs │ │ ├── PlotCircular.cs │ │ ├── PlotDataset.cs │ │ ├── PlotGaussian.cs │ │ ├── PlotImage.cs │ │ ├── PlotLabelAxis.cs │ │ ├── PlotLogLin.cs │ │ ├── PlotLogLog.cs │ │ ├── PlotMarkers.cs │ │ ├── PlotMockup.cs │ │ ├── PlotParticles.cs │ │ ├── PlotSinc.cs │ │ └── PlotWavelet.cs │ ├── GtkTest.csproj │ ├── GtkTest │ │ ├── Gtk.AxisTestsForm.cs │ │ ├── Gtk.FinancialDemo.cs │ │ ├── Gtk.InteractivePlotSurface2D.cs │ │ ├── Gtk.MainWindow.cs │ │ ├── Gtk.MenuForm.cs │ │ ├── Gtk.PlotSurface2D.cs │ │ ├── Gtk.PlotSurface2DSamples.cs │ │ ├── class.png │ │ └── package.png │ └── Resources │ │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ ├── format │ │ ├── prop-base │ │ │ ├── AxisTestsForm.resx.svn-base │ │ │ ├── FinancialDemo.resx.svn-base │ │ │ ├── MenuForm.resx.svn-base │ │ │ ├── NPlotDemo-icon.ico.svn-base │ │ │ ├── PlotSurface2DDemo.resx.svn-base │ │ │ ├── asx_jbh.xml.svn-base │ │ │ ├── light.wav.svn-base │ │ │ └── pattern01.jpg.svn-base │ │ └── text-base │ │ │ ├── AxisTestsForm.resx.svn-base │ │ │ ├── FinancialDemo.resx.svn-base │ │ │ ├── MenuForm.resx.svn-base │ │ │ ├── NPlotDemo-icon.ico.svn-base │ │ │ ├── PlotSurface2DDemo.resx.svn-base │ │ │ ├── asx_jbh.xml.svn-base │ │ │ ├── light.wav.svn-base │ │ │ └── pattern01.jpg.svn-base │ │ ├── NPlotDemo-icon.ico │ │ ├── asx_jbh.xml │ │ ├── pattern01.jpg │ │ └── sound.wav ├── NPlot.sln ├── NPlot │ ├── Interactions │ │ ├── AxisDrag.cs │ │ ├── HorizontalGuideline.cs │ │ ├── Interaction.cs │ │ ├── InteractivePlotSurface2D.cs │ │ ├── KeyActions.cs │ │ ├── Measure.cs │ │ ├── PlotDrag.cs │ │ ├── PlotSelection.cs │ │ ├── PlotZoom.cs │ │ └── VerticalGuideline.cs │ ├── NPlot.csproj │ └── NPlot │ │ ├── AdapterUtils.cs │ │ ├── ArrowItem.cs │ │ ├── AssemblyInfo.cs │ │ ├── AxesConstraint.cs │ │ ├── Axis.cs │ │ ├── AxisPosition.cs │ │ ├── BarPlot.cs │ │ ├── BasePlot.cs │ │ ├── BaseSequencePlot.cs │ │ ├── Bitmap.PlotSurface2D.cs │ │ ├── CandlePlot.cs │ │ ├── CursorType.cs │ │ ├── DateTimeAxis.cs │ │ ├── FilledRegion.cs │ │ ├── FontScaler.cs │ │ ├── Grid.cs │ │ ├── HistogramPlot.cs │ │ ├── HorizontalLine.cs │ │ ├── IDrawable.cs │ │ ├── IGradient.cs │ │ ├── IPlot.cs │ │ ├── IPlotSurface2D.cs │ │ ├── ISequencePlot.cs │ │ ├── ITransform2D.cs │ │ ├── ImagePlot.cs │ │ ├── LabelAxis.cs │ │ ├── LabelPointPlot.cs │ │ ├── Legend.cs │ │ ├── LegendBase.cs │ │ ├── LinePlot.cs │ │ ├── LinearAxis.cs │ │ ├── LinearGradient.cs │ │ ├── LogAxis.cs │ │ ├── Marker.cs │ │ ├── MarkerItem.cs │ │ ├── Modifier.cs │ │ ├── NPlotException.cs │ │ ├── PageAlignedPhysicalAxis.cs │ │ ├── PhysicalAxis.cs │ │ ├── PiAxis.cs │ │ ├── PiePlot.cs │ │ ├── PlotSurface2D.cs │ │ ├── PointD.cs │ │ ├── PointPlot.cs │ │ ├── RectangleBrushes.cs │ │ ├── RectangleD.cs │ │ ├── SequenceAdapter.cs │ │ ├── StartStep.cs │ │ ├── StepGradient.cs │ │ ├── StepPlot.cs │ │ ├── TextItem.cs │ │ ├── TradingDateTimeAxis.cs │ │ ├── Transform2D.cs │ │ ├── Utils.cs │ │ └── VerticalLine.cs └── SwfTest │ ├── Resources │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ ├── format │ │ ├── prop-base │ │ │ ├── AxisTestsForm.resx.svn-base │ │ │ ├── FinancialDemo.resx.svn-base │ │ │ ├── MenuForm.resx.svn-base │ │ │ ├── NPlotDemo-icon.ico.svn-base │ │ │ ├── PlotSurface2DDemo.resx.svn-base │ │ │ ├── asx_jbh.xml.svn-base │ │ │ ├── light.wav.svn-base │ │ │ └── pattern01.jpg.svn-base │ │ └── text-base │ │ │ ├── AxisTestsForm.resx.svn-base │ │ │ ├── FinancialDemo.resx.svn-base │ │ │ ├── MenuForm.resx.svn-base │ │ │ ├── NPlotDemo-icon.ico.svn-base │ │ │ ├── PlotSurface2DDemo.resx.svn-base │ │ │ ├── asx_jbh.xml.svn-base │ │ │ ├── light.wav.svn-base │ │ │ └── pattern01.jpg.svn-base │ ├── NPlotDemo-icon.ico │ ├── asx_jbh.xml │ ├── pattern01.jpg │ └── sound.wav │ ├── SwfSamples │ ├── PlotABC.cs │ ├── PlotCandle.cs │ ├── PlotCircular.cs │ ├── PlotDataset.cs │ ├── PlotGaussian.cs │ ├── PlotImage.cs │ ├── PlotLabelAxis.cs │ ├── PlotLogLin.cs │ ├── PlotLogLog.cs │ ├── PlotMarkers.cs │ ├── PlotMockup.cs │ ├── PlotParticles.cs │ ├── PlotSample.cs │ ├── PlotSinc.cs │ ├── PlotWavelet.cs │ ├── SwfPlotQE.cs │ ├── SwfPlotSample.cs │ └── SwfPlotWave.cs │ ├── SwfTest.csproj │ └── SwfTest │ ├── Swf.AxisTestsForm.cs │ ├── Swf.FinancialDemo.cs │ ├── Swf.InteractivePlotSurface2D.cs │ ├── Swf.MenuForm.cs │ └── Swf.PlotSurface2DSamples.cs ├── README.md └── nplot_introduction.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific files 2 | *.suo 3 | *.user 4 | *.sln.docstates 5 | *.sln.cache 6 | *~ 7 | *.dotCover 8 | *.pidb 9 | *.userprefs 10 | *.usertasks 11 | *.mdb 12 | .DS_Store 13 | 14 | # Build results 15 | [Dd]ebug/ 16 | [Rr]elease/ 17 | x64/ 18 | build/ 19 | [Bb]in/ 20 | [Oo]bj/ 21 | -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkSamples/GtkPlotQE.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | 6 | using Gtk; 7 | using NPlot; 8 | 9 | namespace GtkSamples 10 | { 11 | public class PlotQE : PlotSample 12 | { 13 | private bool qeExampleTimerEnabled; 14 | private double[] PlotQEExampleValues; 15 | private string[] PlotQEExampleTextValues; 16 | 17 | public PlotQE () 18 | { 19 | infoText = ""; 20 | infoText += "Cs2Te Photocathode QE evolution Example. Demonstrates - \n"; 21 | infoText += " * LabelPointPlot (allows text to be associated with points) \n"; 22 | infoText += " * PointPlot droplines \n"; 23 | infoText += " * LabelAxis \n"; 24 | infoText += " * PhysicalSpacingMin property of LabelAxis \n"; 25 | infoText += "You cannot interact with this chart"; 26 | 27 | qeExampleTimerEnabled = true; 28 | plotSurface.Clear(); 29 | 30 | int len = 24; 31 | string[] s = new string[len]; 32 | PlotQEExampleValues = new double[len]; 33 | PlotQEExampleTextValues = new string[len]; 34 | 35 | Random r = new Random(); 36 | 37 | for (int i=0; i 18.0f) 41 | { 42 | PlotQEExampleTextValues[i] = "KCsTe"; 43 | } 44 | else 45 | { 46 | PlotQEExampleTextValues[i] = ""; 47 | } 48 | s[i] = i.ToString("00") + ".1"; 49 | } 50 | 51 | PointPlot pp = new PointPlot(); 52 | pp.DataSource = PlotQEExampleValues; 53 | pp.Marker = new Marker( Marker.MarkerType.Square, 10 ); 54 | pp.Marker.DropLine = true; 55 | pp.Marker.Pen = Pens.CornflowerBlue; 56 | pp.Marker.Filled = false; 57 | plotSurface.Add( pp ); 58 | 59 | LabelPointPlot tp1 = new LabelPointPlot(); 60 | tp1.DataSource = PlotQEExampleValues; 61 | tp1.TextData = PlotQEExampleTextValues; 62 | tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above; 63 | tp1.Marker = new Marker( Marker.MarkerType.None, 10 ); 64 | plotSurface.Add( tp1 ); 65 | 66 | LabelAxis la = new LabelAxis( plotSurface.XAxis1 ); 67 | for (int i=0; i 99 | /// Callback for QE example timer tick. 100 | /// 101 | private bool qeExampleTimer_Tick() 102 | { 103 | if (!qeExampleTimerEnabled ) return false; 104 | 105 | Random r = new Random(); 106 | 107 | for (int i=0; i 18.0f ) { 111 | PlotQEExampleTextValues[i] = "KCsTe"; 112 | } 113 | else { 114 | PlotQEExampleTextValues[i] = ""; 115 | } 116 | } 117 | 118 | plotSurface.Refresh(); 119 | 120 | //returning true means that the timeout routine should be invoked 121 | //again after the timeout period expires. Returning false will 122 | //terminate the timeout ie when it has been disabled. 123 | return qeExampleTimerEnabled; 124 | } 125 | 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkSamples/GtkPlotSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | 6 | using Gtk; 7 | using NPlot; 8 | 9 | namespace GtkSamples 10 | { 11 | public class PlotSample 12 | { 13 | protected NPlot.Gtk.InteractivePlotSurface2D plotSurface; 14 | protected string infoText = ""; 15 | 16 | public PlotSample() 17 | { 18 | plotSurface = new NPlot.Gtk.InteractivePlotSurface2D (); 19 | 20 | // Set defaults for the sample plotSurface 21 | plotSurface.AutoScaleAutoGeneratedAxes = false; 22 | plotSurface.AutoScaleTitle = false; 23 | plotSurface.Canvas.ModifyBg (StateType.Normal); 24 | plotSurface.Legend = null; 25 | plotSurface.Canvas.Name = "plotSurface"; 26 | plotSurface.ShowCoordinates = true; 27 | plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; 28 | plotSurface.Title = ""; 29 | plotSurface.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); 30 | } 31 | 32 | public string InfoText 33 | { 34 | get { return infoText; } 35 | } 36 | 37 | public DrawingArea Canvas 38 | { 39 | get { return plotSurface.Canvas; } 40 | } 41 | 42 | public NPlot.Gtk.InteractivePlotSurface2D PlotSurface 43 | { 44 | get { return plotSurface; } 45 | } 46 | 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkSamples/GtkPlotWave.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | 6 | using NPlot; 7 | using Gtk; 8 | 9 | namespace GtkSamples 10 | { 11 | public class PlotWave : PlotSample 12 | { 13 | public PlotWave() : base () 14 | { 15 | infoText = ""; 16 | infoText += "Sound Wave Example. Demonstrates - \n"; 17 | infoText += " * StepPlot (centered) and HorizontalLine IDrawables \n"; 18 | infoText += " * AxisDrag Interaction - try left clicking and dragging X or Y axes \n"; 19 | infoText += " * Vertical & Horizontal GuideLines - without fragmentation problems! \n"; 20 | infoText += " * Rubberband Selection - click and drag to zoom an area of the plot \n"; 21 | infoText += " * Key actions : +,- zoom, left/right/up/down pan, Home restores original scale and origin"; 22 | 23 | System.IO.Stream file = 24 | Assembly.GetExecutingAssembly().GetManifestResourceStream("GtkTest.Resources.sound.wav"); 25 | 26 | System.Int16[] w = new short[5000]; 27 | byte[] a = new byte[10000]; 28 | 29 | file.Read( a, 0, 10000 ); 30 | for (int i=100; i<5000; ++i) { 31 | w[i] = BitConverter.ToInt16(a,i*2); 32 | } 33 | file.Close(); 34 | 35 | plotSurface.Clear(); 36 | 37 | plotSurface.AddInteraction (new AxisDrag ()); 38 | plotSurface.AddInteraction (new KeyActions ()); 39 | plotSurface.AddInteraction (new NPlot.PlotSelection (Color.Gray)); 40 | plotSurface.AddInteraction (new VerticalGuideline (Color.Gray)); 41 | plotSurface.AddInteraction (new HorizontalGuideline (Color.Gray)); 42 | 43 | plotSurface.Add(new HorizontalLine(0.0, Color.LightBlue)); 44 | 45 | StepPlot sp = new StepPlot (); 46 | sp.DataSource = w; 47 | sp.Color = Color.Yellow; 48 | sp.Center = true; 49 | plotSurface.Add( sp ); 50 | 51 | plotSurface.YAxis1.FlipTicksLabel = true; 52 | 53 | plotSurface.PlotBackColor = Color.DarkBlue; 54 | plotSurface.Canvas.ModifyBg (StateType.Normal, new Gdk.Color (100, 100, 100) ); 55 | plotSurface.XAxis1.Color = Color.White; 56 | plotSurface.YAxis1.Color = Color.White; 57 | 58 | plotSurface.Refresh(); 59 | 60 | } 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkSamples/PlotABC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | 6 | using NPlot; 7 | 8 | namespace GtkSamples 9 | { 10 | public class PlotABC : PlotSample 11 | { 12 | public PlotABC () 13 | { 14 | infoText = ""; 15 | infoText += "ABC (logo for australian broadcasting commission) Example. Demonstrates - \n"; 16 | infoText += " * How to set the background of a plotsurface as an image. \n"; 17 | infoText += " * EqualAspectRatio axis constraint \n"; 18 | infoText += " * Plot Zoom with Mouse Wheel, and mouse position Focus point"; 19 | 20 | plotSurface.Clear(); 21 | const int size = 200; 22 | float [] xs = new float [size]; 23 | float [] ys = new float [size]; 24 | for (int i=0; i 2 | 3 | 4 | Debug 5 | x86 6 | 10.0.0 7 | 2.0 8 | {5415AE99-2877-4730-AF1F-F94DCD12C31A} 9 | Exe 10 | GtkTest 11 | GtkTest 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | x86 22 | false 23 | 24 | 25 | none 26 | true 27 | bin\Release 28 | prompt 29 | 4 30 | x86 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | False 64 | 65 | 66 | False 67 | 68 | 69 | False 70 | 71 | 72 | False 73 | 74 | 75 | False 76 | 77 | 78 | 79 | 80 | 81 | {E4B99177-77A3-4C92-B881-A6CB57E3BF89} 82 | NPlot 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkTest/Gtk.MainWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gtk; 3 | 4 | namespace Samples 5 | { 6 | public class MainWindow: Window 7 | { 8 | TreeView samplesTree; 9 | TreeStore store; 10 | Image icon; 11 | VBox sampleBox; 12 | Label title; 13 | Widget currentSample; 14 | 15 | DataField nameCol = new DataField (); 16 | DataField widgetCol = new DataField (); 17 | DataField iconCol = new DataField (); 18 | 19 | 20 | public MainWindow () 21 | { 22 | Title = "NPlot.Gtk Samples Application"; 23 | Width = 500; 24 | Height = 400; 25 | 26 | Menu menu = new Menu (); 27 | 28 | var file = new MenuItem ("File"); 29 | file.SubMenu = new Menu (); 30 | file.SubMenu.Items.Add (new MenuItem ("Open")); 31 | file.SubMenu.Items.Add (new MenuItem ("New")); 32 | MenuItem mi = new MenuItem ("Close"); 33 | mi.Clicked += delegate { 34 | Application.Exit(); 35 | }; 36 | file.SubMenu.Items.Add (mi); 37 | menu.Items.Add (file); 38 | 39 | var edit = new MenuItem ("Edit"); 40 | edit.SubMenu = new Menu (); 41 | edit.SubMenu.Items.Add (new MenuItem ("Copy")); 42 | edit.SubMenu.Items.Add (new MenuItem ("Cut")); 43 | edit.SubMenu.Items.Add (new MenuItem ("Paste")); 44 | menu.Items.Add (edit); 45 | 46 | MainMenu = menu; 47 | 48 | 49 | HPaned box = new HPaned (); 50 | 51 | icon = Image.LoadFromResource ("class.png"); //HWT chk 52 | 53 | store = new TreeStore (nameCol, iconCol, widgetCol); 54 | samplesTree = new TreeView (); 55 | samplesTree.Columns.Add ("Name", iconCol, nameCol); 56 | 57 | AddSample (null, "Boxes", typeof(Boxes)); 58 | AddSample (null, "Buttons", typeof(ButtonSample)); 59 | AddSample (null, "CheckBox", typeof(Checkboxes)); 60 | AddSample (null, "Clipboard", typeof(ClipboardSample)); 61 | AddSample (null, "ColorSelector", typeof(ColorSelectorSample)); 62 | AddSample (null, "ComboBox", typeof(ComboBoxes)); 63 | AddSample (null, "Drag & Drop", typeof(DragDrop)); 64 | AddSample (null, "Expander", typeof (ExpanderSample)); 65 | AddSample (null, "Progress bars", typeof(ProgressBarSample)); 66 | AddSample (null, "Frames", typeof(Frames)); 67 | AddSample (null, "Images", typeof(Images)); 68 | AddSample (null, "Labels", typeof(Labels)); 69 | AddSample (null, "ListBox", typeof(ListBoxSample)); 70 | AddSample (null, "LinkLabels", typeof(LinkLabels)); 71 | AddSample (null, "ListView", typeof(ListView1)); 72 | AddSample (null, "Markdown", typeof (MarkDownSample)); 73 | 74 | samplesTree.DataSource = store; 75 | 76 | box.Panel1.Content = samplesTree; 77 | 78 | sampleBox = new VBox (); 79 | title = new Label ("Sample:"); 80 | sampleBox.PackStart (title, BoxMode.None); 81 | 82 | box.Panel2.Content = sampleBox; 83 | box.Panel2.Resize = true; 84 | box.Position = 160; 85 | 86 | Content = box; 87 | 88 | samplesTree.SelectionChanged += HandleSamplesTreeSelectionChanged; 89 | 90 | CloseRequested += HandleCloseRequested; 91 | } 92 | 93 | void HandleCloseRequested (object sender, CloseRequestedEventArgs args) 94 | { 95 | args.Handled = !MessageDialog.Confirm ("Samples will be closed", Command.Ok); 96 | } 97 | 98 | protected override void Dispose (bool disposing) 99 | { 100 | base.Dispose (disposing); 101 | 102 | if (statusIcon != null) { 103 | statusIcon.Dispose (); 104 | } 105 | } 106 | 107 | void HandleSamplesTreeSelectionChanged (object sender, EventArgs e) 108 | { 109 | if (samplesTree.SelectedRow != null) { 110 | if (currentSample != null) 111 | sampleBox.Remove (currentSample); 112 | Sample s = store.GetNavigatorAt (samplesTree.SelectedRow).GetValue (widgetCol); 113 | if (s.Type != null) { 114 | if (s.Widget == null) 115 | s.Widget = (Widget)Activator.CreateInstance (s.Type); 116 | sampleBox.PackStart (s.Widget, BoxMode.FillAndExpand); 117 | } 118 | 119 | } 120 | } 121 | 122 | 123 | TreePosition AddSample (TreePosition pos, string name, Type sampleType) 124 | { 125 | //if (page != null) 126 | // page.Margin.SetAll (5); 127 | return store.AddNode (pos).SetValue (nameCol, name).SetValue (iconCol, icon).SetValue (widgetCol, new Sample (sampleType)).CurrentPosition; 128 | } 129 | } 130 | 131 | class Sample 132 | { 133 | public Sample (Type type) 134 | { 135 | Type = type; 136 | } 137 | 138 | public Type Type; 139 | public Widget Widget; 140 | } 141 | } 142 | 143 | -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkTest/Gtk.MenuForm.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * Gtk.MenuForm.cs 5 | * 6 | * This is NPlot.MenuForm with interactive features added and 7 | * implemented using Gtk# Graphics (Gtk.MenuForm) (HWT 2011) 8 | * 9 | * Copyright (C) 2003-2009 Matt Howlett and others. 10 | * All rights reserved. 11 | * 12 | * Redistribution and use in source and binary forms, with or without modification, 13 | * are permitted provided that the following conditions are met: 14 | * 15 | * 1. Redistributions of source code must retain the above copyright notice, this 16 | * list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, 18 | * this list of conditions and the following disclaimer in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 3. Neither the name of NPlot nor the names of its contributors may 21 | * be used to endorse or promote products derived from this software without 22 | * specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 32 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | using System; 37 | using System.Drawing; 38 | using System.Collections; 39 | using System.ComponentModel; 40 | using System.Threading; 41 | 42 | using Gtk; 43 | 44 | namespace NPlotDemo 45 | { 46 | /// 47 | /// Summary description for MenuForm. 48 | /// 49 | public class MenuForm : Gtk.Window 50 | { 51 | private Gtk.Label demosLabel; 52 | private Gtk.Button plotSurface2DDemoButton; 53 | private Gtk.Button multiPlotDemoButton; 54 | private Gtk.Label testsLabel; 55 | private Gtk.ComboBox TestSelectComboBox; 56 | private Gtk.Button RunTestButton; 57 | private Gtk.Button quitButton; 58 | private Gtk.Window displayForm = null; 59 | 60 | public MenuForm() : base ("Gtk# Demo") 61 | { 62 | InitializeComponent(); 63 | } 64 | 65 | #region Gtk Menu Window generation 66 | /// 67 | /// Replaces Windows Form Designer code 68 | /// 69 | private void InitializeComponent() 70 | { 71 | SetSizeRequest( 192, 240 ); // Define MenuForm size 72 | // 73 | // Define an 8x6 table on which to lay out the test buttons, etc 74 | // 75 | Gtk.Table layout = new Gtk.Table ( 8, 6, true ); 76 | layout.BorderWidth = 8; 77 | layout.ColumnSpacing = 2; 78 | layout.RowSpacing = 2; 79 | Add( layout ); 80 | 81 | // Create menu components, then add to layout 82 | // 83 | // DemosLabel 84 | // 85 | demosLabel = new Gtk.Label( "Demos" ); 86 | layout.Attach( demosLabel, 0,2, 0,1 ); 87 | // 88 | // plotSurface2DDemoButton 89 | // 90 | plotSurface2DDemoButton = new Gtk.Button( "PlotSurface2D Demo" ); 91 | plotSurface2DDemoButton.Clicked += new System.EventHandler(this.plotSurface2DDemoButton_Click); 92 | layout.Attach( plotSurface2DDemoButton, 0,6, 1,2 ); 93 | // 94 | // multiPlotDemoButton 95 | // 96 | multiPlotDemoButton = new Gtk.Button( "Multi Plot Demo" ); 97 | multiPlotDemoButton.Clicked += new System.EventHandler(this.runDemoButton_Click); 98 | layout.Attach( multiPlotDemoButton, 0,6, 2,3 ); 99 | // 100 | // testsLabel 101 | // 102 | testsLabel = new Gtk.Label( "Tests" ); 103 | layout.Attach ( testsLabel, 0,2, 3,4 ); 104 | // 105 | // TestSelectComboBox 106 | // 107 | // 108 | TestSelectComboBox = ComboBox.NewText (); 109 | TestSelectComboBox.AppendText ("Axis Test"); 110 | TestSelectComboBox.AppendText ("PlotSurface2D"); 111 | layout.Attach ( TestSelectComboBox, 0,6, 4,5 ); 112 | // 113 | // RunTestButton 114 | // 115 | RunTestButton = new Gtk.Button( "Run Selected Test" ); 116 | RunTestButton.Clicked += new System.EventHandler(this.RunTestButton_Click); 117 | layout.Attach ( RunTestButton, 0,6, 5,6 ); 118 | // 119 | // quitButton 120 | // 121 | quitButton = new Gtk.Button ( "Quit" ); 122 | quitButton.Clicked += new System.EventHandler(this.quitButton_Click); 123 | layout.Attach ( quitButton, 2,4, 7,8, 0,0,0,0 ); 124 | 125 | } 126 | #endregion 127 | 128 | [STAThread] 129 | static void Main() 130 | { 131 | Application.Init(); // Initialise Gtk 132 | MenuForm mf = new MenuForm (); 133 | mf.ShowAll(); 134 | Application.Run(); 135 | } 136 | 137 | private void runDemoButton_Click(object sender, System.EventArgs e) 138 | { 139 | displayForm = new FinancialDemo(); 140 | displayForm.ShowAll(); 141 | } 142 | 143 | private void plotSurface2DDemoButton_Click(object sender, System.EventArgs e) 144 | { 145 | displayForm = new PlotSurface2DDemo(); 146 | displayForm.ShowAll(); 147 | } 148 | 149 | 150 | private void quitButton_Click(object sender, System.EventArgs e) 151 | { 152 | Application.Quit(); 153 | } 154 | 155 | private void RunTestButton_Click(object sender, System.EventArgs e) 156 | { 157 | TreeIter iter; 158 | bool activeIter; 159 | string str; 160 | 161 | activeIter = TestSelectComboBox.GetActiveIter (out iter); 162 | if (activeIter) 163 | { 164 | str = (string)TestSelectComboBox.Model.GetValue (iter, 0); 165 | if (str.Equals("Axis Test")) 166 | { 167 | displayForm = new AxisTestsForm(); 168 | displayForm.ShowAll(); 169 | } 170 | if (str.Equals("PlotSurface2D")) 171 | { 172 | displayForm = new PlotSurface2DDemo(); 173 | displayForm.ShowAll(); 174 | } 175 | } 176 | } 177 | 178 | 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkTest/class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/GtkTest/class.png -------------------------------------------------------------------------------- /NPlot/GtkTest/GtkTest/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/GtkTest/package.png -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 53 4 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources 5 | END 6 | NPlotDemo-icon.ico 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 72 10 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/NPlotDemo-icon.ico 11 | END 12 | PlotSurface2DDemo.resx 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 76 16 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/PlotSurface2DDemo.resx 17 | END 18 | light.wav 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 63 22 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/light.wav 23 | END 24 | MenuForm.resx 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 67 28 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/MenuForm.resx 29 | END 30 | FinancialDemo.resx 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 72 34 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/FinancialDemo.resx 35 | END 36 | AxisTestsForm.resx 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 72 40 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/AxisTestsForm.resx 41 | END 42 | asx_jbh.xml 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 65 46 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/asx_jbh.xml 47 | END 48 | pattern01.jpg 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 67 52 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/pattern01.jpg 53 | END 54 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/entries: -------------------------------------------------------------------------------- 1 | 8 2 | 3 | dir 4 | 31 5 | https://nplot.svn.sourceforge.net/svnroot/nplot/trunk/demo/csharp/resources 6 | https://nplot.svn.sourceforge.net/svnroot/nplot 7 | 8 | 9 | 10 | 2006-10-11T14:47:45.632802Z 11 | 2 12 | anmar 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | d24cb6f0-7a1f-0410-a64c-9fc4892c6eea 28 | 29 | NPlotDemo-icon.ico 30 | file 31 | 32 | 33 | 34 | 35 | 2008-01-08T11:59:13.209420Z 36 | a78a91ff7a8c59192edc05466a68bee5 37 | 2006-10-11T14:47:45.632802Z 38 | 2 39 | anmar 40 | has-props 41 | 42 | PlotSurface2DDemo.resx 43 | file 44 | 45 | 46 | 47 | 48 | 2008-01-08T11:59:13.219435Z 49 | 125e66150f42b777fd0e4458473a8d25 50 | 2006-10-11T14:47:45.632802Z 51 | 2 52 | anmar 53 | has-props 54 | 55 | light.wav 56 | file 57 | 58 | 59 | 60 | 61 | 2008-01-08T11:59:13.219435Z 62 | ae6d3505361cb0326d41660d5c9395b8 63 | 2006-10-11T14:47:45.632802Z 64 | 2 65 | anmar 66 | has-props 67 | 68 | MenuForm.resx 69 | file 70 | 71 | 72 | 73 | 74 | 2008-01-08T11:59:13.229449Z 75 | a530f9cd231bebe98ca920c502388821 76 | 2006-10-11T14:47:45.632802Z 77 | 2 78 | anmar 79 | has-props 80 | 81 | FinancialDemo.resx 82 | file 83 | 84 | 85 | 86 | 87 | 2008-01-08T11:59:13.239464Z 88 | 11f0ca52a45582f9575950d4b4a90094 89 | 2006-10-11T14:47:45.632802Z 90 | 2 91 | anmar 92 | has-props 93 | 94 | AxisTestsForm.resx 95 | file 96 | 97 | 98 | 99 | 100 | 2008-01-08T11:59:13.249478Z 101 | 902a24a82f2ef018f23afa9fa83f4605 102 | 2006-10-11T14:47:45.632802Z 103 | 2 104 | anmar 105 | has-props 106 | 107 | asx_jbh.xml 108 | file 109 | 110 | 111 | 112 | 113 | 2008-01-08T11:59:13.259492Z 114 | 3059bd9c25583f51b7eb707c23714c80 115 | 2006-10-11T14:47:45.632802Z 116 | 2 117 | anmar 118 | has-props 119 | 120 | pattern01.jpg 121 | file 122 | 123 | 124 | 125 | 126 | 2008-01-08T11:59:13.279521Z 127 | 2f99aec788109eab4bf37bd94d02f499 128 | 2006-10-11T14:47:45.632802Z 129 | 2 130 | anmar 131 | has-props 132 | 133 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/format: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/AxisTestsForm.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/FinancialDemo.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/MenuForm.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/NPlotDemo-icon.ico.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/PlotSurface2DDemo.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/asx_jbh.xml.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/light.wav.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/prop-base/pattern01.jpg.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/text-base/NPlotDemo-icon.ico.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/Resources/.svn/text-base/NPlotDemo-icon.ico.svn-base -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/text-base/light.wav.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/Resources/.svn/text-base/light.wav.svn-base -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/.svn/text-base/pattern01.jpg.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/Resources/.svn/text-base/pattern01.jpg.svn-base -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/NPlotDemo-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/Resources/NPlotDemo-icon.ico -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/pattern01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/Resources/pattern01.jpg -------------------------------------------------------------------------------- /NPlot/GtkTest/Resources/sound.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/GtkTest/Resources/sound.wav -------------------------------------------------------------------------------- /NPlot/NPlot/Interactions/HorizontalGuideline.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NPlot - A charting library for .NET 3 | // 4 | // HorizontalGuideline.cs 5 | // 6 | // Copyright (C) Hywel Thomas and others. 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modification, 10 | // are permitted provided that the following conditions are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright notice, this 13 | // list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the following disclaimer in the documentation 16 | // and/or other materials provided with the distribution. 17 | // 3. Neither the name of NPlot nor the names of its contributors may 18 | // be used to endorse or promote products derived from this software without 19 | // specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 29 | // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | // OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | /// 38 | /// Horizontal guideline 39 | /// 40 | public class HorizontalGuideline : Interaction 41 | { 42 | private Color lineColor; 43 | private Rectangle lineExtent = Rectangle.Empty; 44 | 45 | private bool drawPending; // for testing 46 | private int overRuns = 0; 47 | 48 | /// 49 | /// Constructor with specific color 50 | /// 51 | public HorizontalGuideline (Color color) 52 | { 53 | lineColor = color; 54 | } 55 | 56 | /// 57 | /// LineColor property 58 | /// 59 | public Color LineColor 60 | { 61 | get { return lineColor; } 62 | set { lineColor = value; } 63 | } 64 | 65 | /// 66 | /// MouseMove method for Guideline 67 | /// 68 | /// mouse X position 69 | /// mouse Y position 70 | /// mouse and keyboard modifiers 71 | /// the InteractivePlotSurface2D 72 | public override bool DoMouseMove (int X, int Y, Modifier keys, InteractivePlotSurface2D ps) 73 | { 74 | Rectangle plotArea = ps.PlotAreaBoundingBoxCache; 75 | 76 | if (drawPending) { 77 | overRuns += 1; 78 | return false; 79 | } 80 | 81 | // note previous guideline ready to erase it 82 | Rectangle prevExtent = lineExtent; 83 | 84 | // Only display guideline when mouse is within the plotArea 85 | if (plotArea.Contains(X,Y)) { 86 | int h = 1; 87 | int w = plotArea.Right - plotArea.Left + 1; 88 | lineExtent = new Rectangle (plotArea.X, Y, w, h); 89 | drawPending = true; 90 | } 91 | else { 92 | lineExtent = Rectangle.Empty; 93 | } 94 | ps.QueueDraw (prevExtent); 95 | ps.QueueDraw (lineExtent); 96 | return false; 97 | } 98 | 99 | /// 100 | /// MouseLeave method for Guideline 101 | /// 102 | /// the InteractivePlotSurface2D 103 | public override bool DoMouseLeave (InteractivePlotSurface2D ps) 104 | { 105 | if (lineExtent != Rectangle.Empty) { 106 | // erase previous vertical guideline 107 | ps.QueueDraw (lineExtent); 108 | } 109 | lineExtent = Rectangle.Empty; 110 | return false; 111 | } 112 | 113 | public override void DoDraw (Graphics g, Rectangle dirtyRect) 114 | { 115 | // Draw guideline based on current lineExtent if non-Empty 116 | //Console.WriteLine ("Drawing: {0} {1} {2} {3} ", lineExtent.X, lineExtent.Y, lineExtent.Width, lineExtent.Height); 117 | if (lineExtent != Rectangle.Empty) { 118 | Point start = new Point (lineExtent.X, lineExtent.Y); 119 | Point end = new Point (lineExtent.X + lineExtent.Width - 1, lineExtent.Y); 120 | using (Pen pen = new Pen (lineColor)) { 121 | g.DrawLine (pen, start, end); 122 | } 123 | } 124 | drawPending = false; // clear over-run flag 125 | } 126 | 127 | } // HorizontalGuideline 128 | 129 | } 130 | 131 | -------------------------------------------------------------------------------- /NPlot/NPlot/Interactions/Interaction.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NPlot - A charting library for .NET 3 | // 4 | // Interaction.cs 5 | // 6 | // Copyright (C) Hywel Thomas, Matt Howlett and others 2003-2013 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modification, 10 | // are permitted provided that the following conditions are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright notice, this 13 | // list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the following disclaimer in the documentation 16 | // and/or other materials provided with the distribution. 17 | // 3. Neither the name of NPlot nor the names of its contributors may 18 | // be used to endorse or promote products derived from this software without 19 | // specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 29 | // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | // OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | /// 38 | /// Encapsulates a number of separate "Interactions". An interaction comprises a number 39 | /// of handlers for mouse and keyboard events that work in a specific way, eg rescaling 40 | /// the axes, scrolling the PlotSurface, etc. 41 | /// 42 | /// 43 | /// This is a virtual base class, rather than abstract, since particular Interactions will 44 | /// only require to override a limited number of the possible default handlers. These do 45 | /// nothing, and return false so that the plot does not require redrawing. 46 | /// 47 | public class Interaction 48 | { 49 | public Interaction () 50 | { 51 | } 52 | 53 | public virtual bool DoMouseEnter (InteractivePlotSurface2D ps) 54 | { 55 | return false; 56 | } 57 | 58 | public virtual bool DoMouseLeave (InteractivePlotSurface2D ps) 59 | { 60 | return false; 61 | } 62 | 63 | public virtual bool DoMouseDown (int X, int Y, Modifier keys, InteractivePlotSurface2D ps) 64 | { 65 | return false; 66 | } 67 | 68 | public virtual bool DoMouseUp (int X, int Y, Modifier keys, InteractivePlotSurface2D ps) 69 | { 70 | return false; 71 | } 72 | 73 | public virtual bool DoMouseMove (int X, int Y, Modifier keys, InteractivePlotSurface2D ps) 74 | { 75 | return false; 76 | } 77 | 78 | public virtual bool DoMouseScroll (int X, int Y, int direction, Modifier keys, InteractivePlotSurface2D ps) 79 | { 80 | return false; 81 | } 82 | 83 | public virtual bool DoKeyPress (Modifier keys, InteractivePlotSurface2D ps) 84 | { 85 | return false; 86 | } 87 | 88 | public virtual bool DoKeyRelease (Modifier keys, InteractivePlotSurface2D ps) 89 | { 90 | return false; 91 | } 92 | 93 | /// 94 | /// Draw Overlay content over the cached background plot 95 | /// 96 | public virtual void DoDraw (Graphics g, Rectangle dirtyRect) 97 | { 98 | } 99 | 100 | } 101 | 102 | } 103 | 104 | -------------------------------------------------------------------------------- /NPlot/NPlot/Interactions/KeyActions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NPlot - A charting library for .NET 3 | // 4 | // KeyActions.cs 5 | // 6 | // Copyright (C) Hywel Thomas, Matt Howlett and others 2003-2013 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modification, 10 | // are permitted provided that the following conditions are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright notice, this 13 | // list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the following disclaimer in the documentation 16 | // and/or other materials provided with the distribution. 17 | // 3. Neither the name of NPlot nor the names of its contributors may 18 | // be used to endorse or promote products derived from this software without 19 | // specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 29 | // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | // OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | using System; 33 | 34 | namespace NPlot 35 | { 36 | 37 | public class KeyActions : Interaction 38 | { 39 | /// 40 | /// Links some of the standard keyboard keys to plot scrolling and zooming. 41 | /// Since all key-interactions are applied to the complete PlotSurface, any 42 | /// translation or zooming is applied to all axes that have been defined 43 | /// 44 | /// The following key actions are currently implemented :- 45 | /// Left - scrolls the viewport to the left 46 | /// Right - scrolls the viewport to the right 47 | /// Up - scrolls the viewport up 48 | /// Down - scrolls the viewport down 49 | /// + - zooms in 50 | /// - - zooms out 51 | /// Alt - reduces the effect of the above actions 52 | /// Home - restores original view and dimensions 53 | /// More could be added, but these are a start. 54 | /// 55 | /// 56 | 57 | const double right = +0.25, left = -0.25; 58 | const double up = +0.25, down = -0.25; 59 | const double altFactor = 0.4; // Alt key reduces effect 60 | const double zoomIn = -0.5; // Should give reversible 61 | const double zoomOut = +1.0; // ZoomIn / ZoomOut actions 62 | const double symmetrical = 0.5; 63 | 64 | private float sensitivity_ = 1.0f; // default value 65 | 66 | /// 67 | /// Sensitivity factor for axis zoom 68 | /// 69 | /// 70 | public float Sensitivity 71 | { 72 | get { return sensitivity_; } 73 | set { sensitivity_ = value; } 74 | } 75 | 76 | /// 77 | /// Handler for KeyPress events 78 | /// 79 | /// the NPlot key enumeration 80 | /// the InteractivePlotSurface2D 81 | /// 82 | public override bool DoKeyPress(Modifier keys, InteractivePlotSurface2D ps) 83 | { 84 | double factor = Sensitivity; 85 | if (((keys & Modifier.Alt) != 0)) { 86 | factor *= altFactor; 87 | } 88 | if ((keys & Modifier.Home) != 0) { 89 | ps.SetOriginalDimensions(); 90 | return true; 91 | } 92 | if ((keys & Modifier.Left) != 0) { 93 | ps.CacheAxes(); 94 | ps.TranslateXAxes (left*factor); 95 | return true; 96 | } 97 | if ((keys & Modifier.Right) != 0) { 98 | ps.CacheAxes(); 99 | ps.TranslateXAxes (right*factor); 100 | return true; 101 | } 102 | if ((keys & Modifier.Up) != 0) { 103 | ps.CacheAxes(); 104 | ps.TranslateYAxes (up*factor); 105 | return true; 106 | } 107 | if ((keys & Modifier.Down) != 0) { 108 | ps.CacheAxes(); 109 | ps.TranslateYAxes (down*factor); 110 | return true; 111 | } 112 | if ((keys & Modifier.Plus) != 0) { 113 | ps.CacheAxes(); 114 | ps.ZoomXAxes (zoomIn*factor,symmetrical); 115 | ps.ZoomYAxes (zoomIn*factor,symmetrical); 116 | return true; 117 | } 118 | if ((keys & Modifier.Minus) != 0) { 119 | ps.CacheAxes(); 120 | ps.ZoomXAxes (zoomOut*factor,symmetrical); 121 | ps.ZoomYAxes (zoomOut*factor,symmetrical); 122 | return true; 123 | } 124 | return false; 125 | } 126 | 127 | /// 128 | /// Handler for KeyRelease events 129 | /// 130 | /// the NPlot key enumeration 131 | /// the InteractivePlotSurface2D 132 | /// 133 | public override bool DoKeyRelease(Modifier keys, InteractivePlotSurface2D ps) 134 | { 135 | return false; 136 | } 137 | 138 | } // Key Actions 139 | 140 | } -------------------------------------------------------------------------------- /NPlot/NPlot/Interactions/PlotZoom.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NPlot - A charting library for .NET 3 | // 4 | // PlotZoom.cs 5 | // 6 | // Copyright (C) Hywel Thomas, Matt Howlett and others 2003-2013 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modification, 10 | // are permitted provided that the following conditions are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright notice, this 13 | // list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the following disclaimer in the documentation 16 | // and/or other materials provided with the distribution. 17 | // 3. Neither the name of NPlot nor the names of its contributors may 18 | // be used to endorse or promote products derived from this software without 19 | // specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 29 | // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | // OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | using System; 33 | using System.Drawing; 34 | //using GLib; // Omit timeout for now clear focus on MouseMove 35 | 36 | namespace NPlot 37 | { 38 | /// 39 | /// Mouse Scroll (wheel) increases or decreases both axes scaling factors 40 | /// Zoom direction is Up/+ve/ZoomIn or Down/-ve/ZoomOut. If the mouse 41 | /// pointer is inside the plot area, its position is used as the focus point 42 | /// of the zoom, otherwise the centre of the plot is used as the default 43 | /// 44 | public class PlotZoom : Interaction 45 | { 46 | private double sensitivity_ = 1.0; // default value 47 | private Rectangle focusRect = Rectangle.Empty; 48 | private Point p = Point.Empty; 49 | private bool zoomActive = false; 50 | private InteractivePlotSurface2D surface; 51 | 52 | public PlotZoom () 53 | { 54 | } 55 | 56 | /// 57 | /// Mouse Scroll (wheel) method for AxisZoom interaction 58 | /// 59 | public override bool DoMouseScroll (int X, int Y, int direction, Modifier keys, InteractivePlotSurface2D ps) 60 | { 61 | // Add timeout into Gtk loop when scroll starts - Omit for now 62 | // GLib.Timeout.Add (500, new GLib.TimeoutHandler (zoomTimeout) ); 63 | zoomActive = true; 64 | surface = ps; 65 | 66 | double proportion = 0.1*sensitivity_; // use initial zoom of 10% 67 | double focusX = 0.5, focusY = 0.5; // default focus point 68 | 69 | // Zoom direction is +1 for Up/ZoomIn, or -1 for Down/ZoomOut 70 | proportion *= -direction; 71 | 72 | // delete previous focusPoint drawing - this is all a bit 'tentative' 73 | ps.QueueDraw (focusRect); 74 | 75 | Rectangle area = ps.PlotAreaBoundingBoxCache; 76 | if (area.Contains(X,Y)) { 77 | p.X = X; 78 | p.Y = Y; 79 | focusX = (double)(X - area.Left)/(double)area.Width; 80 | focusY = (double)(area.Bottom - Y)/(double)area.Height; 81 | } 82 | 83 | // Zoom in/out for all defined axes 84 | ps.CacheAxes(); 85 | ps.ZoomXAxes (proportion,focusX); 86 | ps.ZoomYAxes (proportion,focusY); 87 | 88 | 89 | // Note: r = 16, and Focus extents range from x-2*r-1 to x+2*r+1, y-2*r-1 to y+2*r+1 90 | int x = p.X-31; 91 | int y = p.Y-31; 92 | focusRect = new Rectangle (x, y, 64, 64); 93 | 94 | // draw new focusRect 95 | ps.QueueDraw (focusRect); 96 | 97 | return (true); 98 | } 99 | 100 | /// 101 | /// MouseMove method for PlotScroll 102 | /// 103 | public override bool DoMouseMove (int X, int Y, Modifier keys, InteractivePlotSurface2D ps) 104 | { 105 | zoomActive = false; 106 | ps.QueueDraw (focusRect); 107 | return false; 108 | } 109 | 110 | public override void DoDraw (Graphics g, Rectangle dirtyRect) 111 | { 112 | DrawFocus (g, p); 113 | } 114 | 115 | /// 116 | /// Sensitivity factor for axis zoom 117 | /// 118 | /// 119 | public double Sensitivity 120 | { 121 | get { return sensitivity_; } 122 | set { sensitivity_ = value; } 123 | } 124 | 125 | private void DrawFocus (Graphics g, Point p) 126 | { 127 | // Draw a 'Google-Earth'-type Focus-point when zooming 128 | if (zoomActive) { 129 | using (Pen rPen = new Pen (Color.White)) { 130 | Rectangle r1 = new Rectangle (p.X-15, p.Y-15, 32,32); 131 | g.DrawArc (rPen, r1, 0, 360); 132 | r1 = new Rectangle (p.X-19, p.Y-19, 40,40); 133 | g.DrawArc (rPen, r1, 0, 360); 134 | g.DrawLine (rPen, p.X-30, p.Y, p.X-15, p.Y); 135 | g.DrawLine (rPen, p.X+30, p.Y, p.X+17, p.Y); 136 | g.DrawLine (rPen, p.X, p.Y-30, p.X, p.Y-15); 137 | g.DrawLine (rPen, p.X, p.Y+30, p.X, p.Y+17); 138 | } 139 | } 140 | } 141 | 142 | 143 | /// 144 | /// Callback for zoom timeout - compiled but not active at present 145 | /// 146 | private bool zoomTimeout () 147 | { 148 | // clear zoom flag and remove last focusPoint 149 | zoomActive = false; 150 | surface.QueueDraw (focusRect); 151 | //returning true means that the timeout routine should be invoked 152 | //again after the timeout period expires. Returning false will 153 | //terminate the timeout (ie until invoked again by Scrolling) 154 | return false; 155 | } 156 | 157 | } // Mouse Wheel Zoom 158 | 159 | } 160 | -------------------------------------------------------------------------------- /NPlot/NPlot/Interactions/VerticalGuideline.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NPlot - A charting library for .NET 3 | // 4 | // VerticalGuideline.cs 5 | // 6 | // Copyright (C) Hywel Thomas, Matt Howlett and others 2003-2013 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modification, 10 | // are permitted provided that the following conditions are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright notice, this 13 | // list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the following disclaimer in the documentation 16 | // and/or other materials provided with the distribution. 17 | // 3. Neither the name of NPlot nor the names of its contributors may 18 | // be used to endorse or promote products derived from this software without 19 | // specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 29 | // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | // OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | /// 38 | /// Vertical guideline 39 | /// 40 | public class VerticalGuideline : Interaction 41 | { 42 | private Color lineColor; 43 | private Rectangle lineExtent = Rectangle.Empty; 44 | 45 | private bool drawPending; // for testing 46 | private int overRuns = 0; 47 | 48 | /// 49 | /// Constructor with specific color 50 | /// 51 | public VerticalGuideline (Color color) 52 | { 53 | lineColor = color; 54 | } 55 | 56 | /// 57 | /// LineColor property 58 | /// 59 | public Color LineColor 60 | { 61 | get { return lineColor; } 62 | set { lineColor = value; } 63 | } 64 | 65 | /// 66 | /// MouseMove method for Guideline 67 | /// 68 | /// mouse X position 69 | /// mouse Y position 70 | /// mouse and keyboard modifiers 71 | /// the InteractivePlotSurface2D 72 | public override bool DoMouseMove (int X, int Y, Modifier keys, InteractivePlotSurface2D ps) 73 | { 74 | Rectangle plotArea = ps.PlotAreaBoundingBoxCache; 75 | 76 | if (drawPending) { 77 | overRuns += 1; 78 | return false; 79 | } 80 | 81 | // note previous guideline ready to erase it 82 | Rectangle prevExtent = lineExtent; 83 | 84 | // Only display guideline when mouse is within the plotArea 85 | if (plotArea.Contains(X,Y)) { 86 | int w = 1; 87 | int h = plotArea.Bottom - plotArea.Top + 1; 88 | lineExtent = new Rectangle (X, plotArea.Top, w, h); 89 | drawPending = true; 90 | } 91 | else { 92 | lineExtent = Rectangle.Empty; 93 | } 94 | ps.QueueDraw (prevExtent); 95 | ps.QueueDraw (lineExtent); 96 | return false; 97 | } 98 | 99 | /// 100 | /// MouseLeave method for Guideline 101 | /// 102 | /// the InteractivePlotSurface2D 103 | public override bool DoMouseLeave (InteractivePlotSurface2D ps) 104 | { 105 | if (lineExtent != Rectangle.Empty) { 106 | // erase previous vertical guideline 107 | ps.QueueDraw (lineExtent); 108 | } 109 | lineExtent = Rectangle.Empty; 110 | return false; 111 | } 112 | 113 | 114 | public override void DoDraw (Graphics g, Rectangle dirtyRect) 115 | { 116 | // Draw guideline based on current lineExtent if non-Empty 117 | //Console.WriteLine ("Drawing: {0} {1} {2} {3} ", lineExtent.X, lineExtent.Y, lineExtent.Width, lineExtent.Height); 118 | if (lineExtent != Rectangle.Empty) { 119 | Point start = new Point (lineExtent.X, lineExtent.Y); 120 | Point end = new Point (lineExtent.X, lineExtent.Y + lineExtent.Height - 1); 121 | using (Pen pen = new Pen (lineColor)) { 122 | g.DrawLine (pen, start, end); 123 | } 124 | //Console.WriteLine ("Draw: {0} {1} {2} {3} ", lineExtent.X, lineExtent.Y, lineExtent.Width, lineExtent.Height); 125 | } 126 | drawPending = false; // clear over-run flag 127 | } 128 | 129 | } // VerticalGuideline 130 | 131 | } 132 | 133 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 10.0.0 7 | 2.0 8 | {E4B99177-77A3-4C92-B881-A6CB57E3BF89} 9 | Library 10 | NPlot 11 | NPlot 12 | 13 | 14 | True 15 | full 16 | False 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | x86 22 | False 23 | 24 | 25 | none 26 | True 27 | bin\Release 28 | prompt 29 | 4 30 | x86 31 | False 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | False 108 | gtk-sharp-2.0 109 | 110 | 111 | False 112 | gtk-sharp-2.0 113 | 114 | 115 | False 116 | glib-sharp-2.0 117 | 118 | 119 | False 120 | gtk-sharp-2.0 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * AssemblyInfo.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Reflection; 34 | using System.Runtime.CompilerServices; 35 | 36 | [assembly: AssemblyTitle("NPlot")] 37 | [assembly: AssemblyDescription("NPlot is a charting library for .NET")] 38 | [assembly: AssemblyConfiguration("")] 39 | [assembly: AssemblyCompany("NPlot project")] 40 | [assembly: AssemblyProduct("NPlot")] 41 | [assembly: AssemblyCopyright("Copyright (C) 2003-2007 Matt Howlett and others")] 42 | [assembly: AssemblyTrademark("This program is under The BSD license")] 43 | [assembly: AssemblyCulture("")] 44 | [assembly: AssemblyVersion("0.9.10.1")] 45 | [assembly: CLSCompliant(true)] 46 | 47 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/AxisPosition.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NPlot - A charting library for .NET 3 | // 4 | // Axis.cs 5 | // Copyright (C) 2003-2009 Matt Howlett and others. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without modification, 9 | // are permitted provided that the following conditions are met: 10 | // 11 | // 1. Redistributions of source code must retain the above copyright notice, this 12 | // list of conditions and the following disclaimer. 13 | // 2. Redistributions in binary form must reproduce the above copyright notice, 14 | // this list of conditions and the following disclaimer in the documentation 15 | // and/or other materials provided with the distribution. 16 | // 3. Neither the name of NPlot nor the names of its contributors may 17 | // be used to endorse or promote products derived from this software without 18 | // specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | // OF THE POSSIBILITY OF SUCH DAMAGE. 30 | // 31 | 32 | using System; 33 | 34 | namespace NPlot 35 | { 36 | public enum XAxisPosition 37 | { 38 | Top, 39 | Bottom 40 | } 41 | 42 | public enum YAxisPosition 43 | { 44 | Left, 45 | Right 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/BasePlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * BasePlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// Supplies implementation of basic legend handling properties, and 40 | /// basic data specifying properties which are used by all plots. 41 | /// 42 | /// If C# had multiple inheritance, the heirachy would be different. 43 | public abstract class BasePlot 44 | { 45 | 46 | /// 47 | /// A label to associate with the plot - used in the legend. 48 | /// 49 | public string Label 50 | { 51 | get 52 | { 53 | return label_; 54 | } 55 | set 56 | { 57 | this.label_ = value; 58 | } 59 | } 60 | 61 | private string label_ = ""; 62 | 63 | 64 | /// 65 | /// Whether or not to include an entry for this plot in the legend if it exists. 66 | /// 67 | public bool ShowInLegend 68 | { 69 | get 70 | { 71 | return showInLegend_; 72 | } 73 | set 74 | { 75 | this.showInLegend_ = value; 76 | } 77 | } 78 | private bool showInLegend_ = true; 79 | 80 | 81 | /// 82 | /// Gets or sets the source containing a list of values used to populate the plot object. 83 | /// 84 | public object DataSource 85 | { 86 | get 87 | { 88 | return this.dataSource_; 89 | } 90 | set 91 | { 92 | this.dataSource_ = value; 93 | } 94 | } 95 | private object dataSource_ = null; 96 | 97 | 98 | /// 99 | /// Gets or sets the specific data member in a multimember data source to get data from. 100 | /// 101 | public string DataMember 102 | { 103 | get 104 | { 105 | return this.dataMember_; 106 | } 107 | set 108 | { 109 | this.dataMember_ = value; 110 | } 111 | } 112 | private string dataMember_ = null; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/BaseSequencePlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * BaseSequencePlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | 34 | namespace NPlot 35 | { 36 | 37 | /// 38 | /// Adds additional basic functionality to BasePlot that is common to all 39 | /// plots that implement the ISequencePlot interface. 40 | /// 41 | /// If C# had multiple inheritance, the heirachy would be different. The way it is isn't very nice. 42 | public class BaseSequencePlot : BasePlot, ISequencePlot 43 | { 44 | 45 | /// 46 | /// Gets or sets the data, or column name for the ordinate [y] axis. 47 | /// 48 | public object OrdinateData 49 | { 50 | get 51 | { 52 | return this.ordinateData_; 53 | } 54 | set 55 | { 56 | this.ordinateData_ = value; 57 | } 58 | } 59 | private object ordinateData_ = null; 60 | 61 | 62 | /// 63 | /// Gets or sets the data, or column name for the abscissa [x] axis. 64 | /// 65 | public object AbscissaData 66 | { 67 | get 68 | { 69 | return this.abscissaData_; 70 | } 71 | set 72 | { 73 | this.abscissaData_ = value; 74 | } 75 | } 76 | private object abscissaData_ = null; 77 | 78 | 79 | /// 80 | /// Writes text data of the plot object to the supplied string builder. It is 81 | /// possible to specify that only data in the specified range be written. 82 | /// 83 | /// the StringBuilder object to write to. 84 | /// a region used if onlyInRegion is true. 85 | /// If true, only data enclosed in the provided region will be written. 86 | public void WriteData( System.Text.StringBuilder sb, RectangleD region, bool onlyInRegion ) 87 | { 88 | SequenceAdapter data_ = 89 | new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData ); 90 | 91 | sb.Append( "Label: " ); 92 | sb.Append( this.Label ); 93 | sb.Append( "\r\n" ); 94 | data_.WriteData( sb, region, onlyInRegion ); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/CursorType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NPlot 4 | { 5 | /// 6 | /// CursorTypes for NPlot that are useful for Interactions 7 | /// 8 | public enum CursorType 9 | { 10 | None, // no cursor displayed 11 | LeftPointer, // standard mouse pointer 12 | RightPointer, // same but pointing right 13 | CrossHair, // for accurate coordinates 14 | Hand, // use for dragging in plot 15 | LeftRight, // expanding horizontal axis 16 | UpDown, // expanding vertical axis 17 | Zoom // expanding both axes 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/FontScaler.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * FontScaler.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | } 39 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/IDrawable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // NPlot - A charting library for .NET 3 | // 4 | // IDrawable.cs 5 | // Copyright (C) 2003-2006 Matt Howlett and others. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without modification, 9 | // are permitted provided that the following conditions are met: 10 | // 11 | // 1. Redistributions of source code must retain the above copyright notice, this 12 | // list of conditions and the following disclaimer. 13 | // 2. Redistributions in binary form must reproduce the above copyright notice, 14 | // this list of conditions and the following disclaimer in the documentation 15 | // and/or other materials provided with the distribution. 16 | // 3. Neither the name of NPlot nor the names of its contributors may 17 | // be used to endorse or promote products derived from this software without 18 | // specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | // OF THE POSSIBILITY OF SUCH DAMAGE. 30 | // 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// Defines a Draw method for drawing objects against an x and y 40 | /// Physical Axis. 41 | /// 42 | public interface IDrawable 43 | { 44 | /// 45 | /// Draws this object against an x and y PhysicalAxis. 46 | /// 47 | /// The graphics surface on which to draw. 48 | /// The physical x-axis to draw against. 49 | /// The physical y-axis to draw against. 50 | void Draw (Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/IGradient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * IGradient.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | using System.Drawing.Drawing2D; 35 | 36 | namespace NPlot 37 | { 38 | 39 | /// 40 | /// Defines a gradient. 41 | /// 42 | public interface IGradient 43 | { 44 | 45 | /// 46 | /// Gets a color corresponding to a number between 0.0 and 1.0 inclusive. 47 | /// 48 | /// the number to get corresponding color for (between 0.0 and 1.0) 49 | /// The color corresponding to the supplied number. 50 | Color GetColor( double prop ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/IPlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * IPlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System.Drawing; 33 | 34 | namespace NPlot 35 | { 36 | 37 | /// 38 | /// Defines the interface for objects that (a) can draw a representation of 39 | /// themselves in the legend and (b) can recommend a good axis to draw themselves 40 | /// against. 41 | /// 42 | public interface IPlot : IDrawable 43 | { 44 | 45 | /// 46 | /// Method used to draw a representation of the plot in a legend. 47 | /// 48 | void DrawInLegend( Graphics g, Rectangle startEnd ); 49 | 50 | 51 | /// 52 | /// The label associated with the plot [used in legend] 53 | /// 54 | string Label { get; set; } 55 | 56 | 57 | /// 58 | /// Whether or not to include an entry for this plot in the legend if it exists. 59 | /// 60 | bool ShowInLegend { get; set; } 61 | 62 | 63 | /// 64 | /// The method used to set the default abscissa axis. 65 | /// 66 | Axis SuggestXAxis(); 67 | 68 | 69 | /// 70 | /// The method used to set the default ordinate axis. 71 | /// 72 | Axis SuggestYAxis(); 73 | 74 | 75 | /// 76 | /// Write data associated with the plot as text. 77 | /// 78 | /// the string builder to write to. 79 | /// Only write out data in this region if onlyInRegion is true. 80 | /// If true, only data in region is written, else all data is written. 81 | void WriteData( System.Text.StringBuilder sb, RectangleD region, bool onlyInRegion ); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/ISequencePlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * IPlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | 34 | namespace NPlot 35 | { 36 | 37 | /// 38 | /// Defines an mix-in style interface for plots that use SequenceAdapter to interpret supplied data. 39 | /// 40 | public interface ISequencePlot 41 | { 42 | 43 | /// 44 | /// Gets or sets the source containing a list of values used to populate the plot object. 45 | /// 46 | object DataSource { get; set; } 47 | 48 | /// 49 | /// Gets or sets the specific data member in a multimember data source to get data from. 50 | /// 51 | string DataMember { get; set; } 52 | 53 | /// 54 | /// Gets or sets the data, or column name for the abscissa [x] axis. 55 | /// 56 | object AbscissaData { get; set; } 57 | 58 | /// 59 | /// Gets or sets the data, or column name for the ordinate [y] axis. 60 | /// 61 | object OrdinateData { get; set; } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/ITransform2D.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * ITransform2D.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// This interface is useful in the Plot classes for transforming 40 | /// world to physical coordinates. Create on using the GetTransformer 41 | /// static method in Transform2D. 42 | /// 43 | public interface ITransform2D 44 | { 45 | 46 | /// 47 | /// Transforms the given world point to physical coordinates 48 | /// 49 | PointF Transform( double x, double y ); 50 | 51 | /// 52 | /// Transforms the given world point to physical coordinates 53 | /// 54 | PointF Transform( PointD worldPoint ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/LinearGradient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * LinearGradient.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// Class for creating a linear gradient. 40 | /// 41 | public class LinearGradient : IGradient 42 | { 43 | 44 | /// 45 | /// Constructor. 46 | /// 47 | /// The color corresponding to 0.0 48 | /// The color corresponding to 1.0 49 | public LinearGradient( Color minColor, Color maxColor ) 50 | { 51 | this.minColor_ = minColor; 52 | this.maxColor_ = maxColor; 53 | } 54 | 55 | 56 | /// 57 | /// The color corresponding to 0.0 58 | /// 59 | public Color MaxColor 60 | { 61 | get 62 | { 63 | return this.maxColor_; 64 | } 65 | set 66 | { 67 | this.maxColor_ = value; 68 | } 69 | } 70 | private Color maxColor_; 71 | 72 | 73 | /// 74 | /// The color corresponding to 1.0 75 | /// 76 | public Color MinColor 77 | { 78 | get 79 | { 80 | return this.minColor_; 81 | } 82 | set 83 | { 84 | this.minColor_ = value; 85 | } 86 | } 87 | private Color minColor_; 88 | 89 | 90 | /// 91 | /// The color corresponding to NaN 92 | /// 93 | public Color VoidColor 94 | { 95 | get 96 | { 97 | return voidColor_; 98 | } 99 | set 100 | { 101 | voidColor_ = value; 102 | } 103 | } 104 | private Color voidColor_ = Color.Black; 105 | 106 | 107 | /// 108 | /// Gets a color corresponding to a number between 0.0 and 1.0 inclusive. The color will 109 | /// be a linear interpolation of the min and max colors. 110 | /// 111 | /// the number to get corresponding color for (between 0.0 and 1.0) 112 | /// The color corresponding to the supplied number. 113 | public Color GetColor( double prop ) 114 | { 115 | if (Double.IsNaN(prop)) 116 | { 117 | return voidColor_; 118 | } 119 | 120 | if ( prop <= 0.0 ) 121 | { 122 | return this.MinColor; 123 | } 124 | 125 | if ( prop >= 1.0 ) 126 | { 127 | return this.MaxColor; 128 | } 129 | 130 | byte r = (byte)((int)(this.MinColor.R) + (int)(((double)this.MaxColor.R - (double)this.MinColor.R)*prop)); 131 | byte g = (byte)((int)(this.MinColor.G) + (int)(((double)this.MaxColor.G - (double)this.MinColor.G)*prop)); 132 | byte b = (byte)((int)(this.MinColor.B) + (int)(((double)this.MaxColor.B - (double)this.MinColor.B)*prop)); 133 | 134 | return Color.FromArgb(r,g,b); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/MarkerItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * MarkerItem.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// Class for placement of a single marker. 40 | /// 41 | public class MarkerItem : IDrawable 42 | { 43 | 44 | private Marker marker_; 45 | private double x_; 46 | private double y_; 47 | 48 | 49 | /// 50 | /// Constructs a square marker at the (world) point point. 51 | /// 52 | /// the world position at which to place the marker 53 | public MarkerItem( PointD point ) 54 | { 55 | marker_ = new Marker( Marker.MarkerType.Square ); 56 | x_ = point.X; 57 | y_ = point.Y; 58 | } 59 | 60 | 61 | /// 62 | /// Default constructor - a square black marker. 63 | /// 64 | /// The world x position of the marker 65 | /// The world y position of the marker 66 | public MarkerItem( double x, double y ) 67 | { 68 | marker_ = new Marker( Marker.MarkerType.Square ); 69 | x_ = x; 70 | y_ = y; 71 | } 72 | 73 | 74 | /// 75 | /// Constructor 76 | /// 77 | /// The marker to place on the chart. 78 | /// The world x position of the marker 79 | /// The world y position of the marker 80 | public MarkerItem( Marker marker, double x, double y ) 81 | { 82 | marker_ = marker; 83 | x_ = x; 84 | y_ = y; 85 | } 86 | 87 | /// 88 | /// Constructor 89 | /// 90 | /// The marker to place on the chart. 91 | /// The world position of the marker 92 | public MarkerItem( Marker marker, PointD point ) 93 | { 94 | marker_ = marker; 95 | x_ = point.X; 96 | y_ = point.Y; 97 | } 98 | 99 | /// 100 | /// Draws the marker on a plot surface. 101 | /// 102 | /// graphics surface on which to draw 103 | /// The X-Axis to draw against. 104 | /// The Y-Axis to draw against. 105 | public void Draw( System.Drawing.Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis ) 106 | { 107 | PointF point = new PointF( 108 | xAxis.WorldToPhysical( x_, true ).X, 109 | yAxis.WorldToPhysical( y_, true ).Y ); 110 | 111 | marker_.Draw( g, (int)point.X, (int)point.Y ); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/Modifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace NPlot 4 | { 5 | /// 6 | /// Common set of button/key flags that NPlot will respond to for Interactions 7 | /// 8 | [System.Flags] 9 | public enum Modifier 10 | { 11 | None = 0x00000, // no keys 12 | Alt = 0x00001, // the Alt key 13 | Control = 0x00002, // the Control key 14 | Shift = 0x00004, // the Shift key 15 | Command = 0x00008, // the Command key 16 | Button1 = 0x00010, // the first (left) mouse button 17 | Button2 = 0x00020, // the second (middle) mouse button 18 | Button3 = 0x00040, // the third (right) mouse button 19 | Spare1 = 0x00080, 20 | Home = 0x00100, // a restricted set of keyboard keys 21 | End = 0x00200, // that NPlot will respond to 22 | Left = 0x00400, 23 | Up = 0x00800, 24 | Right = 0x01000, 25 | Down = 0x02000, 26 | PageUp = 0x02000, 27 | PageDn = 0x04000, 28 | Plus = 0x08000, 29 | Minus = 0x10000 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/NPlotException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * NPlotException.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | 34 | namespace NPlot 35 | { 36 | 37 | /// 38 | /// All exceptions thrown by NPlot are of this type. 39 | /// 40 | public class NPlotException : System.Exception 41 | { 42 | 43 | /// 44 | /// Constructor 45 | /// 46 | /// The error message that explains the reason for the exception. 47 | /// The exception that is the cause of the current exception. 48 | public NPlotException( string message, System.Exception innerException ) 49 | : base( message, innerException ) 50 | { 51 | } 52 | 53 | /// 54 | /// Constructor 55 | /// 56 | /// The error message that explains the reason for the exception. 57 | public NPlotException( string message ) 58 | : base( message ) 59 | { 60 | } 61 | 62 | /// 63 | /// Constructor. 64 | /// 65 | public NPlotException() 66 | { 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/PageAlignedPhysicalAxis.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PageAlignedPhysicalAxis.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Collections; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// The bare minimum needed to do world->physical and physical->world transforms for 40 | /// vertical axes. Also includes tick placements. Built for speed. 41 | /// 42 | /// currently unused 43 | public class PageAlignedPhysicalAxis 44 | { 45 | 46 | private int pMin_; 47 | private int pMax_; 48 | private int pLength_; // cached. 49 | 50 | private double worldMin_; 51 | private double worldMax_; 52 | private double worldLength_; // cached. 53 | 54 | 55 | /// 56 | /// Construct from a fully-blown physical axis. 57 | /// 58 | /// the physical axis to get initial values from. 59 | public PageAlignedPhysicalAxis( PhysicalAxis physicalAxis ) 60 | { 61 | worldMin_ = physicalAxis.Axis.WorldMin; 62 | worldMax_ = physicalAxis.Axis.WorldMax; 63 | worldLength_ = worldMax_ - worldMin_; 64 | 65 | if ( physicalAxis.PhysicalMin.X == physicalAxis.PhysicalMax.X ) 66 | { 67 | pMin_ = physicalAxis.PhysicalMin.Y; 68 | pMax_ = physicalAxis.PhysicalMax.Y; 69 | } 70 | else if ( physicalAxis.PhysicalMin.Y == physicalAxis.PhysicalMax.Y ) 71 | { 72 | pMin_ = physicalAxis.PhysicalMin.X; 73 | pMax_ = physicalAxis.PhysicalMax.X; 74 | } 75 | else 76 | { 77 | throw new NPlotException( "Physical axis is not page aligned" ); 78 | } 79 | 80 | pLength_ = pMax_ - pMin_; 81 | 82 | } 83 | 84 | 85 | /// 86 | /// return the physical coordinate corresponding to the supplied world coordinate. 87 | /// 88 | /// world coordinate to determine physical coordinate for. 89 | /// the physical coordinate corresoindng to the supplied world coordinate. 90 | public float WorldToPhysical( double world ) 91 | { 92 | return (float)(((world-worldMin_) / worldLength_) * (float)pLength_ + (float)pMin_); 93 | } 94 | 95 | 96 | /// 97 | /// return the physical coordinate corresponding to the supplied world coordinate, 98 | /// clipped if it is outside the bounds of the axis 99 | /// 100 | /// world coordinate to determine physical coordinate for. 101 | /// the physical coordinate corresoindng to the supplied world coordinate. 102 | public float WorldToPhysicalClipped( double world ) 103 | { 104 | if (world > worldMax_) 105 | { 106 | return pMax_; 107 | } 108 | 109 | if (world < worldMin_) 110 | { 111 | return pMin_; 112 | } 113 | 114 | // is this quicker than returning WorldToPhysical? 115 | return (float)(((world-worldMin_) / worldLength_) * (float)pLength_ + (float)pMin_); 116 | } 117 | 118 | 119 | /// 120 | /// return the world coordinate corresponding to the supplied physical coordinate. 121 | /// 122 | /// physical coordinate to determine world coordinate for. 123 | /// the world coordinate corresponding to the supplied 124 | public double PhysicalToWorld( float physical ) 125 | { 126 | return ((float)(physical-pMin_) / (float)pLength_) * worldLength_ + worldMin_; 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/PiePlot.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/NPlot/NPlot/PiePlot.cs -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/PointD.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PointD.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | namespace NPlot 33 | { 34 | 35 | /// 36 | /// Represtents a point in two-dimensional space. Used for representation 37 | /// of points world coordinates. 38 | /// 39 | public struct PointD 40 | { 41 | /// 42 | /// X-Coordinate of the point. 43 | /// 44 | public double X; 45 | 46 | /// 47 | /// Y-Coordinate of the point. 48 | /// 49 | public double Y; 50 | 51 | /// 52 | /// Constructor 53 | /// 54 | /// X-Coordinate of the point. 55 | /// Y-Coordinate of the point. 56 | public PointD( double x, double y ) 57 | { 58 | X = x; 59 | Y = y; 60 | } 61 | 62 | /// 63 | /// returns a string representation of the point. 64 | /// 65 | /// string representation of the point. 66 | public override string ToString() 67 | { 68 | return X.ToString() + "\t" + Y.ToString(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/PointPlot.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * PointPlot.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// Encapsulates functionality for drawing data as a series of points. 40 | /// 41 | public class PointPlot : BaseSequencePlot, ISequencePlot, IPlot 42 | { 43 | 44 | private Marker marker_; 45 | 46 | /// 47 | /// Default Constructor 48 | /// 49 | public PointPlot() 50 | { 51 | marker_ = new Marker(); 52 | } 53 | 54 | /// 55 | /// Constructor for the marker plot. 56 | /// 57 | /// The marker to use. 58 | public PointPlot( Marker marker ) 59 | { 60 | marker_ = marker; 61 | } 62 | 63 | 64 | /// 65 | /// Draws the point plot on a GDI+ surface against the provided x and y axes. 66 | /// 67 | /// The GDI+ surface on which to draw. 68 | /// The X-Axis to draw against. 69 | /// The Y-Axis to draw against. 70 | public virtual void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis ) 71 | { 72 | SequenceAdapter data_ = 73 | new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData ); 74 | 75 | float leftCutoff_ = xAxis.PhysicalMin.X - marker_.Size; 76 | float rightCutoff_ = xAxis.PhysicalMax.X + marker_.Size; 77 | 78 | for (int i=0; i 102 | /// Returns an x-axis that is suitable for drawing this plot. 103 | /// 104 | /// A suitable x-axis. 105 | public Axis SuggestXAxis() 106 | { 107 | SequenceAdapter data_ = 108 | new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData ); 109 | 110 | return data_.SuggestXAxis(); 111 | } 112 | 113 | 114 | /// 115 | /// Returns a y-axis that is suitable for drawing this plot. 116 | /// 117 | /// A suitable y-axis. 118 | public Axis SuggestYAxis() 119 | { 120 | SequenceAdapter data_ = 121 | new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData ); 122 | 123 | return data_.SuggestYAxis(); 124 | } 125 | 126 | 127 | /// 128 | /// Draws a representation of this plot in the legend. 129 | /// 130 | /// The graphics surface on which to draw. 131 | /// A rectangle specifying the bounds of the area in the legend set aside for drawing. 132 | public void DrawInLegend( Graphics g, Rectangle startEnd ) 133 | { 134 | if (marker_.Size > 0) 135 | { 136 | marker_.Draw(g, (startEnd.Left + startEnd.Right) / 2, (startEnd.Top + startEnd.Bottom) / 2); 137 | } 138 | else if (marker_.Pen.Width > 0) 139 | { 140 | g.DrawLine(marker_.Pen, 141 | (startEnd.Left + startEnd.Right) / 2, (startEnd.Top + startEnd.Bottom - marker_.Pen.Width) / 2, 142 | (startEnd.Left + startEnd.Right) / 2, (startEnd.Top + startEnd.Bottom + marker_.Pen.Width) / 2); 143 | } 144 | } 145 | 146 | 147 | /// 148 | /// The Marker object used for the plot. 149 | /// 150 | public Marker Marker 151 | { 152 | set 153 | { 154 | marker_ = value; 155 | } 156 | get 157 | { 158 | return marker_; 159 | } 160 | } 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/RectangleD.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * RectangleD.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// Stores a set of four double numbers that represent the location and size of 40 | /// a rectangle. TODO: implement more functionality similar to Drawing.RectangleF. 41 | /// 42 | public struct RectangleD 43 | { 44 | /// 45 | /// Constructor 46 | /// 47 | public RectangleD( double x, double y, double width, double height ) 48 | { 49 | x_ = x; 50 | y_ = y; 51 | width_ = width; 52 | height_ = height; 53 | } 54 | 55 | /// 56 | /// The rectangle height. 57 | /// 58 | public double Height 59 | { 60 | get 61 | { 62 | return height_; 63 | } 64 | set 65 | { 66 | height_ = value; 67 | } 68 | } 69 | 70 | /// 71 | /// The rectangle width. 72 | /// 73 | public double Width 74 | { 75 | get 76 | { 77 | return width_; 78 | } 79 | set 80 | { 81 | width_ = value; 82 | } 83 | } 84 | 85 | /// 86 | /// The minimum x coordinate of the rectangle. 87 | /// 88 | public double X 89 | { 90 | get 91 | { 92 | return x_; 93 | } 94 | set 95 | { 96 | x_ = value; 97 | } 98 | } 99 | 100 | 101 | /// 102 | /// The minimum y coordinate of the rectangle. 103 | /// 104 | public double Y 105 | { 106 | get 107 | { 108 | return y_; 109 | } 110 | set 111 | { 112 | y_ = value; 113 | } 114 | } 115 | 116 | 117 | private double x_; 118 | private double y_; 119 | private double width_; 120 | private double height_; 121 | 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/StartStep.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * StartStep.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | 34 | namespace NPlot 35 | { 36 | 37 | /// 38 | /// Encapsulates a Start and Step value. This is useful for specifying a regularly spaced set of 39 | /// abscissa values. 40 | /// 41 | public class StartStep 42 | { 43 | 44 | private double start_; 45 | private double step_; 46 | 47 | /// 48 | /// Constructor 49 | /// 50 | /// the first value of the set of points specified by this object. 51 | /// the step that specifies the separation between successive points. 52 | public StartStep( double start, double step ) 53 | { 54 | this.Start = start; 55 | this.Step = step; 56 | } 57 | 58 | 59 | /// 60 | /// The first value of the set of points specified by this object. 61 | /// 62 | public double Start 63 | { 64 | get 65 | { 66 | return start_; 67 | } 68 | set 69 | { 70 | this.start_ = value; 71 | } 72 | } 73 | 74 | 75 | /// 76 | /// The step that specifies the separation between successive points. 77 | /// 78 | public double Step 79 | { 80 | get 81 | { 82 | return this.step_; 83 | } 84 | set 85 | { 86 | this.step_ = value; 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/StepGradient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * StepGradient.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | /// 38 | /// Class for creating a rainbow legend. 39 | /// 40 | public class StepGradient : IGradient 41 | { 42 | 43 | /// 44 | /// Types of step gradient defined. 45 | /// 46 | public enum Type 47 | { 48 | /// 49 | /// Rainbow gradient type (colors of the rainbow) 50 | /// 51 | Rainbow, 52 | 53 | /// 54 | /// RGB gradient type (red, green blud). 55 | /// 56 | RGB 57 | } 58 | 59 | 60 | /// 61 | /// Sets the type of step gradient. 62 | /// 63 | public Type StepType 64 | { 65 | get 66 | { 67 | return stepType_; 68 | } 69 | set 70 | { 71 | stepType_ = value; 72 | } 73 | } 74 | Type stepType_ = Type.RGB; 75 | 76 | 77 | /// 78 | /// Default Constructor 79 | /// 80 | public StepGradient() 81 | { 82 | } 83 | 84 | 85 | /// 86 | /// Constructor 87 | /// 88 | /// type of gradient 89 | public StepGradient( Type stepType ) 90 | { 91 | stepType_ = stepType; 92 | } 93 | 94 | 95 | /// 96 | /// Gets a color corresponding to a number between 0.0 and 1.0 inclusive. The color will 97 | /// be a linear interpolation of the min and max colors. 98 | /// 99 | /// the number to get corresponding color for (between 0.0 and 1.0) 100 | /// The color corresponding to the supplied number. 101 | public Color GetColor( double prop ) 102 | { 103 | switch (stepType_) 104 | { 105 | case Type.RGB: 106 | { 107 | if (prop < 1.0 / 3.0) 108 | { 109 | return Color.Red; 110 | } 111 | if (prop < 2.0 / 3.0) 112 | { 113 | return Color.Green; 114 | } 115 | return Color.Blue; 116 | } 117 | case Type.Rainbow: 118 | { 119 | if (prop < 0.125) 120 | { 121 | return Color.Red; 122 | } 123 | if (prop < 0.25) 124 | { 125 | return Color.Orange; 126 | } 127 | if (prop < 0.375) 128 | { 129 | return Color.Yellow; 130 | } 131 | if (prop < 0.5) 132 | { 133 | return Color.Green; 134 | } 135 | if (prop < 0.625) 136 | { 137 | return Color.Cyan; 138 | } 139 | if (prop < 0.75) 140 | { 141 | return Color.Blue; 142 | } 143 | if (prop < 0.825) 144 | { 145 | return Color.Purple; 146 | } 147 | return Color.Pink; 148 | } 149 | default: 150 | { 151 | return Color.Black; 152 | } 153 | } 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /NPlot/NPlot/NPlot/TextItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * TextItem.cs 5 | * Copyright (C) 2003-2006 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | 35 | namespace NPlot 36 | { 37 | 38 | /// 39 | /// This class implements drawing text against two physical axes. 40 | /// 41 | public class TextItem : IDrawable 42 | { 43 | 44 | private void Init() 45 | { 46 | FontFamily fontFamily = new FontFamily("Arial"); 47 | font_ = new Font(fontFamily, 10, FontStyle.Regular, GraphicsUnit.Pixel); 48 | } 49 | 50 | 51 | /// 52 | /// Constructor 53 | /// 54 | /// The position the text starts. 55 | /// The text. 56 | public TextItem( PointD position, string text ) 57 | { 58 | start_ = position; 59 | text_ = text; 60 | Init(); 61 | } 62 | 63 | 64 | /// 65 | /// Text associated. 66 | /// 67 | public string Text 68 | { 69 | get 70 | { 71 | return text_; 72 | } 73 | set 74 | { 75 | text_ = value; 76 | } 77 | } 78 | private string text_ = ""; 79 | 80 | 81 | /// 82 | /// The starting point for the text. 83 | /// 84 | public PointD Start 85 | { 86 | get 87 | { 88 | return start_; 89 | } 90 | set 91 | { 92 | start_ = value; 93 | } 94 | } 95 | private PointD start_; 96 | 97 | 98 | /// 99 | /// Draws the text on a plot surface. 100 | /// 101 | /// graphics surface on which to draw 102 | /// The X-Axis to draw against. 103 | /// The Y-Axis to draw against. 104 | public void Draw( System.Drawing.Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis ) 105 | { 106 | Point startPoint = new Point( 107 | (int)xAxis.WorldToPhysical( start_.X, true ).X, 108 | (int)yAxis.WorldToPhysical( start_.Y, true ).Y ); 109 | 110 | g.DrawString(text_, font_, textBrush_,(int)startPoint.X,(int)startPoint.Y); 111 | } 112 | 113 | 114 | /// 115 | /// The brush used to draw the text. 116 | /// 117 | public Brush TextBrush 118 | { 119 | get 120 | { 121 | return textBrush_; 122 | } 123 | set 124 | { 125 | textBrush_ = value; 126 | } 127 | } 128 | 129 | 130 | /// 131 | /// Set the text to be drawn with a solid brush of this color. 132 | /// 133 | public Color TextColor 134 | { 135 | set 136 | { 137 | textBrush_ = new SolidBrush( value ); 138 | } 139 | } 140 | 141 | /// 142 | /// The font used to draw the text associated with the arrow. 143 | /// 144 | public Font TextFont 145 | { 146 | get 147 | { 148 | return this.font_; 149 | } 150 | set 151 | { 152 | this.font_ = value; 153 | } 154 | } 155 | 156 | private Brush textBrush_ = new SolidBrush( Color.Black ); 157 | //private Pen pen_ = new Pen( Color.Black ); 158 | private Font font_; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 53 4 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources 5 | END 6 | NPlotDemo-icon.ico 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 72 10 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/NPlotDemo-icon.ico 11 | END 12 | PlotSurface2DDemo.resx 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 76 16 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/PlotSurface2DDemo.resx 17 | END 18 | light.wav 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 63 22 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/light.wav 23 | END 24 | MenuForm.resx 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 67 28 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/MenuForm.resx 29 | END 30 | FinancialDemo.resx 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 72 34 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/FinancialDemo.resx 35 | END 36 | AxisTestsForm.resx 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 72 40 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/AxisTestsForm.resx 41 | END 42 | asx_jbh.xml 43 | K 25 44 | svn:wc:ra_dav:version-url 45 | V 65 46 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/asx_jbh.xml 47 | END 48 | pattern01.jpg 49 | K 25 50 | svn:wc:ra_dav:version-url 51 | V 67 52 | /svnroot/nplot/!svn/ver/2/trunk/demo/csharp/resources/pattern01.jpg 53 | END 54 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/entries: -------------------------------------------------------------------------------- 1 | 8 2 | 3 | dir 4 | 31 5 | https://nplot.svn.sourceforge.net/svnroot/nplot/trunk/demo/csharp/resources 6 | https://nplot.svn.sourceforge.net/svnroot/nplot 7 | 8 | 9 | 10 | 2006-10-11T14:47:45.632802Z 11 | 2 12 | anmar 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | d24cb6f0-7a1f-0410-a64c-9fc4892c6eea 28 | 29 | NPlotDemo-icon.ico 30 | file 31 | 32 | 33 | 34 | 35 | 2008-01-08T11:59:13.209420Z 36 | a78a91ff7a8c59192edc05466a68bee5 37 | 2006-10-11T14:47:45.632802Z 38 | 2 39 | anmar 40 | has-props 41 | 42 | PlotSurface2DDemo.resx 43 | file 44 | 45 | 46 | 47 | 48 | 2008-01-08T11:59:13.219435Z 49 | 125e66150f42b777fd0e4458473a8d25 50 | 2006-10-11T14:47:45.632802Z 51 | 2 52 | anmar 53 | has-props 54 | 55 | light.wav 56 | file 57 | 58 | 59 | 60 | 61 | 2008-01-08T11:59:13.219435Z 62 | ae6d3505361cb0326d41660d5c9395b8 63 | 2006-10-11T14:47:45.632802Z 64 | 2 65 | anmar 66 | has-props 67 | 68 | MenuForm.resx 69 | file 70 | 71 | 72 | 73 | 74 | 2008-01-08T11:59:13.229449Z 75 | a530f9cd231bebe98ca920c502388821 76 | 2006-10-11T14:47:45.632802Z 77 | 2 78 | anmar 79 | has-props 80 | 81 | FinancialDemo.resx 82 | file 83 | 84 | 85 | 86 | 87 | 2008-01-08T11:59:13.239464Z 88 | 11f0ca52a45582f9575950d4b4a90094 89 | 2006-10-11T14:47:45.632802Z 90 | 2 91 | anmar 92 | has-props 93 | 94 | AxisTestsForm.resx 95 | file 96 | 97 | 98 | 99 | 100 | 2008-01-08T11:59:13.249478Z 101 | 902a24a82f2ef018f23afa9fa83f4605 102 | 2006-10-11T14:47:45.632802Z 103 | 2 104 | anmar 105 | has-props 106 | 107 | asx_jbh.xml 108 | file 109 | 110 | 111 | 112 | 113 | 2008-01-08T11:59:13.259492Z 114 | 3059bd9c25583f51b7eb707c23714c80 115 | 2006-10-11T14:47:45.632802Z 116 | 2 117 | anmar 118 | has-props 119 | 120 | pattern01.jpg 121 | file 122 | 123 | 124 | 125 | 126 | 2008-01-08T11:59:13.279521Z 127 | 2f99aec788109eab4bf37bd94d02f499 128 | 2006-10-11T14:47:45.632802Z 129 | 2 130 | anmar 131 | has-props 132 | 133 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/format: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/AxisTestsForm.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/FinancialDemo.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/MenuForm.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/NPlotDemo-icon.ico.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/PlotSurface2DDemo.resx.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/asx_jbh.xml.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:eol-style 3 | V 6 4 | native 5 | K 13 6 | svn:mime-type 7 | V 10 8 | text/plain 9 | END 10 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/light.wav.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/prop-base/pattern01.jpg.svn-base: -------------------------------------------------------------------------------- 1 | K 13 2 | svn:mime-type 3 | V 24 4 | application/octet-stream 5 | END 6 | -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/text-base/NPlotDemo-icon.ico.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/SwfTest/Resources/.svn/text-base/NPlotDemo-icon.ico.svn-base -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/text-base/light.wav.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/SwfTest/Resources/.svn/text-base/light.wav.svn-base -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/.svn/text-base/pattern01.jpg.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/SwfTest/Resources/.svn/text-base/pattern01.jpg.svn-base -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/NPlotDemo-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/SwfTest/Resources/NPlotDemo-icon.ico -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/pattern01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/SwfTest/Resources/pattern01.jpg -------------------------------------------------------------------------------- /NPlot/SwfTest/Resources/sound.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/NPlot/SwfTest/Resources/sound.wav -------------------------------------------------------------------------------- /NPlot/SwfTest/SwfSamples/PlotABC.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | 6 | using System.Windows.Forms; 7 | using NPlot; 8 | 9 | namespace SwfSamples 10 | { 11 | public class PlotABC : PlotSample 12 | { 13 | public PlotABC () 14 | { 15 | infoText = ""; 16 | infoText += "ABC (logo for australian broadcasting commission) Example. Demonstrates - \n"; 17 | infoText += " * How to set the background of a plotsurface as an image. \n"; 18 | infoText += " * EqualAspectRatio axis constraint \n"; 19 | infoText += " * Plot Zoom with Mouse Wheel, and mouse position Focus point"; 20 | 21 | plotSurface.Clear(); 22 | const int size = 200; 23 | float [] xs = new float [size]; 24 | float [] ys = new float [size]; 25 | for (int i=0; i 18.0f) { 46 | PlotQEExampleTextValues[i] = "KCsTe"; 47 | } 48 | else { 49 | PlotQEExampleTextValues[i] = ""; 50 | } 51 | s[i] = i.ToString("00") + ".1"; 52 | } 53 | 54 | PointPlot pp = new PointPlot(); 55 | pp.DataSource = PlotQEExampleValues; 56 | pp.Marker = new Marker( Marker.MarkerType.Square, 10 ); 57 | pp.Marker.DropLine = true; 58 | pp.Marker.Pen = Pens.CornflowerBlue; 59 | pp.Marker.Filled = false; 60 | plotSurface.Add( pp ); 61 | 62 | LabelPointPlot tp1 = new LabelPointPlot(); 63 | tp1.DataSource = PlotQEExampleValues; 64 | tp1.TextData = PlotQEExampleTextValues; 65 | tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above; 66 | tp1.Marker = new Marker( Marker.MarkerType.None, 10 ); 67 | plotSurface.Add( tp1 ); 68 | 69 | LabelAxis la = new LabelAxis( plotSurface.XAxis1 ); 70 | for (int i=0; i 98 | /// Callback for QE example timer tick. 99 | /// 100 | /// unused 101 | /// unused 102 | private void qeExampleTimer_Tick (object sender, System.EventArgs e) 103 | { 104 | Random r = new Random(); 105 | 106 | for (int i=0; i 18.0f ) { 109 | PlotQEExampleTextValues[i] = "KCsTe"; 110 | } 111 | else { 112 | PlotQEExampleTextValues[i] = ""; 113 | } 114 | } 115 | plotSurface.Refresh(); 116 | } 117 | 118 | } 119 | } 120 | 121 | -------------------------------------------------------------------------------- /NPlot/SwfTest/SwfSamples/SwfPlotSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | using System.Windows.Forms; 6 | 7 | using NPlot; 8 | 9 | namespace SwfSamples 10 | { 11 | public class PlotSample 12 | { 13 | protected NPlot.Swf.InteractivePlotSurface2D plotSurface; 14 | protected string infoText = ""; 15 | 16 | public PlotSample() 17 | { 18 | plotSurface = new NPlot.Swf.InteractivePlotSurface2D (); 19 | 20 | // Set defaults for the sample plotSurface 21 | plotSurface.AutoScaleAutoGeneratedAxes = false; 22 | plotSurface.AutoScaleTitle = false; 23 | plotSurface.Legend = null; 24 | plotSurface.ShowCoordinates = true; 25 | plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; 26 | plotSurface.Title = ""; 27 | plotSurface.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); 28 | plotSurface.Canvas.Name = "plotCanvas"; 29 | plotSurface.Canvas.BackColor = System.Drawing.SystemColors.Control; 30 | plotSurface.Canvas.Anchor = 31 | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; 32 | } 33 | 34 | public string InfoText 35 | { 36 | get { return infoText; } 37 | } 38 | 39 | public Control Canvas 40 | { 41 | get {return plotSurface.Canvas;} 42 | } 43 | 44 | public NPlot.Swf.InteractivePlotSurface2D PlotSurface 45 | { 46 | get { return plotSurface; } 47 | } 48 | 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /NPlot/SwfTest/SwfSamples/SwfPlotWave.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Reflection; 5 | 6 | using NPlot; 7 | 8 | namespace SwfSamples 9 | { 10 | public class PlotWave : PlotSample 11 | { 12 | public PlotWave() : base () 13 | { 14 | infoText = ""; 15 | infoText += "Sound Wave Example. Demonstrates - \n"; 16 | infoText += " * StepPlot (centered) and HorizontalLine IDrawables \n"; 17 | infoText += " * AxisDrag Interaction - try left clicking and dragging X or Y axes \n"; 18 | infoText += " * Vertical & Horizontal GuideLines - without fragmentation problems! \n"; 19 | infoText += " * Rubberband Selection - click and drag to zoom an area of the plot \n"; 20 | infoText += " * Key actions : +,- zoom, left/right/up/down pan, Home restores original scale and origin"; 21 | 22 | System.IO.Stream file = 23 | Assembly.GetExecutingAssembly().GetManifestResourceStream("SwfTest.Resources.sound.wav"); 24 | 25 | System.Int16[] w = new short[5000]; 26 | byte[] a = new byte[10000]; 27 | 28 | file.Read( a, 0, 10000 ); 29 | for (int i=100; i<5000; ++i) { 30 | w[i] = BitConverter.ToInt16(a,i*2); 31 | } 32 | file.Close(); 33 | 34 | plotSurface.Clear(); 35 | 36 | plotSurface.AddInteraction (new AxisDrag ()); 37 | plotSurface.AddInteraction (new KeyActions ()); 38 | plotSurface.AddInteraction (new NPlot.PlotSelection (Color.Gray)); 39 | plotSurface.AddInteraction (new VerticalGuideline (Color.Gray)); 40 | plotSurface.AddInteraction (new HorizontalGuideline (Color.Gray)); 41 | 42 | plotSurface.Add(new HorizontalLine(0.0, Color.LightBlue)); 43 | 44 | StepPlot sp = new StepPlot (); 45 | sp.DataSource = w; 46 | sp.Color = Color.Yellow; 47 | sp.Center = true; 48 | plotSurface.Add( sp ); 49 | 50 | plotSurface.YAxis1.FlipTicksLabel = true; 51 | 52 | plotSurface.PlotBackColor = Color.DarkBlue; 53 | plotSurface.Canvas.BackColor = Color.FromArgb (100, 100, 100); 54 | plotSurface.XAxis1.Color = Color.White; 55 | plotSurface.YAxis1.Color = Color.White; 56 | 57 | plotSurface.Refresh(); 58 | 59 | } 60 | 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /NPlot/SwfTest/SwfTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 10.0.0 7 | 2.0 8 | {1BA22AB4-C228-4115-BEA2-1C2548BFCC33} 9 | Exe 10 | SwfTest 11 | SwfTest 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | x86 22 | false 23 | 24 | 25 | none 26 | true 27 | bin\Release 28 | prompt 29 | 4 30 | x86 31 | false 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | {E4B99177-77A3-4C92-B881-A6CB57E3BF89} 61 | NPlot 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /NPlot/SwfTest/SwfTest/Swf.AxisTestsForm.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * NPlot - A charting library for .NET 3 | * 4 | * Swf.AxisTestsForm.cs 5 | * Copyright (C) 2003-2009 Matt Howlett and others. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without modification, 9 | * are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, this 12 | * list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 3. Neither the name of NPlot nor the names of its contributors may 17 | * be used to endorse or promote products derived from this software without 18 | * specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 24 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 | * OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | using System; 33 | using System.Drawing; 34 | using System.Collections; 35 | using System.ComponentModel; 36 | using System.Windows.Forms; 37 | 38 | using NPlot; 39 | 40 | namespace NPlotDemo 41 | { 42 | /// 43 | /// Summary description for Tests. 44 | /// 45 | public class AxisTestsForm : System.Windows.Forms.Form 46 | { 47 | /// 48 | /// Required designer variable. 49 | /// 50 | private System.ComponentModel.Container components = null; 51 | 52 | public AxisTestsForm() 53 | { 54 | // 55 | // Required for Windows Form Designer support 56 | // 57 | InitializeComponent(); 58 | 59 | // 60 | // TODO: Add any constructor code after InitializeComponent call 61 | // 62 | this.Paint += new PaintEventHandler(Tests_Paint); 63 | 64 | } 65 | 66 | /// 67 | /// Clean up any resources being used. 68 | /// 69 | protected override void Dispose( bool disposing ) 70 | { 71 | if( disposing ) 72 | { 73 | if(components != null) 74 | { 75 | components.Dispose(); 76 | } 77 | } 78 | base.Dispose( disposing ); 79 | } 80 | 81 | #region Windows Form Designer generated code 82 | /// 83 | /// Required method for Designer support 84 | /// 85 | private void InitializeComponent() 86 | { 87 | // 88 | // AxisTestsForm 89 | // 90 | this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 91 | this.ClientSize = new System.Drawing.Size(600, 400); 92 | this.Name = "AxisTestsForm"; 93 | this.Text = "Tests"; 94 | 95 | } 96 | #endregion 97 | 98 | #region Axis Tests 99 | // 100 | // The actual Axis tests 101 | // 102 | private void Tests_Paint (object sender, PaintEventArgs e) 103 | { 104 | Graphics g = e.Graphics; 105 | Rectangle bounds = e.ClipRectangle; 106 | 107 | Rectangle boundingBox; 108 | Point tl = Point.Empty; 109 | Point br = Point.Empty; 110 | 111 | tl.X = bounds.Left + 20; tl.Y = bounds.Top + 10; 112 | br.X = bounds.Left + 20; br.Y = bounds.Bottom - 50; 113 | 114 | NPlot.LinearAxis a = new LinearAxis (0, 10); 115 | a.Draw (g, tl, br, out boundingBox ); 116 | 117 | a.Reversed = true; 118 | tl.X += 30; br.X += 30; 119 | a.Draw (g, tl, br, out boundingBox ); 120 | 121 | a.SmallTickSize = 0; 122 | a.Draw (g, new Point(90,10), new Point(90, 200), out boundingBox ); 123 | 124 | a.LargeTickStep = 2.5; 125 | a.Draw( g, new Point(120,10), new Point(120,200), out boundingBox ); 126 | 127 | a.NumberOfSmallTicks = 5; 128 | a.SmallTickSize = 2; 129 | a.Draw( g, new Point(150,10), new Point(150,200), out boundingBox ); 130 | 131 | a.AxisColor = Color.Cyan; 132 | a.Draw( g, new Point(180,10), new Point(180,200), out boundingBox ); 133 | 134 | a.TickTextColor= Color.Cyan; 135 | a.Draw( g, new Point(210,10), new Point(210,200), out boundingBox ); 136 | 137 | a.TickTextBrush = Brushes.Black; 138 | a.AxisPen = Pens.Black; 139 | a.Draw( g, new Point(240,10), new Point(300,200), out boundingBox ); 140 | 141 | a.WorldMax = 100000; 142 | a.WorldMin = -3; 143 | a.LargeTickStep = double.NaN; 144 | a.Draw( g, new Point(330,10), new Point(330,200), out boundingBox ); 145 | 146 | a.NumberFormat = "{0:0.0E+0}"; 147 | a.Draw( g, new Point(380,10), new Point(380,200), out boundingBox ); 148 | 149 | // Test for default TicksAngle on positive X-axis, ie Ticks below X-axis 150 | NPlot.LinearAxis aX = new LinearAxis(0, 10); 151 | 152 | tl.X = bounds.Left + 90; tl.Y = bounds.Bottom - 150; 153 | br.X = bounds.Right - 30; br.Y = bounds.Bottom - 150; 154 | 155 | aX.Draw (g, tl, br, out boundingBox ); 156 | 157 | // Set TicksAngle to PI/4 anti-clockwise from positive X-axis direction 158 | aX.TicksAngle = (float)Math.PI / 4.0f; 159 | tl.Y += 40; br.Y += 40; 160 | aX.Draw (g, tl, br, out boundingBox ); 161 | 162 | DateTime timeMin = new DateTime (2013, 1, 1, 12, 30, 0); 163 | DateTime timeMax = new DateTime (2013, 2, 2, 12, 30, 0); 164 | 165 | DateTimeAxis dta = new DateTimeAxis (timeMin, timeMax); 166 | 167 | tl.Y += 30; br.Y += 30; 168 | dta.Draw (g, tl, br, out boundingBox); 169 | 170 | timeMin = new DateTime (2013, 1, 1, 12, 30, 0); 171 | timeMax = new DateTime (2013, 1, 1, 12, 59, 30); 172 | 173 | dta.WorldMin = (double)timeMin.Ticks; 174 | dta.WorldMax = (double)timeMax.Ticks; 175 | 176 | tl.Y += 30; br.Y += 30; 177 | dta.Draw (g, tl, br, out boundingBox); 178 | 179 | } 180 | #endregion 181 | 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /nplot_introduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hwthomas/NPlot/33557caa3ead84ffa70f1ecfe56d4c2a3cc5ca64/nplot_introduction.pdf --------------------------------------------------------------------------------