예제 #1
0
 @Override
 public void clear(boolean all) {
   if (all) {
     if (fontCache != null) fontCache.clear();
     if (lineBreaker != null) lineBreaker.clear();
     if (charBreaker != null) charBreaker.clear();
   }
 }
예제 #2
0
 protected LineBreakIterator getCharacterBreakIterator() {
   LineBreaker cb = charBreaker;
   return (cb != null) ? cb.getIterator(context.getReporter()) : null;
 }
예제 #3
0
 protected LineBreakIterator getLineBreakIterator() {
   LineBreaker lb = lineBreaker;
   return (lb != null) ? lb.getIterator(context.getReporter()) : null;
 }
예제 #4
0
 @Override
 public void processDerivedOptions() {
   File fontSpecificationDirectory = null;
   if (fontSpecificationDirectoryPath != null) {
     fontSpecificationDirectory = new File(fontSpecificationDirectoryPath);
     if (!fontSpecificationDirectory.exists())
       throw new InvalidOptionUsageException(
           "font-directory", "directory does not exist: " + fontSpecificationDirectoryPath);
     else if (!fontSpecificationDirectory.isDirectory())
       throw new InvalidOptionUsageException(
           "font-directory", "not a directory: " + fontSpecificationDirectoryPath);
   }
   List<File> fontSpecificationFiles = null;
   if ((fontSpecificationFileNames != null) && !fontSpecificationFileNames.isEmpty()) {
     for (String name : fontSpecificationFileNames) {
       File fontSpecificationFile = new File(name);
       if (!fontSpecificationFile.exists())
         throw new InvalidOptionUsageException("font", "file does not exist: " + name);
       else if (!fontSpecificationFile.isFile())
         throw new InvalidOptionUsageException("font", "not a file: " + name);
       else {
         if (fontSpecificationFiles == null)
           fontSpecificationFiles = new java.util.ArrayList<File>();
         fontSpecificationFiles.add(fontSpecificationFile);
       }
     }
   }
   Reporter reporter = context.getReporter();
   this.fontCache = new FontCache(fontSpecificationDirectory, fontSpecificationFiles, reporter);
   if (lineBreakerName == null) lineBreakerName = defaultLineBreakerName;
   LineBreaker lb = LineBreaker.getInstance(lineBreakerName);
   this.lineBreaker = lb;
   if (charBreakerName == null) charBreakerName = defaultCharacterBreakerName;
   LineBreaker cb = LineBreaker.getInstance(charBreakerName);
   this.charBreaker = cb;
   this.defaults = new Defaults();
   if (defaultBackgroundColor != null) {
     com.skynav.ttv.model.value.Color[] retColor = new com.skynav.ttv.model.value.Color[1];
     if (com.skynav.ttv.verifier.util.Colors.isColor(
         defaultBackgroundColor, new Location(), context, retColor))
       defaults.setBackgroundColor(
           new Color(
               retColor[0].getRed(),
               retColor[0].getGreen(),
               retColor[0].getBlue(),
               retColor[0].getAlpha()));
     else
       throw new InvalidOptionUsageException(
           "default-background-color", "invalid color syntax:  " + defaultBackgroundColor);
   }
   if (defaultColor != null) {
     com.skynav.ttv.model.value.Color[] retColor = new com.skynav.ttv.model.value.Color[1];
     if (com.skynav.ttv.verifier.util.Colors.isColor(
         defaultColor, new Location(), context, retColor))
       defaults.setColor(
           new Color(
               retColor[0].getRed(),
               retColor[0].getGreen(),
               retColor[0].getBlue(),
               retColor[0].getAlpha()));
     else
       throw new InvalidOptionUsageException(
           "default-color", "invalid color syntax:  " + defaultColor);
   }
   if (defaultFontFamilies != null) {
     List<com.skynav.ttv.model.value.FontFamily> families =
         new java.util.ArrayList<com.skynav.ttv.model.value.FontFamily>();
     Object[] treatments =
         new Object[] {com.skynav.ttv.verifier.util.QuotedGenericFontFamilyTreatment.Allow};
     if (com.skynav.ttv.verifier.util.Fonts.isFontFamilies(
         defaultFontFamilies, null, context, treatments, families)) {
       List<String> fontFamilies = new java.util.ArrayList<String>(families.size());
       for (com.skynav.ttv.model.value.FontFamily f : families) fontFamilies.add(f.toString());
       defaults.setFontFamilies(fontFamilies);
     } else
       throw new InvalidOptionUsageException(
           "default-font-families", "invalid font families syntax:  " + defaultFontFamilies);
   }
   if (defaultWhitespace != null) {
     try {
       defaults.setWhitespace(Whitespace.valueOf(defaultWhitespace.toUpperCase()));
     } catch (IllegalArgumentException e) {
       throw new InvalidOptionUsageException(
           "default-whitespace", "invalid whitespace syntax:  " + defaultWhitespace);
     }
   }
 }