public virtual void testGetMedia() { c.setComponentType(null); JDFMedia m = (JDFMedia)c.appendElement(ElementName.MEDIA); Assert.AreEqual(m, c.getMedia()); }
public void testSetGetDimension() { JDFDoc doc = new JDFDoc("JDF"); JDFNode root = doc.getJDFRoot(); JDFResourcePool resPool = root.getCreateResourcePool(); KElement kElem = resPool.appendResource(ElementName.MEDIA, EnumResourceClass.Consumable, null); Assert.IsTrue(kElem is JDFMedia); JDFMedia media = ((JDFMedia)kElem); media.setDimensionCM(new JDFXYPair(2.54, 2.54)); JDFXYPair result = media.getDimension(); Assert.AreEqual(new JDFXYPair(72, 72), result); result = media.getDimensionCM(); Assert.AreEqual(new JDFXYPair(2.54, 2.54), result); result = media.getDimensionInch(); Assert.AreEqual(new JDFXYPair(1, 1), result); media.setDimensionInch(new JDFXYPair(1, 1)); result = media.getDimension(); Assert.AreEqual(new JDFXYPair(72, 72), result); result = media.getDimensionCM(); Assert.AreEqual(new JDFXYPair(2.54, 2.54), result); result = media.getDimensionInch(); Assert.AreEqual(new JDFXYPair(1, 1), result); }
/// /// <summary> * gets the media dimension in points, </summary> /// * <returns> the media/@Dimension; null if no media is available </returns> /// public virtual JDFXYPair getMediaDimension() { JDFMedia m = getMedia(); if (m == null) { return(null); } return(m.getDimension()); }
public virtual void testGetMediaLayout() { c.setComponentType(null); JDFLayout lo = c.appendLayout(); JDFMedia m = lo.appendMedia(); Assert.AreEqual(m, c.getMedia()); lo.makeRootResource(null, null, true); Assert.AreEqual(m, c.getMedia()); }
public virtual void testGetMediaDimension() { JDFExposedMedia xm = (JDFExposedMedia) new JDFDoc("JDF").getRoot().appendElement(ElementName.RESOURCEPOOL).appendElement(ElementName.EXPOSEDMEDIA); Assert.IsNull(xm.getMediaDimension()); JDFMedia m = xm.appendMedia(); Assert.IsNull(xm.getMediaDimension()); JDFXYPair dim = new JDFXYPair(10, 20); m.setDimension(dim); Assert.AreEqual(dim, xm.getMediaDimension()); m.makeRootResource(null, null, true); Assert.AreEqual(dim, xm.getMediaDimension()); }
public void testThicknessFromWeight() { JDFMedia m = (JDFMedia) new JDFDoc("Media").getRoot(); m.setThicknessFromWeight(true, false); m.setMediaType(EnumMediaType.Paper); Assert.IsFalse(m.hasAttribute(AttributeName.THICKNESS)); m.setWeight(80.0); m.setThicknessFromWeight(true, false); Assert.AreEqual(100.0, m.getThickness(), 1.0); JDFMedia m2 = (JDFMedia)m.addPartition(EnumPartIDKey.Run, "r1"); m2.setWeight(40.0); m.setThicknessFromWeight(true, true); Assert.AreEqual(50.0, m2.getThickness(), 1.0); Assert.AreEqual(100.0, m.getThickness(), 1.0); }
public void testHoleType() { JDFDoc doc = new JDFDoc("JDF"); JDFNode root = doc.getJDFRoot(); JDFResourcePool resPool = root.getCreateResourcePool(); // check HoleType for JDFMedia KElement kElem = resPool.appendResource(ElementName.MEDIA, EnumResourceClass.Consumable, null); Assert.IsTrue(kElem is JDFMedia); JDFMedia media = ((JDFMedia)kElem); List <ValuedEnum> v = new List <ValuedEnum>(); v.Add(EnumHoleType.None); v.Add(EnumHoleType.C9_5m_round_0t); Assert.AreEqual("C9.5m-round-0t", EnumHoleType.C9_5m_round_0t.getName()); media.setHoleType(v); CollectionAssert.AreEqual(media.getHoleType(), v); Assert.AreEqual(v[1].getName(), ((EnumHoleType)media.getHoleType()[1]).getName()); Assert.AreEqual("C9.5m-round-0t", ((EnumHoleType)media.getHoleType()[1]).getName()); // overwrite HoleType low level to check if conversion of DOT and HYPHEN // to UNDERSCORE was successful media.setAttribute(AttributeName.HOLETYPE, "C9.5m-round-0t"); Assert.AreEqual(EnumHoleType.C9_5m_round_0t, (media.getHoleType()[0])); // now check the same with JDFHoleMakingParams kElem = resPool.appendResource(ElementName.HOLEMAKINGPARAMS, EnumResourceClass.Consumable, null); Assert.IsTrue(kElem is JDFHoleMakingParams); JDFHoleMakingParams holeMakingParams = ((JDFHoleMakingParams)kElem); holeMakingParams.setHoleType(v); CollectionAssert.AreEqual(holeMakingParams.getHoleType(), v); Assert.AreEqual(v[1].getName(), ((EnumHoleType)holeMakingParams.getHoleType()[1]).getName()); Assert.AreEqual("C9.5m-round-0t", ((EnumHoleType)holeMakingParams.getHoleType()[1]).getName()); }
/// /// <summary> * get the media that is associated with this component, either directly or in the layout </summary> /// * <returns> the media, null if none there </returns> /// public virtual JDFMedia getMedia() { JDFMedia m = (JDFMedia)getElement(ElementName.MEDIA); if (m != null) { return(m); } JDFLayout lo = getLayout(); if (lo == null) { return(null); } lo = (JDFLayout)lo.getPartition(getPartMap(), EnumPartUsage.Implicit); m = lo.getMedia(EnumMediaType.Paper); if (m == null) { m = lo.getMedia(0); } return(m); }
public virtual void testTagMap() { JDFLayout lo = (JDFLayout)root.addResource(ElementName.LAYOUT, null, EnumUsage.Input, null, null, null, null); JDFMedia med = (JDFMedia)root.addResource(ElementName.MEDIA, null, EnumUsage.Input, null, null, null, null); JDFMedia medM = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "MaleCover"); JDFMedia medF = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "FemaleCover"); JDFMedia medB = (JDFMedia)med.addPartition(EnumPartIDKey.RunTags, "MaleBigBody MaleSmallBody FemaleBigBody FemaleSmallBody"); JDFLayout loM = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleCover"); loM.refElement(medM); JDFLayout loF = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "FemaleCover"); loF.refElement(medF); JDFLayout loBB = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleBigBody FemaleBigBody"); loBB.refElement(medB); JDFLayout loSB = (JDFLayout)lo.addPartition(EnumPartIDKey.RunTags, "MaleSmallBody FemaleSmallBody"); loSB.refElement(medB); lo.setXMLComment("Layout for versioned product"); KElement metaMap = rl.appendElement(METADATA_MAP); metaMap.setXMLComment("The MetadataMap element maps arbitrary tags in the document to a structural RunTag partition key\n" + "Note that any partition key may be mapped.\n" + "Note also that although an XPath syntax is used, this may be mapped to any hierarchical structure including but not limited to XML.\n"); metaMap.setAttribute("Name", "RunTags"); metaMap.setAttribute(AttributeName.DATATYPE, "PartIDKey"); metaMap.setAttribute(AttributeName.VALUEFORMAT, "%s%s"); metaMap.setAttribute(AttributeName.VALUETEMPLATE, "sex,section"); KElement expr = metaMap.appendElement(EXPR); expr.setXMLComment("This expression maps the value of /Dokument/Rezipient/@Sex to a variable \"sex\"\n" + "The Mapping is unconditional, therefore no Term is required"); expr.setAttribute("Name", "sex"); expr.setAttribute("Path", "/Dokument/Rezipient/@Sex"); expr = metaMap.appendElement(EXPR); expr.setXMLComment("Maps all elements with /Dokument/Sektion=Einband to Cover"); expr.setAttribute("Name", "section"); expr.setAttribute("Value", "Cover"); JDFNameEvaluation nev = (JDFNameEvaluation)expr.appendElement(ElementName.NAMEEVALUATION); nev.setAttribute("Path", "/Dokument/Sektion"); nev.setRegExp("Einband"); expr = metaMap.appendElement(EXPR); expr.setXMLComment("Maps all elements with /Dokument/Sektion=HauptTeil and >50 pages to BigBody"); expr.setAttribute("Name", "section"); expr.setAttribute("Value", "BigBody"); JDFand and = (JDFand)expr.appendElement("and"); nev = (JDFNameEvaluation)and.appendElement(ElementName.NAMEEVALUATION); nev.setAttribute("Path", "/Dokument/Sektion"); nev.setRegExp("HauptTeil"); JDFIntegerEvaluation iev = (JDFIntegerEvaluation)and.appendTerm(EnumTerm.IntegerEvaluation); iev.setAttribute("Path", "count(PAGE)"); iev.setValueList(new JDFIntegerRangeList("51~INF")); expr = metaMap.appendElement(EXPR); expr.setXMLComment("Maps all elements with /Dokument/Sektion=HauptTeil and <=50 pages to SmallBody"); expr.setAttribute("Name", "section"); expr.setAttribute("Value", "SmallBody"); and = (JDFand)expr.appendElement("and"); nev = (JDFNameEvaluation)and.appendElement(ElementName.NAMEEVALUATION); nev.setAttribute("Path", "/Dokument/Sektion"); nev.setRegExp("HauptTeil"); iev = (JDFIntegerEvaluation)and.appendTerm(EnumTerm.IntegerEvaluation); iev.setAttribute("Path", "count(PAGE)"); iev.setValueList(new JDFIntegerRangeList("0~INF")); rl.setFileURL("bigVariable.ppml"); rl.setXMLComment("this runlist points to a ppml with arbitrary structural tagging"); JDFResourceLink rll = root.getLink(rl, null); rll.appendPart().setDocIndex(new JDFIntegerRangeList("10 ~ 20")); rll.setXMLComment("this link selects the 11-20 document"); doc.write2File(sm_dirTestDataTemp + "metadataMap.jdf", 2, false); }