Operation.cs :  » PDF » PDF-Clown » it » stefanochizzolini » clown » documents » contents » objects » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » PDF » PDF Clown 
PDF Clown » it » stefanochizzolini » clown » documents » contents » objects » Operation.cs
/*
  Copyright 2006,2007,2008 Stefano Chizzolini. http://clown.stefanochizzolini.it

  Contributors:
    * Stefano Chizzolini (original code developer, http://www.stefanochizzolini.it)

  This file should be part of the source code distribution of "PDF Clown library"
  (the Program): see the accompanying README files for more info.

  This Program is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later version.

  This Program is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY, either expressed or implied; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.

  You should have received a copy of the GNU General Public License along with this
  Program (see README files); if not, go to the GNU website (http://www.gnu.org/).

  Redistribution and use, with or without modification, are permitted provided that such
  redistributions retain the above copyright notice, license and disclaimer, along with
  this list of conditions.
*/

using it.stefanochizzolini.clown.bytes;
using it.stefanochizzolini.clown.objects;

using System;
using System.Collections.Generic;
using System.Text;

namespace it.stefanochizzolini.clown.documents.contents.objects{
  /**
    <summary>Content stream instruction [PDF:1.6:3.7.1].</summary>
  */
  public class Operation
    : ContentObject
  {
    #region static
    #region interface
    #region public
    /**
      <summary>Gets a specific operation.</summary>
      <param name="operator_">Operator.</param>
      <param name="operands">List of operands.</param>
      <returns>Operation associated to the operator.</returns>
    */
    public static Operation Get(
      string operator_,
      List<PdfDirectObject> operands
      )
    {
      /*
        NOTE: This is a factory method for any operation-derived object.
      */
      if(operator_ == null)
        return null;

      if(operator_.Equals(SaveGraphicsState.OperatorKeyword)) return SaveGraphicsState.Value;
      if(operator_.Equals(SetFont.OperatorKeyword)) return new SetFont(operands);
      if(operator_.Equals(SetStrokeColor.OperatorKeyword)) return new SetStrokeColor(operands);
      if(operator_.Equals(SetStrokeColorSpace.OperatorKeyword)) return new SetStrokeColorSpace(operands);
      if(operator_.Equals(SetFillColor.OperatorKeyword)) return new SetFillColor(operands);
      if(operator_.Equals(SetFillColorSpace.OperatorKeyword)) return new SetFillColorSpace(operands);
      if(operator_.Equals(RestoreGraphicsState.OperatorKeyword)) return RestoreGraphicsState.Value;
      if(operator_.Equals(BeginSubpath.OperatorKeyword)) return new BeginSubpath(operands);
      if(operator_.Equals(CloseSubpath.OperatorKeyword)) return CloseSubpath.Value;
      if(operator_.Equals(CloseStroke.OperatorKeyword)) return CloseStroke.Value;
      if(operator_.Equals(Fill.OperatorKeyword)
        || operator_.Equals(Fill.ObsoleteOperatorKeyword)) return Fill.Value;
      if(operator_.Equals(FillEvenOdd.OperatorKeyword)) return FillEvenOdd.Value;
      if(operator_.Equals(Stroke.OperatorKeyword)) return Stroke.Value;
      if(operator_.Equals(FillStroke.OperatorKeyword)) return FillStroke.Value;
      if(operator_.Equals(FillStrokeEvenOdd.OperatorKeyword)) return FillStrokeEvenOdd.Value;
      if(operator_.Equals(CloseFillStroke.OperatorKeyword)) return CloseFillStroke.Value;
      if(operator_.Equals(CloseFillStrokeEvenOdd.OperatorKeyword)) return CloseFillStrokeEvenOdd.Value;
      if(operator_.Equals(EndPathNoOp.OperatorKeyword)) return EndPathNoOp.Value;
      if(operator_.Equals(ModifyClipPath.OperatorKeyword)) return ModifyClipPath.Value;
      if(operator_.Equals(ModifyClipPathEvenOdd.OperatorKeyword)) return ModifyClipPathEvenOdd.Value;
      if(operator_.Equals(TranslateTextToNextLine.OperatorKeyword)) return TranslateTextToNextLine.Value;
      if(operator_.Equals(ShowText.OperatorKeyword)) return new ShowText(operands);
      if(operator_.Equals(TranslateTextRelative.OperatorKeyword)) return new TranslateTextRelative(operands);
      if(operator_.Equals(SetTextMatrix.OperatorKeyword)) return new SetTextMatrix(operands);
      if(operator_.Equals(ModifyCTM.OperatorKeyword)) return new ModifyCTM(operands);
      if(operator_.Equals(PaintXObject.OperatorKeyword)) return new PaintXObject(operands);
      if(operator_.Equals(PaintShadingObject.OperatorKeyword)) return new PaintShadingObject(operands);
      if(operator_.Equals(SetCharSpace.OperatorKeyword)) return new SetCharSpace(operands);
      if(operator_.Equals(SetLineCap.OperatorKeyword)) return new SetLineCap(operands);
      if(operator_.Equals(SetLineDash.OperatorKeyword)) return new SetLineDash(operands);
      if(operator_.Equals(SetLineJoin.OperatorKeyword)) return new SetLineJoin(operands);
      if(operator_.Equals(SetLineWidth.OperatorKeyword)) return new SetLineWidth(operands);
      if(operator_.Equals(SetMiterLimit.OperatorKeyword)) return new SetMiterLimit(operands);
      if(operator_.Equals(SetTextLead.OperatorKeyword)) return new SetTextLead(operands);
      if(operator_.Equals(SetTextRise.OperatorKeyword)) return new SetTextRise(operands);
      if(operator_.Equals(SetTextScale.OperatorKeyword)) return new SetTextScale(operands);
      if(operator_.Equals(SetTextRenderMode.OperatorKeyword)) return new SetTextRenderMode(operands);
      if(operator_.Equals(SetWordSpace.OperatorKeyword)) return new SetWordSpace(operands);
      if(operator_.Equals(DrawLine.OperatorKeyword)) return new DrawLine(operands);
      if(operator_.Equals(DrawRectangle.OperatorKeyword)) return new DrawRectangle(operands);
      if(operator_.Equals(DrawCurve.FinalOperator)
        || operator_.Equals(DrawCurve.FullOperator)
        || operator_.Equals(DrawCurve.InitialOperator)) return new DrawCurve(operator_,operands);
      if(operator_.Equals(EndInlineImage.OperatorKeyword)) return EndInlineImage.Value;
      if(operator_.Equals(BeginText.OperatorKeyword)) return BeginText.Value;
      if(operator_.Equals(EndText.OperatorKeyword)) return EndText.Value;
      if(operator_.Equals(BeginMarkedContent.SimpleOperatorKeyword)) return new BeginMarkedContent((PdfName)operands[0]);
      if(operator_.Equals(BeginMarkedContent.PropertyListOperatorKeyword)) return new BeginMarkedContent((PdfName)operands[0],operands[1]);
      if(operator_.Equals(EndMarkedContent.OperatorKeyword)) return EndMarkedContent.Value;
      if(operator_.Equals(BeginInlineImage.OperatorKeyword)) return BeginInlineImage.Value;
      if(operator_.Equals(EndInlineImage.OperatorKeyword)) return EndInlineImage.Value;

      // No explicit operation implementation available.
      return new Operation(operator_,operands);
    }
    #endregion
    #endregion
    #endregion

    #region dynamic
    #region fields
    protected string operator_;
    protected List<PdfDirectObject> operands;
    #endregion

    #region constructors
    public Operation(
      string operator_
      )
    {this.operator_ = operator_;}

    public Operation(
      String operator_,
      PdfDirectObject operand
      )
    {
      this.operator_ = operator_;

      this.operands = new List<PdfDirectObject>();
      this.operands.Add(operand);
    }

    public Operation(
      string operator_,
      List<PdfDirectObject> operands
      )
    {
      this.operator_ = operator_;
      this.operands = operands;
    }
    #endregion

    #region interface
    #region public
    public string Operator
    {get{return operator_;}}

    public List<PdfDirectObject> Operands
    {get{return operands;}}

    public override string ToString(
      )
    {
      StringBuilder buffer = new StringBuilder();

      // Begin.
      buffer.Append("{");

      // Operator.
      buffer.Append(operator_);

      // Operands.
      if(operands != null)
      {
        buffer.Append(" [");
        for(
          int i = 0, count = operands.Count;
          i < count;
          i++
          )
        {
          if(i > 0)
          {buffer.Append(", ");}

          buffer.Append(operands[i].ToString());
        }
        buffer.Append("]");
      }

      // End.
      buffer.Append("}");

      return buffer.ToString();
    }

    public override void WriteTo(
      IOutputStream stream
      )
    {
      if(operands != null)
      {
        foreach(PdfDirectObject operand in operands)
        {operand.WriteTo(stream); stream.Write(" ");}
      }
      stream.Write(operator_); stream.Write("\n");
    }
    #endregion
    #endregion
    #endregion
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.