/// /// <summary> * fitsShift - checks whether <code>matrix</code> matches the /// * <code>Shift</code> attribute specified for this Evaluation /// * </summary> /// * <param name="matrix"> /// * matrix to test </param> /// * <returns> boolean - true, if 'matrix' matches the Shift or if Shift is not /// * specified </returns> /// private bool fitsShift(JDFMatrix matrix) { if (!hasAttribute(AttributeName.SHIFT)) { return(true); } JDFRectangle shiftValue = new JDFRectangle(getShift()); double minTx = shiftValue.Llx; double minTy = shiftValue.Lly; double maxTx = shiftValue.Urx; double maxTy = shiftValue.Ury; double Tx = matrix.Tx; double Ty = matrix.Ty; if (!hasAttribute(AttributeName.TOLERANCE)) { return((Tx >= minTx) && (Tx <= maxTx) && (Ty >= minTy) && (Ty <= maxTy)); } double nT = getTolerance().X; // negative tolerance double pT = getTolerance().Y; // positive tolerance return((Tx - nT >= minTx) && (Tx + pT <= maxTx) && (Ty - nT >= minTy) && (Ty + pT <= maxTy)); }
public virtual JDFRectangle getCurrentValue() { try { JDFRectangle r = new JDFRectangle(getAttribute(AttributeName.CURRENTVALUE)); return(r); } catch (FormatException) { throw new JDFException("JDFRectangleState.getCurrentValue: Attribute CURRENTVALUE is not capable to create JDFRectangle"); } }
/// /// <summary> * fitsTolerance - checks whether this Evaluation has a specified Tolerance /// * that it is not equal to "0 0", and expands original the rangelist to the /// * rangelist that fits Tolerance. /// * </summary> /// * <param name="rangeList"> /// * original rangelist </param> /// * <returns> NumberRangeList - expanded rangelist, returns original range if /// * Tolerance=="0 0" </returns> /// private JDFRectangleRangeList fitsTolerance(JDFRectangleRangeList origRangeList) { double nt = getTolerance().X; // negative tolerance double pt = getTolerance().Y; // positive tolerance if ((nt == 0) && (pt == 0)) { return(origRangeList); } // expand our original range into the range +/- Tolerance JDFRectangleRangeList rangeList = new JDFRectangleRangeList(origRangeList); JDFRectangleRangeList tolRangeList = new JDFRectangleRangeList(); int size = rangeList.Count; for (int i = 0; i < size; i++) { JDFRectangleRange range = (JDFRectangleRange)rangeList[i]; JDFRectangle left = range.Left; double leftLlx = left.Llx; double leftLly = left.Lly; double leftUrx = left.Urx; double leftUry = left.Ury; left.Llx = leftLlx - nt; left.Lly = leftLly - nt; left.Urx = leftUrx - nt; left.Ury = leftUry - nt; JDFRectangle right = range.Right; double rightLlx = right.Llx; double rightLly = right.Lly; double rightUrx = right.Urx; double rightUry = right.Ury; right.Llx = rightLlx + pt; right.Lly = rightLly + pt; right.Urx = rightUrx + pt; right.Ury = rightUry + pt; range.Left = left; range.Right = right; tolRangeList.Append(range); } return(tolRangeList); }
// // * // FitsValue Methods // /// /// <summary> * fitsValue - checks whether <code>value</code> matches the testlists /// * specified for this Evaluation /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <returns> boolean - true, if <code>value</code> matches the testlists or if /// * testlists are not specified </returns> /// public sealed override bool fitsValue(string @value) { if (!fitsListType(@value)) { return(false); } JDFRectangleRangeList rrl = null; try { rrl = new JDFRectangleRangeList(@value); } catch (FormatException) { return(false); } int siz = rrl.Count; for (int i = 0; i < siz; i++) // For every range, that rangelist // consists of, { // we test both of range deliminators - right and left, if they fit // HWRelation // In this case test of deliminators is sufficient for evaluation of // the whole range JDFRectangleRange range = (JDFRectangleRange)rrl[i]; JDFRectangle left = range.Left; JDFRectangle right = range.Right; if (left.Equals(right)) { JDFRectangle rectangle = left; if ((fitsValueList(new JDFRectangleRange(rectangle)) && fitsHWRelation(rectangle)) == false) { return(false); } } else { if ((fitsValueList(range) && fitsHWRelation(left) && fitsHWRelation(right)) == false) { return(false); } } } return(true); }
/// /// <summary> * (20) get JDFRectangle attribute Offset </summary> /// * <returns> JDFRectangle the value of the attribute, null if a the /// * attribute value is not a valid to create a JDFRectangle </returns> /// public virtual JDFRectangle getOffset() { string strAttrName = ""; JDFRectangle nPlaceHolder = null; strAttrName = getAttribute(AttributeName.OFFSET, null, JDFConstants.EMPTYSTRING); try { nPlaceHolder = new JDFRectangle(strAttrName); } catch (FormatException) { return(null); } return(nPlaceHolder); }
/// /// <summary> * (20) get JDFRectangle attribute SurfaceContentsBox </summary> /// * <returns> JDFRectangle the value of the attribute, null if a the /// * attribute value is not a valid to create a JDFRectangle </returns> /// public virtual JDFRectangle getSurfaceContentsBox() { string strAttrName = ""; JDFRectangle nPlaceHolder = null; strAttrName = getAttribute(AttributeName.SURFACECONTENTSBOX, null, JDFConstants.EMPTYSTRING); try { nPlaceHolder = new JDFRectangle(strAttrName); } catch (FormatException) { return(null); } return(nPlaceHolder); }
/// /// <summary> * (20) get JDFRectangle attribute RelativeBox </summary> /// * <returns> JDFRectangle the value of the attribute, null if a the /// * attribute value is not a valid to create a JDFRectangle </returns> /// public virtual JDFRectangle getRelativeBox() { string strAttrName = ""; JDFRectangle nPlaceHolder = null; strAttrName = getAttribute(AttributeName.RELATIVEBOX, null, JDFConstants.EMPTYSTRING); try { nPlaceHolder = new JDFRectangle(strAttrName); } catch (FormatException) { return(null); } return(nPlaceHolder); }
/// /// <summary> * (20) get JDFRectangle attribute SourceTrimBox </summary> /// * <returns> JDFRectangle the value of the attribute, null if a the /// * attribute value is not a valid to create a JDFRectangle </returns> /// public virtual JDFRectangle getSourceTrimBox() { string strAttrName = ""; JDFRectangle nPlaceHolder = null; strAttrName = getAttribute(AttributeName.SOURCETRIMBOX, null, JDFConstants.EMPTYSTRING); try { nPlaceHolder = new JDFRectangle(strAttrName); } catch (FormatException) { return(null); } return(nPlaceHolder); }
/// /// <summary> * (20) get JDFRectangle attribute ApplicationArea </summary> /// * <returns> JDFRectangle the value of the attribute, null if a the /// * attribute value is not a valid to create a JDFRectangle </returns> /// public virtual JDFRectangle getApplicationArea() { string strAttrName = ""; JDFRectangle nPlaceHolder = null; strAttrName = getAttribute(AttributeName.APPLICATIONAREA, null, JDFConstants.EMPTYSTRING); try { nPlaceHolder = new JDFRectangle(strAttrName); } catch (FormatException) { return(null); } return(nPlaceHolder); }
/// /// <summary> * fitsValue - checks whether <code>value</code> matches the Allowed/Present /// * test lists specified for this State /// * </summary> /// * <param name="value"> /// * value to test </param> /// * <param name="testlists"> /// * the test lists the value has to match. In this State the test /// * lists are ValueList and HWRelation.<br> /// * Choose one of two values: FitsValue_Allowed or /// * FitsValue_Present. (Defaults to Allowed) /// * </param> /// * <returns> boolean - true, if <code>value</code> matches testlists or if /// * AllowedValueList and AllowedValueMod are not specified </returns> /// public sealed override bool fitsValue(string @value, EnumFitsValue testlists) { if (fitsListType(@value)) { JDFRectangleRangeList rrl = null; try { rrl = new JDFRectangleRangeList(@value); } catch (FormatException) { return(false); } int siz = rrl.Count; for (int i = 0; i < siz; i++) // For every range, that rangelist // consists of, { // we test both of range deliminators - right and left, if they // fit HWRelation // In this case test of deliminators is sufficient for // evaluation of the whole range JDFRectangleRange range = (JDFRectangleRange)rrl[i]; JDFRectangle left = range.Left; JDFRectangle right = range.Right; bool bFitsHW; if (left.Equals(right)) { bFitsHW = fitsHWRelation(left, testlists); } else { bFitsHW = fitsHWRelation(left, testlists) && fitsHWRelation(right, testlists); } if (!bFitsHW) { return(false); } } return(fitsValueList(rrl, testlists)); // if we are here bFitsHW is // true, test ValueList } return(false); // the value doesn't fit ListType attribute of this State }
/// /// <summary> * fitsHWRelation - checks whether <code>rect</code> value matches the /// * HWRelation specified for this Evaluation /// * </summary> /// * <param name="rect"> /// * rectangle value to test </param> /// * <returns> boolean - true, if <code>rect</code> matches HWRelation or if /// * HWRelation is not specified </returns> /// private bool fitsHWRelation(JDFRectangle rect) { double width = rect.Urx - rect.Llx; double height = rect.Ury - rect.Lly; if (!hasAttribute(AttributeName.HWRELATION)) { return(true); } if (!hasAttribute(AttributeName.TOLERANCE)) { return(getHWRelation().evaluateXY(width, height, JDFBaseDataTypes_Fields.EPSILON, JDFBaseDataTypes_Fields.EPSILON)); } double nt = getTolerance().X; // negative tolerance double pt = getTolerance().Y; // positive tolerance return(getHWRelation().evaluateXY(width, height, nt, pt)); }
// // * // Element getter / setter // // // * (non-Javadoc) // * // * @see // * org.cip4.jdflib.resource.devicecapability.JDFAbstractState#addValue(java // * .lang.String, org.cip4.jdflib.datatypes.JDFBaseDataTypes.EnumFitsValue) // public override void addValue(string @value, EnumFitsValue testlists) { if (fitsValue(@value, testlists)) { return; } JDFRectangle rect; try { rect = new JDFRectangle(@value); } catch (FormatException) { return; // nop for bad values } if (testlists == null || EnumFitsValue.Allowed.Equals(testlists)) { JDFRectangleRangeList list = getAllowedValueList(); if (list == null) { list = new JDFRectangleRangeList(); } list.Append(rect); setAllowedValueList(list); } if (testlists == null || EnumFitsValue.Present.Equals(testlists)) { JDFRectangleRangeList list = getPresentValueList(); if (list == null || !hasAttribute(AttributeName.PRESENTVALUELIST)) { list = new JDFRectangleRangeList(); } list.Append(rect); setPresentValueList(list); } }
/// /// <summary> * fitsShift - checks whether <code>matrix</code> matches the AllowedShift /// * or PresentShift specified for this State /// * </summary> /// * <param name="matrix"> /// * matrix to test </param> /// * <param name="shift"> /// * switches between AllowedShift and PresentShift. </param> /// * <returns> boolean - true, if <code>matrix</code> matches the Shift or if /// * AllowedShift is not specified </returns> /// private bool fitsShift(JDFMatrix matrix, EnumFitsValue shift) { if (shift == null || shift.Equals(EnumFitsValue.Allowed)) { if (!hasAttribute(AttributeName.ALLOWEDSHIFT)) { return(true); } } else { if (!hasAttribute(AttributeName.ALLOWEDSHIFT) && !hasAttribute(AttributeName.PRESENTSHIFT)) { return(true); } } JDFRectangle shiftValue; if (shift == null || shift.Equals(EnumFitsValue.Allowed)) { shiftValue = new JDFRectangle(getAllowedShift()); } else { shiftValue = new JDFRectangle(getPresentShift()); } double minTx = shiftValue.Llx; double minTy = shiftValue.Lly; double maxTx = shiftValue.Urx; double maxTy = shiftValue.Ury; double Tx = matrix.Tx; double Ty = matrix.Ty; return((Tx >= minTx) && (Tx <= maxTx) && (Ty >= minTy) && (Ty <= maxTy)); }
/// /// <summary> * fitsHWRelation - checks whether <code>rect</code> matches the /// * AllowedHWRelation/PresentHWRelation specified for this State /// * </summary> /// * <param name="rect"> /// * rectangle value to test </param> /// * <param name="hwrelation"> /// * Switches between AllowedHWRelation and PresentHWRelation. </param> /// * <returns> boolean - true, if <code>rect</code> matches hwrelation or if /// * AllowedHWRelation is not specified </returns> /// private bool fitsHWRelation(JDFRectangle rect, EnumFitsValue hwrelation) { EnumXYRelation relation; if (hwrelation.Equals(EnumFitsValue.Allowed)) { relation = getAllowedHWRelation(); } else { relation = getPresentHWRelation(); } if (relation == null) { return(true); } double width = rect.Urx - rect.Llx; double height = rect.Ury - rect.Lly; return(relation.evaluateXY(width, height, JDFBaseDataTypes_Fields.EPSILON, JDFBaseDataTypes_Fields.EPSILON)); }
// --------------------------------------------------------------------- // Methods for Attribute SourceTrimBox // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute SourceTrimBox </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setSourceTrimBox(JDFRectangle @value) { setAttribute(AttributeName.SOURCETRIMBOX, @value, null); }
// --------------------------------------------------------------------- // Methods for Attribute SourceClipBox // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute SourceClipBox </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setSourceClipBox(JDFRectangle @value) { setAttribute(AttributeName.SOURCECLIPBOX, @value, null); }
// --------------------------------------------------------------------- // Methods for Attribute SourceBleedBox // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute SourceBleedBox </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setSourceBleedBox(JDFRectangle @value) { setAttribute(AttributeName.SOURCEBLEEDBOX, @value, null); }
// ************************************************************************ // * Attribute getter / setter // * ************************************************************************ // // --------------------------------------------------------------------- // Methods for Attribute CutBox // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute CutBox </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setCutBox(JDFRectangle @value) { setAttribute(AttributeName.CUTBOX, @value, null); }
// --------------------------------------------------------------------- // Methods for Attribute PDFXTrimBoxToMediaBoxOffset // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute PDFXTrimBoxToMediaBoxOffset </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setPDFXTrimBoxToMediaBoxOffset(JDFRectangle @value) { setAttribute(AttributeName.PDFXTRIMBOXTOMEDIABOXOFFSET, @value, null); }
// --------------------------------------------------------------------- // Methods for Attribute RelativeBox // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute RelativeBox </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setRelativeBox(JDFRectangle @value) { setAttribute(AttributeName.RELATIVEBOX, @value, null); }
public virtual void setDefaultValue(JDFRectangle @value) { setAttribute(AttributeName.DEFAULTVALUE, @value.ToString(), null); }
// // * // Attribute getter / setter // public virtual void setCurrentValue(JDFRectangle @value) { setAttribute(AttributeName.CURRENTVALUE, @value.ToString(), null); }
// ************************************************************************ // * Attribute getter / setter // * ************************************************************************ // // --------------------------------------------------------------------- // Methods for Attribute ApplicationArea // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute ApplicationArea </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setApplicationArea(JDFRectangle @value) { setAttribute(AttributeName.APPLICATIONAREA, @value, null); }
// --------------------------------------------------------------------- // Methods for Attribute Offset // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute Offset </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setOffset(JDFRectangle @value) { setAttribute(AttributeName.OFFSET, @value, null); }
// ************************************************************************ // * Attribute getter / setter // * ************************************************************************ // // --------------------------------------------------------------------- // Methods for Attribute AbsoluteBox // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute AbsoluteBox </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setAbsoluteBox(JDFRectangle @value) { setAttribute(AttributeName.ABSOLUTEBOX, @value, null); }
// --------------------------------------------------------------------- // Methods for Attribute PrintableArea // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute PrintableArea </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setPrintableArea(JDFRectangle @value) { setAttribute(AttributeName.PRINTABLEAREA, @value, null); }
public void testFitsValue_MatrixState() { JDFDoc jdfDoc = new JDFDoc(ElementName.JDF); JDFNode root = jdfDoc.getJDFRoot(); JDFMatrix matrix1 = new JDFMatrix("1 0 0 1 3.14 21631.3"); JDFMatrix matrix2 = new JDFMatrix("0 1 1 0 2 21000"); List <ValuedEnum> transforms = new List <ValuedEnum>(); transforms.Add(EnumOrientation.Rotate0); transforms.Add(EnumOrientation.Rotate270); transforms.Add(EnumOrientation.Flip0); JDFRectangle shift = new JDFRectangle("2 4 20000 23000"); string value1 = "1 0 0 1 3.14 21631.3"; JDFMatrixState k = (JDFMatrixState)root.appendElement("MatrixState"); k.appendValue(); // k.setValueValueUsage(0, EnumFitsValue.Allowed); k.setValueAllowedValue(0, matrix2); k.appendValue(); // k.setValueValueUsage(1, EnumFitsValue.Present); k.setValueAllowedValue(1, matrix1); k.setAllowedTransforms(transforms); k.setAllowedShift(shift); k.setAllowedRotateMod(15); EnumListType lt = EnumListType.UniqueList; // JDFAbstractState.EnumListType lt = EnumListType.ListType.Unknown; // JDFAbstractState.EnumListType lt = EnumListType.ListType.List; k.setListType(lt); // EnumListType listType = k.getListType(); Assert.IsTrue(k.fitsValue(value1, EnumFitsValue.Allowed), "Matrix OK"); string @value = "1 2 3 4 5 6 7 8 9 10 11 12 3 4 5 6 7 8"; VString vs = new VString(@value, JDFConstants.BLANK); int siz = vs.Count; Assert.AreEqual(0, siz % 6, "It is not a Matrix"); VString matrixList = new VString(); int i = 0; StringBuilder sb = new StringBuilder(250); sb.Append(vs[i]); while ((i + 1) < siz) { do { sb.Append(JDFConstants.BLANK); i++; sb.Append(vs[i]); } while ((i + 1) % 6 != 0); matrixList.Add(sb.ToString()); if ((i + 1) < siz) { i++; sb = new StringBuilder(250); sb.Append(vs[i]); } } for (int z = 0; z < matrixList.Count; z++) { JDFMatrix matrix3 = new JDFMatrix(matrixList.stringAt(z)); //matrix3.A; } }
// --------------------------------------------------------------------- // Methods for Attribute PDFXBleedBoxToTrimBoxOffset // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute PDFXBleedBoxToTrimBoxOffset </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setPDFXBleedBoxToTrimBoxOffset(JDFRectangle @value) { setAttribute(AttributeName.PDFXBLEEDBOXTOTRIMBOXOFFSET, @value, null); }
// --------------------------------------------------------------------- // Methods for Attribute SurfaceContentsBox // --------------------------------------------------------------------- /// /// <summary> * (36) set attribute SurfaceContentsBox </summary> /// * <param name="value">: the value to set the attribute to </param> /// public virtual void setSurfaceContentsBox(JDFRectangle @value) { setAttribute(AttributeName.SURFACECONTENTSBOX, @value, null); }
public virtual void setShift(JDFRectangle @value) { setAttribute(AttributeName.SHIFT, @value.ToString()); }