本文整理汇总了C#中System.util.StringTokenizer类的典型用法代码示例。如果您正苦于以下问题:C# StringTokenizer类的具体用法?C# StringTokenizer怎么用?C# StringTokenizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringTokenizer类属于System.util命名空间,在下文中一共展示了StringTokenizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetField
internal bool SetField(String field, PdfObject value) {
Hashtable map = fields;
StringTokenizer tk = new StringTokenizer(field, ".");
if (!tk.HasMoreTokens())
return false;
while (true) {
String s = tk.NextToken();
Object obj = map[s];
if (tk.HasMoreTokens()) {
if (obj == null) {
obj = new Hashtable();
map[s] = obj;
map = (Hashtable)obj;
continue;
}
else if (obj is Hashtable)
map = (Hashtable)obj;
else
return false;
}
else {
if (!(obj is Hashtable)) {
map[s] = value;
return true;
}
else
return false;
}
}
}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:30,代码来源:FdfWriter.cs
示例2: GlyphList
static GlyphList()
{
Stream istr = null;
try {
istr = BaseFont.GetResourceStream(BaseFont.RESOURCE_PATH + "glyphlist.txt");
if (istr == null) {
String msg = "glyphlist.txt not found as resource.";
throw new Exception(msg);
}
byte[] buf = new byte[1024];
MemoryStream outp = new MemoryStream();
while (true) {
int size = istr.Read(buf, 0, buf.Length);
if (size == 0)
break;
outp.Write(buf, 0, size);
}
istr.Close();
istr = null;
String s = PdfEncodings.ConvertToString(outp.ToArray(), null);
StringTokenizer tk = new StringTokenizer(s, "\r\n");
while (tk.HasMoreTokens()) {
String line = tk.NextToken();
if (line.StartsWith("#"))
continue;
StringTokenizer t2 = new StringTokenizer(line, " ;\r\n\t\f");
String name = null;
String hex = null;
if (!t2.HasMoreTokens())
continue;
name = t2.NextToken();
if (!t2.HasMoreTokens())
continue;
hex = t2.NextToken();
int num = int.Parse(hex, NumberStyles.HexNumber);
unicode2names[num] = name;
names2unicode[name] = new int[]{num};
}
}
catch (Exception e) {
Console.Error.WriteLine("glyphlist.txt loading error: " + e.Message);
}
finally {
if (istr != null) {
try {
istr.Close();
}
catch {
// empty on purpose
}
}
}
}
开发者ID:boecko,项目名称:iTextSharp,代码行数:53,代码来源:GlyphList.cs
示例3: Text
virtual public void Text(String str) {
StringTokenizer tk = new StringTokenizer(str);
while (tk.HasMoreTokens()) {
String word = tk.NextToken();
// System.out.Println("\"" + word + "\"");
switch (currElement) {
case ELEM_CLASSES:
consumer.AddClass(word);
break;
case ELEM_EXCEPTIONS:
exception.Add(word);
exception = NormalizeException(exception);
consumer.AddException(GetExceptionWord(exception), new List<object>(exception));
exception.Clear();
break;
case ELEM_PATTERNS:
consumer.AddPattern(GetPattern(word),
GetInterletterValues(word));
break;
}
}
}
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:22,代码来源:SimplePatternParser.cs
示例4: GetTable
/**
* Creates an Table object based on a list of properties.
* @param attributes
* @return a Table
*/
public static Table GetTable(Properties attributes)
{
String value;
Table table;
value = attributes[ElementTags.WIDTHS];
if (value != null) {
StringTokenizer widthTokens = new StringTokenizer(value, ";");
ArrayList values = new ArrayList();
while (widthTokens.HasMoreTokens()) {
values.Add(widthTokens.NextToken());
}
table = new Table(values.Count);
float[] widths = new float[table.Columns];
for (int i = 0; i < values.Count; i++) {
value = (String)values[i];
widths[i] = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
table.Widths = widths;
}
else {
value = attributes[ElementTags.COLUMNS];
try {
table = new Table(int.Parse(value));
}
catch {
table = new Table(1);
}
}
table.Border = Table.BOX;
table.BorderWidth = 1;
table.DefaultCell.Border = Table.BOX;
value = attributes[ElementTags.LASTHEADERROW];
if (value != null) {
table.LastHeaderRow = int.Parse(value);
}
value = attributes[ElementTags.ALIGN];
if (value != null) {
table.SetAlignment(value);
}
value = attributes[ElementTags.CELLSPACING];
if (value != null) {
table.Spacing = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
value = attributes[ElementTags.CELLPADDING];
if (value != null) {
table.Padding = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
value = attributes[ElementTags.OFFSET];
if (value != null) {
table.Offset = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
}
value = attributes[ElementTags.WIDTH];
if (value != null) {
if (value.EndsWith("%"))
table.Width = float.Parse(value.Substring(0, value.Length - 1), System.Globalization.NumberFormatInfo.InvariantInfo);
else {
table.Width = float.Parse(value, System.Globalization.NumberFormatInfo.InvariantInfo);
table.Locked = true;
}
}
table.TableFitsPage = Utilities.CheckTrueOrFalse(attributes, ElementTags.TABLEFITSPAGE);
table.CellsFitPage = Utilities.CheckTrueOrFalse(attributes, ElementTags.CELLSFITPAGE);
table.Convert2pdfptable = Utilities.CheckTrueOrFalse(attributes, ElementTags.CONVERT2PDFP);
SetRectangleProperties(table, attributes);
return table;
}
开发者ID:bmictech,项目名称:iTextSharp,代码行数:75,代码来源:ElementFactory.cs
示例5: MergeField
internal void MergeField(String name, AcroFields.Item item)
{
Hashtable map = fieldTree;
StringTokenizer tk = new StringTokenizer(name, ".");
if (!tk.HasMoreTokens())
return;
while (true) {
String s = tk.NextToken();
Object obj = map[s];
if (tk.HasMoreTokens()) {
if (obj == null) {
obj = new Hashtable();
map[s] = obj;
map = (Hashtable)obj;
continue;
}
else if (obj is Hashtable)
map = (Hashtable)obj;
else
return;
}
else {
if (obj is Hashtable)
return;
PdfDictionary merged = (PdfDictionary)item.merged[0];
if (obj == null) {
PdfDictionary field = new PdfDictionary();
foreach (PdfName key in merged.Keys) {
if (fieldKeys.ContainsKey(key))
field.Put(key, merged.Get(key));
}
ArrayList list = new ArrayList();
list.Add(field);
CreateWidgets(list, item);
map[s] = list;
}
else {
ArrayList list = (ArrayList)obj;
PdfDictionary field = (PdfDictionary)list[0];
PdfName type1 = (PdfName)field.Get(PdfName.FT);
PdfName type2 = (PdfName)merged.Get(PdfName.FT);
if (type1 == null || !type1.Equals(type2))
return;
int flag1 = 0;
PdfObject f1 = field.Get(PdfName.FF);
if (f1 != null && f1.IsNumber())
flag1 = ((PdfNumber)f1).IntValue;
int flag2 = 0;
PdfObject f2 = merged.Get(PdfName.FF);
if (f2 != null && f2.IsNumber())
flag2 = ((PdfNumber)f2).IntValue;
if (type1.Equals(PdfName.BTN)) {
if (((flag1 ^ flag2) & PdfFormField.FF_PUSHBUTTON) != 0)
return;
if ((flag1 & PdfFormField.FF_PUSHBUTTON) == 0 && ((flag1 ^ flag2) & PdfFormField.FF_RADIO) != 0)
return;
}
else if (type1.Equals(PdfName.CH)) {
if (((flag1 ^ flag2) & PdfFormField.FF_COMBO) != 0)
return;
}
CreateWidgets(list, item);
}
return;
}
}
}
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:67,代码来源:PdfCopyFieldsImp.cs
示例6: GetFont
/**
* Creates a Font object based on a chain of properties.
* @param chain chain of properties
* @return an iText Font object
*/
public Font GetFont(ChainedProperties chain) {
// [1] font name
String face = chain[HtmlTags.FACE];
// try again, under the CSS key.
//ISSUE: If both are present, we always go with face, even if font-family was
// defined more recently in our ChainedProperties. One solution would go like this:
// Map all our supported style attributes to the 'normal' tag name, so we could
// look everything up under that one tag, retrieving the most current value.
if (face == null || face.Trim().Length == 0) {
face = chain[HtmlTags.FONTFAMILY];
}
// if the font consists of a comma separated list,
// take the first font that is registered
if (face != null) {
StringTokenizer tok = new StringTokenizer(face, ",");
while (tok.HasMoreTokens()) {
face = tok.NextToken().Trim();
if (face.StartsWith("\""))
face = face.Substring(1);
if (face.EndsWith("\""))
face = face.Substring(0, face.Length - 1);
if (provider.IsRegistered(face))
break;
}
}
// [2] encoding
String encoding = chain[HtmlTags.ENCODING];
if (encoding == null)
encoding = BaseFont.WINANSI;
// [3] embedded
// [4] font size
String value = chain[HtmlTags.SIZE];
float size = 12;
if (value != null)
size = float.Parse(value, CultureInfo.InvariantCulture);
// [5] font style
int style = 0;
// text-decoration
String decoration = chain[HtmlTags.TEXTDECORATION];
if (decoration != null && decoration.Trim().Length != 0) {
if (HtmlTags.UNDERLINE.Equals(decoration)) {
style |= Font.UNDERLINE;
} else if (HtmlTags.LINETHROUGH.Equals(decoration)) {
style |= Font.STRIKETHRU;
}
}
// italic
if (chain.HasProperty(HtmlTags.I))
style |= Font.ITALIC;
// bold
if (chain.HasProperty(HtmlTags.B))
style |= Font.BOLD;
// underline
if (chain.HasProperty(HtmlTags.U))
style |= Font.UNDERLINE;
// strikethru
if (chain.HasProperty(HtmlTags.S))
style |= Font.STRIKETHRU;
// [6] Color
BaseColor color = HtmlUtilities.DecodeColor(chain[HtmlTags.COLOR]);
// Get the font object from the provider
return provider.GetFont(face, encoding, true, size, style, color);
}
开发者ID:Gianluigi,项目名称:dssnet,代码行数:77,代码来源:ElementFactory.cs
示例7: DrawMultiLineOfText
virtual public void DrawMultiLineOfText(PdfFormField field, string text, BaseFont font, float fontSize, float llx, float lly, float urx, float ury) {
PdfAppearance tp = PdfAppearance.CreateAppearance(writer, urx - llx, ury - lly);
PdfAppearance tp2 = (PdfAppearance)tp.Duplicate;
tp2.SetFontAndSize(font, fontSize);
tp2.ResetRGBColorFill();
field.DefaultAppearanceString = tp2;
tp.DrawTextField(0f, 0f, urx - llx, ury - lly);
tp.BeginVariableText();
tp.SaveState();
tp.Rectangle(3f, 3f, urx - llx - 6f, ury - lly - 6f);
tp.Clip();
tp.NewPath();
tp.BeginText();
tp.SetFontAndSize(font, fontSize);
tp.ResetRGBColorFill();
tp.SetTextMatrix(4, 5);
System.util.StringTokenizer tokenizer = new System.util.StringTokenizer(text, "\n");
float yPos = ury - lly;
while (tokenizer.HasMoreTokens()) {
yPos -= fontSize * 1.2f;
tp.ShowTextAligned(PdfContentByte.ALIGN_LEFT, tokenizer.NextToken(), 3, yPos, 0);
}
tp.EndText();
tp.RestoreState();
tp.EndVariableText();
field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
}
开发者ID:jagruti23,项目名称:itextsharp,代码行数:27,代码来源:PdfAcroForm.cs
示例8: IterateOutlines
public static Object[] IterateOutlines(PdfWriter writer, PdfIndirectReference parent, IList<Dictionary<String, Object>> kids, bool namedAsNames) {
PdfIndirectReference[] refs = new PdfIndirectReference[kids.Count];
for (int k = 0; k < refs.Length; ++k)
refs[k] = writer.PdfIndirectReference;
int ptr = 0;
int count = 0;
foreach (Dictionary<String, Object> map in kids) {
Object[] lower = null;
IList<Dictionary<String, Object>> subKid = null;
if (map.ContainsKey("Kids"))
subKid = (IList<Dictionary<String, Object>>)map["Kids"];
if (subKid != null && subKid.Count > 0)
lower = IterateOutlines(writer, refs[ptr], subKid, namedAsNames);
PdfDictionary outline = new PdfDictionary();
++count;
if (lower != null) {
outline.Put(PdfName.FIRST, (PdfIndirectReference)lower[0]);
outline.Put(PdfName.LAST, (PdfIndirectReference)lower[1]);
int n = (int)lower[2];
if (map.ContainsKey("Open") && "false".Equals(map["Open"])) {
outline.Put(PdfName.COUNT, new PdfNumber(-n));
}
else {
outline.Put(PdfName.COUNT, new PdfNumber(n));
count += n;
}
}
outline.Put(PdfName.PARENT, parent);
if (ptr > 0)
outline.Put(PdfName.PREV, refs[ptr - 1]);
if (ptr < refs.Length - 1)
outline.Put(PdfName.NEXT, refs[ptr + 1]);
outline.Put(PdfName.TITLE, new PdfString((String)map["Title"], PdfObject.TEXT_UNICODE));
String color = null;
if (map.ContainsKey("Color"))
color = (String)map["Color"];
if (color != null) {
try {
PdfArray arr = new PdfArray();
StringTokenizer tk = new StringTokenizer(color);
for (int k = 0; k < 3; ++k) {
float f = float.Parse(tk.NextToken(), System.Globalization.NumberFormatInfo.InvariantInfo);
if (f < 0) f = 0;
if (f > 1) f = 1;
arr.Add(new PdfNumber(f));
}
outline.Put(PdfName.C, arr);
} catch {} //in case it's malformed
}
String style = GetVal(map, "Style");
if (style != null) {
style = style.ToLower(System.Globalization.CultureInfo.InvariantCulture);
int bits = 0;
if (style.IndexOf("italic") >= 0)
bits |= 1;
if (style.IndexOf("bold") >= 0)
bits |= 2;
if (bits != 0)
outline.Put(PdfName.F, new PdfNumber(bits));
}
CreateOutlineAction(outline, map, writer, namedAsNames);
writer.AddToBody(outline, refs[ptr]);
++ptr;
}
return new Object[]{refs[0], refs[refs.Length - 1], count};
}
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:66,代码来源:SimpleBookmark.cs
示例9: CreateDestinationArray
internal static PdfArray CreateDestinationArray(String value, PdfWriter writer)
{
PdfArray ar = new PdfArray();
StringTokenizer tk = new StringTokenizer(value);
int n = int.Parse(tk.NextToken());
ar.Add(writer.GetPageReference(n));
if (!tk.HasMoreTokens()) {
ar.Add(PdfName.XYZ);
ar.Add(new float[]{0, 10000, 0});
}
else {
String fn = tk.NextToken();
if (fn.StartsWith("/"))
fn = fn.Substring(1);
ar.Add(new PdfName(fn));
for (int k = 0; k < 4 && tk.HasMoreTokens(); ++k) {
fn = tk.NextToken();
if (fn.Equals("null"))
ar.Add(PdfNull.PDFNULL);
else
ar.Add(new PdfNumber(fn));
}
}
return ar;
}
开发者ID:karino2,项目名称:wikipediaconv,代码行数:25,代码来源:SimpleNamedDestination.cs
示例10: GetRGBColor
/**
* Gives you a Color based on a name.
*
* @param name
* a name such as black, violet, cornflowerblue or #RGB or #RRGGBB
* or rgb(R,G,B)
* @return the corresponding Color object
* @throws IllegalArgumentException
* if the String isn't a know representation of a color.
*/
public static Color GetRGBColor(String name)
{
int[] c = { 0, 0, 0, 0 };
if (name.StartsWith("#")) {
if (name.Length == 4) {
c[0] = int.Parse(name.Substring(1, 1), NumberStyles.HexNumber) * 16;
c[1] = int.Parse(name.Substring(2, 1), NumberStyles.HexNumber) * 16;
c[2] = int.Parse(name.Substring(3), NumberStyles.HexNumber) * 16;
return new Color(c[0], c[1], c[2], c[3]);
}
if (name.Length == 7) {
c[0] = int.Parse(name.Substring(1, 2), NumberStyles.HexNumber);
c[1] = int.Parse(name.Substring(3, 2), NumberStyles.HexNumber);
c[2] = int.Parse(name.Substring(5), NumberStyles.HexNumber);
return new Color(c[0], c[1], c[2], c[3]);
}
throw new ArgumentException(
"Unknown color format. Must be #RGB or #RRGGBB");
}
else if (name.StartsWith("rgb(")) {
StringTokenizer tok = new StringTokenizer(name, "rgb(), \t\r\n\f");
for (int k = 0; k < 3; ++k) {
String v = tok.NextToken();
if (v.EndsWith("%"))
c[k] = int.Parse(v.Substring(0, v.Length - 1)) * 255 / 100;
else
c[k] = int.Parse(v);
if (c[k] < 0)
c[k] = 0;
else if (c[k] > 255)
c[k] = 255;
}
return new Color(c[0], c[1], c[2], c[3]);
}
name = name.ToLower(CultureInfo.InvariantCulture);
if (!NAMES.ContainsKey(name))
throw new ArgumentException("Color '" + name
+ "' not found.");
c = (int[]) NAMES[name];
return new Color(c[0], c[1], c[2], c[3]);
}
开发者ID:bmictech,项目名称:iTextSharp,代码行数:51,代码来源:WebColors.cs
示例11: CJKFont
/** Creates a CJK font.
* @param fontName the name of the font
* @param enc the encoding of the font
* @param emb always <CODE>false</CODE>. CJK font and not embedded
* @throws DocumentException on error
* @throws IOException on error
*/
internal CJKFont(string fontName, string enc, bool emb)
{
LoadProperties();
this.FontType = FONT_TYPE_CJK;
string nameBase = GetBaseName(fontName);
if (!IsCJKFont(nameBase, enc))
throw new DocumentException("Font '" + fontName + "' with '" + enc + "' encoding is not a CJK font.");
if (nameBase.Length < fontName.Length) {
style = fontName.Substring(nameBase.Length);
fontName = nameBase;
}
this.fontName = fontName;
encoding = CJK_ENCODING;
vertical = enc.EndsWith("V");
CMap = enc;
if (enc.StartsWith("Identity-")) {
cidDirect = true;
string s = cjkFonts[fontName];
s = s.Substring(0, s.IndexOf('_'));
char[] c = (char[])allCMaps[s];
if (c == null) {
c = ReadCMap(s);
if (c == null)
throw new DocumentException("The cmap " + s + " does not exist as a resource.");
c[CID_NEWLINE] = '\n';
allCMaps.Add(s, c);
}
translationMap = c;
}
else {
char[] c = (char[])allCMaps[enc];
if (c == null) {
string s = cjkEncodings[enc];
if (s == null)
throw new DocumentException("The resource cjkencodings.properties does not contain the encoding " + enc);
StringTokenizer tk = new StringTokenizer(s);
string nt = tk.NextToken();
c = (char[])allCMaps[nt];
if (c == null) {
c = ReadCMap(nt);
allCMaps.Add(nt, c);
}
if (tk.HasMoreTokens()) {
string nt2 = tk.NextToken();
char[] m2 = ReadCMap(nt2);
for (int k = 0; k < 0x10000; ++k) {
if (m2[k] == 0)
m2[k] = c[k];
}
allCMaps.Add(enc, m2);
c = m2;
}
}
translationMap = c;
}
fontDesc = (Hashtable)allFonts[fontName];
if (fontDesc == null) {
fontDesc = ReadFontProperties(fontName);
allFonts.Add(fontName, fontDesc);
}
hMetrics = (IntHashtable)fontDesc["W"];
vMetrics = (IntHashtable)fontDesc["W2"];
}
开发者ID:bmictech,项目名称:iTextSharp,代码行数:70,代码来源:CJKFont.cs
示例12: CreateOutlineAction
internal static void CreateOutlineAction(PdfDictionary outline, Dictionary<String, Object> map, PdfWriter writer, bool namedAsNames) {
try {
String action = GetVal(map, "Action");
if ("GoTo".Equals(action)) {
String p;
if ((p = GetVal(map, "Named")) != null) {
if (namedAsNames)
outline.Put(PdfName.DEST, new PdfName(p));
else
outline.Put(PdfName.DEST, new PdfString(p, null));
}
else if ((p = GetVal(map, "Page")) != null) {
PdfArray ar = new PdfArray();
StringTokenizer tk = new StringTokenizer(p);
int n = int.Parse(tk.NextToken());
ar.Add(writer.GetPageReference(n));
if (!tk.HasMoreTokens()) {
ar.Add(PdfName.XYZ);
ar.Add(new float[]{0, 10000, 0});
}
else {
String fn = tk.NextToken();
if (fn.StartsWith("/"))
fn = fn.Substring(1);
ar.Add(new PdfName(fn));
for (int k = 0; k < 4 && tk.HasMoreTokens(); ++k) {
fn = tk.NextToken();
if (fn.Equals("null"))
ar.Add(PdfNull.PDFNULL);
else
ar.Add(new PdfNumber(fn));
}
}
outline.Put(PdfName.DEST, ar);
}
}
else if ("GoToR".Equals(action)) {
String p;
PdfDictionary dic = new PdfDictionary();
if ((p = GetVal(map, "Named")) != null)
dic.Put(PdfName.D, new PdfString(p, null));
else if ((p = GetVal(map, "NamedN")) != null)
dic.Put(PdfName.D, new PdfName(p));
else if ((p = GetVal(map, "Page")) != null){
PdfArray ar = new PdfArray();
StringTokenizer tk = new StringTokenizer(p);
ar.Add(new PdfNumber(tk.NextToken()));
if (!tk.HasMoreTokens()) {
ar.Add(PdfName.XYZ);
ar.Add(new float[]{0, 10000, 0});
}
else {
String fn = tk.NextToken();
if (fn.StartsWith("/"))
fn = fn.Substring(1);
ar.Add(new PdfName(fn));
for (int k = 0; k < 4 && tk.HasMoreTokens(); ++k) {
fn = tk.NextToken();
if (fn.Equals("null"))
ar.Add(PdfNull.PDFNULL);
else
ar.Add(new PdfNumber(fn));
}
}
dic.Put(PdfName.D, ar);
}
String file = GetVal(map, "File");
if (dic.Size > 0 && file != null) {
dic.Put(PdfName.S, PdfName.GOTOR);
dic.Put(PdfName.F, new PdfString(file));
String nw = GetVal(map, "NewWindow");
if (nw != null) {
if (nw.Equals("true"))
dic.Put(PdfName.NEWWINDOW, PdfBoolean.PDFTRUE);
else if (nw.Equals("false"))
dic.Put(PdfName.NEWWINDOW, PdfBoolean.PDFFALSE);
}
outline.Put(PdfName.A, dic);
}
}
else if ("URI".Equals(action)) {
String uri = GetVal(map, "URI");
if (uri != null) {
PdfDictionary dic = new PdfDictionary();
dic.Put(PdfName.S, PdfName.URI);
dic.Put(PdfName.URI, new PdfString(uri));
outline.Put(PdfName.A, dic);
}
}
else if ("JS".Equals(action)) {
String code = GetVal(map, "Code");
if(code != null) {
outline.Put(PdfName.A, PdfAction.JavaScript(code, writer));
}
}
else if ("Launch".Equals(action)) {
String file = GetVal(map, "File");
if (file != null) {
PdfDictionary dic = new PdfDictionary();
dic.Put(PdfName.S, PdfName.LAUNCH);
//.........这里部分代码省略.........
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:101,代码来源:SimpleBookmark.cs
示例13: SetParagraphLeading
/**
* Sets the leading of a Paragraph object.
* @param paragraph the Paragraph for which we set the leading
* @param leading the String value of the leading
*/
protected static void SetParagraphLeading(Paragraph paragraph, String leading) {
// default leading
if (leading == null) {
paragraph.SetLeading(0, 1.5f);
return;
}
try {
StringTokenizer tk = new StringTokenizer(leading, " ,");
// absolute leading
String v = tk.NextToken();
float v1 = float.Parse(v, CultureInfo.InvariantCulture);
if (!tk.HasMoreTokens()) {
paragraph.SetLeading(v1, 0);
return;
}
// relative leading
v = tk.NextToken();
float v2 = float.Parse(v, CultureInfo.InvariantCulture);
paragraph.SetLeading(v1, v2);
} catch {
// default leading
paragraph.SetLeading(0, 1.5f);
}
}
开发者ID:Gianluigi,项目名称:dssnet,代码行数:29,代码来源:ElementFactory.cs
示例14: ParseAttributes
/// <summary>
/// This method parses a string with attributes and returns a Properties object.
/// </summary>
/// <param name="str">a string of this form: 'key1="value1"; key2="value2";... keyN="valueN" '</param>
/// <returns>a Properties object</returns>
public static Properties ParseAttributes(string str) {
Properties result = new Properties();
if (str == null) return result;
StringTokenizer keyValuePairs = new StringTokenizer(str, ";");
StringTokenizer keyValuePair;
string key;
string value;
while (keyValuePairs.HasMoreTokens()) {
keyValuePair = new StringTokenizer(keyValuePairs.NextToken(), ":");
if (keyValuePair.HasMoreTokens()) key = keyValuePair.NextToken().Trim().Trim();
else continue;
if (keyValuePair.HasMoreTokens()) value = keyValuePair.NextToken().Trim();
else continue;
if (value.StartsWith("\"")) value = value.Substring(1);
if (value.EndsWith("\"")) value = value.Substring(0, value.Length - 1);
result.Add(key.ToLower(CultureInfo.InvariantCulture), value);
}
return result;
}
开发者ID:pusp,项目名称:o2platform,代码行数:24,代码来源:Markup.cs
示例15: HTMLWorker
static HTMLWorker() {
StringTokenizer tok = new StringTokenizer(tagsSupportedString);
while (tok.HasMoreTokens())
tagsSupported[tok.NextToken()] = null;
}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:5,代码来源:HTMLWorker.cs
注:本文中的System.util.StringTokenizer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论