package org.verapdf.model.operator;

import org.verapdf.model.baselayer.Object;
import org.verapdf.model.coslayer.CosInteger;
import org.verapdf.model.coslayer.CosReal;
import org.verapdf.model.coslayer.CosString;
import org.verapdf.model.coslayer.CosArray;
import org.verapdf.model.coslayer.CosName;
import org.verapdf.model.coslayer.CosDict;
import org.verapdf.model.coslayer.CosRenderingIntent;

import org.verapdf.model.pdlayer.PDColorSpace;
import org.verapdf.model.pdlayer.PDExtGState;
import org.verapdf.model.pdlayer.PDXObject;
import org.verapdf.model.pdlayer.PDInlineImage;
import org.verapdf.model.pdlayer.PDShading;
import org.verapdf.model.pdlayer.PDFont;

% base class for all operators in the content stream
type Operator extends Object {
	
}

% General graphics state operators
type OpGeneralGS extends Operator {

}

% we define arguments as links to the Cos objects rather than than simple properties 
% because they shall be checked for implementation limits

% set line width operator
type Op_w_line_width extends OpGeneralGS {
	% line width
	link lineWidth: CosReal;
}

% set line cap operator
type Op_J_line_cap extends OpGeneralGS {
	% line cap
	link lineCap: CosInteger;
}

% set line join operator
type Op_j_line_join extends OpGeneralGS {
	% line join
	link lineJoin: CosInteger;
}

% miter limit operator
type Op_M_miter_limit extends OpGeneralGS {
	% miter limit
	link miterLimit: CosReal;
}

% set dash pattern operator
type Op_d extends OpGeneralGS {
	% dash array
	link dashArray: CosArray;
	% dash phase
	link dashPhase: CosReal;
}

% rendering intent operator
type Op_ri extends OpGeneralGS {
	% rendering intent
	link renderingIntent: CosRenderingIntent;
}

% flatness operator
type Op_i extends OpGeneralGS {
	% flatness
	link flatness: CosReal;
}

% extended graphics state operator
type Op_gs extends OpGeneralGS {
	% ExtGState dictionary
	link extGState: PDExtGState;
}

% Special graphics state operators
type OpSpecialGS extends Operator {

}

% gsave operator
type Op_q_gsave extends OpSpecialGS {
	% the number of nested g/Q pair (subject to implementation limits)
	property nestingLevel: Integer;
}

% grestore operator
type Op_Q_grestore extends OpSpecialGS {

}

% current transformation matrix
type Op_cm extends OpSpecialGS {
	% the coefficients of the concatenation matrix
	link matrix: CosReal+;
}

% Path construction operators
type OpPathConstruction extends Operator {

}

% moveto operator
type Op_m_moveto extends OpPathConstruction {
	% operator arguments
	link point: CosReal+;
}

% lineto operator
type Op_l extends OpPathConstruction {
	% operator arguments
	link point: CosReal+;
}

% curveto operator
type Op_c extends OpPathConstruction {
	% operator arguments
	link controlPoints: CosReal+;
}

% special curveto operator
type Op_v extends OpPathConstruction {
	% operator arguments
	link controlPoints: CosReal+;
}

% special curveto operator
type Op_y extends OpPathConstruction {
	% operator arguments
	link controlPoints: CosReal+;
}

% close subpath operator
type Op_h extends OpPathConstruction {

}

% rect operator
type Op_re extends OpPathConstruction {
	% rectangle box
	link rectBox: CosReal+;
}

% Path paint operators
type OpPathPaint extends Operator {

}

% path close and stroke operator
type Op_s_close_stroke extends OpPathPaint {
	% stroke color space
	link strokeCS: PDColorSpace;
}

% path stroke operator
type Op_S_stroke extends OpPathPaint {
	% stroke color space
	link strokeCS: PDColorSpace;
}

% path fill operator
type Op_f_fill extends OpPathPaint {
	% fill color space
	link fillCS: PDColorSpace;
}

% another path fill operator
type Op_F_fill_obsolete extends OpPathPaint {
	% fill color space
	link fillCS: PDColorSpace;
}

% path fill (even-odd rule) operator
type Op_FStar extends OpPathPaint {
	% fill color space
	link fillCS: PDColorSpace;	
}

% path fill and stroke operator
type Op_B_fill_stroke extends OpPathPaint {
	% fill color space
	link fillCS: PDColorSpace;
	% stroke color space
	link strokeCS: PDColorSpace;		
}

% path fill (even-odd rule) and stroke operator
type Op_BStar_eofill_stroke extends OpPathPaint {
	% fill color space
	link fillCS: PDColorSpace;
	% stroke color space
	link strokeCS: PDColorSpace;		
}

% path close, fill and stroke operator
type Op_b_closepath_fill_stroke extends OpPathPaint {
	% fill color space
	link fillCS: PDColorSpace;
	% stroke color space
	link strokeCS: PDColorSpace;		
}

% path close, fill (even-odd rule) and stroke operator
type Op_bstar_closepath_eofill_stroke extends OpPathPaint {
	% fill color space
	link fillCS: PDColorSpace;
	% stroke color space
	link strokeCS: PDColorSpace;		
}

% path painting no-op
type Op_n extends OpPathPaint {
 
}

% Clip operators
type OpClip extends Operator {

}

% clip (non-zero rule)
type Op_W_clip extends OpClip {

}

% clip (even-odd rule)
type Op_WStar extends OpClip {

}


% Text object operators
type OpTextObject extends Operator {

}
%OpTextObject->Op_ET, Op_BT

% Text state operators
type OpTextState extends Operator {

}

