Bitmap.PlotSurface2D.cs

Go to the documentation of this file.
00001 /*
00002 NPlot - A charting library for .NET
00003 
00004 Bitmap.PlotSurface2D.cs
00005 Copyright (C) 2003 
00006 Matt Howlett
00007 
00008 Redistribution and use of NPlot or parts there-of in source and
00009 binary forms, with or without modification, are permitted provided
00010 that the following conditions are met:
00011 
00012 1. Re-distributions in source form must retain at the head of each
00013    source file the above copyright notice, this list of conditions
00014    and the following disclaimer.
00015 
00016 2. Any product ("the product") that makes use NPlot or parts 
00017    there-of must either:
00018   
00019     (a) allow any user of the product to obtain a complete machine-
00020         readable copy of the corresponding source code for the 
00021         product and the version of NPlot used for a charge no more
00022         than your cost of physically performing source distribution,
00023         on a medium customarily used for software interchange, or:
00024 
00025     (b) reproduce the following text in the documentation, about 
00026         box or other materials intended to be read by human users
00027         of the product that is provided to every human user of the
00028         product: 
00029    
00030               "This product includes software developed as 
00031               part of the NPlot library project available 
00032               from: http://www.nplot.com/" 
00033 
00034         The words "This product" may optionally be replace with 
00035         the actual name of the product.
00036 
00037 ------------------------------------------------------------------------
00038 
00039 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00040 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00041 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00042 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00043 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00044 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00045 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00046 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00047 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00048 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00049 
00050 */
00051 
00052 using System;
00053 using System.Drawing;
00054 using System.Drawing.Drawing2D;
00055 using System.Collections;
00056 
00057 namespace NPlot
00058 {
00059 
00060         namespace Bitmap
00061         {
00062 
00067                 public class PlotSurface2D: IPlotSurface2D 
00068                 {
00069 
00075                         public PlotSurface2D( int width, int height )
00076                         {
00077                                 b_ = new System.Drawing.Bitmap( width, height );
00078                                 ps_ = new NPlot.PlotSurface2D();        
00079                         }
00080 
00085                         public PlotSurface2D( System.Drawing.Bitmap b )
00086                         {
00087                                 b_ = b;
00088                                 ps_ = new NPlot.PlotSurface2D();        
00089                         }
00090 
00091 
00097                         public void Draw( Graphics g, Rectangle bounds )
00098                         {
00099                                 ps_.Draw( g, bounds );
00100                         }
00101 
00102 
00106                         public void Clear()
00107                         {
00108                                 ps_.Clear();
00109                         }
00110 
00111 
00117                         public void Add( IDrawable p )
00118                         {
00119                                 ps_.Add( p );
00120                         }
00121 
00122 
00130                         public void Add( IDrawable p, NPlot.PlotSurface2D.XAxisPosition xp, NPlot.PlotSurface2D.YAxisPosition yp )
00131                         {
00132                                 ps_.Add( p, xp, yp );
00133                         }
00134 
00141                         public void Add( IDrawable p, int zOrder )
00142                         {
00143                                 ps_.Add( p, zOrder );
00144                         }
00145 
00146 
00155                         public void Add( IDrawable p, NPlot.PlotSurface2D.XAxisPosition xp,
00156                                 NPlot.PlotSurface2D.YAxisPosition yp, int zOrder )
00157                         {
00158                                 ps_.Add( p, xp, yp , zOrder);
00159                         }
00160 
00164                         public string Title
00165                         {
00166                                 get 
00167                                 {
00168                                         return ps_.Title;
00169                                 }
00170                                 set 
00171                                 {
00172                                         ps_.Title = value;
00173                                 }
00174                         }
00175 
00176 
00180                         public Font TitleFont 
00181                         {
00182                                 get 
00183                                 {
00184                                         return ps_.TitleFont;
00185                                 }
00186                                 set 
00187                                 {
00188                                         ps_.TitleFont = value;
00189                                 }
00190                         }
00191 
00192 
00197                         public int Padding
00198                         {
00199                                 get
00200                                 {
00201                                         return ps_.Padding;
00202                                 }
00203                                 set
00204                                 {
00205                                         ps_.Padding = value;
00206                                 }
00207                         }
00208 
00209 
00213                         public Axis XAxis1
00214                         {
00215                                 get
00216                                 {
00217                                         return ps_.XAxis1;
00218                                 }
00219                                 set
00220                                 {
00221                                         ps_.XAxis1 = value;
00222                                 }
00223                         }
00224 
00225 
00229                         public Axis YAxis1
00230                         {
00231                                 get
00232                                 {
00233                                         return ps_.YAxis1;
00234                                 }
00235                                 set
00236                                 {
00237                                         ps_.YAxis1 = value;
00238                                 }
00239                         }
00240 
00241 
00245                         public Axis XAxis2
00246                         {
00247                                 get
00248                                 {
00249                                         return ps_.XAxis2;
00250                                 }
00251                                 set
00252                                 {
00253                                         ps_.XAxis2 = value;
00254                                 }
00255                         }
00256 
00257 
00261                         public Axis YAxis2
00262                         {
00263                                 get
00264                                 {
00265                                         return ps_.YAxis2;
00266                                 }
00267                                 set
00268                                 {
00269                                         ps_.YAxis2 = value;
00270                                 }
00271                         }
00272 
00273 
00277                         public NPlot.Legend Legend
00278                         {
00279                                 get
00280                                 {
00281                                         return ps_.Legend;
00282                                 }
00283                                 set
00284                                 {
00285                                         ps_.Legend = value;
00286                                 }
00287                         }
00288 
00292                         public int LegendZOrder
00293                         {
00294                                 get
00295                                 {
00296                                         return ps_.LegendZOrder;
00297                                 }
00298                                 set
00299                                 {
00300                                         ps_.LegendZOrder = value;
00301                                 }
00302                         }
00303 
00307                         public System.Drawing.Color PlotBackColor
00308                         {
00309                                 set
00310                                 {
00311                                         ps_.PlotBackColor = value;
00312                                 }
00313                         }
00314 
00315 
00319                         public System.Drawing.Bitmap PlotBackImage
00320                         {
00321                                 set
00322                                 {
00323                                         ps_.PlotBackImage = value;
00324                                 }
00325                         }
00326 
00327 
00331                         public IRectangleBrush PlotBackBrush
00332                         {
00333                                 set
00334                                 {
00335                                         ps_.PlotBackBrush = value;
00336                                 }
00337                         }
00338 
00339 
00343                         public System.Drawing.Drawing2D.SmoothingMode SmoothingMode 
00344                         { 
00345                                 get
00346                                 {
00347                                         return ps_.SmoothingMode;
00348                                 }
00349                                 set
00350                                 {
00351                                         ps_.SmoothingMode = value;
00352                                 }
00353                         }
00354 
00355 
00359                         public int Width 
00360                         {
00361                                 get
00362                                 {
00363                                         return b_.Width;
00364                                 }
00365                         }
00366 
00367 
00371                         public int Height 
00372                         {
00373                                 get 
00374                                 {
00375                                         return b_.Height;
00376                                 }
00377                         }
00378 
00379 
00385                         public System.IO.MemoryStream ToStream( System.Drawing.Imaging.ImageFormat imageFormat ) 
00386                         {
00387                                 System.IO.MemoryStream stream = new System.IO.MemoryStream();
00388                                 ps_.Draw(Graphics.FromImage(this.Bitmap),new System.Drawing.Rectangle(0,0,b_.Width,b_.Height));
00389                                 this.Bitmap.Save(stream, imageFormat);
00390                                 return stream;
00391                         }
00392 
00393 
00397                         public System.Drawing.Bitmap Bitmap 
00398                         {
00399                                 get 
00400                                 {
00401                                         return b_;
00402                                 }
00403                                 set
00404                                 {
00405                                         b_ = value;
00406                                 }
00407                         }
00408 
00409 
00413                         public Color BackColor
00414                         {
00415                                 set
00416                                 {
00417                                         backColor_ = value;
00418                                 }
00419                         }
00420                         object backColor_ = null;
00421                         
00422 
00426                         public void Refresh()
00427                         {
00428                                 if (this.backColor_!=null)
00429                                 {
00430                                         Graphics g = Graphics.FromImage( b_ );
00431                                         g.FillRectangle( (new Pen( (Color)this.backColor_)).Brush,0,0,b_.Width,b_.Height );
00432                                 }
00433                                 ps_.Draw( Graphics.FromImage(b_), new System.Drawing.Rectangle(0,0,b_.Width,b_.Height) );
00434                         }
00435 
00436 
00437                         private NPlot.PlotSurface2D ps_;
00438                         private System.Drawing.Bitmap b_;
00439 
00440                         
00446                         public void AddAxesConstraint( AxesConstraint c )
00447                         {
00448                                 ps_.AddAxesConstraint( c );
00449                         }
00450 
00451 
00456                         public bool AutoScaleTitle
00457                         {
00458                                 get
00459                                 {
00460                                         return ps_.AutoScaleTitle;
00461                                 }
00462                                 set
00463                                 {
00464                                         ps_.AutoScaleTitle = value;
00465                                 }
00466                         }
00467 
00468 
00477                         public bool AutoScaleAutoGeneratedAxes
00478                         {
00479                                 get
00480                                 {
00481                                         return ps_.AutoScaleAutoGeneratedAxes;
00482                                 }
00483                                 set
00484                                 {
00485                                         ps_.AutoScaleAutoGeneratedAxes = value;
00486                                 }
00487                         }
00488 
00489 
00493                         public Color TitleColor
00494                         {
00495                                 set
00496                                 {
00497                                         ps_.TitleColor = value;
00498                                 }
00499                         }
00500 
00501 
00505                         public Brush TitleBrush
00506                         {
00507                                 get
00508                                 {
00509                                         return ps_.TitleBrush;
00510                                 }
00511                                 set
00512                                 {
00513                                         ps_.TitleBrush = value;
00514                                 }
00515                         }
00516 
00522             public void Remove(IDrawable p, bool updateAxes)
00523             {
00524                 ps_.Remove(p, updateAxes);
00525             }
00526 
00527 
00531                         public ArrayList Drawables
00532                         {
00533                                 get
00534                                 {
00535                                         return ps_.Drawables;
00536                                 }
00537                         }
00538 
00539                 }
00540         }
00541 }

Generated on Sat Nov 5 01:04:05 2005 for NPlot by  doxygen 1.4.5