type Op_Tz extends OpTextState {
	% the horizontal text scaling
	link scale: CosReal;
}

type Op_Tr extends OpTextState {
	% rendering mode
	property renderingMode: Integer;
}

type Op_Tc extends OpTextState {
	% character spacing
	link charSpace: CosReal;
}

type Op_Tf extends OpTextState {
	% font size
	link size: CosReal;
	% the text font
	link fontName: CosName;
}

type Op_Tl extends OpTextState {
	% the text leading
	link leading: CosReal;
}

type Op_Ts extends OpTextState {
	% text rise
	link rise: CosReal;
}

type Op_Tw extends OpTextState {
	% word spacing
	link wordSpace: CosReal;
}
%OpTextState->Op_Tc, Op_Tw, Op_Tz, Op_TL, Op_Tf, Op_Tr, Op_Ts

% Text position operators
type OpTextPosition extends Operator {

}

type Op_Td extends OpTextPosition {
	% horizontal offset
	link horizontalOffset: CosReal;
	% vertical offset
	link verticalOffset: CosReal;
}

type Op_TD_Big extends OpTextPosition {
	% horizontal offset
	link horizontalOffset: CosReal;
	% vertical offset
	link verticalOffset: CosReal;
}

type Op_Tm extends OpTextPosition {
	% elements of text matrix
	link controlPoints: CosReal+;
}
% OpTextPosition->Op_Td, Op_TD, Op_Tm, Op_T*

% Text show operators
type OpTextShow extends Operator {
	% Link to the current font. There is no font specified for text in rendering mode 3.
	link font: PDFont?;
	% Link to all glyphs used in the text. There are no glyphs in case of rendering mode 3
	link usedGlyphs: Glyph*;
	% fill color space, if the rendering mode specifies fill operation (0,2,4,6)
	link fillCS: PDColorSpace?;
	% stroke color space, if the rendering mode specifies stroke operation (1,2,5,6)
	link strokeCS: PDColorSpace?;
}

% Text show operator
type Op_Tj extends OpTextShow {
	% string to show (before font encoding mapping is applied)
	link showString: CosString;
}

% Text show operator with individual glyph positioning
type Op_TJ_Big extends OpTextShow {
	% array containing strings and glyphs width
	link specialStrings: CosArray;
}

% EOL and text show operator
type Op_Quote extends OpTextShow {
	% string to show (before font encoding mapping is applied)
	link showString: CosString;
}

% EOL and text show operator with char and word spacing
type Op_DoubleQuote extends OpTextShow {
	% string to show (before font encoding mapping is applied)
	link showString: CosString;
	% unscaled word spacing
	link wordSpacing: CosReal;
	% unscaled character spacing
	link characterSpacing: CosReal;
}


% Type3 font operators
type OpType3Font extends Operator {

}

type Op_d0 extends OpType3Font {
	% the horizontal displacement in the glyph coordinate system
	link horizontalDisplacement: CosReal;
	% the vertical displacement in the glyph coordinate system
	link verticalDisplacement: CosReal;
}

type Op_d1 extends OpType3Font {
	% width and bounding box information for the glyph
	link controlPoints: CosReal+;
}
% OpType3Font->Op_d0, Op_d1

% Color operators
type OpColor extends Operator {

}

% Op_Color->Op_CS, Op_cs, Op_SC, Op_SCN, Op_sc, Op_scn, Op_G, Op_g, Op_RG, Op_rg, Op_K, Op_k

% Shading operators
type OpShading extends Operator {

}

% smooth shading operator
type Op_sh extends OpShading {
	% link to the corresponding Shading resource
	link shading: PDShading;
}

% Inline image operators
type OpInlineImage extends Operator {

}

% Begin inline image
type Op_BI extends OpInlineImage {

}

% End inline image dictionary
type Op_ID extends OpInlineImage {
	% link to dictionary containing image parameters
	link inlineImageDictionary : CosDict;
}

% End inline image data
type Op_EI extends OpInlineImage {
	% link to the inline image object
	link inlineImage: PDInlineImage;
}

% XObject operators
type OpXObject extends Operator {

}

% XObject Do operator
type Op_Do extends OpXObject {
	% link to the corresponding XObject resource
	link xObject: PDXObject;
}


% Marked content operators
type OpMarkedContent extends Operator {

}

% define marked content point
type Op_MP extends OpMarkedContent {
	% tag name
	link tag: CosName;
}

% define marked content point with properties
type Op_DP extends OpMarkedContent {
	% tag name
	link tag: CosName;
	% properties dictionary
	link properties: CosDict;
}

% start marked content region
type Op_BMC extends OpMarkedContent {
	% tag name
	link tag: CosName;
}

% start marked content region with properties
type Op_BDC extends OpMarkedContent {
	% tag name
	link tag: CosName;
	% properties dictionary
	link properties: CosDict;
}

% end marked content region
type Op_EMC extends OpMarkedContent {

}

% Compatibility operators
type OpCompatibility extends Operator {

}

% begin compatibility region
type Op_BX extends OpCompatibility {

}

% end compatibility region
type Op_EX extends OpCompatibility {

}

% any operator not defined in PDF Reference
type Op_Undefined extends OpCompatibility {

}

% glyph used in text
type Glyph extends Object {
	% true if the width of the glyph in the embedded font program is consistent with the width specified in the Font dictionary
	property isWidthConsistent: Boolean;
	% true if glyph is present in the font program
	property isGlyphPresent: Boolean;
}

% glyph in the composite font
type CIDGlyph extends Glyph {
	% CID value of the glyph as derived from the font CMap
	property CID: Integer;
}
